Пример #1
0
        //basic scroll right now
        internal void update(double gameTime, SimpleMouseState mouseState)
        {
            if (inventory != null && (invResult = inventory.update(mouseState)) != ItemID.na) {
                //if the inventory returns an item
                inventory = null;
                mBarracks.swapItems(changingChamp, invResult);
                return;
            }
            int mouseY = mouseState.getPos().Y;
            if (GeoLib.isInRect(start,overallRect, new Vector2f(mouseState.getPos().X, mouseState.getPos().Y))){//start.X <= mouseState.getPos().X && mouseState.getPos().X <= start.X + overallRect.Width) {
                if (start.Y <= mouseY && mouseY <= start.Y + scroll) {
                    //clicked in the top box
                    if (mouseState.DoneReleasedIt(mouseButton.LEFT)) {
                        backButton();
                    }
                }else if(start.Y + overallRect.Height - scroll <= mouseY && mouseY <= start.Y + overallRect.Height){
                    //bottom box
                    if (mouseState.DoneReleasedIt(mouseButton.LEFT)){
                        nextButton();
                    }
                } else if (start.Y + scroll <= mouseY && mouseY <= start.Y + overallRect.Height - scroll) {
                    //somewhere in the middle
                    if (draggedChamp != null && mouseState.getPos().X >= start.X + itemIconStart.X) {//if on right side to hover over icons
                        int hoveredOver = -1;//TODO this could be nicer
                        hoveredOver = (int)(topBar + (mouseState.getPos().Y - (int)start.Y - scroll) / (champBarRect.Height));

                        if (mouseState.DoneReleasedIt(mouseButton.LEFT))
                            clickedChampItem(hoveredOver);
                    }
                    //do drag logic
                    if (mouseState.DoneClickedIt(mouseButton.LEFT)) {
                        Vector2f current = new Vector2f(mouseState.getPos().X, mouseState.getPos().Y);
                        draggedChamp = mBarracks.getChamps()[(int)(topBar + (mouseState.getPos().Y - (int)start.Y - scroll) / (champBarRect.Height))];
                        lastClicked = current;
                    } else if (!mouseState.left) {
                        draggedChamp = null;
                    }
                    //do scroll logic
                    if (mouseState.mouseWheelPos - mouseState.prevMouseWheelPos >= 1) {
                        backButton();
                    }
                    if (mouseState.mouseWheelPos - mouseState.prevMouseWheelPos <= -1) {
                        nextButton();
                    }
                }
                for (int i = 0; i < maxShown; i++) {
                    ItemID item = mBarracks.getChamps()[topBar+ i].item;
                    champsItemIcons[topBar+ i].update(mouseState,
                        new Vector2f(start.X + itemIconStart.X, start.Y + itemIconStart.Y + champBarRect.Height * i + scroll),item);
                }
            }
            if (!mouseState.left)//released
                draggedChamp = null;
        }
Пример #2
0
        internal virtual bool didClick(SimpleMouseState mouseState) {
            bool a = mouseState.DoneClickedIt(mouseButton.LEFT);
            bool b = didHit(mouseState.getPos());

            return a && b;
        }
Пример #3
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;
        }
Пример #4
0
 internal override bool didClick(SimpleMouseState mouseState) {
     rollover = didHit(mouseState.getPos());
     return mouseState.DoneClickedIt(mouseButton.LEFT) && rollover;
 }