Exemplo n.º 1
0
    public void SpawnTile()
    {
        if (TopTiles.Count == 0 || LeftTiles.Count == 0)
        {
            CreateTiles(10);
        }


        int RandomIndex = Random.Range(0, 2);

        if (RandomIndex == 0)
        {
            GameObject tmp = LeftTiles.Pop();
            tmp.SetActive(true);
            tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(RandomIndex).position;
            currentTile            = tmp;
        }
        else if (RandomIndex == 1)
        {
            GameObject tmp = TopTiles.Pop();
            tmp.SetActive(true);
            tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(RandomIndex).position;
            currentTile            = tmp;
        }

        int spawnPickup = Random.Range(0, 10);

        if (spawnPickup == 0)
        {
            currentTile.transform.GetChild(1).gameObject.SetActive(true);
        }

        currentTile = (GameObject)Instantiate(TilePrefabs[RandomIndex], currentTile.transform.GetChild(0).transform.GetChild(RandomIndex).position, Quaternion.identity);
    }
Exemplo n.º 2
0
    public void SpawnTile()
    {
        if (LeftTiles.Count == 0 || TopTiles.Count == 0)
        {
            CreateTiles(10);
        }

        //generam numere intre 0 si 1
        int randomIndex = Random.Range(0, 2);

        if (randomIndex == 0)
        {
            GameObject tmp = LeftTiles.Pop();
            tmp.SetActive(true);
            tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position;

            currentTile = tmp;
        }
        else if (randomIndex == 1)
        {
            GameObject tmp = TopTiles.Pop();
            tmp.SetActive(true);
            tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position;

            currentTile = tmp;
        }

        int spawnPickup = Random.Range(0, 10);

        if (spawnPickup == 0)
        {
            currentTile.transform.GetChild(1).gameObject.SetActive(true);
        }
    }
Exemplo n.º 3
0
 public void CreateTiles(int amount)
 {
     for (int i = 0; i < amount; i++)
     {
         LeftTiles.Push(Instantiate(TilePrefabs[0]));
         TopTiles.Push(Instantiate(TilePrefabs[1]));
         TopTiles.Peek().name = "TopTile";
         TopTiles.Peek().SetActive(false);
         LeftTiles.Peek().name = "LeftTile";
         LeftTiles.Peek().SetActive(false);
     }
 }
Exemplo n.º 4
0
    /////////////////////////////////////////////
    public void SpawnTileEasyMode()
    {
        int catePiese = Random.Range(1, 4);

        if (LeftTiles.Count == 0 || TopTiles.Count == 0)
        {
            CreateTiles(10);
        }

        //generam numere intre 0 si 1
        int randomIndex = Random.Range(0, 2);


        //daca e 0, spawnam left tile
        if (randomIndex == 0)
        {
            for (int i = 0; i < catePiese; i++)
            {
                GameObject tmp = LeftTiles.Pop();
                tmp.SetActive(true);
                tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position;

                currentTile = tmp;
            }
        }

        //daca e 1, spawnam top tile

        else if (randomIndex == 1)
        {
            for (int i = 0; i < catePiese; i++)
            {
                GameObject tmp = TopTiles.Pop();
                tmp.SetActive(true);
                tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position;

                currentTile = tmp;
            }
        }

        int spawnPickup = Random.Range(0, 10);

        if (spawnPickup == 0)
        {
            currentTile.transform.GetChild(1).gameObject.SetActive(true);
        }

        //currentTile = Instantiate(tilePrefabs[randomIndex], currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position, Quaternion.identity);
    }
Exemplo n.º 5
0
    public void SpawnTile()
    {
        //check if we have some tiles to take before we try to spawn them
        if (LeftTiles.Count == 0 || TopTiles.Count == 0)
        {
            CreateTiles(10);
        }

        //CurrentTile -> Tile -> LeftAttachPoint
        //currentTile = Instantiate(leftTilePrefab, currentTile.transform.GetChild(0).transform.GetChild(0).position, Quaternion.identity);
        //currentTile = Instantiate(topTilePrefab, currentTile.transform.GetChild(0).transform.GetChild(1).position, Quaternion.identity);

        //Generating a random number between 0 and 1
        int randomIndex = Random.Range(0, 2);

        if (randomIndex == 0)
        {
            //pop remove the tile from the stack
            GameObject tmp = LeftTiles.Pop();
            //in createtiles we set false
            tmp.SetActive(true);
            tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position;
            currentTile            = tmp;
        }
        else if (randomIndex == 1)
        {
            //pop remove the tile from the stack
            GameObject tmp = TopTiles.Pop();
            //in createtiles we set false
            tmp.SetActive(true);
            tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position;
            currentTile            = tmp;
        }

        int spawnPickup = Random.Range(0, 10);

        if (spawnPickup == 0)
        {
            //enable the pickup same like tick,pickup is the second child
            currentTile.transform.GetChild(1).gameObject.SetActive(true);
        }

        //Left -> Element0, Top -> Element1
        //currentTile = Instantiate(tilePrefabs[0], currentTile.transform.GetChild(0).transform.GetChild(0).position, Quaternion.identity);
        //currentTile = Instantiate(tilePrefabs[1], currentTile.transform.GetChild(0).transform.GetChild(1).position, Quaternion.identity);
        //currentTile = Instantiate(tilePrefabs[randomIndex], currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position, Quaternion.identity);
    }
Exemplo n.º 6
0
    /// <summary>
    /// Takes care for placing the tiles randomly and recyle them.
    /// Also adds pickups for bonus point randomly for red and golden apples.
    /// </summary>
    public void SpawnTile()
    {
        if (LeftTiles.Count == 0 || TopTiles.Count == 0)
        {
            CreateTiles(10);
        }

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

        if (randomIndex == 0)
        {
            GameObject tmp = LeftTiles.Pop();
            tmp.SetActive(true);
            tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position;
            currentTile            = tmp;
        }
        else if (randomIndex == 1)
        {
            GameObject tmp = TopTiles.Pop();
            tmp.SetActive(true);
            tmp.transform.position = currentTile.transform.GetChild(0).transform.GetChild(randomIndex).position;
            currentTile            = tmp;
        }
        // Each tile will have a 50% chance of spawing a red- or golden-apple with their own chance, 1/8 and 1/50 respectily.
        int spawnPickup = Random.Range(0, 2);

        if (spawnPickup == 0)
        {
            //int + ny if(redapple == 0) + 0, 10
            int redApple = Random.Range(0, 8);
            if (redApple == 0)
            {
                currentTile.transform.GetChild(1).gameObject.SetActive(true);
            }
        }
        else if (spawnPickup == 1)
        {
            int goldenApple = Random.Range(0, 50);
            if (goldenApple == 0)
            {
                currentTile.transform.GetChild(2).gameObject.SetActive(true);
            }
        }
    }