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
|
|
@ -385,8 +385,10 @@ Shield = NodePath("../DamageReceiver/ShieldProvider")
|
|||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="InteractionController"]
|
||||
shape = SubResource("CircleShape2D_g3wua")
|
||||
|
||||
[node name="ItemUser" type="Node2D" parent="."]
|
||||
[node name="ItemUser" type="Node2D" parent="." node_paths=PackedStringArray("Health", "Shield")]
|
||||
script = ExtResource("29_m323t")
|
||||
Health = NodePath("../DamageReceiver/HealthProvider")
|
||||
Shield = NodePath("../DamageReceiver/ShieldProvider")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
visible = false
|
||||
|
|
|
|||
|
|
@ -177,10 +177,11 @@ visible = false
|
|||
|
||||
[node name="DebugContainer" type="PanelContainer" parent="."]
|
||||
visible = false
|
||||
offset_left = 66.0
|
||||
offset_top = 45.0
|
||||
offset_right = 259.0
|
||||
offset_bottom = 156.0
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
|
||||
[node name="PauseMenuContainer" type="PanelContainer" parent="."]
|
||||
visible = false
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@
|
|||
[ext_resource type="Resource" uid="uid://d1lc8lhq1b05p" path="res://Resources/Debug/DebugLevels.tres" id="3_cvgqx"]
|
||||
[ext_resource type="Texture2D" uid="uid://d1a0nwd4wdph7" path="res://Sprites/UI/Back_Small.png" id="5_1xl3a"]
|
||||
|
||||
[node name="DebugMenu" type="VBoxContainer" node_paths=PackedStringArray("ButtonsContainer", "DefaultSelectedButton")]
|
||||
[node name="DebugMenu" type="VBoxContainer" node_paths=PackedStringArray("ButtonsContainer", "CheatsContainer", "DefaultSelectedButton")]
|
||||
process_mode = 3
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
|
|
@ -17,6 +17,7 @@ script = ExtResource("1_5vtnj")
|
|||
ButtonTheme = ExtResource("2_6il8q")
|
||||
Levels = ExtResource("3_cvgqx")
|
||||
ButtonsContainer = NodePath("ScrollContainer/Level Select")
|
||||
CheatsContainer = NodePath("HBoxContainer/ScrollContainer/CheatsContainer")
|
||||
DefaultSelectedButton = NodePath("ScrollContainer/Level Select/BackButton")
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="."]
|
||||
|
|
@ -35,6 +36,15 @@ theme_override_font_sizes/font_size = 14
|
|||
text = "God Mode
|
||||
"
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="HBoxContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
|
||||
[node name="CheatsContainer" type="HBoxContainer" parent="HBoxContainer/ScrollContainer"]
|
||||
layout_mode = 2
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
|
|
|||
|
|
@ -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