Kinda works ish now

This commit is contained in:
Victor Turgeon 2023-06-11 16:32:03 -04:00
parent 0b735bc009
commit 99c83fef2b
6 changed files with 123 additions and 43 deletions

View File

@ -1,16 +1,16 @@
[gd_scene load_steps=4 format=3 uid="uid://bh6e2nxqswoqg"]
[ext_resource type="Script" path="res://buildings/arms_building.cs" id="1_wbsyl"]
[ext_resource type="PackedScene" path="res://assets/meshes/nuke.tscn" id="2_upv26"]
[ext_resource type="PackedScene" uid="uid://py8i4xd737su" path="res://assets/meshes/nuke.tscn" id="2_upv26"]
[ext_resource type="PackedScene" uid="uid://m3lrwoup4i4r" path="res://buildings/grass_block.tscn" id="3_xrkoj"]
[node name="radiotower" type="Node3D" node_paths=PackedStringArray("BlocksNode")]
[node name="nukesilo" type="Node3D" node_paths=PackedStringArray("BlocksNode")]
transform = Transform3D(-1, 0, -1.50996e-07, 0, 1, 0, 1.50996e-07, 0, -1, 0, 0, 0)
script = ExtResource("1_wbsyl")
Megaton = 10
Approval = -5
Megaton = 20
Approval = -15
BlocksNode = NodePath("blocks")
DisplayName = "Radio Tower"
DisplayName = "Nuke Silo"
KashCost = 30
[node name="nuke" parent="." instance=ExtResource("2_upv26")]

View File

