bacteria.gd 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. extends KinematicBody2D
  2. var motion = Vector2(0,1)
  3. var dir = Vector2(0,1)
  4. export var speed = 200
  5. var attackrange = 80
  6. signal dieproxy
  7. var exppt = 0
  8. var currentxp = 0
  9. var totalxp = 0
  10. var nextxp = 25
  11. var lv = 1
  12. func get_stat(arg):
  13. var buff = 1.0
  14. for x in Powerups.dict.values():
  15. if x.has(arg):
  16. buff *= x[arg]
  17. print(arg +" stat is : "+ str(buff))
  18. return buff
  19. func _load():
  20. self.speed = get_stat('speed') * 200
  21. self.xpmult = get_stat('xpmult')
  22. $hitbox.dmg = get_stat('dmg') * 10
  23. $hitbox.critical_chance = get_stat('critical_chance') - 1.0
  24. $hitbox.critical_dmg = get_stat('critical_dmg')
  25. $Health.reactive_dmg = get_stat('dmg') * get_stat('react_dmg')
  26. $Health.hpmult = get_stat('hppickup')
  27. $Health.chance = (get_stat('invunerabilitychance') - 1.0)
  28. $Health.chance += ((get_stat('invunerabilitychancemult') - 1.0)*self.speed/100)
  29. $Health.invutime = get_stat('invunerabilitytime')
  30. $hitbox.hpsteal = get_stat('hpsteal')
  31. $hitbox.stealhp = get_stat('stealhp')
  32. $hitbox.apc = get_stat('atkspeed')
  33. $Health.regen = get_stat('regen') - 1
  34. $Health.health = get_stat('hp') * 50
  35. $Health.health_max = get_stat('hp') * 50
  36. $Camera2D.zoom.x = get_stat('camzoom')
  37. $Camera2D.zoom.y = get_stat('camzoom')
  38. $Health._ready()
  39. print('real invu chance is : ' + str($Health.chance))
  40. self.attackrange = get_stat('range') * 80
  41. for x in get_node("Icon").get_children():
  42. for y in x.get_children():
  43. for z in y.get_children():
  44. z.queue_free()
  45. var sprite = Sprite.new()
  46. sprite.hframes = 2
  47. sprite.texture = Powerups.dict[y.name].img
  48. y.add_child(sprite)
  49. func _physics_process(delta):
  50. move_and_slide(motion * speed)
  51. $hitbox.position = dir * attackrange
  52. $Icon.rotation = atan2(motion.y,motion.x)
  53. $AnimationPlayer.playback_speed = motion.length() * speed / 100 * 1.5
  54. func _input(event):
  55. if event is InputEventScreenDrag or event is InputEventScreenTouch and event.is_pressed():
  56. dir = (event.position - get_global_transform_with_canvas().origin).normalized()
  57. motion = dir
  58. func _on_Health_die():
  59. emit_signal('dieproxy')
  60. pass # Replace with function body.
  61. var xpmult = 1.0
  62. signal level_up
  63. signal menuclose
  64. func _on_hitbox_gotxp(arg):
  65. totalxp += arg * xpmult
  66. currentxp += arg * xpmult
  67. while currentxp > nextxp:
  68. currentxp -= nextxp
  69. emit_signal("level_up")
  70. nextxp += 5
  71. lv += 1
  72. print(lv)
  73. $CanvasLayer/VBoxContainer/Label.set_text(str(int(currentxp)))
  74. $CanvasLayer/VBoxContainer/Label3.set_text('Lv.'+str(lv))
  75. $CanvasLayer/ProgressBar2.set_value( currentxp )
  76. $CanvasLayer/ProgressBar2.set_max( nextxp )
  77. yield(get_parent().get_node("PowerUpControl"),"close_menu")
  78. yield(Timergen.createtime(self,0.01677),'timeout')
  79. pass # Replace with function body.