mirror of
https://github.com/PfandBoss/SemesterGameJam2022.git
synced 2025-11-12 12:16:14 +01:00
updatet some things
This commit is contained in:
@@ -5,35 +5,40 @@ class_name Cannon
|
|||||||
enum STATE {INACTIVE, RELOADING, SHOOTING}
|
enum STATE {INACTIVE, RELOADING, SHOOTING}
|
||||||
enum AMMO {NORMAL, HEAVY, LIGHT}
|
enum AMMO {NORMAL, HEAVY, LIGHT}
|
||||||
var currentAmmo: AMMO
|
var currentAmmo: AMMO
|
||||||
var CAN_ENGAGE = true
|
var currentPowderStashValue = 0
|
||||||
|
var maxPowderStashValue = 3
|
||||||
|
var CAN_ENGAGE = false
|
||||||
var DAMAGE = 5
|
var DAMAGE = 5
|
||||||
@onready var train = get_parent() as Train
|
@onready var train = get_parent() as Train
|
||||||
|
|
||||||
#------------Methods-------------#
|
#------------Methods-------------#
|
||||||
func _ready():
|
func _ready():
|
||||||
maxStashValue = 1
|
maxStashValue = 1
|
||||||
currentStashValue = 1
|
currentStashValue = 0
|
||||||
currentState = STATE.INACTIVE
|
currentState = STATE.INACTIVE
|
||||||
#TODO: FINISH
|
#TODO: FINISH
|
||||||
func interact(player):
|
func interact(player):
|
||||||
|
|
||||||
if currentState == STATE.INACTIVE:
|
if currentState == STATE.INACTIVE:
|
||||||
#TODO: RELOADING
|
if player.getResource == 0:
|
||||||
if currentStashValue < maxStashValue:
|
if currentStashValue < maxStashValue:
|
||||||
currentState = STATE.RELOADING
|
currentStashValue += 1
|
||||||
currentStashValue += 1
|
return
|
||||||
|
return
|
||||||
|
if player.getResource == 1:
|
||||||
|
if currentPowderStashValue < maxPowderStashValue:
|
||||||
|
currentPowderStashValue += 1
|
||||||
|
return
|
||||||
return
|
return
|
||||||
return
|
|
||||||
|
|
||||||
func shoot():
|
func shoot():
|
||||||
if not CAN_ENGAGE:
|
if not CAN_ENGAGE:
|
||||||
return false
|
return false
|
||||||
CAN_ENGAGE = false
|
CAN_ENGAGE = false
|
||||||
create_tween().tween_callback(func(): CAN_ENGAGE = true).set_delay(2)
|
create_tween().tween_callback(func(): CAN_ENGAGE = true).set_delay(2)
|
||||||
|
if currentStashValue >= 1 and currentPowderStashValue >= 1 and currentState == STATE.INACTIVE:
|
||||||
if currentStashValue >= 1 and currentState == STATE.INACTIVE:
|
|
||||||
currentState = STATE.SHOOTING
|
currentState = STATE.SHOOTING
|
||||||
currentStashValue -= 1
|
currentStashValue -= 1
|
||||||
|
currentPowderStashValue = 0
|
||||||
currentState = STATE.INACTIVE
|
currentState = STATE.INACTIVE
|
||||||
return true
|
return true
|
||||||
return false
|
return false
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ extends Module
|
|||||||
|
|
||||||
class_name Storage
|
class_name Storage
|
||||||
|
|
||||||
enum TYPE {CANNONBALL, GUNPOWDER, COAL}
|
enum TYPE {AMMO, GUNPOWDER, COAL}
|
||||||
|
|
||||||
|
|
||||||
@export var currentType: TYPE
|
@export var currentType: TYPE
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ extends CharacterBody3D
|
|||||||
var SPEED = 10
|
var SPEED = 10
|
||||||
var movement = Vector3(0,0,0)
|
var movement = Vector3(0,0,0)
|
||||||
var inventory = 0 #1 - full, 0 - empty inventory
|
var inventory = 0 #1 - full, 0 - empty inventory
|
||||||
var resource = 0
|
var resource = 0 : set = setResource, get = getResource
|
||||||
|
|
||||||
var is_alive = true
|
var is_alive = true
|
||||||
@onready var is_player1 = true
|
@onready var is_player1 = true
|
||||||
@@ -24,7 +24,6 @@ func _physics_process(delta):
|
|||||||
$AnimatedSprite3D.play(walking)
|
$AnimatedSprite3D.play(walking)
|
||||||
else:
|
else:
|
||||||
$AnimatedSprite3D.play(idle)
|
$AnimatedSprite3D.play(idle)
|
||||||
|
|
||||||
movement = Vector3(0,0,0)
|
movement = Vector3(0,0,0)
|
||||||
check_interaction()
|
check_interaction()
|
||||||
check_input()
|
check_input()
|
||||||
@@ -40,7 +39,6 @@ func _physics_process(delta):
|
|||||||
move_and_slide()
|
move_and_slide()
|
||||||
|
|
||||||
func check_input():
|
func check_input():
|
||||||
|
|
||||||
if is_player1:
|
if is_player1:
|
||||||
if Input.is_action_pressed("p1_left"):
|
if Input.is_action_pressed("p1_left"):
|
||||||
movement.x -= 1
|
movement.x -= 1
|
||||||
@@ -90,3 +88,10 @@ func fill_inventory(type):
|
|||||||
2:
|
2:
|
||||||
walking = "walking_coal"
|
walking = "walking_coal"
|
||||||
idle = "idle_coal"
|
idle = "idle_coal"
|
||||||
|
|
||||||
|
|
||||||
|
func getResource():
|
||||||
|
return self.resource
|
||||||
|
|
||||||
|
func setResource(resource : int):
|
||||||
|
self.resource = resource
|
||||||
|
|||||||
Reference in New Issue
Block a user