Add Area Damage Ability to Cannon V3

This commit is contained in:
Moe Poi ~ 2023-10-21 00:59:00 +07:00
parent 98b66a0647
commit 223441e957
8 changed files with 85 additions and 41 deletions

View file

@ -2,9 +2,11 @@ extends Area2D
const right = Vector2.RIGHT
var speed : int = 0
var damage : int = 0
var speed: int = 0
var damage: int = 0
var dir = 0
var area_damage: bool = false
var area_damage_target = []
func _physics_process(_delta):
var move_dir = Vector2(1,0).rotated(dir)
@ -15,5 +17,9 @@ func _on_VisibilityNotifier2D_screen_exited():
func _on_Bullet_body_entered(body):
if body.is_in_group("Enemy"):
body.get_parent().hit(damage)
if area_damage:
for enemy in area_damage_target:
enemy.hit(damage)
else:
body.get_parent().hit(damage)
queue_free()

View file

@ -76,7 +76,8 @@ var tower = [
"speed": 3,
"damage": 30,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Railgun",
@ -86,7 +87,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Cannon (V2)",
@ -96,7 +98,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Railgun (V2)",
@ -106,7 +109,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Cannon (V3)",
@ -116,7 +120,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": true
},
{
"name": "Railgun (V3)",
@ -126,7 +131,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
}
]

View file

@ -106,7 +106,8 @@ var tower = [
"speed": 3,
"damage": 30,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Railgun",
@ -116,7 +117,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Cannon (V2)",
@ -126,7 +128,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Railgun (V2)",
@ -136,7 +139,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Cannon (V3)",
@ -146,7 +150,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": true
},
{
"name": "Railgun (V3)",
@ -156,7 +161,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
}
]

View file

@ -88,7 +88,8 @@ var tower = [
"speed": 3,
"damage": 30,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Railgun",
@ -98,7 +99,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Cannon (V2)",
@ -108,7 +110,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Railgun (V2)",
@ -118,7 +121,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Cannon (V3)",
@ -128,7 +132,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": true
},
{
"name": "Railgun (V3)",
@ -138,7 +143,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
}
]

View file

@ -94,7 +94,8 @@ var tower = [
"speed": 3,
"damage": 30,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Railgun",
@ -104,7 +105,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Cannon (V2)",
@ -114,7 +116,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Railgun (V2)",
@ -124,7 +127,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Cannon (V3)",
@ -134,7 +138,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": true
},
{
"name": "Railgun (V3)",
@ -144,7 +149,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
}
]

View file

@ -94,7 +94,8 @@ var tower = [
"speed": 3,
"damage": 30,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Railgun",
@ -104,7 +105,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Cannon (V2)",
@ -114,7 +116,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Railgun (V2)",
@ -124,7 +127,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Cannon (V3)",
@ -134,7 +138,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": true
},
{
"name": "Railgun (V3)",
@ -144,7 +149,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
}
]

View file

@ -136,7 +136,8 @@ var tower = [
"speed": 3,
"damage": 30,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": true
},
{
"name": "Railgun",
@ -146,7 +147,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Cannon (V2)",
@ -156,7 +158,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Railgun (V2)",
@ -166,7 +169,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
},
{
"name": "Cannon (V3)",
@ -176,7 +180,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": true
},
{
"name": "Railgun (V3)",
@ -186,7 +191,8 @@ var tower = [
"speed": 3,
"damage": 40,
"health": 100,
"durability_reduction": 10
"durability_reduction": 10,
"area_damage": false
}
]

View file

@ -15,8 +15,7 @@ var damage: int = 0
var speed: int = 0
var shoot_timer: float = 0
var durability_reduction: int = 0
var is_shoot: bool = true
var area_damage: bool = false
var enemies = []
@ -32,6 +31,7 @@ func set_tower(id: int, placement_id):
speed = config.tower[tower_id]['speed']
shoot_timer = config.tower[tower_id]['timer']
durability_reduction = config.tower[tower_id]['durability_reduction']
area_damage = config.tower[tower_id]['area_damage']
func set_timer():
timer.wait_time = shoot_timer
@ -62,6 +62,8 @@ func _shoot():
bullet_instance.global_position = global_position
bullet_instance.speed = speed
bullet_instance.damage = damage
bullet_instance.area_damage = area_damage
bullet_instance.area_damage_target = enemies
get_tree().current_scene.add_child(bullet_instance)
health -= durability_reduction
timer.start()