예제 #1
0
        public void SelectRandomPerson(Friendly targ1, Friendly targ2)
        {
            var hold = new List <Person>()
            {
                targ1,
                targ2
            };

            var RNG = new Random();

            target = hold[RNG.Next(0, hold.Count)];
        }
예제 #2
0
 public Battle(Friendly _F1, Friendly _F2, Enemy _E1, Enemy _E2, SpriteBatch sb, SpriteFont sf)
 {
     F1            = _F1;
     F2            = _F2;
     E1            = _E1;
     E2            = _E2;
     config        = new Config();
     CombatantList = new List <Person>
     {
         { F1 },
         { F2 },
         { E1 },
         { E2 },
     };
     drawBattle = new DrawBattle(sb, sf);
 }
예제 #3
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();
            }
            ms = new MouseState();


            // Makes sure game is only running the logic it needs to.
            switch (state)
            {
            case GameState.SelectMove:
                // Has button logic for finding correct moves and saving them each person's Attackname attribute

                // Attempting to catch game-breaking bug with parCou.
                try
                {
                    // Removes party member from pool if they die.
                    if (!Party[parCou].checkAlive())
                    {
                        Party.Remove(Party[parCou]);

                        // if Party [1] dies, remove party[1] from the list, and move on with Party[2](Now Party[1])
                        // So do nothing.

                        // if Party [3] dies, remove party[3] from the list, and go to the next state.
                        //  0 base      1 base
                        if (parCou > Party.Count + 1)
                        {
                            state = GameState.PreformAttack;
                            break;
                        }
                    }
                }
                catch (Exception e)
                {
                    throw new Exception("ParCou error. Inform Developer of exact steps to replicate" +
                                        e.Message);
                }

                // Has logic for clicking on buttons.
                #region
                if (Manager.Move1Select.ButtonClicked())
                {
                    Party[parCou].attackName = Manager.Move1Select.moveName;
                    state = GameState.SelectTarget;
                    Click.Play();
                }

                if (Manager.Move2Select.ButtonClicked())
                {
                    Party[parCou].attackName = Manager.Move2Select.moveName;
                    state = GameState.SelectTarget;
                    Click.Play();
                }
                if (Manager.Move3Select.ButtonClicked())
                {
                    Party[parCou].attackName = Manager.Move3Select.moveName;
                    state = GameState.SelectTarget;
                    Click.Play();
                }
                if (Manager.Move4Select.ButtonClicked())
                {
                    Party[parCou].attackName = Manager.Move4Select.moveName;
                    state = GameState.SelectTarget;
                    Click.Play();
                }
                #endregion


                // Logic purly for sounds.
                #region
                // If the mouse has entered a button[enterbutton], the sound is not playing[hover.state], and the sound has
                // only played once [hovercheck]
                if ((Manager.Move1Select.enterButton() || Manager.Move2Select.enterButton() ||
                     Manager.Move3Select.enterButton() || Manager.Move4Select.enterButton()) &&
                    hover.State != SoundState.Playing && !hoverCheck)
                {
                    hover.Play();
                    hoverCheck = true;
                }

                // Makes the hoverCheck false when the mouse leaves the button area.
                if (!(Manager.Move1Select.enterButton() || Manager.Move2Select.enterButton() ||
                      Manager.Move3Select.enterButton() || Manager.Move4Select.enterButton()))
                {
                    hoverCheck = false;
                }
                #endregion

                break;

            case GameState.SelectTarget:

                // Logic for selecting target and going back to previous screen.
                #region
                if (Enemy1Select.ButtonClicked() && Enemy1Select.target.checkAlive())
                {
                    Party[parCou].target = Enemy1Select.target;
                    if (parCou == (Party.Count - 1))
                    {
                        state  = GameState.PreformAttack;
                        parCou = 0;
                    }

                    else
                    {
                        parCou++;
                        state = GameState.SelectMove;
                    }
                    Click.Play();
                }



                if (Enemy2Select.ButtonClicked() && Enemy2Select.target.checkAlive())
                {
                    Party[parCou].target = Enemy2Select.target;
                    if (parCou == (Party.Count - 1))
                    {
                        state  = GameState.PreformAttack;
                        parCou = 0;
                    }
                    else
                    {
                        state = GameState.SelectMove;
                        parCou++;
                    }
                    Click.Play();
                }


                if (Manager.Back.ButtonClicked())
                {
                    state = GameState.SelectMove;
                    Click.Play();
                }
                #endregion

                // Logic stricly for sounds
                if ((Manager.Back.enterButton() || Enemy1Select.enterButton() || Enemy2Select.enterButton()) &&
                    hover.State != SoundState.Playing && !hoverCheck)
                {
                    hover.Play();
                    hoverCheck = true;
                }

                if (!(Manager.Back.enterButton() || Enemy1Select.enterButton() || Enemy2Select.enterButton()))
                {
                    hoverCheck = false;
                }



                break;

            case GameState.PreformAttack:

                // Begins the turn
                var test = new Battle(player, ally, guard1, guard2, spriteBatch, font);

                // Running the turn returns a string. If the string is null, it runs the logic.
                if (string.IsNullOrEmpty(battleData))
                {
                    battleData = test.RunBattle(player.attackName, ally.attackName, guard1.attackName, guard2.attackName);
                }

                // If the screen is clicked during this state, the timer times out.
                if (Manager.Screen.ButtonClicked())
                {
                    count = 600;
                }

                // increments timer if there is time to be counted.
                if (count < 600)
                {
                    count++;
                }

                // If the timer is done or the screen is clicked.
                else
                {
                    // Run each stage of the battle until the user clicks.
                    // Lose if your team dies
                    if (!player.checkAlive() && !ally.checkAlive())
                    {
                        state = GameState.Lose;
                    }

                    // win if the other team dies
                    else if (!guard1.checkAlive() && !guard2.checkAlive())
                    {
                        //Reruns all initialize data to reset game(creates entirely new combatant group).
                        // Also where the round/level increment.
                        #region
                        // Increments current round
                        currentRound++;

                        // Resets all combatants, and levels up guards.
                        player = new Friendly("Player", "(Special Unit)", 5, Divine, Evasive);
                        ally   = new Friendly("Ally", "(Attack Unit)", 5, Divine, Offensive);
                        guard1 = new Enemy("Guard 1", "(Attack Unit)", currentRound, Mage, Offensive);
                        guard2 = new Enemy("Guard 2", "(Tank Unit)", currentRound, Martial, Defensive);

                        // Brings everyone back to life.
                        Party = new List <Friendly>
                        {
                            player,
                            ally
                        };

                        // Begins counter at 0
                        parCou = 0;

                        // TODO: FIGURE OUT HOW TO GET BUTTONS IN MANAGER
                        // The problem is that the enemies aren't established in the manager class.
                        // The manager class is only for Rectangles and Buttons. Changable logic
                        // (such as players, kingdoms, and movelists) stay in the Game1 class for now.
                        // Units can't be made public because it messes with the game in scary ways.
                        Enemy1Select = new Button(Manager.BattleButton1, guard1, guard1.name);
                        Enemy2Select = new Button(Manager.BattleButton3, guard2, guard2.name);



                        // Handles enemy "AI"
                        guard1.AddMove(new List <string>
                        {
                            "Chop", "Ready Guard", "Faint Attack", "Helm Smash", "Shield Charge"
                        });
                        guard2.AddMove(new List <string>
                        {
                            "Chop", "Ready Guard", "Faint Attack", "Helm Smash", "Shield Charge"
                        });
                        guard1.LoadAI(player, ally);
                        guard2.LoadAI(player, ally);


                        // Resets Data Box logic
                        battleData = "";
                        count      = 0;
                        grow       = 0;
                        #endregion

                        state = GameState.SelectMove;
                    }


                    // if someone on both teams is alive, goes back to select move.
                    else
                    {
                        // text display box is reset
                        battleData = "";
                        count      = 0;
                        grow       = 0;
                        // State is reverted.
                        state = GameState.SelectMove;
                    }
                }
                break;
            }
            // Saves previous ms state.
            msPrev = ms;
            base.Update(gameTime);
        }
