Exemplo n.º 1
0
    // SPAWN TILES ()
    public void SpawnTile()
    {
        if (FloorTiles.Count == 0 || TunnelTiles.Count == 0)
        {
            CreateTiles(10); // We need 10 tiles of both to make sure that the player thinks it's an endless path.
        }

        int randomIndex = Random.Range(0, 2); // Random Index

        if (randomIndex == 0 && currentTile != null)
        {
            GameObject temp = FloorTiles.Pop();                                                         // Pop it out of the stack, into the Game World.
            temp.SetActive(true);                                                                       // Make visible
            temp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(0).position; // Set position equal to the last tiles' first child: "AttachPoint"
            currentTile             = temp;                                                             // set current tile equal to our new object
        }
        else if (randomIndex == 1 && currentTile != null)
        {
            GameObject temp = TunnelTiles.Pop();
            temp.SetActive(true);
            temp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(0).position;
            currentTile             = temp;
        }

        else // STARTING TILE
        {
            currentTile = tilePrefabs[1]; // Set tunnel as start tile.
            GameObject temp = TunnelTiles.Pop();
            temp.SetActive(true);
            temp.transform.position = startPosition; // Set the position equal to pathspawners position
            currentTile             = temp;
        }
    }