Tile vector
This commit is contained in:
parent
de2c6261b0
commit
9197d0a939
2 changed files with 5 additions and 5 deletions
|
|
@ -7,8 +7,6 @@ namespace Newlon.Components.Level;
|
|||
public partial class PlantField : Node2D
|
||||
{
|
||||
private Sprite2D _plantSetter;
|
||||
private readonly Vector2 tile = new Vector2(Utility.TileWidth, Utility.TileHeight);
|
||||
|
||||
private PlantResource _resource;
|
||||
private Seedpacket _slot;
|
||||
private bool _previousCanPlace;
|
||||
|
|
@ -39,7 +37,7 @@ public partial class PlantField : Node2D
|
|||
_plantSetter.GlobalPosition = mouse_pos;
|
||||
|
||||
// Getting position in grid coordinates
|
||||
var expected_pos = (_plantSetter.GlobalPosition / tile).Ceil() * tile - new Vector2(20, 14);
|
||||
var expected_pos = (_plantSetter.GlobalPosition / Utility.Tile).Ceil() * Utility.Tile - new Vector2(20, 14);
|
||||
|
||||
// Checking for boundaries
|
||||
bool inBoundary = expected_pos.X > Utility.LeftFieldBoundary.X && expected_pos.X < Utility.RightFieldBoundary.X && expected_pos.Y > Utility.LeftFieldBoundary.Y && expected_pos.Y < Utility.RightFieldBoundary.Y;
|
||||
|
|
@ -82,11 +80,11 @@ public partial class PlantField : Node2D
|
|||
{
|
||||
var plant = _resource.Scene.Instantiate<RuntimePlantData>();
|
||||
PoolContainer.Instance.Plants.AddChild(plant);
|
||||
plant.GlobalPosition = (_plantSetter.GlobalPosition / tile).Ceil() * tile - new Vector2(20, 14);
|
||||
plant.GlobalPosition = (_plantSetter.GlobalPosition / Utility.Tile).Ceil() * Utility.Tile - new Vector2(20, 14);
|
||||
plant.Resource = _resource;
|
||||
plant.Line = (int)plant.GlobalPosition.Y/Utility.TileHeight;
|
||||
|
||||
PoolContainer.Instance.EntityField[_resource.Layer].Add(plant.GlobalPosition, plant as IEntity);
|
||||
PoolContainer.Instance.EntityField[_resource.Layer].Add(plant.GlobalPosition, plant);
|
||||
|
||||
RuntimeLevelData.Instance.SpendSun(_resource.Cost);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue