small updates to prep
This commit is contained in:
parent
3b23e7b50d
commit
64e0b3a510
@ -503,7 +503,7 @@ position = Vector2(-74, 277)
|
||||
[node name="Coins" type="Node2D" parent="." unique_id=935250051]
|
||||
|
||||
[node name="Coin" parent="Coins" unique_id=1684921412 instance=ExtResource("13_trtic")]
|
||||
position = Vector2(512, 462)
|
||||
position = Vector2(362, 342)
|
||||
|
||||
[node name="Coin2" parent="Coins" unique_id=1619880767 instance=ExtResource("13_trtic")]
|
||||
position = Vector2(457, 467)
|
||||
|
||||
@ -9,7 +9,7 @@ var coinsCollected = 0
|
||||
|
||||
var timer := Timer.new()
|
||||
|
||||
#add new levels
|
||||
#Level Handling
|
||||
var levels=["res://scenes/game.tscn","res://scenes/level2.tscn"]
|
||||
var timers=[16,10]
|
||||
var currentLevel = 0
|
||||
@ -28,30 +28,28 @@ func _ready() -> void:
|
||||
timer.connect("timeout", secondCounter)
|
||||
timer.start()
|
||||
|
||||
# called by the scenemanager
|
||||
#Scene Handling
|
||||
# called by the scenemanager upon scene load
|
||||
func reset()->void:
|
||||
# reset the time
|
||||
timeAvailable = timers[currentLevel]
|
||||
enemiesDict.clear()
|
||||
playerHealth = playerStartingHealth
|
||||
|
||||
#Time Handling
|
||||
func secondCounter()->void:
|
||||
timeAvailable -=1
|
||||
if timeAvailable <=0:
|
||||
print("YOU LOSE BABY!!")
|
||||
levelChangeSignal.emit(levels[currentLevel])
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
#Coin Handling
|
||||
func _on_coin_collected(body:Player, coin:Coin)-> void:
|
||||
coinsCollected +=1
|
||||
destroySignal.emit(coin)
|
||||
|
||||
#Any time coins are destroyed, game controller is informed how many left
|
||||
func totalCoins(value)-> void:
|
||||
print(value)
|
||||
if value <=0:
|
||||
print("You WON!!!")
|
||||
currentLevel +=1
|
||||
@ -59,6 +57,7 @@ func totalCoins(value)-> void:
|
||||
currentLevel = 0
|
||||
levelChangeSignal.emit(levels[currentLevel])
|
||||
|
||||
#Triggers are area traps
|
||||
func _on_trigger(body: Variant, effect, trigger) -> void:
|
||||
print("GC knows trigger...."+effect)
|
||||
if body is Crate:
|
||||
@ -76,6 +75,7 @@ func _on_trigger(body: Variant, effect, trigger) -> void:
|
||||
timeAvailable +=5
|
||||
destroySignal.emit(trigger)
|
||||
|
||||
#Enemy Handling
|
||||
func _on_slime_damage(body, slime)->void:
|
||||
# print("Slime attacked player for "+str(enemiesDict[slime]["damage"]))
|
||||
playerHealth -= enemiesDict[slime]["damage"]
|
||||
@ -83,10 +83,8 @@ func _on_slime_damage(body, slime)->void:
|
||||
print("PLAYER KILLED!")
|
||||
#reload current level
|
||||
levelChangeSignal.emit(levels[currentLevel])
|
||||
|
||||
func totalEnemies(value)->void:
|
||||
print("Number of Enemies: "+str(value))
|
||||
|
||||
func addEnemyToLevel(slime:Slime)->void:
|
||||
#random number up to 10
|
||||
var randDamage:int = randi()%10
|
||||
@ -108,14 +106,13 @@ func crateUpdate(cratesAmount)->void:
|
||||
if currentLevel >= levels.size():
|
||||
currentLevel = 0
|
||||
levelChangeSignal.emit(levels[currentLevel])
|
||||
|
||||
func bulletDamage(body:Node2D, bullet:Bullet)->void:
|
||||
if body is Crate:
|
||||
#destroy crate
|
||||
destroySignal.emit(body)
|
||||
destroySignal.emit(bullet)
|
||||
#Update to damage Slime Enemies
|
||||
if body is Slime:
|
||||
print("bullet hitting slime")
|
||||
#damage the slime
|
||||
enemiesDict[body]["health"] -= 10
|
||||
if enemiesDict[body]["health"] <=0:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user