Пример #1
0
 // Use this for initialization
 void Start()
 {
     //set the sprite order in layer to -ve the y co-ordinate
     this.gameObject.GetComponent <SpriteRenderer>().sortingOrder = -(int)this.gameObject.transform.position.y;
     //set the varibles to the correct objects
     end    = GameObject.Find("board/finish").GetComponent <endNode>();
     board  = GameObject.Find("board").GetComponent <boardTiles>();
     towers = GameObject.Find("Game Data").GetComponent <towerData>();
     hero   = GameObject.Find("hero").GetComponent <heroMovement>();
     //set the checked directions to unchecked (true)
     Up    = true;
     Down  = true;
     Left  = true;
     Right = true;
     //start the inital pathfind
     startPath();
 }
Пример #2
0
 // Use this for initialization
 void Start()
 {
     //set the hero and the towerData object
     hero   = GameObject.Find("hero").GetComponent <heroMovement>();
     towers = GameObject.Find("Game Data").GetComponent <towerData>();
     //remove eveything from the list to then add all the tiles to the list
     tileNodes.Clear();
     foreach (GameObject tile in GameObject.FindGameObjectsWithTag("Tile"))
     {
         //for every tile add to this list
         tileNodes.Add(tile.GetComponent <pathNodes>());
         if (tile.name == "grass")
         {
             //if the tile can be build on then add to this list as well
             tileSpawns.Add(tile.GetComponent <spawnTower>());
         }
     }
 }