leomovskii

Cell

Jul 29th, 2022
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.61 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Cell : MonoBehaviour {
  6.  
  7.     SpriteRenderer image;
  8.     int value;
  9.     public Game game;
  10.     public Vector2Int position;
  11.  
  12.     void Start() {
  13.         image = GetComponent<SpriteRenderer>();
  14.     }
  15.  
  16.     public int GetValue() {
  17.         return value;
  18.     }
  19.  
  20.     public void SetValue(int newValue) {
  21.         value = newValue;
  22.         if (newValue == 0) {
  23.             image.color = Color.white;
  24.         } else if (newValue == -1) {
  25.             image.color = Color.blue;
  26.         } else if (newValue == 1) {
  27.             image.color = Color.red;
  28.         }
  29.     }
  30.  
  31.     void OnMouseDown() {
  32.         game.Click(position);
  33.     }
  34. }
Add Comment
Please, Sign In to add comment