hotbar resize
This commit is contained in:
parent
27d839b86f
commit
1cd9ef3f3a
9 changed files with 55 additions and 23 deletions
|
|
@ -114,6 +114,11 @@ short_shovel={
|
||||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":115,"location":0,"echo":false,"script":null)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
cheat_unlock_all={
|
||||||
|
"deadzone": 0.2,
|
||||||
|
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194334,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
[internationalization]
|
[internationalization]
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=48 format=3 uid="uid://cfnmspei3k4p7"]
|
[gd_scene load_steps=49 format=3 uid="uid://cfnmspei3k4p7"]
|
||||||
|
|
||||||
[ext_resource type="PackedScene" uid="uid://ky35veswaytr" path="res://scenes/gui/sun_counter.tscn" id="1_le3od"]
|
[ext_resource type="PackedScene" uid="uid://ky35veswaytr" path="res://scenes/gui/sun_counter.tscn" id="1_le3od"]
|
||||||
[ext_resource type="Theme" uid="uid://b8l285cjcgeyi" path="res://assets/themes/GameStyle.tres" id="1_xf6ra"]
|
[ext_resource type="Theme" uid="uid://b8l285cjcgeyi" path="res://assets/themes/GameStyle.tres" id="1_xf6ra"]
|
||||||
|
|
@ -8,6 +8,7 @@
|
||||||
[ext_resource type="PackedScene" uid="uid://cgm7td1hgs0rr" path="res://scenes/gui/fast_forward_button.tscn" id="4_66uy4"]
|
[ext_resource type="PackedScene" uid="uid://cgm7td1hgs0rr" path="res://scenes/gui/fast_forward_button.tscn" id="4_66uy4"]
|
||||||
[ext_resource type="Script" uid="uid://di45o67gxmiql" path="res://scripts/gui/seedpackets/HotbarShortcutSetter.cs" id="5_5kkbf"]
|
[ext_resource type="Script" uid="uid://di45o67gxmiql" path="res://scripts/gui/seedpackets/HotbarShortcutSetter.cs" id="5_5kkbf"]
|
||||||
[ext_resource type="PackedScene" uid="uid://u5l3jd00s8vd" path="res://scenes/gui/pause_button.tscn" id="5_jyq78"]
|
[ext_resource type="PackedScene" uid="uid://u5l3jd00s8vd" path="res://scenes/gui/pause_button.tscn" id="5_jyq78"]
|
||||||
|
[ext_resource type="Script" uid="uid://bygqu13os20wi" path="res://scripts/gui/PlantHotbarSize.cs" id="5_xq48m"]
|
||||||
[ext_resource type="PackedScene" uid="uid://b4lx8adw6rbqs" path="res://scenes/particles/dirt_explosion.tscn" id="6_5jtun"]
|
[ext_resource type="PackedScene" uid="uid://b4lx8adw6rbqs" path="res://scenes/particles/dirt_explosion.tscn" id="6_5jtun"]
|
||||||
[ext_resource type="Script" uid="uid://c36bj8u7jghc7" path="res://scripts/audio/ChannelPlayer.cs" id="7_5kkbf"]
|
[ext_resource type="Script" uid="uid://c36bj8u7jghc7" path="res://scripts/audio/ChannelPlayer.cs" id="7_5kkbf"]
|
||||||
[ext_resource type="AudioStream" uid="uid://dfbg6dxg4actb" path="res://assets/audio/sfx/shovel.mp3" id="8_xq48m"]
|
[ext_resource type="AudioStream" uid="uid://dfbg6dxg4actb" path="res://assets/audio/sfx/shovel.mp3" id="8_xq48m"]
|
||||||
|
|
@ -232,6 +233,7 @@ layout_mode = 2
|
||||||
custom_minimum_size = Vector2(377, 64)
|
custom_minimum_size = Vector2(377, 64)
|
||||||
layout_mode = 2
|
layout_mode = 2
|
||||||
theme_override_styles/panel = SubResource("StyleBoxTexture_ps2iw")
|
theme_override_styles/panel = SubResource("StyleBoxTexture_ps2iw")
|
||||||
|
script = ExtResource("5_xq48m")
|
||||||
|
|
||||||
[node name="Seedpackets" type="HBoxContainer" parent="MarginContainer/Control/Hotbar/PanelContainer"]
|
[node name="Seedpackets" type="HBoxContainer" parent="MarginContainer/Control/Hotbar/PanelContainer"]
|
||||||
process_mode = 3
|
process_mode = 3
|
||||||
|
|
|
||||||
|
|
@ -19,5 +19,9 @@ public partial class Cheats : Node
|
||||||
|
|
||||||
GetTree().CurrentScene.AddChild(spawner);
|
GetTree().CurrentScene.AddChild(spawner);
|
||||||
}
|
}
|
||||||
|
if (@event.IsActionPressed("cheat_unlock_all"))
|
||||||
|
{
|
||||||
|
PlayerProgress.Instance.PlayerPlants = GameRegistry.GetPlants();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using Godot;
|
using Godot;
|
||||||
using Godot.Collections;
|
using Godot.Collections;
|
||||||
|
using Newlon.Components.Level;
|
||||||
using Newlon.Systems.Effects;
|
using Newlon.Systems.Effects;
|
||||||
|
|
||||||
namespace Newlon.Components;
|
namespace Newlon.Components;
|
||||||
|
|
@ -58,22 +59,30 @@ public partial class Entity : Node2D
|
||||||
#region Brain
|
#region Brain
|
||||||
[Export] private AnimationPlayer _player;
|
[Export] private AnimationPlayer _player;
|
||||||
[Export] private AnimationTree _tree;
|
[Export] private AnimationTree _tree;
|
||||||
public virtual void DisableBrain()
|
private bool forceToggledBrain = false;
|
||||||
|
private bool brainEnabled = true;
|
||||||
|
public virtual void DisableBrain(bool force = true)
|
||||||
{
|
{
|
||||||
|
if (brainEnabled == false) return;
|
||||||
if (_player != null)
|
if (_player != null)
|
||||||
_player.ProcessMode = ProcessModeEnum.Pausable;
|
_player.ProcessMode = ProcessModeEnum.Pausable;
|
||||||
if (_tree != null)
|
if (_tree != null)
|
||||||
_tree.ProcessMode = ProcessModeEnum.Pausable;
|
_tree.ProcessMode = ProcessModeEnum.Pausable;
|
||||||
ProcessMode = ProcessModeEnum.Disabled;
|
ProcessMode = ProcessModeEnum.Disabled;
|
||||||
|
forceToggledBrain = force;
|
||||||
|
brainEnabled = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void EnableBrain()
|
public virtual void EnableBrain(bool force = true)
|
||||||
{
|
{
|
||||||
|
if (brainEnabled) return;
|
||||||
if (_player != null)
|
if (_player != null)
|
||||||
_player.ProcessMode = ProcessModeEnum.Inherit;
|
_player.ProcessMode = ProcessModeEnum.Inherit;
|
||||||
if (_tree != null)
|
if (_tree != null)
|
||||||
_tree.ProcessMode = ProcessModeEnum.Inherit;
|
_tree.ProcessMode = ProcessModeEnum.Inherit;
|
||||||
ProcessMode = ProcessModeEnum.Inherit;
|
ProcessMode = ProcessModeEnum.Inherit;
|
||||||
|
forceToggledBrain = force;
|
||||||
|
brainEnabled = true;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
#region Effects
|
#region Effects
|
||||||
|
|
@ -171,6 +180,11 @@ public partial class Entity : Node2D
|
||||||
public override void _Ready()
|
public override void _Ready()
|
||||||
{
|
{
|
||||||
HP = MaxHP;
|
HP = MaxHP;
|
||||||
|
if (RuntimeLevelData.Instance != null)
|
||||||
|
{
|
||||||
|
if (RuntimeLevelData.Instance.GetLevelState() != RuntimeLevelData.LevelStates.Game) DisableBrain(false);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
|
||||||
24
scripts/gui/PlantHotbarSize.cs
Normal file
24
scripts/gui/PlantHotbarSize.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
using Godot;
|
||||||
|
using Newlon.Components.Level;
|
||||||
|
using System;
|
||||||
|
|
||||||
|
public partial class PlantHotbarSize : PanelContainer
|
||||||
|
{
|
||||||
|
const int MARGIN = 4;
|
||||||
|
const int PACKET_WIDTH = 41;
|
||||||
|
const int MINIMUM_Y = 64;
|
||||||
|
public override void _Ready()
|
||||||
|
{
|
||||||
|
CustomMinimumSize = new Vector2(MARGIN * 2 + PACKET_WIDTH * PlayerProgress.Instance.MaxSeedpackets, MINIMUM_Y);
|
||||||
|
|
||||||
|
RuntimeLevelData.Instance.OnLevelStateChanged += OnLevelStateChanged;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnLevelStateChanged(RuntimeLevelData.LevelStates state)
|
||||||
|
{
|
||||||
|
if (state != RuntimeLevelData.LevelStates.ChooseYourSeeds)
|
||||||
|
{
|
||||||
|
CustomMinimumSize = new Vector2(0, MINIMUM_Y);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
scripts/gui/PlantHotbarSize.cs.uid
Normal file
1
scripts/gui/PlantHotbarSize.cs.uid
Normal file
|
|
@ -0,0 +1 @@
|
||||||
|
uid://bygqu13os20wi
|
||||||
|
|
@ -24,11 +24,12 @@ public partial class RewardScene : Node
|
||||||
}
|
}
|
||||||
|
|
||||||
var rewardedObject = reward.GetPreview().Instantiate();
|
var rewardedObject = reward.GetPreview().Instantiate();
|
||||||
subviewport.AddChild(rewardedObject);
|
|
||||||
|
|
||||||
if (rewardedObject is Entity entity)
|
if (rewardedObject is Entity entity)
|
||||||
{
|
{
|
||||||
entity.DisableBrain();
|
entity.DisableBrain();
|
||||||
}
|
}
|
||||||
|
subviewport.AddChild(rewardedObject);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,9 +13,6 @@ public partial class LevelController : Node
|
||||||
public static LevelController Instance { get; private set; }
|
public static LevelController Instance { get; private set; }
|
||||||
public RewardResource Reward { get; private set; }
|
public RewardResource Reward { get; private set; }
|
||||||
private string pathToInitiator;
|
private string pathToInitiator;
|
||||||
|
|
||||||
private bool _isLevelRunning = false;
|
|
||||||
|
|
||||||
public override void _EnterTree()
|
public override void _EnterTree()
|
||||||
{
|
{
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
|
@ -32,16 +29,10 @@ public partial class LevelController : Node
|
||||||
/// <param name="levelResource">Execution of level</param>
|
/// <param name="levelResource">Execution of level</param>
|
||||||
public void StartLevel(PackedScene levelTileset, AdventureLevelResource levelResource)
|
public void StartLevel(PackedScene levelTileset, AdventureLevelResource levelResource)
|
||||||
{
|
{
|
||||||
if (_isLevelRunning)
|
|
||||||
return;
|
|
||||||
|
|
||||||
pathToInitiator = GetTree().CurrentScene.SceneFilePath;
|
pathToInitiator = GetTree().CurrentScene.SceneFilePath;
|
||||||
RuntimeLevelData.LevelResource = levelResource;
|
RuntimeLevelData.LevelResource = levelResource;
|
||||||
|
|
||||||
GetTree().ChangeSceneToPacked(levelTileset);
|
GetTree().ChangeSceneToPacked(levelTileset);
|
||||||
|
|
||||||
|
|
||||||
_isLevelRunning = true;
|
|
||||||
}
|
}
|
||||||
public void RestartLevel()
|
public void RestartLevel()
|
||||||
{
|
{
|
||||||
|
|
@ -51,13 +42,8 @@ public partial class LevelController : Node
|
||||||
}
|
}
|
||||||
public void EndLevel()
|
public void EndLevel()
|
||||||
{
|
{
|
||||||
if (_isLevelRunning == false)
|
|
||||||
return;
|
|
||||||
|
|
||||||
|
|
||||||
RuntimeLevelData.LevelResource = null;
|
RuntimeLevelData.LevelResource = null;
|
||||||
|
|
||||||
_isLevelRunning = false;
|
|
||||||
if (Reward != null)
|
if (Reward != null)
|
||||||
{
|
{
|
||||||
GetTree().ChangeSceneToFile(REWARD_SCENE_UID);
|
GetTree().ChangeSceneToFile(REWARD_SCENE_UID);
|
||||||
|
|
@ -72,7 +58,6 @@ public partial class LevelController : Node
|
||||||
if (pathToInitiator == null) return;
|
if (pathToInitiator == null) return;
|
||||||
|
|
||||||
GetTree().ChangeSceneToFile(pathToInitiator);
|
GetTree().ChangeSceneToFile(pathToInitiator);
|
||||||
|
|
||||||
pathToInitiator = null;
|
pathToInitiator = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -92,10 +92,6 @@ public partial class RuntimeLevelData : Node
|
||||||
{
|
{
|
||||||
return _currentState;
|
return _currentState;
|
||||||
}
|
}
|
||||||
public override void _ExitTree()
|
|
||||||
{
|
|
||||||
LevelController.Instance.EndLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//private Array<PlantResource> _selectedPlants;
|
//private Array<PlantResource> _selectedPlants;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue