droppable items and win

This commit is contained in:
Rendo 2025-07-20 22:11:23 +05:00
commit 5bdbfa4d82
47 changed files with 820 additions and 85 deletions

View file

@ -1,9 +1,10 @@
using Godot;
using Newlon;
public partial class ExitButton : Button
{
public override void _Pressed()
{
GetTree().ChangeSceneToFile("uid://bfstrli64u23y");
LevelController.Instance.EndLevel();
}
}

View file

@ -1,4 +1,5 @@
using Godot;
using Newlon.Components.Level;
namespace Newlon.Components.GUI;
@ -12,10 +13,32 @@ public partial class FastForwardButton : Button
private int speed = 1;
public override void _Ready()
{
RuntimeLevelData.Instance.OnLevelStateChanged += OnLevelStateChanged;
}
private void OnLevelStateChanged(RuntimeLevelData.LevelStates state)
{
if (state == RuntimeLevelData.LevelStates.Game) return;
speed = 1;
Update();
}
public void OnPressed()
{
speed = Mathf.Wrap(speed+1, 1, 4);
if (RuntimeLevelData.Instance.GetLevelState() != RuntimeLevelData.LevelStates.Game) return;
speed = Mathf.Wrap(speed + 1, 1, 4);
flashAnimator.Play("flash");
Update();
}
private void Update()
{
switch (speed)
{
case 1:
@ -29,8 +52,6 @@ public partial class FastForwardButton : Button
break;
}
flashAnimator.Play("flash");
Engine.TimeScale = speed;
}
}

View file

@ -27,7 +27,7 @@ public partial class PauseMenu : Control
}
public void Exit()
{
GetTree().ChangeSceneToFile("uid://bfstrli64u23y");
LevelController.Instance.EndLevel();
currently_paused = false;
}
public static void Pause()

View file

@ -1,12 +1,12 @@
using Godot;
using System;
using Newlon;
public partial class RestartButton : Button
{
public override void _Pressed()
{
GetTree().Paused = false;
GetTree().ReloadCurrentScene();
LevelController.Instance.RestartLevel();
}
}

View file

@ -0,0 +1,34 @@
using Godot;
using Newlon;
using Newlon.Components;
using Newlon.Components.Plants;
public partial class RewardScene : Node
{
public override void _Ready()
{
var reward = LevelController.Instance.Reward;
var subviewport = GetNode<SubViewport>("%SubViewport");
var nameLabel = GetNode<Label>("%NameLabel");
var descriptionLabel = GetNode<RichTextLabel>("%DescriptionLabel");
var continueButton = GetNode<Button>("%ContinueButton");
var field = GetNode<Sprite2D>("%Field");
nameLabel.Text = Tr(reward.Name);
descriptionLabel.Text = Tr(reward.Description);
continueButton.Pressed += LevelController.Instance.ReturnToInitiator;
if (reward is PlantReward plantReward && plantReward.Plant.customFrame != null)
{
field.Texture = plantReward.Plant.customFrame.almanachField;
}
var rewardedObject = reward.GetPreview().Instantiate();
subviewport.AddChild(rewardedObject);
if (rewardedObject is Entity entity)
{
entity.DisableBrain();
}
}
}

View file

@ -0,0 +1 @@
uid://cqlghusry0hej

View file

@ -1,6 +1,7 @@
using Godot;
[GlobalClass]
[Tool]
public partial class CustomSeedpacketFrame : Resource
{
[Export] public Texture2D frame;