mirror of
https://github.com/PfandBoss/SemesterGameJam2022.git
synced 2025-11-12 04:16:12 +01:00
added cannon functionality
This commit is contained in:
@@ -7,6 +7,7 @@ var currentPowderStashValue = 0
|
||||
var maxPowderStashValue = 3
|
||||
var CAN_ENGAGE = false
|
||||
var DAMAGE = 5
|
||||
var ammoType = -1
|
||||
@onready var train = get_parent() as Train
|
||||
|
||||
#------------Methods-------------#
|
||||
@@ -20,6 +21,7 @@ func interact(player):
|
||||
if player.getResource() == 0:
|
||||
if currentStashValue < maxStashValue:
|
||||
currentStashValue += 1
|
||||
ammoType = 0
|
||||
player.clearInventory()
|
||||
$AudioStreamPlayer2.play()
|
||||
return
|
||||
@@ -30,10 +32,41 @@ func interact(player):
|
||||
player.clearInventory()
|
||||
$AudioStreamPlayer2.play()
|
||||
return
|
||||
return
|
||||
|
||||
if player.getResource() == 3:
|
||||
if currentStashValue < maxStashValue:
|
||||
currentStashValue += 1
|
||||
ammoType = 1
|
||||
player.clearInventory()
|
||||
$AudioStreamPlayer2.play()
|
||||
return
|
||||
|
||||
if player.getResource() == 4:
|
||||
if currentStashValue < maxStashValue:
|
||||
currentStashValue += 1
|
||||
ammoType = 2
|
||||
player.clearInventory()
|
||||
$AudioStreamPlayer2.play()
|
||||
return
|
||||
|
||||
func shoot():
|
||||
if currentStashValue >= 1 and currentPowderStashValue >= 1 and currentState == STATE.INACTIVE:
|
||||
if currentStashValue >= 1 and currentPowderStashValue >= 1 and currentState == STATE.INACTIVE and ammoType == 0:
|
||||
currentState = STATE.SHOOTING
|
||||
currentStashValue -= 1
|
||||
currentPowderStashValue = 0
|
||||
currentState = STATE.INACTIVE
|
||||
$AudioStreamPlayer.play(0)
|
||||
return true
|
||||
|
||||
if currentStashValue >= 1 and currentPowderStashValue >= 2 and currentState == STATE.INACTIVE and ammoType == 1:
|
||||
currentState = STATE.SHOOTING
|
||||
currentStashValue -= 1
|
||||
currentPowderStashValue = 0
|
||||
currentState = STATE.INACTIVE
|
||||
$AudioStreamPlayer.play(0)
|
||||
return true
|
||||
|
||||
if currentStashValue >= 1 and currentPowderStashValue >= 3 and currentState == STATE.INACTIVE and ammoType == 2:
|
||||
currentState = STATE.SHOOTING
|
||||
currentStashValue -= 1
|
||||
currentPowderStashValue = 0
|
||||
|
||||
Reference in New Issue
Block a user