Esempio n. 1
0
    void Spawn(bool skip = false)
    {
        int isSafe = Random.Range(0, 2);

        if (skip)
        {
            isSafe = 1;
        }
        else
        {
            if (isSafe == 0)
            {
                int count = 0;
                for (int i = 1; i < FrogGameMemory.GetInputCount(); i++)
                {
                    if (indexList[indexList.Count - i] == false)
                    {
                        count++;
                    }
                }

                if (count >= FrogGameMemory.GetInputCount() - 1)
                {
                    isSafe = 1;
                }
            }
        }

        //isSafe = 1;

        GameObject ne = Instantiate(terrainPrefab, spawner.position, Quaternion.identity, spawner);

        if (isSafe == 1)
        {
            ne.GetComponent <FrogGameTerrain>().Initialize(true, indexList.Count);
            indexList.Add(true);
        }
        else
        {
            ne.GetComponent <FrogGameTerrain>().Initialize(false, indexList.Count);
            indexList.Add(false);
        }

        RefreshTerrain();
    }
Esempio n. 2
0
    void Start()
    {
        latestIndexTerrain = new int[FrogGameMemory.GetInputCount()];
        latestIndex        = new bool[FrogGameMemory.GetInputCount()];

        latestIndexOffset = 4;

        latestJumpType = 0;
        scoreValue     = 0;
        isGameOver     = false;
        isGameOverPrev = false;
        //
        for (int i = 0; i < FrogGameMemory.GetInputCount() + 5; i++)
        {
            Spawn(true);
        }

        GetLatestIndex();
    }