Esempio n. 1
0
    void OnCollisionEnter2D(Collision2D other)
    {
        if (firstOnce)
        {
            if (!isGround)
            {
                if (other.gameObject.tag == "Terrain")
                {
                    if (!other.gameObject.GetComponent <FrogGameTerrain>().isSafeTerrain)
                    {
                        FrogGameMaster.isGameOver = true;
                        FrogGameMemory.AddMemory((bool[])FrogGameMaster.latestIndex.Clone(), FrogGameMaster.latestJumpType, false);
                    }
                    else
                    {
                        FrogGameMemory.AddMemory((bool[])FrogGameMaster.latestIndex.Clone(), FrogGameMaster.latestJumpType, true);
                    }

                    gameMaster.GetLatestIndex();
                }
                isGround = true;
            }
        }
        else
        {
            firstOnce = true;
            isGround  = true;
        }
    }
Esempio n. 2
0
    void RandomMove()
    {
        randomTime -= Time.deltaTime;
        if (randomTime < 0)
        {
            if (FrogGameMemory.memoryFragments.Count > 0)
            {
                randomTime = Random.Range(0.0f, randomTimeMax / (FrogGameMemory.memoryFragments.Count * 2));
            }
            else
            {
                randomTime = Random.Range(0.0f, randomTimeMax);
            }

            Jump(FrogGameMemory.CheckMemory(latestIndex));
        }
    }
Esempio n. 3
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. 4
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();
    }