@ -19,38 +19,29 @@ transform = Transform3D(0.0261279, 0, 0, 0, 0.042186, 0, 0, 0, 0.0268019, -0.878
[node name="grass_block" parent="blocks" instance=ExtResource("3_nf4at")]
[node name="grass_block2" parent="blocks" node_paths=PackedStringArray("_ray") instance=ExtResource("3_nf4at")]
[node name="grass_block2" parent="blocks" instance=ExtResource("3_nf4at")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, -2)
_ray = NodePath("../grass_block/RayCast3D")
[node name="grass_block3" parent="blocks" node_paths=PackedStringArray("_ray") instance=ExtResource("3_nf4at")]
[node name="grass_block3" parent="blocks" instance=ExtResource("3_nf4at")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 0, -2)
_ray = NodePath("../grass_block/RayCast3D")
[node name="grass_block4" parent="blocks" node_paths=PackedStringArray("_ray") instance=ExtResource("3_nf4at")]
[node name="grass_block4" parent="blocks" instance=ExtResource("3_nf4at")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -2)
_ray = NodePath("../grass_block/RayCast3D")
[node name="grass_block5" parent="blocks" node_paths=PackedStringArray("_ray") instance=ExtResource("3_nf4at")]
[node name="grass_block5" parent="blocks" instance=ExtResource("3_nf4at")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, -4)
_ray = NodePath("../grass_block/RayCast3D")
[node name="grass_block6" parent="blocks" node_paths=PackedStringArray("_ray") instance=ExtResource("3_nf4at")]
[node name="grass_block6" parent="blocks" instance=ExtResource("3_nf4at")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 0, -4)
_ray = NodePath("../grass_block/RayCast3D")
[node name="grass_block7" parent="blocks" node_paths=PackedStringArray("_ray") instance=ExtResource("3_nf4at")]
[node name="grass_block7" parent="blocks" instance=ExtResource("3_nf4at")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -4)
_ray = NodePath("../grass_block/RayCast3D")
[node name="grass_block8" parent="blocks" node_paths=PackedStringArray("_ray") instance=ExtResource("3_nf4at")]
[node name="grass_block8" parent="blocks" instance=ExtResource("3_nf4at")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 2, 0, -6)
_ray = NodePath("../grass_block/RayCast3D")
[node name="grass_block9" parent="blocks" node_paths=PackedStringArray("_ray") instance=ExtResource("3_nf4at")]
[node name="grass_block9" parent="blocks" instance=ExtResource("3_nf4at")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, -2, 0, -6)
_ray = NodePath("../grass_block/RayCast3D")
[node name="grass_block10" parent="blocks" node_paths=PackedStringArray("_ray") instance=ExtResource("3_nf4at")]
[node name="grass_block10" parent="blocks" instance=ExtResource("3_nf4at")]
transform = Transform3D(1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, -6)
_ray = NodePath("../grass_block/RayCast3D")

View File

@ -1,12 +1,13 @@
[gd_scene load_steps=4 format=3 uid="uid://2pw0p13lcklv"]
[ext_resource type="Script" path="res://buildings/kash_building.cs" id="1_bcr1q"]
[ext_resource type="PackedScene" path="res://assets/meshes/factory.tscn" id="2_st133"]
[ext_resource type="PackedScene" uid="uid://bbxjweewwjrd4" path="res://assets/meshes/factory.tscn" id="2_st133"]
[ext_resource type="PackedScene" uid="uid://m3lrwoup4i4r" path="res://buildings/grass_block.tscn" id="3_4p2cy"]
[node name="factory" type="Node3D" node_paths=PackedStringArray("BlocksNode")]
transform = Transform3D(-1, 0, -8.74228e-08, 0, 1, 0, 8.74228e-08, 0, -1, 0, 0, 0)
script = ExtResource("1_bcr1q")
KashGenPerSec = 2
BlocksNode = NodePath("blocks")
DisplayName = "Factory"
KashCost = 6

View File

@ -1,12 +1,13 @@
[gd_scene load_steps=4 format=3 uid="uid://b8f1n3hp1fdlm"]
[ext_resource type="Script" path="res://buildings/propaganda_building.cs" id="1_oo36g"]
[ext_resource type="PackedScene" path="res://assets/meshes/radiotower.tscn" id="2_4131e"]
[ext_resource type="PackedScene" uid="uid://cy2sb2tms48ir" path="res://assets/meshes/radiotower.tscn" id="2_4131e"]
[ext_resource type="PackedScene" uid="uid://m3lrwoup4i4r" path="res://buildings/grass_block.tscn" id="3_pn4dl"]
[node name="radiotower2" type="Node3D" node_paths=PackedStringArray("BlocksNode")]
[node name="radiotower" type="Node3D" node_paths=PackedStringArray("BlocksNode")]
transform = Transform3D(-1, 0, -1.50996e-07, 0, 1, 0, 1.50996e-07, 0, -1, 0, 0, 0)
script = ExtResource("1_oo36g")
Approval = 10
BlocksNode = NodePath("blocks")
DisplayName = "Radio Tower"
KashCost = 5

View File

@ -17,8 +17,20 @@ public partial class player : Camera3D
private Node3D _cursorPoint;
private bool _mUp, _mDown, _mLeft, _mRight, _wIn, _wOut;
private enum buildingType
{
kash,
pr,
nuke
}
[Export]
private PackedScene _test_building;
private PackedScene _kash_building;
[Export]
private PackedScene _pr_building;
[Export]
private PackedScene _nuke_building;
[Export]
private TextureProgressBar _nuke, _pr, _kash;
@ -57,25 +69,70 @@ public partial class player : Camera3D
public override void _Ready()
{
//for debugging TODO: Remove
game_manager.CurrentState = game_manager.State.Building;
if (_test_building != null)
{
CurrentBuilding = _test_building.Instantiate<base_building>();
GetTree().Root.CallDeferred("add_child", CurrentBuilding);
}
_tmrChtr.Start();
_tmrChtr.Timeout += () => Chatter = "";
_tmrCashGen.Timeout += MakeMoney;
_btnEnd.Pressed += () => _sndBtn.Play();
_btnNukes.Pressed += () => { _sndBtn.Play(); ChangeScore(30, -5, 10, 0); };
_btnPR.Pressed += () => { _sndBtn.Play(); ChangeScore(5, 10, 0, 0); };
_btnKashCow.Pressed += () => { _sndBtn.Play(); ChangeScore(6, 0, 0, 1); };
_btnNukes.Pressed += () => HandleBtnNuke();
_btnPR.Pressed += () => HandleBtnPR();
_btnKashCow.Pressed += () => HandleBtnKash();
Chatter = "The enemy is stockpiling weapons of mass destruction.";
SetBarLabels();
}
private void UnHandBuilding()
{
if (CurrentBuilding != null)
{
GetTree().Root.RemoveChild(CurrentBuilding);
CurrentBuilding.QueueFree();
CurrentBuilding = null;
game_manager.CurrentState = game_manager.State.Play;
}
}
private void InstantiateBuilding(buildingType type)
{
PackedScene toInstantiate = null;
UnHandBuilding();
switch (type)
{
case buildingType.kash:
toInstantiate = _kash_building;
break;
case buildingType.pr:
toInstantiate = _pr_building;
break;
case buildingType.nuke:
toInstantiate = _nuke_building;
break;
default:
toInstantiate = _kash_building;
break;
}
CurrentBuilding = toInstantiate.Instantiate<base_building>();
GetTree().Root.CallDeferred("add_child", CurrentBuilding);
game_manager.CurrentState = game_manager.State.Building;
}
private void HandleBtnNuke()
{
_sndBtn.Play();
InstantiateBuilding(buildingType.nuke);
}
private void HandleBtnPR()
{
_sndBtn.Play();
InstantiateBuilding(buildingType.pr);
}
private void HandleBtnKash()
{
_sndBtn.Play();
InstantiateBuilding(buildingType.kash);
}
public override void _Process(double delta)
{
Vector3 rot = this.Rotation;
@ -177,7 +234,7 @@ public partial class player : Camera3D
Chatter = "Game Over.";
}
public void ChangeScore(int price, int pr, int nukes, int kashFlow = 0)
public void BuildBuilding(int price, int pr, int nukes, int kashFlow = 0)
{
if (price > Kash)
{
@ -191,6 +248,10 @@ public partial class player : Camera3D
Kash -= price;
KashFlow += kashFlow;
base_building tempBuilding = (base_building)CurrentBuilding.Duplicate();
GetTree().Root.CallDeferred("add_child", tempBuilding);
game_manager.CurrentState = game_manager.State.Play;
SetBarLabels();
CheckGame();
}
@ -224,12 +285,32 @@ public partial class player : Camera3D
CurrentBuilding.RotateY(Mathf.DegToRad(90));
}
if (Input.IsActionJustPressed("cancel"))
{
UnHandBuilding();
}
if (Input.IsActionJustPressed("build"))
{
if (CurrentBuilding.IsPlaceable)
{
base_building tempBuilding = (base_building)CurrentBuilding.Duplicate();
GetTree().Root.CallDeferred("add_child", tempBuilding);
switch (CurrentBuilding.DisplayName)
{
case "Radio Tower":
propaganda_building radio = (propaganda_building)CurrentBuilding;
BuildBuilding(radio.KashCost, radio.Approval, 0);
break;
case "Nuke Silo":
arms_building silo = (arms_building)CurrentBuilding;
BuildBuilding(silo.KashCost, silo.Approval, silo.Megaton);
break;
case "Factory":
kash_building factory = (kash_building)CurrentBuilding;
BuildBuilding(factory.KashCost, 0, 0, factory.KashGenPerSec);
break;
default:
break;
}
}
}
}

