You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
67 lines
1.5 KiB
67 lines
1.5 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
|
|
[ExecuteInEditMode]
|
|
|
|
public class Tile : MonoBehaviour
|
|
{
|
|
// Start is called before the first frame update
|
|
|
|
public enum TileType : int {Dirt = 0, Grass = 1, Water = 2, Unwalkable = 3};
|
|
[SerializeField]
|
|
private int currentType;
|
|
public TileType myType;
|
|
|
|
public int movementCost;
|
|
public bool walkable;
|
|
|
|
public GameObject myManager;
|
|
|
|
public void Refresh(){
|
|
gameObject.GetComponent<Renderer>().material = myManager.GetComponent<GridGeneration>().tileTextures[currentType];
|
|
Debug.Log("printing");
|
|
}
|
|
|
|
void Start()
|
|
{
|
|
this.runInEditMode = true;
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
State();
|
|
|
|
}
|
|
|
|
void State(){
|
|
switch(myType){
|
|
case TileType.Dirt:
|
|
movementCost = 1;
|
|
walkable = true;
|
|
currentType = (int) myType;
|
|
break;
|
|
|
|
case TileType.Grass:
|
|
movementCost = 3;
|
|
walkable = true;
|
|
currentType = (int) myType;
|
|
break;
|
|
|
|
case TileType.Water:
|
|
movementCost = 2;
|
|
walkable = true;
|
|
currentType = (int) myType;
|
|
break;
|
|
|
|
case TileType.Unwalkable:
|
|
walkable = false;
|
|
currentType = (int) myType;
|
|
break;
|
|
|
|
}
|
|
}
|
|
}
|