From 8802b8643e1906d50ac1e154dad251a1f9671953 Mon Sep 17 00:00:00 2001 From: Arthur Date: Sun, 11 Dec 2022 00:17:57 +0100 Subject: [PATCH] added cannon functionality --- Nodes/Train_P1.tscn | 33 ++++++++++++++++++++++++++++++++- Nodes/Train_P2.tscn | 37 ++++++++++++++++++++++++++++++++++++- Nodes/game.tscn | 2 +- scripts/Modules/Cannon.gd | 37 +++++++++++++++++++++++++++++++++++-- 4 files changed, 104 insertions(+), 5 deletions(-) diff --git a/Nodes/Train_P1.tscn b/Nodes/Train_P1.tscn index bf1ac13..40f5018 100644 --- a/Nodes/Train_P1.tscn +++ b/Nodes/Train_P1.tscn @@ -1,4 +1,8 @@ +<<<<<<< Updated upstream [gd_scene load_steps=24 format=3 uid="uid://md2ofbviios3"] +======= +[gd_scene load_steps=27 format=3 uid="uid://md2ofbviios3"] +>>>>>>> Stashed changes [ext_resource type="Script" path="res://scripts/Train.gd" id="1_0x664"] [ext_resource type="PackedScene" path="res://Nodes/engine.tscn" id="3_1ix85"] @@ -12,10 +16,17 @@ [ext_resource type="Texture2D" uid="uid://d35iaj0nq122a" path="res://walking_powder1.png" id="6_kfxv2"] [ext_resource type="Texture2D" uid="uid://eg0k8esm2scp" path="res://p5lFkJY.png" id="6_m0hj7"] [ext_resource type="Texture2D" uid="uid://du7d6fk4dabd7" path="res://cVOQuID.png" id="7_d8go0"] +[ext_resource type="Texture2D" uid="uid://b4yysvn1ibspa" path="res://walking_giant1.png" id="7_vmdku"] [ext_resource type="Texture2D" uid="uid://ctbxpx6p36bdi" path="res://walking_ball2.png" id="8_0u1e2"] +[ext_resource type="Texture2D" uid="uid://nbfs0w8tpjt4" path="res://walking_large1.png" id="8_mkx82"] [ext_resource type="Texture2D" uid="uid://ckdlv6b7okseq" path="res://walking_powder2.png" id="10_a137a"] [ext_resource type="Texture2D" uid="uid://b5ioch3ad8y6r" path="res://walking_coal2.png" id="11_1jgcf"] +<<<<<<< Updated upstream [ext_resource type="Texture2D" uid="uid://7qppu15lvd1j" path="res://Nodes/Keys.png" id="13_d8wle"] +======= +[ext_resource type="Texture2D" uid="uid://4hcjvygte1em" path="res://walking_giant2.png" id="14_3p5dx"] +[ext_resource type="Texture2D" uid="uid://clgd25fer2yka" path="res://walking_large2.png" id="15_iuchn"] +>>>>>>> Stashed changes [ext_resource type="PackedScene" uid="uid://bkpnrgcfr1jgl" path="res://Nodes/Bin.tscn" id="16_q3kvk"] [ext_resource type="AudioStream" uid="uid://bsc5ku8mloa6j" path="res://Assets/Sounds/_SOUNDFX_/Gunpowder.wav" id="17_ajifv"] @@ -48,6 +59,16 @@ animations = [{ "name": &"idle_coal", "speed": 1.0 }, { +"frames": [ExtResource("7_vmdku")], +"loop": true, +"name": &"idle_giant", +"speed": 1.0 +}, { +"frames": [ExtResource("8_mkx82")], +"loop": true, +"name": &"idle_large", +"speed": 1.0 +}, { "frames": [ExtResource("6_kfxv2")], "loop": true, "name": &"idle_powder", @@ -68,6 +89,16 @@ animations = [{ "name": &"walking_coal", "speed": 2.0 }, { +"frames": [ExtResource("7_vmdku"), ExtResource("14_3p5dx")], +"loop": true, +"name": &"walking_giant", +"speed": 2.0 +}, { +"frames": [ExtResource("8_mkx82"), ExtResource("15_iuchn")], +"loop": true, +"name": &"walking_large", +"speed": 2.0 +}, { "frames": [ExtResource("6_kfxv2"), ExtResource("10_a137a")], "loop": true, "name": &"walking_powder", @@ -114,7 +145,7 @@ transform = Transform3D(1, 0, -3.55271e-15, 0, 1, 0, 3.55271e-15, 0, 1, 3.19744e [node name="AnimatedSprite3D" type="AnimatedSprite3D" parent="CharacterBody3D"] transform = Transform3D(0.3, 0, 0, 0, -1.31134e-08, 0.3, 0, -0.3, -1.31134e-08, 0, -2, 0) frames = SubResource("SpriteFrames_6p0y6") -animation = &"walking_coal" +animation = &"walking_giant" speed_scale = 2.0 playing = true diff --git a/Nodes/Train_P2.tscn b/Nodes/Train_P2.tscn index 1cae0c2..22207f7 100644 --- a/Nodes/Train_P2.tscn +++ b/Nodes/Train_P2.tscn @@ -1,4 +1,8 @@ +<<<<<<< Updated upstream [gd_scene load_steps=25 format=3 uid="uid://bikdn7ep2vpxw"] +======= +[gd_scene load_steps=28 format=3 uid="uid://bikdn7ep2vpxw"] +>>>>>>> Stashed changes [ext_resource type="Script" path="res://scripts/Train.gd" id="1_mcmgl"] [ext_resource type="PackedScene" uid="uid://c1mymb38wqdg6" path="res://Nodes/train.tscn" id="2_xoa1a"] @@ -10,15 +14,26 @@ [ext_resource type="Texture2D" uid="uid://ci4yd4vjr17o1" path="res://o_walking_coal1.png" id="7_jsqie"] [ext_resource type="Texture2D" uid="uid://os0kogn0mkus" path="res://o_walking_powder1.png" id="7_lwj85"] [ext_resource type="Texture2D" uid="uid://j7jwtqmvg0m8" path="res://o_walking2.png" id="8_isr5o"] +[ext_resource type="Texture2D" uid="uid://86mwqq8jadtj" path="res://o_walking_giant1.png" id="8_t43v2"] +[ext_resource type="Texture2D" uid="uid://ifauy3vee10v" path="res://o_walking_large1.png" id="9_b6l2s"] [ext_resource type="Texture2D" uid="uid://djsergj3l4t2c" path="res://o_walking_ball2.png" id="9_rt6ws"] [ext_resource type="Texture2D" uid="uid://ctssikrodjqvc" path="res://o_walking_powder2.png" id="11_eefgn"] [ext_resource type="Texture2D" uid="uid://nctqw3vt5q0y" path="res://o_walking_coal2.png" id="12_581v4"] [ext_resource type="PackedScene" uid="uid://bkpnrgcfr1jgl" path="res://Nodes/Bin.tscn" id="14_n2rwc"] +<<<<<<< Updated upstream [ext_resource type="Texture2D" uid="uid://7qppu15lvd1j" path="res://Nodes/Keys.png" id="14_otf4l"] [ext_resource type="PackedScene" uid="uid://byo1m0n20yl45" path="res://Nodes/cannon.tscn" id="15_sof53"] [ext_resource type="PackedScene" uid="uid://cet80w4yr8rse" path="res://Storage.tscn" id="16_7dojn"] [ext_resource type="PackedScene" path="res://Nodes/engine.tscn" id="17_regf7"] [ext_resource type="AudioStream" uid="uid://bsc5ku8mloa6j" path="res://Assets/Sounds/_SOUNDFX_/Gunpowder.wav" id="17_xnc4h"] +======= +[ext_resource type="Texture2D" uid="uid://ce5imf2m4w5y2" path="res://o_walking_giant2.png" id="15_jsgah"] +[ext_resource type="PackedScene" uid="uid://byo1m0n20yl45" path="res://Nodes/cannon.tscn" id="15_sof53"] +[ext_resource type="PackedScene" uid="uid://cet80w4yr8rse" path="res://Storage.tscn" id="16_7dojn"] +[ext_resource type="Texture2D" uid="uid://b3pb0trgav15s" path="res://o_walking_large2.png" id="16_a8x3b"] +[ext_resource type="PackedScene" uid="uid://bhivunrkj87cy" path="res://Nodes/engine.tscn" id="17_regf7"] +[ext_resource type="AudioStream" uid="uid://b52sd64x20ulv" path="res://Assets/Sounds/_SOUNDFX_/Gunpowder.wav" id="17_xnc4h"] +>>>>>>> Stashed changes [sub_resource type="BoxShape3D" id="BoxShape3D_dijw3"] size = Vector3(1, 3.77669, 24) @@ -49,6 +64,16 @@ animations = [{ "name": &"idle_coal", "speed": 1.0 }, { +"frames": [ExtResource("8_t43v2")], +"loop": true, +"name": &"idle_giant", +"speed": 1.0 +}, { +"frames": [ExtResource("9_b6l2s")], +"loop": true, +"name": &"idle_large", +"speed": 1.0 +}, { "frames": [ExtResource("7_lwj85")], "loop": true, "name": &"idle_powder", @@ -69,6 +94,16 @@ animations = [{ "name": &"walking_coal", "speed": 2.0 }, { +"frames": [ExtResource("8_t43v2"), ExtResource("15_jsgah")], +"loop": true, +"name": &"walking_giant", +"speed": 2.0 +}, { +"frames": [ExtResource("9_b6l2s"), ExtResource("16_a8x3b")], +"loop": true, +"name": &"walking_large", +"speed": 2.0 +}, { "frames": [ExtResource("7_lwj85"), ExtResource("11_eefgn")], "loop": true, "name": &"walking_powder", @@ -115,7 +150,7 @@ transform = Transform3D(1, 0, -3.55271e-15, 0, 1, 0, 3.55271e-15, 0, 1, 2.84217e [node name="AnimatedSprite3D" type="AnimatedSprite3D" parent="CharacterBody3D"] transform = Transform3D(0.3, 0, 0, 0, -1.31134e-08, 0.3, 0, -0.3, -1.31134e-08, 0, -2, 0) frames = SubResource("SpriteFrames_ltjyh") -animation = &"walking_coal" +animation = &"walking_giant" speed_scale = 2.0 playing = true diff --git a/Nodes/game.tscn b/Nodes/game.tscn index aeb5d02..d016a0f 100644 --- a/Nodes/game.tscn +++ b/Nodes/game.tscn @@ -1,7 +1,7 @@ [gd_scene load_steps=10 format=3 uid="uid://cqkd0g15r5btu"] [ext_resource type="Script" path="res://scripts/Logic/Game.gd" id="1_gf730"] -[ext_resource type="PackedScene" path="res://Nodes/light_setup.tscn" id="2_8im8o"] +[ext_resource type="PackedScene" uid="uid://nxapkgcq2c70" path="res://Nodes/light_setup.tscn" id="2_8im8o"] [ext_resource type="PackedScene" uid="uid://bqe8ucbruto1j" path="res://Nodes/StartNode.tscn" id="3_s558u"] [ext_resource type="PackedScene" uid="uid://md2ofbviios3" path="res://Nodes/Train_P1.tscn" id="4_05mbx"] [ext_resource type="PackedScene" uid="uid://bikdn7ep2vpxw" path="res://Nodes/Train_P2.tscn" id="5_gee2r"] diff --git a/scripts/Modules/Cannon.gd b/scripts/Modules/Cannon.gd index b090023..82247dc 100644 --- a/scripts/Modules/Cannon.gd +++ b/scripts/Modules/Cannon.gd @@ -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