Bullet delay now upgrades on a tier system
This commit is contained in:
parent
7ce69fb960
commit
845dc35e37
59
Player.gd
59
Player.gd
|
@ -5,7 +5,7 @@ signal shooting_speed_upgrade
|
||||||
export (PackedScene) var Laser
|
export (PackedScene) var Laser
|
||||||
|
|
||||||
#Default ship strengths and costs
|
#Default ship strengths and costs
|
||||||
const SHOOTING_SPEED_UPGRADE_TIER1 = 50 #To be replaced
|
const SHOOTING_SPEED_UPGRADE_DEFAULT = 1500 #To be replaced
|
||||||
const BULLET_DELAY_TIER1 = 0.8
|
const BULLET_DELAY_TIER1 = 0.8
|
||||||
const BULLET_DELAY_TIER2 = 0.5
|
const BULLET_DELAY_TIER2 = 0.5
|
||||||
const BULLET_DELAY_TIER3 = 0.2
|
const BULLET_DELAY_TIER3 = 0.2
|
||||||
|
@ -22,13 +22,6 @@ const SHIP_SPEED_TIER3 = 300
|
||||||
const SHIP_SPEED_TIER4 = 500
|
const SHIP_SPEED_TIER4 = 500
|
||||||
const SHIP_SPEED_TIER5 = 800
|
const SHIP_SPEED_TIER5 = 800
|
||||||
|
|
||||||
#func upgradeBulletDelay():
|
|
||||||
# if (bullet_delay_tier == 1 && money >= BULLET_DELAY_TIER2_COST):
|
|
||||||
# bullet_delay = BULLET_DELAY_TIER2
|
|
||||||
# money -= BULLET_DELAY_TIER2_COST
|
|
||||||
# ship_value += BULLET_DELAY_TIER2_COST
|
|
||||||
#
|
|
||||||
|
|
||||||
var screensize
|
var screensize
|
||||||
|
|
||||||
var ship_speed = SHIP_SPEED_TIER1
|
var ship_speed = SHIP_SPEED_TIER1
|
||||||
|
@ -42,7 +35,38 @@ var ship_value = 0
|
||||||
var refund_percentage = 1
|
var refund_percentage = 1
|
||||||
var money = 100
|
var money = 100
|
||||||
|
|
||||||
var shooting_speed_upgrade = 50
|
var shooting_speed_upgrade = SHOOTING_SPEED_UPGRADE_DEFAULT
|
||||||
|
|
||||||
|
func upgradeBulletDelay():
|
||||||
|
if (can_shoot == true):
|
||||||
|
if (bullet_delay == 0.8 && money >= BULLET_DELAY_TIER2_COST):
|
||||||
|
bullet_delay = BULLET_DELAY_TIER2
|
||||||
|
money -= BULLET_DELAY_TIER2_COST
|
||||||
|
ship_value += BULLET_DELAY_TIER2_COST
|
||||||
|
elif (bullet_delay == 0.5 && money >= BULLET_DELAY_TIER3_COST):
|
||||||
|
bullet_delay = BULLET_DELAY_TIER3
|
||||||
|
money -= BULLET_DELAY_TIER3_COST
|
||||||
|
ship_value += BULLET_DELAY_TIER3_COST
|
||||||
|
elif (bullet_delay == 0.2 && money >= BULLET_DELAY_TIER4_COST):
|
||||||
|
bullet_delay = BULLET_DELAY_TIER4
|
||||||
|
money -= BULLET_DELAY_TIER4_COST
|
||||||
|
ship_value += BULLET_DELAY_TIER4_COST
|
||||||
|
elif (bullet_delay == 0.1 && money >= BULLET_DELAY_TIER5_COST):
|
||||||
|
bullet_delay = BULLET_DELAY_TIER5
|
||||||
|
money -= BULLET_DELAY_TIER5_COST
|
||||||
|
ship_value += BULLET_DELAY_TIER5_COST
|
||||||
|
elif (bullet_delay <= 0.01):
|
||||||
|
emit_signal("bullet_delay_fully_upgraded")
|
||||||
|
elif (bullet_delay <= 0.05 && money >= shooting_speed_upgrade):
|
||||||
|
bullet_delay = bullet_delay*0.95
|
||||||
|
money -= shooting_speed_upgrade
|
||||||
|
ship_value += shooting_speed_upgrade
|
||||||
|
shooting_speed_upgrade *= 1.1
|
||||||
|
|
||||||
|
timer.set_wait_time(bullet_delay)
|
||||||
|
prints(bullet_delay)
|
||||||
|
timer.start()
|
||||||
|
can_shoot = false
|
||||||
|
|
||||||
func _ready():
|
func _ready():
|
||||||
timer = Timer.new()
|
timer = Timer.new()
|
||||||
|
@ -56,13 +80,11 @@ func _ready():
|
||||||
|
|
||||||
screensize = get_viewport_rect().size
|
screensize = get_viewport_rect().size
|
||||||
$AnimatedSprite.play()
|
$AnimatedSprite.play()
|
||||||
# Initialization here
|
|
||||||
pass
|
|
||||||
|
|
||||||
func refund():
|
func refund():
|
||||||
bullet_delay = BULLET_DELAY_TIER1
|
bullet_delay = BULLET_DELAY_TIER1
|
||||||
ship_speed = SHIP_SPEED_TIER1
|
ship_speed = SHIP_SPEED_TIER1
|
||||||
shooting_speed_upgrade = SHOOTING_SPEED_UPGRADE_TIER1
|
shooting_speed_upgrade = SHOOTING_SPEED_UPGRADE_DEFAULT
|
||||||
money += ship_value*refund_percentage
|
money += ship_value*refund_percentage
|
||||||
emit_signal("refund", ship_value*refund_percentage)
|
emit_signal("refund", ship_value*refund_percentage)
|
||||||
ship_value = 0
|
ship_value = 0
|
||||||
|
@ -94,19 +116,10 @@ func _process(delta):
|
||||||
position.x = clamp(position.x, 0, screensize.x)
|
position.x = clamp(position.x, 0, screensize.x)
|
||||||
position.y = clamp(position.y, 0, screensize.y)
|
position.y = clamp(position.y, 0, screensize.y)
|
||||||
|
|
||||||
|
|
||||||
if (Input.is_action_pressed("ui_select") && can_shoot == true && money >= shooting_speed_upgrade ):
|
|
||||||
emit_signal("shooting_speed_upgrade")
|
|
||||||
money -= shooting_speed_upgrade
|
|
||||||
ship_value += shooting_speed_upgrade
|
|
||||||
shooting_speed_upgrade *= 1.02
|
|
||||||
bullet_delay = bullet_delay * 0.95
|
|
||||||
can_shoot = false
|
|
||||||
timer.set_wait_time(bullet_delay)
|
|
||||||
timer.start()
|
|
||||||
|
|
||||||
if ((Input.is_action_pressed("ui_accept") || shoot_down == true) && can_shoot == true):
|
if ((Input.is_action_pressed("ui_accept") || shoot_down == true) && can_shoot == true):
|
||||||
shoot()
|
shoot()
|
||||||
|
if (Input.is_action_pressed("ui_select") && can_shoot == true):
|
||||||
|
upgradeBulletDelay()
|
||||||
|
|
||||||
func _on_Player_body_entered(body):
|
func _on_Player_body_entered(body):
|
||||||
prints("hit")
|
prints("hit")
|
||||||
|
|
|
@ -20,7 +20,7 @@ custom_solver_bias = 0.0
|
||||||
radius = 19.3222
|
radius = 19.3222
|
||||||
height = 76.5834
|
height = 76.5834
|
||||||
|
|
||||||
[node name="Player" type="Area2D"]
|
[node name="Player" type="Area2D" index="0"]
|
||||||
|
|
||||||
input_pickable = true
|
input_pickable = true
|
||||||
gravity_vec = Vector2( 0, 1 )
|
gravity_vec = Vector2( 0, 1 )
|
||||||
|
|
Loading…
Reference in New Issue