Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- using System.Collections.Generic;
- public class Node : MonoBehaviour {
- List<GameObject> Neighbours;
- public int ListOfNeighbours;
- bool isWalkable;
- SpriteRenderer sR;
- // Use this for initialization
- void Start () {
- Neighbours = new List<GameObject>();
- isWalkable = true;
- sR = GetComponent<SpriteRenderer>();
- }
- // Update is called once per frame
- void Update () {
- if(isWalkable) sR.color = Color.green;
- else sR.color = Color.red;
- }
- void OnTriggerEnter2D(Collider2D coll)
- {
- isWalkable = false;
- }
- void OnTriggerStay2D(Collider2D coll)
- {
- isWalkable = false;
- }
- void OnTriggerExit2D(Collider2D coll)
- {
- isWalkable = true;
- }
- public void AddNeighbour(GameObject n)
- {
- Neighbours.Add(n);
- }
- public void GetNeighbours()
- {
- ListOfNeighbours = Neighbours.Count;
- }
- }
Advertisement
RAW Paste Data
Copied
Advertisement