Exemplo n.º 1
0
        public void Update(double gameTime, SimpleMouseState mState, SimpleKeyboardState kState)
        {
            mouseState = mState;
            keyState = kState;
            mGameTime = gameTime;
            if (mouseState.right && mouseState.getPos().Y < 550) {
                tryImoveHere(selected, new Vector2f(mouseState.getPos().X, mouseState.getPos().Y), gameTime);
            }
            if (keyState.IsKeyDown(RESTART_KEY)) {//restart
                GameBox.getInstance().doLastBossFight();
            }
            if (keyState.IsKeyDown(Keyboard.Key.F1) && !prevKeyState.IsKeyDown(Keyboard.Key.F1)) {//lose fight
                if (fightStatus == FightStatus.fightEngaged || fightStatus == FightStatus.preFight) {
                    fightStatus = FightStatus.fightLost;
                    timer = new Timer(gameTime);
                } else {
                    GameBox.getInstance().initPostFight(bossFight.getFightID(), finalTime, getPlayerAmt(), damageMeter, fightStatus == FightStatus.fightWon, bossFight.getBossInfo().enragetimer,thisRaid);
                }
            }
            if (fightStatus == FightStatus.fightEngaged || fightStatus == FightStatus.preFight) {//stop updatings stuff after fight for now, later we might have mobs move around after
                foreach (Moveable m in moveables) {
                    m.Update(gameTime);
                    m.updateBuffs(gameTime);
                    //EFF check if i need all these checks inside this forloop
                    if (mouseState.left) {
                        if (targetNeeded && currentCursor == targetTexture && selected is PlayerClassI && m.isInMe(mouseState.getPos().X, mouseState.getPos().Y)) {//if looking for target
                            PlayerClassI p = (PlayerClassI)selected;
                            if (!targetAll)
                                p.setTarget(m, gameTime);
                            else
                                setAllPlayersTarget(m, gameTime);
                            targetNeeded = false;
                            targetAll = false;
                            currentCursor = null;
                        } else if (mouseState.DoneClickedIt(mouseButton.LEFT) && m.isInMe(mouseState.getPos().X, mouseState.getPos().Y)) {
                            //selection happens right here
                            //selected = m;
                            setSelected(m);
                        }
                    }
                }
            }
            if (kState.IsKeyDown(RAID_TAB_KEY) && !prevKeyState.IsKeyDown(RAID_TAB_KEY)){
                //if we hit *TAB* select next person in raid? (maybe closest ?)
                if(selected != null){
                    int index = moveables.IndexOf(selected);
                    do{
                        index = (index + 1) % moveables.Count;
                    }while(moveables[index] is Enemy);
                    setSelected(moveables[index]);
                }
            }
            if (selected is PlayerClassI && kState.IsKeyDown(TARGET_KEY) && !prevKeyState.IsKeyDown(TARGET_KEY)) {
                if (!targetNeeded) {
                    targetNeeded = true;
                    currentCursor = targetTexture;
                } else {
                    targetNeeded = false;
                    currentCursor = null;
                }
            }
            if (selected is PlayerClassI && kState.IsKeyDown(TARGETALL_KEY) && !prevKeyState.IsKeyDown(TARGETALL_KEY)) {
                if (!targetAll) {
                    targetNeeded = true;
                    targetAll = true;
                    currentCursor = targetTexture;
                } else {
                    targetNeeded = false;
                    targetAll = false;
                    currentCursor = null;
                }
            }
            if (selected is PlayerClassI && kState.IsKeyDown(USE_KEY) && !prevKeyState.IsKeyDown(USE_KEY)) {
                ((PlayerClassI)selected).doAbility();
            }

            foreach (Projectile p in projectiles) {
                p.Update(gameTime);
                if (p.doesCollide() ) {
                    foreach(PlayerClassI m in getAlivePlayerMoveables()){
                        if(p.getOwner() != m && m.isInMe(p.getMid()))
                            projectilesToRemove.Add(p);
                    }

                }
            }
            foreach (GroundEffect g in groundEffects) {
                if (g.update(gameTime)) {//if thats true, do groundfire
                    if (g.doAbility == null) {
                        removeGroundEffect(g);
                        continue;
                    }
                    List<PlayerClassI> peopleGotHit = new List<PlayerClassI>();
                    foreach (PlayerClassI p in getPlayerMoveables()) {
                        //add people to list near fire
                        if( Math.Sqrt(Math.Pow(p.getMid().X-g.getMid().X,2) + Math.Pow(p.getMid().Y-g.getMid().Y,2)) < 13){
                            peopleGotHit.Add(p);
                        }
                    }
                    foreach(PlayerClassI p in peopleGotHit){
                        g.doAbility(p);
                    }
                    removeGroundEffect(g);
                }
            }
            //clean up
            foreach (Projectile p in projectilesToRemove) {
                projectiles.Remove(p);
            }
            projectilesToRemove.Clear();
            foreach (GroundEffect g in groundEffectsToRemove) {
                groundEffects.Remove(g);
            }
            groundEffectsToRemove.Clear();
            foreach (Projectile p in projectilesToAdd) {
                projectiles.Add(p);
            }
            projectilesToAdd.Clear();
            //check if boss enrages
            if (fightStatus == FightStatus.fightEngaged && !bossEnraged && timer.getTime(gameTime) > bossFight.getBossInfo().enragetimer) {
                bossFight.setEnraged(true);
                bossEnraged = true;
            }

            //end game stuffs
            if (fightStatus == FightStatus.fightEngaged) {
                //check to see if either side has won
                if (bossFight.isBossFightDead()) {//bossdead
                    finalTime = timer.getFormattedTime(gameTime,3);
                    fightStatus = FightStatus.fightWon;
                    //addScreenNote(bossFight.getBossInfo().deathstring); TODO
                    //start timer to go to post game
                    timer.reset(gameTime);
                } else if (!areAnyPlayersAlive()) {//peopledead
                    finalTime = timer.getFormattedTime(gameTime,3);
                    fightStatus = FightStatus.fightLost;
                    //start timer to go to post game
                    timer.reset(gameTime);
                }
            }
            raidFrames.checkClicks(mouseState);
            if (fightStatus == FightStatus.fightLost || fightStatus == FightStatus.fightWon) {
                if (timer.getTime(gameTime) > TIMETILPOSTGAME) {
                    GameBox.getInstance().initPostFight(bossFight.getFightID(), finalTime, getPlayerAmt(), damageMeter, fightStatus == FightStatus.fightWon, bossFight.getBossInfo().enragetimer, thisRaid);
                }
            }
            //scripts
            if(fightStatus == FightStatus.fightEngaged)
                updateScripts(gameTime);
            //backdrops
            if (bUpdate = mBackdrop.update(gameTime, 600))//TODO make its so it moves ya know
                bUpdate = false;
            //objects? but this should be near other important stuff
            foreach (FightObject ob in fightObjects)
                ob.update(gameTime);

            prevMouseState = mouseState;
            prevKeyState = kState;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected void Update(double gameTime) {
            mouseState.update(window);
//            KeyboardState keyState = Keyboard.GetState();
            SimpleKeyboardState keyState = new SimpleKeyboardState(true);
            this.gameTime = gameTime;
            switch (gameState) {
            case GameState.menuScreen:
                menuScreen.Update(gameTime, mouseState);
                break;
            case GameState.bossSelect:
//                bossSelect.Update(gameTime, mouseState.getPos());
                break;
            case GameState.raidSelect:
                raidSelect.Update(gameTime, mouseState);
                break;
            case GameState.inGame:
                inGame.Update(gameTime, mouseState, keyState);
                break;
            case GameState.settingsMenu:
                settingsMenu.Update(gameTime, mouseState);
                break;
            /*case GameState.XXXXX:
                break;*/
            case GameState.postFight:
                postFight.Update(gameTime, mouseState);
                break;
            }
/*            if (keyState.IsKeyDown(Keyboard.Key.NumPad1)) {
                startBossFight(BossFightLibrary.getBossFight(INSTANT_BOSSID), INSTANT_RAIDCOMP);
                BossFightLibrary.getBossFight(ProjectTurtle.src.bossfights.BossFightID.buseyBoss);
            } else if (keyState.IsKeyDown(Keyboard.Key.NumPad2)) {
                startBossFight(BossFightLibrary.getBossFight(BossFightID.dpsCheck), DPSCHECK_RAIDCOMP);
            }
*/
            mouseState.wheelUpdate();
        }