Files
peggle-roguelike/PlayArea.cs
T

53 lines
1.3 KiB
C#

using Godot;
using System;
using System.Collections.Generic;
using System.Linq;
public partial class PlayArea : Node2D
{
public Node2D _leftEdge, _rightEdge;
public Area2D _region;
public Map _map;
public override void _Ready()
{
base._Ready();
_region = GetNode<Area2D>("Region");
_leftEdge = GetNode<Node2D>("LeftEdge");
_rightEdge = GetNode<Node2D>("RightEdge");
CollisionShape2D regionBounds = _region.GetNode<CollisionShape2D>("Bounds");
_map = GetNode<Map>("Map");
TileMapLayer occupiedSpaces = GetNode<TileMapLayer>("OccupiedSpaces");
occupiedSpaces.SetCell(Vector2I.Zero, 0, new Vector2I(4,0));
}
public override void _Process(double delta)
{
base._Process(delta);
}
public void HighlightCells()
{
TileMapLayer occupiedSpaces = GetNode<TileMapLayer>("OccupiedSpaces");
_map._cells.ForEach(c =>
{
if (_map.HasOccupant(c))
{
occupiedSpaces.SetCell(c, 0, new Vector2I(4,0));
}
else if (_map._astar.IsPointSolid(c))
{
}
else
{
occupiedSpaces.SetCell(c, 0, Vector2I.Down*4);
}
});
}
}