-feat: basic ship upgrades and corresponding ui implemented.
This commit is contained in:
parent
6cc79a5e3c
commit
d008a3d32c
|
|
@ -1,10 +1,11 @@
|
|||
[gd_scene load_steps=12 format=3 uid="uid://635xs5haibcn"]
|
||||
[gd_scene load_steps=13 format=3 uid="uid://635xs5haibcn"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://ckh362yqjkpi0" path="res://scenes/player.tscn" id="1_1w06w"]
|
||||
[ext_resource type="Script" path="res://script/game.cs" id="1_dukjm"]
|
||||
[ext_resource type="PackedScene" uid="uid://b6myj160l6vf8" path="res://scenes/hud.tscn" id="2_xbhg5"]
|
||||
[ext_resource type="Script" path="res://script/pause_controller.cs" id="3_3v5pd"]
|
||||
[ext_resource type="PackedScene" uid="uid://dnvcics1ni4pa" path="res://scenes/asteroid.tscn" id="3_b8wlr"]
|
||||
[ext_resource type="PackedScene" uid="uid://bc52c4jrk6lo" path="res://scenes/upgrade_menu.tscn" id="5_p2w52"]
|
||||
[ext_resource type="Texture2D" uid="uid://bjxo7mbl7nert" path="res://assets/Starfield/starfield1.png" id="6_kn6se"]
|
||||
[ext_resource type="PackedScene" uid="uid://4fnk5c2nf6a1" path="res://scenes/border.tscn" id="7_p4rds"]
|
||||
[ext_resource type="Script" path="res://script/wavecontroller.cs" id="8_fhk4p"]
|
||||
|
|
@ -8088,6 +8089,19 @@ offset_top = -100.0
|
|||
offset_right = 200.0
|
||||
offset_bottom = 100.0
|
||||
|
||||
[node name="UpgradeMenu" parent="UI" node_paths=PackedStringArray("PlayerNode") instance=ExtResource("5_p2w52")]
|
||||
visible = false
|
||||
anchors_preset = 8
|
||||
anchor_left = 0.5
|
||||
anchor_top = 0.5
|
||||
anchor_right = 0.5
|
||||
anchor_bottom = 0.5
|
||||
offset_left = -200.0
|
||||
offset_top = -100.0
|
||||
offset_right = 200.0
|
||||
offset_bottom = 100.0
|
||||
PlayerNode = NodePath("../../WaveController/Ships/Friendly/Player")
|
||||
|
||||
[node name="Lasers" type="Node" parent="."]
|
||||
process_mode = 1
|
||||
|
||||
|
|
@ -8141,9 +8155,10 @@ rotation = -1.5708
|
|||
scale = Vector2(37.35, 5)
|
||||
collision_layer = 8
|
||||
|
||||
[node name="WaveController" type="Node2D" parent="."]
|
||||
[node name="WaveController" type="Node2D" parent="." node_paths=PackedStringArray("UpgradeMenu")]
|
||||
process_mode = 1
|
||||
script = ExtResource("8_fhk4p")
|
||||
UpgradeMenu = NodePath("../UI/UpgradeMenu")
|
||||
|
||||
[node name="Ships" type="Node" parent="WaveController"]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,13 +1,23 @@
|
|||
[gd_scene load_steps=5 format=3 uid="uid://btjj225d18y2q"]
|
||||
[gd_scene load_steps=9 format=3 uid="uid://btjj225d18y2q"]
|
||||
|
||||
[ext_resource type="FontFile" uid="uid://be6xxaq8drt5q" path="res://assets/Fonts/Kenney Pixel Square.ttf" id="1_b7j7x"]
|
||||
[ext_resource type="Script" path="res://script/pause_menu.cs" id="1_mq0ks"]
|
||||
[ext_resource type="PackedScene" uid="uid://01tjlnox4crb" path="res://scenes/input_menu.tscn" id="2_ugxyj"]
|
||||
[ext_resource type="FontFile" uid="uid://dtpvg4lmre10g" path="res://assets/Fonts/Kenney Future Narrow.ttf" id="3_p0x5a"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_6mqtv"]
|
||||
font = ExtResource("1_b7j7x")
|
||||
font_size = 28
|
||||
|
||||
[sub_resource type="Theme" id="Theme_siirn"]
|
||||
default_font = ExtResource("3_p0x5a")
|
||||
|
||||
[sub_resource type="Theme" id="Theme_1cogp"]
|
||||
default_font = ExtResource("3_p0x5a")
|
||||
|
||||
[sub_resource type="Theme" id="Theme_gbhoc"]
|
||||
default_font = ExtResource("3_p0x5a")
|
||||
|
||||
[node name="PauseMenu" type="CenterContainer"]
|
||||
process_mode = 2
|
||||
anchors_preset = 15
|
||||
|
|
@ -44,16 +54,19 @@ layout_mode = 2
|
|||
[node name="InputsButton" type="Button" parent="VBox/HBox"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
theme = SubResource("Theme_siirn")
|
||||
text = "Inputs"
|
||||
|
||||
[node name="ResumeButton" type="Button" parent="VBox/HBox"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
theme = SubResource("Theme_1cogp")
|
||||
text = "Resume"
|
||||
|
||||
[node name="QuitButton" type="Button" parent="VBox/HBox"]
|
||||
custom_minimum_size = Vector2(100, 35)
|
||||
layout_mode = 2
|
||||
theme = SubResource("Theme_gbhoc")
|
||||
text = "Main Menu"
|
||||
|
||||
[node name="InputMenu" parent="." instance=ExtResource("2_ugxyj")]
|
||||
|
|
|
|||
112
MB_FYP/scenes/upgrade_menu.tscn
Normal file
112
MB_FYP/scenes/upgrade_menu.tscn
Normal file
|
|
@ -0,0 +1,112 @@
|
|||
[gd_scene load_steps=7 format=3 uid="uid://bc52c4jrk6lo"]
|
||||
|
||||
[ext_resource type="Script" path="res://script/upgrade_menu.cs" id="1_aupyl"]
|
||||
[ext_resource type="FontFile" uid="uid://be6xxaq8drt5q" path="res://assets/Fonts/Kenney Pixel Square.ttf" id="1_rlo6h"]
|
||||
[ext_resource type="FontFile" uid="uid://dtpvg4lmre10g" path="res://assets/Fonts/Kenney Future Narrow.ttf" id="2_m2s84"]
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_6mqtv"]
|
||||
font = ExtResource("1_rlo6h")
|
||||
font_size = 28
|
||||
|
||||
[sub_resource type="LabelSettings" id="LabelSettings_40vj8"]
|
||||
font = ExtResource("2_m2s84")
|
||||
|
||||
[sub_resource type="Theme" id="Theme_olqqp"]
|
||||
default_font = ExtResource("2_m2s84")
|
||||
|
||||
[node name="UpgradeMenu" type="CenterContainer"]
|
||||
process_mode = 2
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_right = -1520.0
|
||||
offset_bottom = -880.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = ExtResource("1_aupyl")
|
||||
|
||||
[node name="ColorRect" type="ColorRect" parent="."]
|
||||
custom_minimum_size = Vector2(400, 200)
|
||||
layout_mode = 2
|
||||
color = Color(0.231373, 0.219608, 0.203922, 1)
|
||||
|
||||
[node name="VBox" type="VBoxContainer" parent="."]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="VBox"]
|
||||
layout_mode = 2
|
||||
text = "Upgrade"
|
||||
label_settings = SubResource("LabelSettings_6mqtv")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="VSeparator" type="VSeparator" parent="VBox"]
|
||||
visibility_layer = 0
|
||||
custom_minimum_size = Vector2(0, 30)
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HBox" type="HBoxContainer" parent="VBox"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Health" type="VBoxContainer" parent="VBox/HBox"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="HealthLabel" type="Label" parent="VBox/HBox/Health"]
|
||||
layout_mode = 2
|
||||
text = "Health"
|
||||
label_settings = SubResource("LabelSettings_40vj8")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="HealthStat" type="Label" parent="VBox/HBox/Health"]
|
||||
layout_mode = 2
|
||||
text = "+ 0%"
|
||||
label_settings = SubResource("LabelSettings_40vj8")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="HealthUpgrade" type="Button" parent="VBox/HBox/Health"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
theme = SubResource("Theme_olqqp")
|
||||
text = "+10%"
|
||||
|
||||
[node name="Damage" type="VBoxContainer" parent="VBox/HBox"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="DamageLabel" type="Label" parent="VBox/HBox/Damage"]
|
||||
layout_mode = 2
|
||||
text = "Damage
|
||||
"
|
||||
label_settings = SubResource("LabelSettings_40vj8")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="DamageStat" type="Label" parent="VBox/HBox/Damage"]
|
||||
layout_mode = 2
|
||||
text = "+ 0%"
|
||||
label_settings = SubResource("LabelSettings_40vj8")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="DamageUpgrade" type="Button" parent="VBox/HBox/Damage"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
theme = SubResource("Theme_olqqp")
|
||||
text = "+10%"
|
||||
|
||||
[node name="Speed" type="VBoxContainer" parent="VBox/HBox"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="SpeedLabel" type="Label" parent="VBox/HBox/Speed"]
|
||||
layout_mode = 2
|
||||
text = "Speed"
|
||||
label_settings = SubResource("LabelSettings_40vj8")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="SpeedStat" type="Label" parent="VBox/HBox/Speed"]
|
||||
layout_mode = 2
|
||||
text = "+ 0%"
|
||||
label_settings = SubResource("LabelSettings_40vj8")
|
||||
horizontal_alignment = 1
|
||||
|
||||
[node name="SpeedUpgrade" type="Button" parent="VBox/HBox/Speed"]
|
||||
custom_minimum_size = Vector2(100, 0)
|
||||
layout_mode = 2
|
||||
theme = SubResource("Theme_olqqp")
|
||||
text = "+10%"
|
||||
|
|
@ -102,7 +102,6 @@ public partial class game : Node2D
|
|||
if (_waveController.CurrWave % 2 == 0)
|
||||
{
|
||||
_player.HealShip(100); // heal ship by 100 at the start of each 2nd round
|
||||
UpdateHealthLabel(_player.Health);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -186,8 +185,8 @@ public partial class game : Node2D
|
|||
{
|
||||
|
||||
_lasers.AddChild(laser);
|
||||
GD.Print(laser.Position);
|
||||
GD.Print(_player.Position);
|
||||
//GD.Print(laser.Position);
|
||||
//GD.Print(_player.Position);
|
||||
}
|
||||
|
||||
private void OnPlayerHealthUpdate(int health)
|
||||
|
|
@ -229,8 +228,7 @@ public partial class game : Node2D
|
|||
|
||||
private void OnAsteroidExploded(Vector2 pos, int size, ship shooter)
|
||||
{
|
||||
// DEBUG PRINT
|
||||
GD.Print($"DEBUG: Asteroid exploded at {pos}, size: {size}");
|
||||
//GD.Print($"DEBUG: Asteroid exploded at {pos}, size: {size}");
|
||||
|
||||
switch (size)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -71,9 +71,30 @@ public partial class player : ship // Inherits from base ship class
|
|||
{
|
||||
Health += health;
|
||||
if (Health > MaxHealth) Health = MaxHealth;
|
||||
EmitSignal(SignalName.HealthUpdate, Health);
|
||||
|
||||
}
|
||||
|
||||
public void HealthUpgrade() // sets health stats (upgrades)
|
||||
{
|
||||
MaxHealth = (int)(MaxHealth * 1.1f);
|
||||
Health = MaxHealth;;
|
||||
EmitSignal(SignalName.HealthUpdate, Health);
|
||||
}
|
||||
|
||||
public void DamageUpgrade() // sets new damage stat (upgrades)
|
||||
{
|
||||
Damage = (int)(Damage * 1.1f);;
|
||||
}
|
||||
|
||||
public void SpeedUpgrade() // sets new speed stats (upgrades)
|
||||
{
|
||||
MaxSpeed = (int)(MaxSpeed * 1.1f);
|
||||
MainSpeed = (int)(MainSpeed * 1.1f);
|
||||
StrafeSpeed = (int)(StrafeSpeed * 1.1f);
|
||||
RotationSpeed = RotationSpeed * 1.1f;
|
||||
}
|
||||
|
||||
private void ToggleFlightAssist()
|
||||
{
|
||||
if (FlightAssistValue == 0f){FlightAssistValue = 2.5f;}
|
||||
|
|
@ -83,7 +104,7 @@ public partial class player : ship // Inherits from base ship class
|
|||
public override void _Ready()
|
||||
{
|
||||
SetupVisual();
|
||||
GD.Print(Faction);
|
||||
//GD.Print(Faction);
|
||||
|
||||
this.SpritePath = Color switch
|
||||
{
|
||||
|
|
@ -92,7 +113,7 @@ public partial class player : ship // Inherits from base ship class
|
|||
ShipColor.BLUE => this.SpritePath + "ShipBlue.png",
|
||||
_ => this.SpritePath
|
||||
};
|
||||
GD.Print(SpritePath);
|
||||
//GD.Print(SpritePath);
|
||||
Sprite.Texture = GD.Load<Texture2D>(SpritePath);
|
||||
|
||||
|
||||
|
|
@ -112,7 +133,7 @@ public partial class player : ship // Inherits from base ship class
|
|||
|
||||
if(Input.IsActionPressed("shoot"))
|
||||
{
|
||||
GD.Print("DEBUG: FIRING PLAYER LASER");
|
||||
//GD.Print("DEBUG: FIRING PLAYER LASER");
|
||||
if (FireTimer > 0f) return;
|
||||
ShootLaser();
|
||||
FireTimer = FireCooldown;
|
||||
|
|
|
|||
72
MB_FYP/script/upgrade_menu.cs
Normal file
72
MB_FYP/script/upgrade_menu.cs
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
using Godot;
|
||||
using System;
|
||||
|
||||
public partial class upgrade_menu : CenterContainer
|
||||
{
|
||||
private Button _healthUpgrade;
|
||||
private Button _speedUpgrade;
|
||||
private Button _damageUpgrade;
|
||||
|
||||
private Label _healthStat;
|
||||
private Label _speedStat;
|
||||
private Label _damageStat;
|
||||
|
||||
private int _healthInt;
|
||||
private int _speedInt;
|
||||
private int _damageInt;
|
||||
|
||||
[Export]
|
||||
public player PlayerNode;
|
||||
|
||||
private int _playerBaseHealth;
|
||||
private int _playerBaseDamage;
|
||||
private int _playerBaseMaxSpeed;
|
||||
private int _playerBaseMainSpeed;
|
||||
private int _playerBaseStrafeSpeed;
|
||||
private float _playerBaseRotationSpeed;
|
||||
|
||||
public override void _Ready()
|
||||
{
|
||||
_healthUpgrade = GetNode<Button>("VBox/HBox/Health/HealthUpgrade");
|
||||
_speedUpgrade = GetNode<Button>("VBox/HBox/Speed/SpeedUpgrade");
|
||||
_damageUpgrade = GetNode<Button>("VBox/HBox/Damage/DamageUpgrade");
|
||||
|
||||
_healthStat = GetNode<Label>("VBox/HBox/Health/HealthStat");
|
||||
_speedStat = GetNode<Label>("VBox/HBox/Speed/SpeedStat");
|
||||
_damageStat = GetNode<Label>("VBox/HBox/Damage/DamageStat");
|
||||
|
||||
_playerBaseHealth = PlayerNode.MaxHealth;
|
||||
_playerBaseDamage = PlayerNode.Damage;
|
||||
_playerBaseMaxSpeed = PlayerNode.MaxSpeed;
|
||||
_playerBaseMainSpeed = PlayerNode.MainSpeed;
|
||||
_playerBaseStrafeSpeed = PlayerNode.StrafeSpeed;
|
||||
_playerBaseRotationSpeed = PlayerNode.RotationSpeed;
|
||||
|
||||
_healthUpgrade.Pressed += () =>
|
||||
{
|
||||
_healthInt += 10;
|
||||
_healthStat.Text = ("+ " + _healthInt + "%");
|
||||
GetTree().Paused = false;
|
||||
PlayerNode.HealthUpgrade();
|
||||
Visible = false;
|
||||
};
|
||||
|
||||
_speedUpgrade.Pressed += () =>
|
||||
{
|
||||
_speedInt += 10;
|
||||
_speedStat.Text = ("+ " + _speedInt + "%");
|
||||
GetTree().Paused = false;
|
||||
PlayerNode.SpeedUpgrade();
|
||||
Visible = false;
|
||||
};
|
||||
|
||||
_damageUpgrade.Pressed += () =>
|
||||
{
|
||||
_damageInt += 10;
|
||||
_damageStat.Text = ("+ " + _damageInt + "%");
|
||||
GetTree().Paused = false;
|
||||
PlayerNode.DamageUpgrade();
|
||||
Visible = false;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
@ -11,8 +11,11 @@ public partial class wavecontroller : Node2D
|
|||
private Node _enemyNode;
|
||||
private player _playerNode;
|
||||
|
||||
public float _aiStatModifier = 1f;
|
||||
|
||||
private float _aiStatModifier = 1f;
|
||||
|
||||
[Export]
|
||||
public upgrade_menu UpgradeMenu;
|
||||
|
||||
private List<Marker2D> _enemySpawns;
|
||||
private List<Marker2D> _friendlySpawns;
|
||||
private PackedScene _aiShipScene;
|
||||
|
|
@ -53,9 +56,16 @@ public partial class wavecontroller : Node2D
|
|||
}
|
||||
}
|
||||
// spawn friendlies after 5 waves & if 1 or less remaining
|
||||
// also trigger upgrade menu at the start of the wave (but not first wave)
|
||||
if ((CurrWave - 1) % 5 == 0 && _friendlyNode.GetChildCount() <= 1)
|
||||
{
|
||||
GD.Print("attempting to spawn friendlies");
|
||||
if (CurrWave != 1)
|
||||
{
|
||||
UpgradeMenu.Show();
|
||||
GetTree().Paused = true;
|
||||
}
|
||||
|
||||
//GD.Print("attempting to spawn friendlies");
|
||||
foreach (var spawn in _friendlySpawns)
|
||||
{
|
||||
Random rand = new Random();
|
||||
|
|
|
|||
Loading…
Reference in a new issue