View File

@ -1,8 +1,11 @@
[gd_scene load_steps=25 format=3 uid="uid://b5gb5paiupum"]
[gd_scene load_steps=28 format=3 uid="uid://b5gb5paiupum"]
[ext_resource type="Script" path="res://player/player.cs" id="1_of2l4"]
[ext_resource type="PackedScene" uid="uid://2pw0p13lcklv" path="res://buildings/kash_buildings/factory.tscn" id="2_ox06o"]
[ext_resource type="AudioStream" uid="uid://07ben02qe8yc" path="res://audio/chatter.wav" id="2_sa1qd"]
[ext_resource type="AudioStream" uid="uid://ds7ec1n3pytnr" path="res://audio/btn.wav" id="3_00x5l"]
[ext_resource type="PackedScene" uid="uid://b8f1n3hp1fdlm" path="res://buildings/propaganda_buildings/radiotower.tscn" id="3_j4p3m"]
[ext_resource type="PackedScene" uid="uid://bh6e2nxqswoqg" path="res://buildings/arms_buildings/nuke.tscn" id="4_2vnif"]
[sub_resource type="CameraAttributesPhysical" id="CameraAttributesPhysical_1ejpb"]
frustum_near = 0.032
@ -89,6 +92,9 @@ _mousePosLabel = NodePath("HUD/Debug info/mousePos")
_cursorPosLabel = NodePath("HUD/Debug info/cursorPointPos")
_cursor = NodePath("cursor")
_cursorPoint = NodePath("cursorPoint")
_kash_building = ExtResource("2_ox06o")
_pr_building = ExtResource("3_j4p3m")
_nuke_building = ExtResource("4_2vnif")
_nuke = NodePath("HUD/Buttons and info/NukeBar")
_pr = NodePath("HUD/Buttons and info/PrBar")
_kash = NodePath("HUD/Buttons and info/KashBar")
@ -212,7 +218,7 @@ offset_top = -132.0
offset_right = -270.0
grow_horizontal = 0
grow_vertical = 0
text = ":)
text = "Approval
"
icon_alignment = 1
expand_icon = true
@ -229,7 +235,7 @@ offset_top = -132.0
offset_right = -406.0
grow_horizontal = 0
grow_vertical = 0
text = "$"
text = "Ka$h"
icon_alignment = 1
expand_icon = true