예제 #1
0
        public static LeaveMeAlone.GameState Update(GameTime gametime)
        {
            int selectLocX = Mouse.GetState().X;
            int selectLocY = Mouse.GetState().Y;

            //Keyboard.GetState();
            //If the mouse is released we can continue taking new input
            if (Mouse.GetState().LeftButton == ButtonState.Released)
            {
                left_click = false;
            }
            if (Mouse.GetState().RightButton == ButtonState.Released)
            {
                right_click = false;
            }
            switch (state)
            {
            case State.Basic:
                if (basic_buttons[1].Intersects(selectLocX, selectLocY))
                {
                    //Go toSkill menu
                    hovertext.changeMessage("Skills:\nShow them your moves!");
                    if (leftClicked())
                    {
                        NewMenu(1);
                    }
                }
                else if (basic_buttons[3].Intersects(selectLocX, selectLocY))
                {
                    hovertext.changeMessage("Bribe:\nCan't take the heat? Buy off your enemies! Everyone has a price! Don't worry, he'll replace himself with a corpse and nobody will know any better");
                    //Go to Bribe menu
                    if (leftClicked())
                    {
                        NewMenu(2);
                    }
                }
                else if (basic_buttons[0].Intersects(selectLocX, selectLocY))
                {
                    hovertext.changeMessage("Attack:\nPut up your dukes, and show them what you are made of! Use your Attack power");
                    //TODO: need a way to select basic attack
                    if (leftClicked())
                    {
                        selected_skill = boss.basic_attack;

                        state = State.Target;
                    }
                }
                else if (basic_buttons[2].Intersects(selectLocX, selectLocY))
                {
                    hovertext.changeMessage("Defend:\nHeal some health and regain energy");
                    //TODO: need a way to select taunt
                    if (leftClicked())
                    {
                        selected_skill = boss.defend;
                        targeted_enemy = -1;     //Don't need this
                        state          = State.Attack;
                    }
                }
                else
                {
                    hovertext.changeMessage("");
                }

                break;

            case State.Skills:
                //Skill Selection
                //if (Mouse.GetState().LeftButton == ButtonState.Pressed && !left_click)
                //{

                message.changeMessage(selectLocX + ", " + selectLocY);
                for (int i = 0; i < 6; i++)
                {
                    if (skill_buttons[i].Intersects(selectLocX, selectLocY))
                    {
                        if (i < boss.selected_skills.Count)
                        {
                            hovertext.changeMessage(skill_buttons[i].text.message + ":\nMana Cost: "
                                                    + boss.selected_skills[i].energy + "\nCooldown: " + boss.selected_skills[i].cooldown + "\n" +
                                                    boss.selected_skills[i].description);
                        }
                        if (leftClicked())
                        {
                            try
                            {
                                selected_skill = boss.selected_skills[i];
                                //check cooldown
                                if (check_cooldown[i] > 0)
                                {
                                    info_text.changeMessage("Can't use skill,\nwait for cooldown:" + check_cooldown[i]);
                                    continue;
                                }
                                //check mana_cost
                                if (selected_skill.energy > boss.energy)
                                {
                                    info_text.changeMessage("Not Enough Energy!");
                                    continue;
                                }

                                if (selected_skill.target == Skill.Target.Single)
                                {
                                    state = State.Target;
                                }
                                else
                                {
                                    state = State.Attack;
                                }
                            }

                            catch
                            {
                            }
                        }
                    }
                }
                if (back_button.Intersects(selectLocX, selectLocY) && leftClicked())
                {
                    NewMenu(0);
                    state = 0;
                }

                //}
                break;

            case State.Bribe:
                //Bribe Stuff

                if (rightClicked())
                {
                    for (int i = 0; i < 4; i++)
                    {
                        if (bribe_amounts[i].Intersects(selectLocX, selectLocY))
                        {
                            bribe_gold -= (int)Math.Pow(10, i + 1);
                            total_amount.UpdateText("How Much?: " + bribe_gold.ToString());
                            right_click = true;
                        }
                    }
                }
                if (leftClicked())
                {
                    for (int i = 0; i < 4; i++)
                    {
                        if (bribe_amounts[i].Intersects(selectLocX, selectLocY))
                        {
                            bribe_gold += (int)Math.Pow(10, i + 1);
                            total_amount.UpdateText("How Much?: " + bribe_gold.ToString());
                            left_click = true;
                        }
                    }
                    if (back_button.Intersects(selectLocX, selectLocY))
                    {
                        NewMenu(0);
                        state      = 0;
                        bribe_gold = 0;
                        total_amount.UpdateText("How Much?: 0");
                    }
                }
                //Send bribe target at enemy
                targeted_enemy = Target();
                if (targeted_enemy >= 0)
                {
                    if (heroes[targeted_enemy].gold <= bribe_gold && Resources.gold >= bribe_gold)
                    {
                        //remove hero
                        heroes[targeted_enemy] = null;
                        Resources.gold        -= bribe_gold;
                        my_amount.UpdateText("My Total: " + Resources.gold);
                        CheckVictoryDefeat();
                    }
                    else
                    {
                        NewMenu(0);
                        state         = 0;
                        hovered_enemy = -1;
                    }
                    bribe_gold = 0;
                    total_amount.UpdateText("How Much?: 0");
                }
                break;

            case State.Target:
                //Targetting

                //highlighted needs to be separate from targeted enemy because target ensure that we have clicked on something
                targeted_enemy = Target();
                if (targeted_enemy != -1)
                {
                    state         = State.Attack;
                    hovered_enemy = -1;
                }
                if (Mouse.GetState().LeftButton == ButtonState.Pressed)
                {
                    if (back_button.Intersects(selectLocX, selectLocY))
                    {
                        NewMenu(0);
                    }
                }

                break;

            case State.Attack:
                //Attacking
                hovertext.message = "";
                Attack(boss);
                updateHealth();

                break;

            case State.Endgame:
                //if (Mouse.GetState().LeftButton == ButtonState.Pressed && !left_click)
                if (UpgradeMenu.leftClicked())
                {
                    if (next_button.Intersects(selectLocX, selectLocY))
                    {
                        //Clear the boss's stats
                        foreach (Status status in boss.statuses)
                        {
                            if (status.effect_time == Status.Effect_Time.Once && status.reverse_affect != null)
                            {
                                Console.WriteLine(status.name);
                                status.reverse_affect(boss);
                            }
                        }
                        boss.statuses.Clear();
                        if (victory)
                        {
                            if (LairManager.EndOfGame && LairManager.BossBattle)
                            {
                                return(LeaveMeAlone.GameState.Credits);
                            }
                            //Do next battle
                            //Go to next (Upgrade) menu
                            PartyManager.PartyNum++;
                            //MainMenu.init();
                            //heroLoc.Clear();
                            victory = false;
                            UpgradeMenu.rerollRooms();
                            UpgradeMenu.left_click = false;
                            LairManager.Init();
                            return(LeaveMeAlone.GameState.Upgrade);
                        }
                        else if (defeat)
                        {
                            //Restart battle
                            //heroLoc.Clear();
                            MainMenu.init(false);
                            return(LeaveMeAlone.GameState.Main);
                        }
                    }
                }
                break;

            case State.EnemyTurn:
                //Enemy Turn
                //Wait to allow the user to see what's happening
                if (enemy_turn > 0 && heroes[enemy_turn - 1] != null)
                {
                    if (heroes[enemy_turn - 1].is_attacking)
                    {
                        break;
                    }
                }
                else
                {
                    if (boss.is_attacking)
                    {
                        break;
                    }
                }

                /*
                 * if (enemy_attack_delay > 0)
                 * {
                 *  enemy_attack_delay--;
                 *  break;
                 * }
                 */
                if (enemy_turn >= heroes.Count())
                {
                    //pass the turn
                    state = State.Basic;
                    NewMenu(0);
                    enemy_turn     = -1;
                    targeted_enemy = -1;
                    CheckVictoryDefeat();
                    break;
                }

                Character enemy = heroes[enemy_turn];
                if (enemy == null)
                {
                    enemy_turn++;
                    break;
                }
                //enemy_attack_delay = 60;

                //AI occurs
                var pair = enemy.Think();
                selected_skill = pair.Key;
                targeted_enemy = pair.Value;
                Attack(enemy);

                //Check if this enemy has haste, and check if a hasted enemy has already attacked
                if (enemy.statuses.Contains(Status.check_haste) && !haste_check)
                {
                    haste_check = true;
                    CheckVictoryDefeat();
                    break;
                }
                else     //pass the turn to the next character
                {
                    haste_check = false;
                    enemy_turn++;
                }
                //Check if end of enemy turn;
                if (enemy_turn >= heroes.Count())
                {
                    state = State.Basic;
                    NewMenu(0);
                    enemy_turn     = -1;
                    targeted_enemy = -1;
                }
                //Check after each Enemy
                CheckVictoryDefeat();
                break;
            }

            for (int i = 0; i < heroes.Count(); i++)
            {
                if (heroes[i] == null)
                {
                    continue;
                }
                heroes[i].Update(gametime);
            }
            boss.Update(gametime);

            updateHealth();

            return(LeaveMeAlone.GameState.Battle);
        }
