TouhouLS/Assets/RealCode/TileRender.cs

58 lines
1.4 KiB
C#
Raw Normal View History

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;
public SpriteRenderer Chains;
2020-08-22 05:29:00 +00:00
public void SetDisplay(TileColor color, TileKind kind) {
SetDisplay(null, color, kind);
}
public void ClearDisplay(){
renderer.sprite = null;
}
2020-08-22 05:29:00 +00:00
public void SetDisplay(TileInfo tile, TileColor color, TileKind kind){
Sprite[] sprites;
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;
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;
}
}