Broken sunflower

This commit is contained in:
Фёдор Веселов 2024-09-17 00:09:49 +05:00
commit 83d36f53b2
6 changed files with 211 additions and 6 deletions

View file

@ -72,6 +72,7 @@ public partial class PlantField : Node2D
LevelController.Instance.Pools.Plants.AddChild(plant);
plant.GlobalPosition = (_plantSetter.GlobalPosition / tile).Ceil() * tile - new Vector2(20, 14);
plant.Resource = _resource;
plant.Line = (int)plant.GlobalPosition.Y/Utility.TileHeight;
LevelController.Instance.Pools.EntityField[_resource.Layer].Add(plant.GlobalPosition, plant as IEntity);

View file

@ -0,0 +1,19 @@
using Godot;
using System;
public partial class PlantSunSpawner : Node2D
{
[Export]
private PackedScene _sunScene;
[Export]
private int _amountPerSun;
public void Spawn()
{
var sun = _sunScene.Instantiate<Sun>();
sun.amount = _amountPerSun;
LevelController.Instance.Pools.Projectiles.AddChild(sun);
sun.GlobalPosition = GlobalPosition;
}
}

View file

@ -10,11 +10,9 @@ public partial class RuntimePlantData : Node2D, IEntity
[Export]
private int _maxHP;
private int _hp;
[Export]
private int _line;
public int Hp => _hp;
public int MaxHp => _maxHP;
public int Line => _line;
public int Line {get; set;}
public PlantResource Resource;
public override void _Ready()
@ -41,7 +39,6 @@ public partial class RuntimePlantData : Node2D, IEntity
Kill();
}
}
public void Kill()
{
LevelController.Instance.Pools.EntityField[Resource.Layer].Remove(GlobalPosition);

View file

@ -0,0 +1,18 @@
using Godot;
using System;
public partial class SunflowerBehaviour : Node
{
private AnimationTree _tree;
public override void _Ready()
{
_tree = GetNode<AnimationTree>("../AnimationTree");
}
public void Timeout()
{
_tree.Set("parameters/conditions/produce",true);
}
}