2020-08-22 05:29:00 +00:00
|
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using TMPro;
|
|
|
|
|
|
|
|
|
|
public class TileRender : MonoBehaviour {
|
|
|
|
|
|
|
|
|
|
public new SpriteRenderer renderer;
|
|
|
|
|
public TextMeshPro textMesh;
|
|
|
|
|
public int id;
|
|
|
|
|
|
2020-08-22 16:28:49 +00:00
|
|
|
|
public SpriteRenderer Chains;
|
|
|
|
|
|
2020-08-22 05:29:00 +00:00
|
|
|
|
public void SetDisplay(TileColor color, TileKind kind) {
|
|
|
|
|
SetDisplay(null, color, kind);
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-22 16:28:49 +00:00
|
|
|
|
|
|
|
|
|
|
2020-08-22 05:29:00 +00:00
|
|
|
|
public void SetDisplay(TileInfo tile, TileColor color, TileKind kind){
|
|
|
|
|
Sprite[] sprites;
|
2020-08-22 16:28:49 +00:00
|
|
|
|
|
|
|
|
|
Chains.enabled = kind.Equals(TileKind.Trash);
|
|
|
|
|
|
2020-08-22 05:29:00 +00:00
|
|
|
|
switch(kind){
|
|
|
|
|
case TileKind.Block:
|
|
|
|
|
case TileKind.Trash:
|
|
|
|
|
sprites = GameBoardInstance.instance.regular;
|
|
|
|
|
break;
|
|
|
|
|
case TileKind.Activator:
|
|
|
|
|
sprites = GameBoardInstance.instance.activators;
|
|
|
|
|
break;
|
|
|
|
|
case TileKind.Activiting:
|
|
|
|
|
sprites = GameBoardInstance.instance.lit;
|
|
|
|
|
break;
|
2020-08-22 07:22:16 +00:00
|
|
|
|
case TileKind.Special:
|
|
|
|
|
int timeSprite = (int)(Time.time * 4);
|
|
|
|
|
renderer.sprite = GameBoardInstance.instance.activators[timeSprite % 4];
|
|
|
|
|
return;
|
2020-08-22 05:29:00 +00:00
|
|
|
|
default:
|
|
|
|
|
sprites = null;
|
|
|
|
|
Debug.LogErrorFormat(this.gameObject,"{0}, {1}, {2} not supported by tile display", tile.color, tile.kind, tile.counter);
|
|
|
|
|
//Debug.LogFormat("TileInfo Instance {0}",TileInfo._instance);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var s = sprites[(int)color];
|
|
|
|
|
renderer.sprite = s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SetCounter(string text){
|
|
|
|
|
textMesh.text = text;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|