Advertisement
Guest User

Node.cs

a guest
Jan 2nd, 2015
319
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4.  
  5. public class Node : MonoBehaviour {
  6.     List<GameObject> Neighbours;
  7.     public int ListOfNeighbours;
  8.     bool isWalkable;
  9.     SpriteRenderer sR;
  10.     // Use this for initialization
  11.     void Start () {
  12.         Neighbours = new List<GameObject>();
  13.         isWalkable = true;
  14.         sR = GetComponent<SpriteRenderer>();
  15.  
  16.     }
  17.    
  18.     // Update is called once per frame
  19.     void Update () {
  20.         if(isWalkable) sR.color = Color.green;
  21.         else sR.color = Color.red;
  22.     }
  23.     void OnTriggerEnter2D(Collider2D coll)
  24.     {
  25.         isWalkable = false;
  26.     }
  27.     void OnTriggerStay2D(Collider2D coll)
  28.     {
  29.         isWalkable = false;
  30.     }
  31.     void OnTriggerExit2D(Collider2D coll)
  32.     {
  33.         isWalkable = true;
  34.     }
  35.     public void AddNeighbour(GameObject n)
  36.     {
  37.         Neighbours.Add(n);
  38.     }
  39.     public void GetNeighbours()
  40.     {
  41.         ListOfNeighbours = Neighbours.Count;
  42.     }
  43. }
Advertisement
RAW Paste Data Copied
Advertisement