|
|
|
|
@ -9,15 +9,10 @@ class Trans:
|
|
|
|
|
var conditionValue
|
|
|
|
|
var from:StringName
|
|
|
|
|
var to:StringName
|
|
|
|
|
var trigger_name:StringName
|
|
|
|
|
var on_end:bool
|
|
|
|
|
|
|
|
|
|
class Trigger:
|
|
|
|
|
var condition:StringName
|
|
|
|
|
var from:StringName
|
|
|
|
|
var to:StringName
|
|
|
|
|
|
|
|
|
|
var run_map = {}
|
|
|
|
|
var trans_list = []
|
|
|
|
|
var trigger_list = []
|
|
|
|
|
var move_sprite_frames:SpriteFrames
|
|
|
|
|
|
|
|
|
|
func _ready():
|
|
|
|
|
@ -38,19 +33,36 @@ func _ready():
|
|
|
|
|
run("jump5","idle_loop")
|
|
|
|
|
trans("jump5","run1","speed_xz",">",1)
|
|
|
|
|
|
|
|
|
|
#受击
|
|
|
|
|
trigger("any","hit1","trigger_hit")
|
|
|
|
|
#地面受击
|
|
|
|
|
trigger_with_condition("any","hit1","trigger_hit","is_on_floor","=",true)
|
|
|
|
|
trigger_with_condition("any","mhit","trigger_mhit","is_on_floor","=",true)
|
|
|
|
|
trigger_with_condition("any","lhit","trigger_lhit","is_on_floor","=",true)
|
|
|
|
|
run("hit1","hit2_loop")
|
|
|
|
|
trans("hit2_loop","hit3","is_stagger","=",false)
|
|
|
|
|
run("hit3","idle_loop")
|
|
|
|
|
run("mhit3","idle_loop")
|
|
|
|
|
trans("hit2_loop","hit3","is_stagger","=",false)
|
|
|
|
|
trans("mhit2_loop","mhit3","is_stagger","=",false)
|
|
|
|
|
trans("lhit2_loop","lhit3","is_stagger","=",false)
|
|
|
|
|
run("mhit1","mhit2_loop")
|
|
|
|
|
run("lhit1","lhit2_loop")
|
|
|
|
|
run("lhit3","idle_loop")
|
|
|
|
|
|
|
|
|
|
#空中受击
|
|
|
|
|
trigger_with_condition("any","airhit1","trigger_hit","is_on_floor","=",false)
|
|
|
|
|
run("airhit1","airhit2_loop")
|
|
|
|
|
trans("airhit2_loop","airhit3","speed_y","<",0)
|
|
|
|
|
run("airhit3","airhit4_loop")
|
|
|
|
|
trans("airhit4_loop","airhit5","is_on_floor","=",true)
|
|
|
|
|
run("airhit5","ground1_loop")
|
|
|
|
|
trans("ground1_loop","ground2","is_stagger","=",false)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func _process(delta):
|
|
|
|
|
if status.is_pause:return
|
|
|
|
|
update_flip()
|
|
|
|
|
update_trigger()
|
|
|
|
|
update_view()
|
|
|
|
|
if status.is_free_control:
|
|
|
|
|
update_trans()
|
|
|
|
|
update_trans(false)
|
|
|
|
|
|
|
|
|
|
func init(default:SpriteFrames):
|
|
|
|
|
sprite_frames = default
|
|
|
|
|
@ -62,50 +74,55 @@ func reset():
|
|
|
|
|
play("idle_loop")
|
|
|
|
|
|
|
|
|
|
func run(from:StringName,to:StringName):
|
|
|
|
|
run_map[from] = to
|
|
|
|
|
_add_trans(from,to,"","","","",true)
|
|
|
|
|
|
|
|
|
|
func trans(from:StringName,to:StringName,condition,compareType,conditionValue):
|
|
|
|
|
var newTrans = Trans.new()
|
|
|
|
|
newTrans.condition = condition
|
|
|
|
|
newTrans.compareType = compareType
|
|
|
|
|
newTrans.conditionValue = conditionValue
|
|
|
|
|
newTrans.from = from
|
|
|
|
|
newTrans.to = to
|
|
|
|
|
trans_list.append(newTrans)
|
|
|
|
|
|
|
|
|
|
func trigger(from:StringName,to:StringName,condition):
|
|
|
|
|
var newTrigger = Trans.new()
|
|
|
|
|
newTrigger.condition = condition
|
|
|
|
|
newTrigger.from = from
|
|
|
|
|
newTrigger.to = to
|
|
|
|
|
trigger_list.append(newTrigger)
|
|
|
|
|
|
|
|
|
|
func update_trigger():
|
|
|
|
|
for trigger in trigger_list:
|
|
|
|
|
if trigger.from == "any" or trigger.from == animation:
|
|
|
|
|
if status.get(trigger.condition):
|
|
|
|
|
status.set(trigger.condition,false)
|
|
|
|
|
play(trigger.to)
|
|
|
|
|
|
|
|
|
|
func update_view():
|
|
|
|
|
#view位置
|
|
|
|
|
position = status.basic_offset + status.shake_offset
|
|
|
|
|
func run_with_condition(from:StringName,to:StringName,condition,compareType,conditionValue):
|
|
|
|
|
_add_trans(from,to,condition,compareType,conditionValue,"",true)
|
|
|
|
|
|
|
|
|
|
func update_trans():
|
|
|
|
|
func trans(from:StringName,to:StringName,condition,compareType,conditionValue):
|
|
|
|
|
_add_trans(from,to,condition,compareType,conditionValue,"",false)
|
|
|
|
|
|
|
|
|
|
func trigger(from:StringName,to:StringName,trigger_name:StringName):
|
|
|
|
|
_add_trans(from,to,"","","",trigger_name,false)
|
|
|
|
|
|
|
|
|
|
func trigger_with_condition(from:StringName,to:StringName,trigger_name:StringName,condition,compareType,conditionValue):
|
|
|
|
|
_add_trans(from,to,condition,compareType,conditionValue,trigger_name,false)
|
|
|
|
|
|
|
|
|
|
func _add_trans(from:StringName,to:StringName,condition,compareType,conditionValue,trigger_name:StringName,on_end:bool):
|
|
|
|
|
var new_trans = Trans.new()
|
|
|
|
|
new_trans.condition = condition
|
|
|
|
|
new_trans.compareType = compareType
|
|
|
|
|
new_trans.conditionValue = conditionValue
|
|
|
|
|
new_trans.from = from
|
|
|
|
|
new_trans.to = to
|
|
|
|
|
new_trans.trigger_name = trigger_name
|
|
|
|
|
new_trans.on_end = on_end
|
|
|
|
|
trans_list.append(new_trans)
|
|
|
|
|
|
|
|
|
|
func update_trans(on_end:bool):
|
|
|
|
|
for trans in trans_list:
|
|
|
|
|
if trans.from == "any" or trans.from == animation:
|
|
|
|
|
if on_end != trans.on_end:
|
|
|
|
|
continue
|
|
|
|
|
if not (trans.from == "any" or trans.from == animation):
|
|
|
|
|
continue
|
|
|
|
|
if trans.condition != "":
|
|
|
|
|
var conditionValue = status.get(trans.condition)
|
|
|
|
|
match trans.compareType:
|
|
|
|
|
">":if conditionValue <= trans.conditionValue:return
|
|
|
|
|
"<":if conditionValue >= trans.conditionValue:return
|
|
|
|
|
"=":if conditionValue != trans.conditionValue:return
|
|
|
|
|
">":if conditionValue <= trans.conditionValue:continue
|
|
|
|
|
"<":if conditionValue >= trans.conditionValue:continue
|
|
|
|
|
"=":if conditionValue != trans.conditionValue:continue
|
|
|
|
|
if trans.trigger_name != "":
|
|
|
|
|
if status.get(trans.trigger_name):
|
|
|
|
|
status.set(trans.trigger_name,false)
|
|
|
|
|
else:continue
|
|
|
|
|
play(trans.to)
|
|
|
|
|
|
|
|
|
|
func update_flip():
|
|
|
|
|
scale.x = 1 if status.is_right else -1
|
|
|
|
|
|
|
|
|
|
func update_view():
|
|
|
|
|
position = status.basic_offset + status.shake_offset
|
|
|
|
|
|
|
|
|
|
func _on_animation_finished():
|
|
|
|
|
if animation in run_map:
|
|
|
|
|
var run = run_map[animation]
|
|
|
|
|
play(run)
|
|
|
|
|
update_trans(true)
|
|
|
|
|
|
|
|
|
|
|