Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class Tile : MonoBehaviour
- {
- [SerializeField] private GameObject _body;
- private Renderer _bodyRend;
- private Unit _occupant;
- public Unit Occupant => _occupant;
- private Grid grid;
- private int x;
- private int y;
- public int X => x;
- public int Y => y;
- private bool isWalkable;
- private bool isOccupied;
- public int gCost;
- public int hCost;
- public int fCost => gCost + hCost;
- public Tile cameFromTile;
- private void Awake()
- {
- _bodyRend = _body.GetComponent<Renderer>();
- }
- public void SetTileData(Grid grid, int x, int y)
- {
- this.grid = grid;
- this.x = x;
- this.y = y;
- }
- public void SetWalkable(bool isWalkable = true)
- {
- this.isWalkable = isWalkable;
- }
- public bool IsWalkable() => isWalkable && !isOccupied;
- public void SetTileMat(Material mat)
- {
- _bodyRend.material = mat;
- }
- public void SetUnitOnTile(Unit unit)
- {
- _occupant = unit;
- isOccupied = _occupant != null;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement