Exemple #1
0
 /**
  * Will reveal any Enemies that have been marked to reveal them selves and will add any state changes to the given StateChange object
  * @param puaseTime
  * @param change
  * @return
  */
 private StateChange revealTrigeredEnemies(int puaseTime, StateChange change)
 {
     if (change == null)
     {
         change = new StateChange();
     }
     if (enemySetPrime != null)
     {
         //rows
         for (int loopRow = 0; loopRow < enemySetPrime.Length; loopRow++)
         {
             //Columns
             if (enemySetPrime[loopRow] != null)
             {
                 for (int loopCollumn = 0; loopCollumn < enemySetPrime[loopRow].Length; loopCollumn++)
                 {
                     //elements
                     if (enemySetPrime[loopRow][loopCollumn] != null)
                     {
                         change.add(enemySetPrime[loopRow][loopCollumn].revealIfSetToo(puaseTime));
                     }
                 }
             }
         }
     }
     return(change);
 }
Exemple #2
0
        /**
         * Will update the BaseEnemies in EnemySetPrime to match the state of there representatives in IObjectSet
         * @return whether or not any changes were made that actually require the game to pause
         * This includes revealing a Enemy, and Moving an enemy
         */
        private StateChange updatePrimeGrid(int pauseTime)
        {
            StateChange changesMade = null;

            updateIOGridPositions();
            if (IObjectSet != null)
            {
                //rows
                for (int loopRow = 0; loopRow < IObjectSet.Length; loopRow++)
                {
                    //Columns
                    if (IObjectSet[loopRow] != null)
                    {
                        for (int loopCollumn = 0; loopCollumn < IObjectSet[loopRow].Length; loopCollumn++)
                        {
                            //elements
                            if (IObjectSet[loopRow][loopCollumn] != null)
                            {
                                changesMade = ((Representative)IObjectSet[loopRow][loopCollumn]).updateSubject(this, pauseTime).add(changesMade);
                            }
                        }
                    }
                }
            }
            return(changesMade);
        }
Exemple #3
0
        /**
         * Will Set the size of the current set to match the current grid
         * Set the targets of existing Enemies to there new position in the grid
         * New Enemies will enter from the Screen edge
         * Enemies not present in the grid will be removed
         * Use get Grid to get the latest version of the grid
         * A state change object will be returned to dictate the changes in player state as a result of the synk
         * Note: BaseEnemy Objects are tied to a specific interactableObjects in the Grid. So adding new InteractableObjects
         * will add new BaseEenemys and removing old Intractable objects will remove old BaseEnemies
         * @param synkSet The set that will be used to Sync
         * @return The changee in game state as a result of the synk
         * This includes revealing a Enemy, and Moving an enemy
         */
        public StateChange synkGrid(InteractableObject[][] synkSet, int pauseTime)
        {
            IObjectSet = synkSet;
            updateIOGridPositions();
            matchSizeIOGridToPrimeGrid();
            setsetSizes();
            StateChange change = updatePrimeGrid(pauseTime);

            return(revealTrigeredEnemies(pauseTime, change));
        }
Exemple #4
0
 /**
  * Will update the health, power and score based on a given StateChange object
  * @param changeState
  * @return
  */
 protected bool changeState(StateChange changeState)
 {
     if (changeState != null)
     {
         player.incrementScore(changeState.changeInPlayerScore);
         powerBar.setPercent(powerBar.getPercent() + changeState.changInBatteryCharge);
         this.incrementHeartCount(changeState.changeInPlayerHealth);
         return(true);
     }
     return(false);
 }
Exemple #5
0
        /**
         * Updates when state = EndState.CONTINUE;
         */
        protected void updateContinue()
        {
            typeSelectedText.text = ("Score: " + player.getScore());

            EnemySoundManager.update();

            //updating turn
            if (this.updateTurn)
            {
                changeState(enemies.updateTurn());
                updateTurn = false;
            }
            player.update();
            player.selectTargetableEnemies();
            //No Animation currently playing user receives update
            if (animationPuaseTimer <= 0)
            {
                if (currentLevel != null)
                {
                    currentLevel.objectGrid.setObjectGrid(enemies.getGrid());
                    synkPlayerStateWithTrueState();
                    currentLevel.update();
                    synkTrueStateWithPlayerState();
                    StateChange change = enemies.synkGrid(currentLevel.objectGrid.getObjectGrid(), animationDelay);
                    changeState(change);
                    if (change != null && change.puaseForAnimation)
                    {
                        animationPuaseTimer = animationDelay;
                        enemies.setEnemyAnimations(0);
                    }
                }
                if (state == GameState.EndState.LOSE)
                {
                    if (currentLevel != null)
                    {
                        currentLevel.end();
                    }
                    gameLose();
                    setUpdateState(updateState.TRANSITION);
                }
                else if (state == GameState.EndState.WIN)
                {
                    if (currentLevel != null)
                    {
                        currentLevel.end();
                    }
                    gameWin();
                    setUpdateState(updateState.TRANSITION);
                }
            }
            //Animation is playing user does not receive update
            else
            {
                animationPuaseTimer--;
            }
            //Esc Menue
            if (BaseCode.activeKeyboard.isKeyDown(Keys.Escape) && active != updateState.ESC)
            {
                setUpdateState(updateState.ESC);
            }
            //Close
            if (BaseCode.activeKeyboard.isKeyDown(Keys.F5))
            {
                base.closeWindow();
                return;
            }
        }
