Exemplo n.º 1
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 override void Update(GameTime gameTime)
        {
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || Keyboard.GetState().IsKeyDown(Keys.Escape))
            {
                Exit();
            }

            switch (gamestate)
            {
            case GameState.Main:
                gamestate = MainMenu.Update(gameTime);
                break;

            case GameState.Upgrade:
                //upgrade_menu
                gamestate = UpgradeMenu.Update(gameTime);
                break;

            case GameState.Lair:
                gamestate = LairManager.Update(gameTime);
                break;

            case GameState.Battle:
                gamestate = BattleManager.Update(gameTime);
                break;

            case GameState.Quit:
                Exit();
                break;

            case GameState.Credits:
                break;
            }
            base.Update(gameTime);
        }
Exemplo n.º 2
0
        /// <summary>
        /// This is called when the game should draw itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.Black);
            spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.NonPremultiplied);
            //RenderTarget2D target = new RenderTarget2D(GraphicsDevice, 800, 480);
            //GraphicsDevice.SetRenderTarget(target);

            switch (gamestate)
            {
            case GameState.Main:
                MainMenu.Draw(spriteBatch);
                break;

            case GameState.Upgrade:
                //upgrade_menu
                UpgradeMenu.Draw(spriteBatch);
                break;

            case GameState.Lair:
                LairManager.Draw(spriteBatch);
                break;

            case GameState.Battle:
                BattleManager.Draw(spriteBatch);
                break;

            case GameState.Credits:
                spriteBatch.Draw(BattleManager.bkgd, new Rectangle(-450, -100, 2000, 1086), Color.White);
                BattleManager.boss.Draw(spriteBatch, Color.White);
                if (CreditTimer > 0 || slide >= 4)
                {
                    EndGameText.Draw(spriteBatch);
                    CreditTimer--;
                }
                else
                {
                    EndGameText.changeMessage(Credits[slide]);
                    CreditTimer = 400;
                    slide++;
                }
                break;
            }
            //spriteBatch.End();
            //GraphicsDevice.SetRenderTarget(null);
            //spriteBatch.Begin();
            //spriteBatch.Draw(target, new Rectangle(0, 0, graphics.PreferredBackBufferWidth, graphics.PreferredBackBufferHeight), Color.White);
            spriteBatch.End();
            // TODO: Add your drawing code here

            base.Draw(gameTime);
        }
Exemplo n.º 3
0
        public static void Init(MenuBoss boss)
        {
            SkillTree.Init(boss.bossType);


            tutorial_state = TutorialState.BuySkill;

            selectedBoss = boss;
            skilltree    = SkillTree.skilltrees[selectedBoss.bossType];

            selectedBoss.MoveTo(new Vector2(0, 0));
            selectedBoss.idle();
            Console.WriteLine("" + Text.fonts.Keys.ToString());
            Console.Out.Flush();
            var test = Text.fonts;

            zeroAvailableRooms();
            UpgradeMenu.rerollRooms();

            selectedSkillSwapButton = new ButtonSkill();
            for (int x = 0; x < SelectedSkills.Length; x++)
            {
                SelectedSkills[x]             = new ButtonSkill();
                SelectedSkills[x].b           = new Button(Button.buttonPic, (int)baseSelectedSkillButtonPos.X, (int)baseSelectedSkillButtonPos.Y + 60 * x, 200, 50);
                SelectedSkills[x].b.text.font = Text.fonts["6809Chargen-12"];
                SelectedSkills[x].b.UpdateText("NONE");
            }

            hovertextpos  = new Vector2(30, 150);
            hovertext     = new Text("", new Vector2(hovertextpos.X + 10, hovertextpos.Y + 10), Text.fonts["RetroComputer-12"]);
            hovertextRect = new Rectangle((int)hovertextpos.X, (int)hovertextpos.Y, 500, 600);
            //250 x 150
            hovertextbackground = BattleManager.hovertextbackground;

            Vector2 statspos = new Vector2(30, boss.sTexture.Height + 10);

            statsTitle     = new Text("Stats", statspos, Text.fonts["RetroComputer-18"]);
            statsTitleRect = new Rectangle((int)statspos.X - 10, (int)statspos.Y - 5, (int)statsTitle.getMeasurements(300).X + 10, (int)statsTitle.font.MeasureString(statsTitle.message).Y + 15);
            statsText      = new Text(BattleManager.boss.StatsToString(), new Vector2(statspos.X, statspos.Y - 70), Text.fonts["RetroComputer-12"]);;
            statsTextRect  = new Rectangle((int)statsText.position.X, (int)statsText.position.Y - 100, (int)statsText.getMeasurements(300).X + 10, (int)statsText.getMeasurements(300).Y + 10);
            statsText.changeMessage("");

            texts["gold"]           = new Text("Gold: " + Resources.gold, new Vector2(150, 0), Text.fonts["6809Chargen-24"], Color.White);
            texts["level"]          = new Text("Level: " + BattleManager.boss.level, new Vector2(150, 50), Text.fonts["6809Chargen-24"], Color.White);
            texts["selectedskills"] = new Text("Selected Skills", new Vector2(baseSelectedSkillButtonPos.X, baseSelectedSkillButtonPos.Y - Text.fonts["6809Chargen-24"].MeasureString("Selected Skills").Y - 10), Text.fonts["6809Chargen-24"], Color.White);
            texts["skilltext"]      = new Text("Skills", new Vector2(baseSkillButtonPos.X + 100, baseSkillButtonPos.Y - 50), Text.fonts["6809Chargen-24"], Color.White);
            texts["roomtext"]       = new Text("Rooms", new Vector2(baseRoomButtonPos.X, baseRoomButtonPos.Y - 50), Text.fonts["6809Chargen-24"], Color.White);
        }
Exemplo n.º 4
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            //RenderTarget2D target = new RenderTarget2D(GraphicsDevice, 1024, 576);
            //GraphicsDevice.SetRenderTarget(target);
            Text.loadContent(Content);
            Button.LoadContent(Content);
            MainMenu.loadContent(Content);
            MenuBoss.LoadContent(Content);
            //UpgradeMenu.loadContent(Content);

            PartyManager.Init();
            Resources.Init();
            SkillTree.LoadContent(Content);
            //SkillTree.Init();


            Character.load_content(Content);
            AnimatedEffect.LoadContent(Content);
            Status.LoadContent(Content);
            BattleManager.LoadContent(Content);
            SkillTree.LoadContent(Content);
            UpgradeMenu.loadContent(Content);
            LairManager.loadContent(Content);

            Menu_Song                   = Content.Load <SoundEffect>("Sounds/Epic_Loop");
            Menu_Song_Instance          = Menu_Song.CreateInstance();
            Menu_Song_Instance.IsLooped = true;
            Menu_Song_Instance.Volume   = .1f;

            Battle_Song                   = Content.Load <SoundEffect>("Sounds/VGameTune");
            Battle_Song_Instance          = Battle_Song.CreateInstance();
            Battle_Song_Instance.IsLooped = true;
            Battle_Song_Instance.Volume   = .1f;

            Main_Song                   = Content.Load <SoundEffect>("Sounds/LingeringChip");
            Main_Song_Instance          = Main_Song.CreateInstance();
            Main_Song_Instance.IsLooped = true;
            Main_Song_Instance.Volume   = .3f;
            //both songs have no duration

            EndGameText = new Text("And So,\n\nThrough much perserverence\nand a low interest mortgage\nour boss was finally\n\nLeft Alone.",
                                   new Vector2(300, 200), Text.fonts["6809Chargen-24"], Color.Cyan);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }