-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCellStateScript.cs
More file actions
49 lines (40 loc) · 1.14 KB
/
CellStateScript.cs
File metadata and controls
49 lines (40 loc) · 1.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
using UnityEngine;
using System.Collections;
public class CellStateScript : MonoBehaviour
{
/// <summary>
/// GameState of a cell
/// 0 = empty
/// 1 = player (yellow)
/// 2 = AI (red)
/// </summary>
public int gameState = 0;
//Materials to be used
public Material backgroundMat;
public Material yellowPieceMat;
public Material redPieceMat;
private MeshRenderer backgroundMesh;
//private UtilityScripts utility;
//private GameObject background;
void Start()
{
//Get MeshRenderer of each cell background
backgroundMesh = gameObject.GetComponent<UtilityScripts>().getChildGameObject(gameObject, "background").GetComponent<MeshRenderer>();
}
//Set background material of a cell based on its gameState
void Update()
{
if (gameState == 0)
{
backgroundMesh.material = backgroundMat;
}
else if (gameState == 1)
{
backgroundMesh.material = yellowPieceMat;
}
else if (gameState == 2)
{
backgroundMesh.material = redPieceMat;
}
}
}