Broken sunflower
This commit is contained in:
parent
0c9ea6ed0f
commit
83d36f53b2
6 changed files with 211 additions and 6 deletions
|
|
@ -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);
|
||||
|
||||
|
|
|
|||
19
scripts/components/plants/PlantSunSpawner.cs
Normal file
19
scripts/components/plants/PlantSunSpawner.cs
Normal 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;
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
|
|
|
|||
18
scripts/components/plants/behaviours/SunflowerBehaviour.cs
Normal file
18
scripts/components/plants/behaviours/SunflowerBehaviour.cs
Normal 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);
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue