mirror of
https://gitlab.com/MaddoScientisto/cirnogodot.git
synced 2026-06-01 10:35:34 +00:00
Cheat buttons
This commit is contained in:
parent
0a631bf5b7
commit
e637f69ce6
7 changed files with 98 additions and 16 deletions
|
|
@ -1,4 +1,5 @@
|
|||
using System;
|
||||
using Cirno.Scripts.Components.Actors;
|
||||
using Cirno.Scripts.Resources;
|
||||
using Godot;
|
||||
|
||||
|
|
@ -6,6 +7,12 @@ namespace Cirno.Scripts.Components.FSM.Player;
|
|||
|
||||
public partial class PlayerFSMItemUseModule : ModuleBase<PlayerState, CharacterBody2D>
|
||||
{
|
||||
[Export]
|
||||
public ActorResourceProvider Health { get; set; }
|
||||
|
||||
[Export]
|
||||
public ActorResourceProvider Shield { get; set; }
|
||||
|
||||
public bool Enabled { get; set; } = false;
|
||||
|
||||
public override void EnterState(PlayerState state)
|
||||
|
|
@ -43,15 +50,18 @@ public partial class PlayerFSMItemUseModule : ModuleBase<PlayerState, CharacterB
|
|||
case ItemTypes.Ammo:
|
||||
break;
|
||||
case ItemTypes.Medkit:
|
||||
Heal(item);
|
||||
break;
|
||||
case ItemTypes.FrogBomb:
|
||||
SpawnSpiderBomb(item);
|
||||
break;
|
||||
case ItemTypes.Bomb:
|
||||
SpawnBomb(item);
|
||||
break;
|
||||
case ItemTypes.Mine:
|
||||
break;
|
||||
case ItemTypes.Battery:
|
||||
RechargeShield(item);
|
||||
break;
|
||||
case ItemTypes.Weapon:
|
||||
break;
|
||||
|
|
@ -67,6 +77,21 @@ public partial class PlayerFSMItemUseModule : ModuleBase<PlayerState, CharacterB
|
|||
|
||||
}
|
||||
|
||||
private void SpawnBomb(LootItem item)
|
||||
{
|
||||
GD.Print("Spawned bomb");
|
||||
}
|
||||
|
||||
private void Heal(LootItem item)
|
||||
{
|
||||
Health.CurrentResource += Mathf.CeilToInt(Health.MaxResource * 25 / 100);
|
||||
}
|
||||
|
||||
private void RechargeShield(LootItem item)
|
||||
{
|
||||
Shield.CurrentResource += Mathf.CeilToInt(Health.MaxResource * 25 / 100);
|
||||
}
|
||||
|
||||
private void SpawnSpiderBomb(LootItem item)
|
||||
{
|
||||
//var bullet = item.WeaponData.BulletData.BulletScene.Instantiate<Bullet>();
|
||||
|
|
|
|||
|
|
@ -6,5 +6,15 @@ namespace Cirno.Scripts.Components.FSM;
|
|||
public partial class PlayerStateMachine : StateMachineBase<PlayerState, CharacterBody2D>
|
||||
{
|
||||
[Export] public override PlayerState InitialState { get; protected set; } = PlayerState.Init;
|
||||
|
||||
public void RefillHealth()
|
||||
{
|
||||
GD.Print("Refilling health");
|
||||
}
|
||||
|
||||
public void RefilleShield()
|
||||
{
|
||||
GD.Print("Refilling shield");
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -130,14 +130,15 @@ public partial class InventoryManager : Node2D
|
|||
switch (itm.Item.Item)
|
||||
{
|
||||
case ItemTypes.Medkit:
|
||||
// Heal
|
||||
case ItemTypes.FrogBomb:
|
||||
// Use Bomb
|
||||
case ItemTypes.Bomb:
|
||||
// Bomb
|
||||
case ItemTypes.Mine:
|
||||
case ItemTypes.Battery:
|
||||
EmitSignal(SignalName.ItemUsed, itm.Item, itm.Count);
|
||||
if (itm.Item.ConsumeOnUse)
|
||||
{
|
||||
RemoveItem(itm.Item.ItemKey, 1);
|
||||
}
|
||||
break;
|
||||
case ItemTypes.Weapon:
|
||||
// Equip weapon
|
||||
|
|
|
|||
|
|
@ -17,6 +17,9 @@ public partial class DebugMenu : MenuBase
|
|||
[Export]
|
||||
public Container ButtonsContainer { get; private set; }
|
||||
|
||||
[Export]
|
||||
public Container CheatsContainer { get; private set; }
|
||||
|
||||
[Export]
|
||||
public Button DefaultSelectedButton { get; private set; }
|
||||
|
||||
|
|
@ -28,17 +31,47 @@ public partial class DebugMenu : MenuBase
|
|||
foreach (var level in Levels.Maps)
|
||||
{
|
||||
if (!level.Enabled) continue;
|
||||
var button = new Button();
|
||||
//button.Text = level.Split("/")[^1].Split(".")[0];
|
||||
button.Text = level.DisplayName;
|
||||
button.Icon = level.Icon;
|
||||
//button.Text = level;
|
||||
button.Theme = ButtonTheme;
|
||||
|
||||
ButtonsContainer.CallDeferred("add_child", button);
|
||||
var button = MakeButton(ButtonsContainer, level.DisplayName, level.Icon);
|
||||
|
||||
// var button = new Button();
|
||||
// //button.Text = level.Split("/")[^1].Split(".")[0];
|
||||
// button.Text = level.DisplayName;
|
||||
// button.Icon = level.Icon;
|
||||
// //button.Text = level;
|
||||
// button.Theme = ButtonTheme;
|
||||
//
|
||||
// ButtonsContainer.CallDeferred("add_child", button);
|
||||
|
||||
button.Pressed += () => ButtonOnPressed(level);
|
||||
}
|
||||
|
||||
var refillHealthButton = MakeButton(CheatsContainer, "Health", null);
|
||||
refillHealthButton.Pressed += RefillHealthButtonOnPressed;
|
||||
|
||||
var refillShieldButton = MakeButton(CheatsContainer, "Shield", null);
|
||||
refillShieldButton.Pressed += RefillShieldButtonOnPressed;
|
||||
|
||||
}
|
||||
|
||||
private void RefillHealthButtonOnPressed()
|
||||
{
|
||||
GameManager.Instance?.Player?.RefillHealth();
|
||||
}
|
||||
|
||||
private void RefillShieldButtonOnPressed()
|
||||
{
|
||||
GameManager.Instance?.Player?.RefilleShield();
|
||||
}
|
||||
|
||||
private Button MakeButton(Control parent, string text, Texture2D icon)
|
||||
{
|
||||
var button = new Button();
|
||||
button.Text = text;
|
||||
button.Icon = icon;
|
||||
button.Theme = ButtonTheme;
|
||||
parent.CallDeferred("add_child", button);
|
||||
return button;
|
||||
}
|
||||
|
||||
private void ButtonOnPressed(DebugMapSelectResource scene)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue