Almanach
This commit is contained in:
parent
008fa31dd4
commit
b932e82555
39 changed files with 575 additions and 78 deletions
|
|
@ -7,7 +7,7 @@ namespace Newlon.Components.Level;
|
|||
public partial class PlantField : Node2D
|
||||
{
|
||||
private Node2D _plantSetter;
|
||||
private PlantResource _resource;
|
||||
private DisplayResource _resource;
|
||||
private Seedpacket _slot;
|
||||
private bool _previousCanPlace;
|
||||
private ChannelPlayer player;
|
||||
|
|
@ -21,18 +21,18 @@ public partial class PlantField : Node2D
|
|||
player = GetNode<ChannelPlayer>("PlantPlayer");
|
||||
}
|
||||
|
||||
public void SetPlant(Seedpacket slot, PlantResource plant)
|
||||
public void SetPlant(Seedpacket slot, DisplayResource resource)
|
||||
{
|
||||
_resource = plant;
|
||||
_resource = resource;
|
||||
_slot = slot;
|
||||
if (plant == null)
|
||||
if (resource == null)
|
||||
{
|
||||
foreach(var child in _plantSetter.GetChildren())
|
||||
child.QueueFree();
|
||||
}
|
||||
else
|
||||
{
|
||||
var scene = plant.Scene.Instantiate<Node2D>();
|
||||
var scene = resource.Scene.Instantiate<Node2D>();
|
||||
_plantSetter.AddChild(scene);
|
||||
scene.UseParentMaterial = true;
|
||||
}
|
||||
|
|
@ -93,7 +93,7 @@ public partial class PlantField : Node2D
|
|||
var plant = _resource.Scene.Instantiate<RuntimePlantData>();
|
||||
PoolContainer.Instance.Plants.AddChild(plant);
|
||||
plant.GlobalPosition = (_plantSetter.GlobalPosition / Utility.Tile).Ceil() * Utility.Tile - new Vector2(20, 14);
|
||||
plant.Resource = _resource;
|
||||
plant.Resource = (PlantResource)_resource;
|
||||
|
||||
PoolContainer.Instance.EntityField[_resource.Layer].Add(plant.GlobalPosition, plant);
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ public partial class RuntimeLevelData : Node
|
|||
}
|
||||
|
||||
[Export]
|
||||
public int SunCount { get; private set; } = 0;
|
||||
public float SunCount { get; private set; } = 0;
|
||||
public event Action<LevelStates> OnLevelStateChanged;
|
||||
|
||||
public static RuntimeLevelData Instance { get; private set; }
|
||||
|
|
@ -29,17 +29,17 @@ public partial class RuntimeLevelData : Node
|
|||
}
|
||||
|
||||
#region Sun
|
||||
public void AddSun(int amount)
|
||||
public void AddSun(float amount)
|
||||
{
|
||||
SunCount += amount;
|
||||
}
|
||||
|
||||
public void SpendSun(int amount)
|
||||
public void SpendSun(float amount)
|
||||
{
|
||||
SunCount -= amount;
|
||||
}
|
||||
|
||||
public bool CheckSpendSun(int amount)
|
||||
public bool CheckSpendSun(float amount)
|
||||
{
|
||||
if (SunCount - amount < 0) return false;
|
||||
|
||||
|
|
|
|||
|
|
@ -38,16 +38,16 @@ public partial class SurvivalZombieSpawner : Node
|
|||
|
||||
cachedTankPool.Sort((x, y) =>
|
||||
{
|
||||
return (int)(x.cost - y.cost);
|
||||
return (int)(x.Cost - y.Cost);
|
||||
});
|
||||
cachedHordePool.Sort((x, y) =>
|
||||
{
|
||||
return (int)(x.cost - y.cost);
|
||||
return (int)(x.Cost - y.Cost);
|
||||
});
|
||||
|
||||
minSupportPoints = cachedSupportPool[0].cost;
|
||||
minTankPoints = cachedTankPool[0].cost;
|
||||
minHordePoints = cachedHordePool[0].cost;
|
||||
minSupportPoints = cachedSupportPool[0].Cost;
|
||||
minTankPoints = cachedTankPool[0].Cost;
|
||||
minHordePoints = cachedHordePool[0].Cost;
|
||||
|
||||
fin_a = (velocity_curve.Sample(velocity_curve.MaxDomain) - velocity_curve.Sample(velocity_curve.MaxDomain - 0.001f)) / 0.001f;
|
||||
}
|
||||
|
|
@ -107,10 +107,10 @@ public partial class SurvivalZombieSpawner : Node
|
|||
while (given_points >= minSupportPoints)
|
||||
{
|
||||
var chosen_zombie = cachedSupportPool[rng.RandiRange(0, cachedSupportPool.Count - 1)];
|
||||
if (given_points - chosen_zombie.cost >= 0)
|
||||
if (given_points - chosen_zombie.Cost >= 0)
|
||||
{
|
||||
wave.Add(chosen_zombie);
|
||||
given_points -= chosen_zombie.cost;
|
||||
given_points -= chosen_zombie.Cost;
|
||||
}
|
||||
}
|
||||
return given_points;
|
||||
|
|
@ -124,14 +124,14 @@ public partial class SurvivalZombieSpawner : Node
|
|||
int zombieIndex = cachedTankPool.Count - 1;
|
||||
while (given_points >= minSupportPoints && zombieIndex > -1)
|
||||
{
|
||||
if (cachedTankPool[zombieIndex].cost > given_points)
|
||||
if (cachedTankPool[zombieIndex].Cost > given_points)
|
||||
{
|
||||
zombieIndex--;
|
||||
continue;
|
||||
}
|
||||
var chosen_zombie = cachedTankPool[zombieIndex];
|
||||
wave.Add(chosen_zombie);
|
||||
given_points -= chosen_zombie.cost;
|
||||
given_points -= chosen_zombie.Cost;
|
||||
}
|
||||
return given_points;
|
||||
}
|
||||
|
|
@ -141,18 +141,18 @@ public partial class SurvivalZombieSpawner : Node
|
|||
{
|
||||
return given_points;
|
||||
}
|
||||
while (is_big == false && cachedHordePool.Count > 1 && cachedHordePool[1].cost * 15 <= given_points)
|
||||
while (is_big == false && cachedHordePool.Count > 1 && cachedHordePool[1].Cost * 15 <= given_points)
|
||||
{
|
||||
cachedHordePool.RemoveAt(0);
|
||||
minHordePoints = cachedHordePool[0].cost;
|
||||
minHordePoints = cachedHordePool[0].Cost;
|
||||
}
|
||||
while (given_points >= minHordePoints)
|
||||
{
|
||||
var chosen_zombie = cachedHordePool[rng.RandiRange(0, cachedHordePool.Count - 1)];
|
||||
if (given_points - chosen_zombie.cost >= 0)
|
||||
if (given_points - chosen_zombie.Cost >= 0)
|
||||
{
|
||||
wave.Add(chosen_zombie);
|
||||
given_points -= chosen_zombie.cost;
|
||||
given_points -= chosen_zombie.Cost;
|
||||
}
|
||||
}
|
||||
return given_points;
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public partial class ZombieSequencer : Node2D
|
|||
|
||||
private void Spawn(string id, int lane)
|
||||
{
|
||||
RuntimeZombieData zombie = GameRegistry.GetZombieByName(id).scene.Instantiate<RuntimeZombieData>();
|
||||
RuntimeZombieData zombie = GameRegistry.GetZombieByName(id).Scene.Instantiate<RuntimeZombieData>();
|
||||
PoolContainer.Instance.Zombies.AddChild(zombie);
|
||||
|
||||
zombie.GlobalPosition = new Vector2(GlobalPosition.X, Utility.RightFieldBoundary.Y - (lane - 1) * Utility.TileHeight);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue