diff --git a/project.godot b/project.godot index 89fbd46..337068a 100644 --- a/project.godot +++ b/project.godot @@ -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) ] } +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] diff --git a/scenes/gui/runtime_gui.tscn b/scenes/gui/runtime_gui.tscn index a5f3c6a..b9d20f1 100644 --- a/scenes/gui/runtime_gui.tscn +++ b/scenes/gui/runtime_gui.tscn @@ -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="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="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="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="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"] @@ -232,6 +233,7 @@ layout_mode = 2 custom_minimum_size = Vector2(377, 64) layout_mode = 2 theme_override_styles/panel = SubResource("StyleBoxTexture_ps2iw") +script = ExtResource("5_xq48m") [node name="Seedpackets" type="HBoxContainer" parent="MarginContainer/Control/Hotbar/PanelContainer"] process_mode = 3 diff --git a/scripts/debug/Cheats.cs b/scripts/debug/Cheats.cs index 71c5794..b2ca5c8 100644 --- a/scripts/debug/Cheats.cs +++ b/scripts/debug/Cheats.cs @@ -19,5 +19,9 @@ public partial class Cheats : Node GetTree().CurrentScene.AddChild(spawner); } + if (@event.IsActionPressed("cheat_unlock_all")) + { + PlayerProgress.Instance.PlayerPlants = GameRegistry.GetPlants(); + } } } diff --git a/scripts/entities/Entity.cs b/scripts/entities/Entity.cs index 4690c82..095be99 100644 --- a/scripts/entities/Entity.cs +++ b/scripts/entities/Entity.cs @@ -1,5 +1,6 @@ using Godot; using Godot.Collections; +using Newlon.Components.Level; using Newlon.Systems.Effects; namespace Newlon.Components; @@ -58,22 +59,30 @@ public partial class Entity : Node2D #region Brain [Export] private AnimationPlayer _player; [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) _player.ProcessMode = ProcessModeEnum.Pausable; if (_tree != null) _tree.ProcessMode = ProcessModeEnum.Pausable; ProcessMode = ProcessModeEnum.Disabled; + forceToggledBrain = force; + brainEnabled = false; } - public virtual void EnableBrain() + public virtual void EnableBrain(bool force = true) { + if (brainEnabled) return; if (_player != null) _player.ProcessMode = ProcessModeEnum.Inherit; if (_tree != null) _tree.ProcessMode = ProcessModeEnum.Inherit; ProcessMode = ProcessModeEnum.Inherit; + forceToggledBrain = force; + brainEnabled = true; } #endregion #region Effects @@ -171,6 +180,11 @@ public partial class Entity : Node2D public override void _Ready() { HP = MaxHP; + if (RuntimeLevelData.Instance != null) + { + if (RuntimeLevelData.Instance.GetLevelState() != RuntimeLevelData.LevelStates.Game) DisableBrain(false); + } } + #endregion } diff --git a/scripts/gui/PlantHotbarSize.cs b/scripts/gui/PlantHotbarSize.cs new file mode 100644 index 0000000..61be9dc --- /dev/null +++ b/scripts/gui/PlantHotbarSize.cs @@ -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); + } + } +} diff --git a/scripts/gui/PlantHotbarSize.cs.uid b/scripts/gui/PlantHotbarSize.cs.uid new file mode 100644 index 0000000..d7986fa --- /dev/null +++ b/scripts/gui/PlantHotbarSize.cs.uid @@ -0,0 +1 @@ +uid://bygqu13os20wi diff --git a/scripts/gui/RewardScene.cs b/scripts/gui/RewardScene.cs index 6ed8db7..f359cd8 100644 --- a/scripts/gui/RewardScene.cs +++ b/scripts/gui/RewardScene.cs @@ -24,11 +24,12 @@ public partial class RewardScene : Node } var rewardedObject = reward.GetPreview().Instantiate(); - subviewport.AddChild(rewardedObject); if (rewardedObject is Entity entity) { entity.DisableBrain(); } + subviewport.AddChild(rewardedObject); + } } diff --git a/scripts/level/LevelController.cs b/scripts/level/LevelController.cs index 7119457..4c7705f 100644 --- a/scripts/level/LevelController.cs +++ b/scripts/level/LevelController.cs @@ -13,9 +13,6 @@ public partial class LevelController : Node public static LevelController Instance { get; private set; } public RewardResource Reward { get; private set; } private string pathToInitiator; - - private bool _isLevelRunning = false; - public override void _EnterTree() { Instance = this; @@ -32,16 +29,10 @@ public partial class LevelController : Node /// Execution of level public void StartLevel(PackedScene levelTileset, AdventureLevelResource levelResource) { - if (_isLevelRunning) - return; - pathToInitiator = GetTree().CurrentScene.SceneFilePath; RuntimeLevelData.LevelResource = levelResource; GetTree().ChangeSceneToPacked(levelTileset); - - - _isLevelRunning = true; } public void RestartLevel() { @@ -51,13 +42,8 @@ public partial class LevelController : Node } public void EndLevel() { - if (_isLevelRunning == false) - return; - - RuntimeLevelData.LevelResource = null; - _isLevelRunning = false; if (Reward != null) { GetTree().ChangeSceneToFile(REWARD_SCENE_UID); @@ -72,7 +58,6 @@ public partial class LevelController : Node if (pathToInitiator == null) return; GetTree().ChangeSceneToFile(pathToInitiator); - pathToInitiator = null; } diff --git a/scripts/level/RuntimeLevelData.cs b/scripts/level/RuntimeLevelData.cs index e5213ce..db6bca7 100644 --- a/scripts/level/RuntimeLevelData.cs +++ b/scripts/level/RuntimeLevelData.cs @@ -92,10 +92,6 @@ public partial class RuntimeLevelData : Node { return _currentState; } - public override void _ExitTree() - { - LevelController.Instance.EndLevel(); - } //private Array _selectedPlants;