コード例 #1
0
    void RandomReset()
    {
        int maxReset = /*(gameMode == GAME_MODE_CLASSIC) ? ((difficultyLevel == DIFFICULTY_LEVEL_HARD) ? Random.Range(-maxPipeReset, maxPipeReset) : Random.Range(0, maxPipeReset)) :*/ Random.Range(1, maxPipeReset + 1);

        int[] usedIndexes = new int[maxReset];

        for (int cntr = 0; cntr < usedIndexes.Length; cntr++)
        {
            usedIndexes[cntr] = -1;
        }

        // Add AI to random reset functionality.
        if (maxReset > 0)
        {
            for (int cntr = 1; cntr <= maxReset; cntr++)
            {
                repeat_iteration :;
                int curIndex = 0;

                while (true)
                {
                    bool isSuccess = true;

                    curIndex = Random.Range(0, TotalPipes);

                    foreach (int index in usedIndexes)
                    {
                        if (index == curIndex)
                        {
                            isSuccess = false; break;
                        }
                    }

                    if (isSuccess)
                    {
                        break;
                    }
                }

                GameObject selectedObject = findGameObjectWithId(curIndex);

                if (selectedObject != null && selectedObject.GetComponent <PipeController>() != null && selectedObject.GetComponent <PipeController>().isInFieldOfView)
                {
                    //selectedObject.GetComponent<PipeController>().isMatched = false;
                    selectedObject.SendMessage("RandomReset");
                    selectedObject.SendMessage("EmphasizePipe");
                    usedIndexes[cntr - 1] = curIndex;
                }
                else /*if (difficultyLevel == DIFFICULTY_LEVEL_HARD || gameMode == GAME_MODE_SURPRISE)*/ goto {
                    repeat_iteration;
                }
            }
        }

        /*if (gameMode == GAME_MODE_SURPRISE)*/ max_pipes = maxReset;
        timeCounter = (max_pipes * LevelList.FindLevelWithId(gameMode, levelNumber).levelTime / ((TypeDefinations.LevelSurpriseModeData)LevelList.FindLevelWithId(gameMode, levelNumber)).maxPipesOnEntry) + ((difficultyLevel == DIFFICULTY_LEVEL_NORMAL) ? ((max_pipes * 6 / ((TypeDefinations.LevelSurpriseModeData)LevelList.FindLevelWithId(gameMode, levelNumber)).maxPipesOnEntry) + 1) : 0); // Relative time calculation.
    }
コード例 #2
0
    void Awake( )
    {
        spriteStack = new SpriteEntry[baseSprites.Length];

        for (int cntr = 0; cntr < baseSprites.Length; cntr++)
        {
            SpriteEntry sprite;

            sprite.baseSprite   = baseSprites[cntr];
            sprite.changeSprite = changeSprites[cntr];

            spriteStack[cntr] = sprite;
        }

        // Load our level into the game.
        GameObject gameObject = (GameObject)Resources.Load(((gameMode == GAME_MODE_CLASSIC) ? "Maps/ClassicMode/Level0" : "Maps/SurpriseMode/Level0") + levelNumber, typeof(GameObject));

        for (int cntr = 0; cntr < gameObject.transform.childCount; cntr++)
        {
            if (gameObject.transform.GetChild(cntr).gameObject.GetComponent <PipeController>() != null)
            {
                gameObject.transform.GetChild(cntr).gameObject.GetComponent <PipeController>().baseController = this;
            }
        }

        Instantiate(gameObject, levelLoadPosition, Quaternion.Euler(0, 0, 0));
        TotalPipes = gameObject.transform.childCount;

        TypeDefinations.LevelData levelData = LevelList.FindLevelWithId(gameMode, levelNumber);
        timeCounter = levelData.levelTime;

        if (gameMode == GAME_MODE_SURPRISE)
        {
            maxWaves      = ((TypeDefinations.LevelSurpriseModeData)levelData).maxWaves;
            roundsPerWave = ((TypeDefinations.LevelSurpriseModeData)levelData).roundsPerWave;
            maxPipeReset  = ((TypeDefinations.LevelSurpriseModeData)levelData).pipeResetCount;
            max_pipes     = ((TypeDefinations.LevelSurpriseModeData)levelData).maxPipesOnEntry;
        }

        waitTime = timeCounter;
    }