2025-02-10 16:52:47 +08:00
|
|
|
|
using System;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2025-02-12 17:53:59 +08:00
|
|
|
|
namespace Game
|
2025-02-10 16:52:47 +08:00
|
|
|
|
{
|
|
|
|
|
public interface IGridCell
|
|
|
|
|
{
|
|
|
|
|
public int X { get; }
|
|
|
|
|
public int Y { get; }
|
|
|
|
|
public bool IsOccupied { get; }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public class GridCell : IGridCell
|
|
|
|
|
{
|
|
|
|
|
private int _x;
|
|
|
|
|
private int _y;
|
|
|
|
|
private bool _isOccupied;
|
|
|
|
|
private Vector2 _position;
|
|
|
|
|
|
|
|
|
|
public int X => _x;
|
|
|
|
|
|
|
|
|
|
public int Y => _y;
|
|
|
|
|
public Vector2 Position => _position;
|
|
|
|
|
|
|
|
|
|
public bool IsOccupied => _isOccupied;
|
|
|
|
|
|
|
|
|
|
public GridCell(int x, int y)
|
|
|
|
|
{
|
|
|
|
|
_x = x;
|
|
|
|
|
_y = y;
|
|
|
|
|
_isOccupied = false;
|
|
|
|
|
_position = new Vector2(_x, _y);
|
|
|
|
|
Draw();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Draw()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Enter()
|
|
|
|
|
{
|
|
|
|
|
_isOccupied = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void Exit()
|
|
|
|
|
{
|
|
|
|
|
_isOccupied = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|