예제 #4
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        protected override void Initialize()
        {
            // Logic for Gauntlet
            currentRound = 1;

            // Kingdoms
            #region
            Martial     = new Kingdom(0.8, 1.2, 1.0, 0.8);
            Mage        = new Kingdom(1.2, 1.0, 0.8, 1.0);
            Divine      = new Kingdom(1.0, 0.8, 1.2, 1.2);
            TestKingdom = new Kingdom(1, 1, 1, 1);
            #endregion

            // Specilizations
            #region
            Offensive = new Specilization(0.8, 1.0, false);
            Defensive = new Specilization(1.2, 0.6, false);
            Evasive   = new Specilization(0.5, 1.3, true);
            TestSpec  = new Specilization(1, 1, false);
            #endregion

            // Combatants
            player = new Friendly("Player", "(Special Unit)", 5, Divine, Evasive);
            ally   = new Friendly("Ally", "(Attack Unit)", 5, Divine, Offensive);
            guard1 = new Enemy("Guard 1", "(Attack Unit)", currentRound, Mage, Offensive);
            guard2 = new Enemy("Guard 2", "(Tank Unit)", currentRound, Martial, Defensive);

            Party = new List <Friendly>
            {
                player,
                ally
            };
            parCou = 0;

            // Rectangles for buttons and drawings
            Manager = new Manager();
            Manager.Intl();

            // Shows mouse
            IsMouseVisible = true;

            // TODO: FIGURE OUT HOW TO GET BUTTONS IN MANAGER
            Enemy1Select = new Button(Manager.BattleButton1, guard1, guard1.name);
            Enemy2Select = new Button(Manager.BattleButton3, guard2, guard2.name);



            // Handles enemy "AI"
            guard1.AddMove(new List <string>
            {
                "Chop", "Ready Guard", "Faint Attack", "Helm Smash", "Shield Charge"
            });
            guard2.AddMove(new List <string>
            {
                "Chop", "Ready Guard", "Faint Attack", "Helm Smash", "Shield Charge"
            });
            guard1.LoadAI(player, ally);
            guard2.LoadAI(player, ally);

            // Begins game on the select move screen
            state = GameState.SelectMove;

            // data needed for showing
            count = 0;
            grow  = 0;

            // Sound effect data
            hoverCheck = false;

            // THIS MUST BE LAST.
            base.Initialize();
        }
예제 #5
0
 /// <summary>
 /// Runs all necesary logic for choosing attacks and targets.
 /// ADDMOVE MUST BE CALLED FIRST.
 /// </summary>
 /// <param name="target1"></param>
 /// <param name="target2"></param>
 public void LoadAI(Friendly target1, Friendly target2)
 {
     SelectRandomMove();
     SelectRandomPerson(target1, target2);
 }