예제 #2
0
        public static LeaveMeAlone.GameState Update(GameTime gameTime)
        {
            lastMouseState    = currentMouseState;
            currentMouseState = Mouse.GetState();
            if (menu_state == MenuState.main)
            {
                if (lastMouseState.LeftButton == ButtonState.Pressed && currentMouseState.LeftButton == ButtonState.Released)
                {
                    if (newGame.Intersects(currentMouseState.X, currentMouseState.Y))
                    {
                        menu_state = MenuState.opening;
                    }
                    else if (loadGame.Intersects(currentMouseState.X, currentMouseState.Y) && !isNewGame)
                    {
                        LeaveMeAlone.Main_Song_Instance.Stop();
                        LeaveMeAlone.Menu_Song_Instance.Play();
                        return(LeaveMeAlone.GameState.Upgrade);
                    }
                    else if (quit.Intersects(currentMouseState.X, currentMouseState.Y))
                    {
                        return(LeaveMeAlone.GameState.Quit);
                    }
                }
            }
            else if (menu_state == MenuState.opening)
            {
                if (lastMouseState.LeftButton == ButtonState.Pressed && currentMouseState.LeftButton == ButtonState.Released)
                {
                    if (next_intro.Intersects(currentMouseState.X, currentMouseState.Y))
                    {
                        line_number++;
                        opening_timer = 0;
                    }
                    if (skip_intro.Intersects(currentMouseState.X, currentMouseState.Y))
                    {
                        line_number = 1 + opening_monologue.Count();
                    }
                }
                if (line_number == 1 + opening_monologue.Count())
                {
                    menu_state = MenuState.boss;
                }
                else if (opening_timer > 300)
                {
                    if (line_number != opening_monologue.Count())
                    {
                        opening_timer = 0;
                    }
                    line_number++;
                }
                else
                {
                    opening_timer++;
                }
            }
            else
            {
                if (brute.Contains(new Vector2(currentMouseState.X, currentMouseState.Y)))
                {
                    bruteHover      = true;
                    mastermindHover = false;
                    operativeHover  = false;
                    brute.walk();
                    mastermind.idle();
                    operative.idle();
                    current = brute;
                }
                else if (mastermind.Contains(new Vector2(currentMouseState.X, currentMouseState.Y)))
                {
                    bruteHover      = false;
                    mastermindHover = true;
                    operativeHover  = false;
                    brute.idle();
                    mastermind.walk();
                    operative.idle();
                    current = mastermind;
                }
                else if (operative.Contains(new Vector2(currentMouseState.X, currentMouseState.Y)))
                {
                    bruteHover      = false;
                    mastermindHover = false;
                    operativeHover  = true;
                    brute.idle();
                    mastermind.idle();
                    operative.walk();
                    current = operative;
                }
                else
                {
                    current         = null;
                    bruteHover      = false;
                    mastermindHover = false;
                    operativeHover  = false;
                    brute.idle();
                    mastermind.idle();
                    operative.idle();
                }
                brute.Update(gameTime);
                mastermind.Update(gameTime);
                operative.Update(gameTime);
                if (lastMouseState.LeftButton == ButtonState.Pressed && currentMouseState.LeftButton == ButtonState.Released && canFinish)
                {
                    Vector2 mousePos = new Vector2(currentMouseState.X, currentMouseState.Y);
                    if (operative.Contains(mousePos) || brute.Contains(mousePos) || mastermind.Contains(mousePos))
                    {
                        BattleManager.boss = new Character(current.bossType, 1, new Vector2(BattleManager.bossLoc.X, BattleManager.bossLoc.Y));


                        BattleManager.heroes = PartyManager.CreateParty();

                        LeaveMeAlone.Main_Song_Instance.Stop();

                        UpgradeMenu.boughtRooms.Clear();
                        Resources.gold = 1000;
                        Resources.exp  = 0;
                        UpgradeMenu.Init(current);
                        LairManager.Init();
                        PartyManager.Init();
                        LairManager.EndOfGame   = false;
                        LairManager.TowerLevel  = 0;
                        LairManager.MaxLevel    = 3;
                        LairManager.LairRooms   = new List <Room>();
                        LairManager.boughtRooms = new List <UpgradeMenu.ButtonRoom>();

                        //return LeaveMeAlone.GameState.Upgrade;
                        return(LeaveMeAlone.GameState.Upgrade);
                    }
                }
                canFinish = true;
            }
            return(LeaveMeAlone.GameState.Main);
        }