123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960 |
- extends KinematicBody2D
- var motion = Vector2()
- var dir = Vector2()
- export var speed = 100
- var attackrange = 80
- signal dieproxy
- var exppt = 0
- var currentxp = 0
- var totalxp = 0
- var nextxp = 100
- var lv = 1
- var dict = {
- 'a': load('res://leg3.png'),
- 'b': load('res://leg2.png'),
- 'c': load('res://leg.png'),
- }
- func _ready():
- for x in get_node("Icon").get_children():
- for y in x.get_children():
- var sprite = Sprite.new()
- sprite.texture = dict[y.name]
- y.add_child(sprite)
- func _physics_process(delta):
-
- move_and_slide(motion * speed)
- $hitbox.position = dir * attackrange
- $Icon.rotation = atan2(motion.y,motion.x)
- $AnimationPlayer.playback_speed = motion.length() * speed / 100 * 1.5
- func _input(event):
- if event is InputEventScreenDrag or event is InputEventScreenTouch and event.is_pressed():
- dir = (event.position - get_global_transform_with_canvas().origin).normalized()
- motion = dir
- else:
- motion *= .8
-
- func _on_Health_die():
- emit_signal('dieproxy')
- pass # Replace with function body.
- func _on_hitbox_gotxp(arg):
- totalxp += arg
- currentxp += arg
- if currentxp > nextxp:
- currentxp -= nextxp
- nextxp *= 1.5
- lv += 1
- print(lv)
- $CanvasLayer/VBoxContainer/Label.set_text(str(currentxp))
- $CanvasLayer/VBoxContainer/Label3.set_text('Lv.'+str(lv))
- $CanvasLayer/VBoxContainer/Label/ProgressBar2.set_value( currentxp )
- $CanvasLayer/VBoxContainer/Label/ProgressBar2.set_max( nextxp )
- pass # Replace with function body.
|