Added 4 fallback colors for extra ranges

This commit is contained in:
Shrihari 2014-03-18 18:06:44 +05:30
parent b283757315
commit 22af95e7b9
2 changed files with 25 additions and 24 deletions

View file

@ -423,16 +423,16 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
allProps = allProps.concat (@thang.moreProgrammableProperties ? [])
for property in allProps
if m = property.match(".*Range$")
if m = property.match ".*Range$"
if @thang[m[0]]? and @thang[m[0]] < 9001
@ranges.push([ m[0], @thang[m[0]] ])
@ranges.push [m[0], @thang[m[0]]]
@ranges = @ranges.sort((a, b) ->
return a[1] < b[1]
)
for range in @ranges
@addMark(range[0])
@addMark range[0]
@addMark('bounds').toggle true if @thang?.drawsBounds
@addMark('shadow').toggle true unless @thangType.get('shadow') is 0
@ -443,17 +443,9 @@ module.exports = CocoSprite = class CocoSprite extends CocoClass
@marks.repair?.toggle @thang?.errorsOut
if @selected
for range in @ranges
@marks[range[0]].toggle true
# @marks.voiceradius?.toggle true
# @marks.visualradius?.toggle true
# @marks.attackradius?.toggle true
else
for range in @ranges
@marks[range[0]].toggle false
# @marks.voiceradius?.toggle false
# @marks.visualradius?.toggle false
# @marks.attackradius?.toggle false
@marks[range[0]].toggle true for range in @ranges
else
@marks[range[0]].toggle false for range in @ranges
mark.update() for name, mark of @marks
#@thang.effectNames = ['berserk', 'confuse', 'control', 'curse', 'fear', 'poison', 'paralyze', 'regen', 'sleep', 'slow', 'haste']

View file

@ -115,26 +115,35 @@ module.exports = class Mark extends CocoClass
@mark.layerIndex = 10
#@mark.cache 0, 0, diameter, diameter # not actually faster than simple ellipse draw
buildRadius: (type) ->
alpha = 1
buildRadius: (range) ->
alpha = 0.35
colors =
voiceRange: "rgba(0, 145, 0, #{alpha})"
visualRange: "rgba(0, 0, 145, #{alpha})"
attackRange: "rgba(145, 0, 0, #{alpha})"
@mark = new createjs.Shape()
@mark.graphics.beginFill colors[type]
r = @sprite.thang[type]
extracolors = [
"rgba(145, 0, 145, #{alpha})"
"rgba(0, 145, 145, #{alpha})"
"rgba(145, 105, 0, #{alpha})"
"rgba(225, 125, 0, #{alpha})"
]
# Find the index of this range, to find the next-smallest radius
rangeNames = @sprite.ranges.map((value, index) ->
value[0]
)
i = rangeNames.indexOf(type)
console.log(i, @sprite.ranges)
i = rangeNames.indexOf(range)
@mark = new createjs.Shape()
if colors[range]?
@mark.graphics.beginFill colors[range]
else
@mark.graphics.beginFill extracolors[i]
# Draw the outer circle
@mark.graphics.drawCircle 0, 0, r * Camera.PPM
@mark.graphics.drawCircle 0, 0, @sprite.thang[range] * Camera.PPM
# Cut out the hollow part if necessary
if i+1 < @sprite.ranges.length