starfighter/MB_FYP/script/upgrade_menu.cs

73 lines
2.2 KiB
C#
Raw Normal View History

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;
};
}
}