1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- extends KinematicBody2D
- var input = ''
- var animation = 'idle'
- var motion = Vector2()
- func _ready():
- print('generated clinet physics of id: ' + name)
- var attacks = ['melee']
- var damage = preload('res://damage_player.tscn')
- var attack_buffers = {'melee':0}
- var vida = 100
- func damage(arg, id):
- vida += arg
- if vida <= 0:
- get_node('../..').hp_update(vida, name)
- queue_free()
- var sidebuffer = true
- #func melee():
- # attack_buffers.melee += 1
- # if fmod(attack_buffers.melee,45) == 0:
- # var newdmg = damage.instance()
- # newdmg.global_position = global_position + (Vector2(70,0) if sidebuffer else Vector2(-70,0))
- # newdmg.attacker = name
- # get_node('../../dmgbox').add_child(newdmg)
- # get_node('../..').player_anim('melee',name)
- export var dmg = 50
- func melee():
- attack_buffers.melee += 1
- if fmod(attack_buffers.melee,45) == 0:
- dmg(70,0)
- get_node('../..').player_anim('melee',name)
- func dmg(arg,arg1):
- get_node('../../../Server/enemies').damage_detection(global_position + (Vector2(arg,arg1) if sidebuffer else Vector2(-arg,arg1)),dmg,name)
- func _physics_process(delta):
- get_node('../..').hp_update(vida, name)
- if motion.x != 0: sidebuffer = motion.x > 0
- for i in attacks:
- funcref(self,i).call_func()
- match input:
- "ui_down":
- motion.y = 100
- animation = 'walk'
- "ui_up":
- motion.y = -100
- animation = 'walk'
- "ui_left":
- motion.x = -100
- animation = 'walk'
- "ui_right":
- motion.x = 100
- animation = 'walk'
- _:
- motion = Vector2.ZERO
- animation = 'idle'
- move_and_slide(motion)
|