Exemple #6
0
        /**
         * Conducts final initialization of gameplay objects including the current level
         * Required to begine a game
         */
        internal void newGame(GhostFinderInterface userCode, int LevelNum)
        {
            //Background Music
            backGroundMusic.setVolume(0.1);

            this.setUpdateState(updateState.INGAME);
            currentLevel = userCode;
            LevelNumber  = LevelNum;

            ((LevelButton)transitionMenue.getPanel(0)).setLevel(this, currentLevel, LevelNum);
            if (mainMenue.getPanel(2).getPanel(0).getPanel(LevelNum + 1) != null)
            {
                ((LevelButton)transitionMenue.getPanel(1)).setLevel(this, ((LevelButton)mainMenue.getPanel(2).getPanel(0).getPanel(LevelNumber + 1)).gameLevel, LevelNumber + 1);
            }
            else
            {
                ((LevelButton)transitionMenue.getPanel(1)).setLevel(this, null);
            }
            ((LevelButton)mainMenue.getPanel(0)).setLevel(this, userCode, LevelNum);
            //endGame();

            setHeartHighlight(false);
            setHeartCount(4);

            //Enemies
            enemies.RemoveAllEnemies();

            //Player
            player.setWidth(player.getHeight() / 2);
            player.setCenterY(BaseCode.worldHeight - (player.getHeight() / 2));
            player.setCollumn(1);
            player.setEnemySet(enemies);
            player.visible = true;
            player.getLight().visible = true;
            BaseCode.activeDrawSet.addToDrawSet(player);
            player.setPriority(7);

            //powerBar
            powerBar.setSize(4.0f, 20.0f);
            powerBar.setCenter((BaseCode.worldWidth - (powerBar.getWidth()) / 2), (powerBar.getHeight() / 2) + 5f);
            powerBar.setMaxScore(10.0f);
            powerBar.setScore(0.0f);
            powerBar.setToVertical();
            powerBar.setVisibility(true);
            BaseCode.activeDrawSet.addToDrawSet(powerBar);
            powerBar.setPriority(7);

            //Animation timer
            animationDelay = 30;

            //typeSelectedText
            typeSelectedText.textPosition.X = 1.0f;
            //typeSelectedText.textPosition.Y = 3.0f;
            typeSelectedText.text    = ("Score: " + player.getScore());
            typeSelectedText.visible = true;
            typeSelectedText.setPriority(7);

            userText.textPosition.X = 20f;
            //userText.textPosition.Y = 3.0f;
            userText.text    = ("");
            userText.visible = true;

            //buttons
            //Reveal
            mediumButton.getBackGround().setSize(4f, 4f);
            mediumButton.getBackGround().setCenter(BaseCode.worldWidth - (mediumButton.getBackGround().getWidth() / 2), (BaseCode.worldHeight / 2));
            mediumButton.setVisibility(true, true);
            mediumButton.setState(MenueSystem.Panel.PanelState.IDLE, true);
            mediumButton.setSparcleVisiblity(false);
            mediumButton.setPriority(7);
            BaseCode.activeDrawSet.addToDrawSet(mediumButton);

            //Wide
            wideButton.getBackGround().setSize(4f, 4f);
            wideButton.getBackGround().setCenter(BaseCode.worldWidth - (mediumButton.getBackGround().getWidth() / 2), (BaseCode.worldHeight / 2) + 5f);
            wideButton.setVisibility(true, true);
            wideButton.setState(MenueSystem.Panel.PanelState.IDLE, true);
            wideButton.setSparcleVisiblity(false);
            wideButton.setPriority(7);
            BaseCode.activeDrawSet.addToDrawSet(wideButton);

            //Laser
            laserButton.getBackGround().setSize(4f, 4f);
            laserButton.getBackGround().setCenter(BaseCode.worldWidth - (mediumButton.getBackGround().getWidth() / 2), (BaseCode.worldHeight / 2) + 10f);
            laserButton.setVisibility(true, true);
            laserButton.setState(MenueSystem.Panel.PanelState.IDLE, true);
            laserButton.setSparcleVisiblity(false);
            laserButton.setPriority(7);
            BaseCode.activeDrawSet.addToDrawSet(laserButton);

            player.setCollumn(0);

            if (userCode != null)
            {
                InteractableObject.setDefualtsToDefualts();
                player.turnLightOnorOff(false);
                userCode.objectGrid.setObjectGrid(enemies.getGrid());
                synkPlayerStateWithTrueState();
                if (userCode.objectGrid != null)
                {
                    userCode.objectGrid.reset();
                }
                if (userCode.primitiveGrid != null)
                {
                    userCode.primitiveGrid.reset();
                }
                userCode.initialize();
                synkTrueStateWithPlayerState();
                userCode.light.updateMaxPosition(userCode.objectGrid.getObjectGrid());
                StateChange change = enemies.synkGrid(userCode.objectGrid.getObjectGrid(), animationDelay);
                if (change != null && change.puaseForAnimation)
                {
                    animationPuaseTimer = animationDelay;
                    enemies.setEnemyAnimations(0);
                }
            }
            state = GameState.EndState.CONTINUE;
        }