示例#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)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            //TurnStart();
            //AllUnits[0].delay = 50;
            //Console.WriteLine(P1Chars[0].buffList[0]);
            //Console.WriteLine(dummy.buffList[0]);
            //TurnEnd();

            mouse = Mouse.GetState();
            if (mouse.LeftButton == ButtonState.Pressed)
            {
                isClicking = true;
                Console.WriteLine(mouse.X + " " + mouse.Y);
            }

            switch (phase)
            {

                case Phase.TurnStart:
                    if ((curUnit.affil != -1) && (isClicking && mouse.LeftButton == ButtonState.Released))
                    {
                        if (new Rectangle(280,415,100,30).Contains(mouse.X, mouse.Y))
                        {

                            phase = Phase.SkillChoice;

                        }
                        else if (new Rectangle(170, 415, 100, 30).Contains(mouse.X, mouse.Y))
                        {
                            EnemyChoiceHelper = "Advance";
                            phase = Phase.EnemyChoice;
                        }
                        else if (new Rectangle(170, 455, 100, 30).Contains(mouse.X, mouse.Y))
                        {
                            AllAdvance();
                            curUnit.delay += 50;
                            TurnEnd();
                        }
                        else if (new Rectangle(170, 495, 100, 30).Contains(mouse.X, mouse.Y))
                        {
                            EnemyChoiceHelper = "Retreat";
                            phase = Phase.EnemyChoice;
                        }
                        else if (new Rectangle(170, 535, 100, 30).Contains(mouse.X, mouse.Y))
                        {
                            AllRetreat();
                            curUnit.delay += 50;
                            TurnEnd();
                        }
                    }
                    if (curUnit.affil == -1)
                    {
                        animations = new List<AnimatedSprite>();
                        ShowInfo(curUnit.name + " is thinking about what to do.");
                        MonsterAI();
                        if (animations.Count != 0)
                        {
                            phase = Phase.Animation;
                        }
                        else
                        {
                            TurnEnd();
                        }
                    }
                    break;
                case Phase.SkillChoice:
                    {

                        //add bulk later, essentially more buttons and shiz

                        if ((isClicking) && (mouse.LeftButton == ButtonState.Released) && (mouse.X >= 165) && (mouse.X <= 385))
                        {
                            try
                            {
                                curSkill = curUnit.skillList[(int)((mouse.Y - 421) / 20)];

                                ExecuteSkill();
                            }
                            catch (ArgumentOutOfRangeException)
                            {
                            }
                        }
                        if (mouse.RightButton == ButtonState.Pressed)
                        {
                            phase = Phase.TurnStart;
                        }
                    }
                    break;
                case Phase.Animation:
                    {
                        if (animator.step == curSkill.stepLimit) phase = Phase.Resolution;
                    }
                    break;
                case Phase.Resolution:
                    {

                        if ((isClicking) && (mouse.LeftButton == ButtonState.Released))
                        {
                            for (int i = 0; i < eneList.Count; i++)
                            {
                                if (dmgList[i] > 0)
                                {
                                    eneList[i].HP -= dmgList[i];
                                    if (eneList[i].HP <= 0)
                                    {
                                        eneList[i].HP = 0;
                                        if (eneList[i].affil == -1)
                                        {
                                            //animation on death!
                                            alphaController = 1;
                                            ShowInfo(eneList[i].name + " has died! " + curUnit.name + " has gained " + ((Monster)(eneList[i])).expOnDeath + " experience!");

                                            Char curChar = (Char)curUnit;
                                            curChar.exp += ((Monster)(eneList[i])).expOnDeath;

                                            while (curChar.exp >= curChar.expToLevel)
                                            {
                                                curChar.exp -= curChar.expToLevel;
                                                curChar.expToLevel = (int)(curChar.expToLevel * 1.11);
                                                LevelUp(curChar);
                                            }

                                            for (int a = 0; a <= 2; a++)
                                            {

                                                DistGrid[eneList[i].number][a] = 0;
                                                DistGrid[a][eneList[i].number] = 0;
                                            }

                                            Mons.Remove((Monster) eneList[i]);
                                            AllUnits.Remove(eneList[i]);
                                            eneList.Remove(eneList[i]);
                                            dmgList.RemoveAt(i);
                                            i--;

                                        }

                                    }
                                }
                            }
                            TurnEnd();
                        }
                    }
                    break;
                case Phase.EnemyChoice:
                    {
                        //25 for the delay as of now
                        if ((isClicking) && (mouse.LeftButton == ButtonState.Released) && (new Rectangle(165, 421, 220, 15 * eneList.Count).Contains(mouse.X,mouse.Y)))
                        {
                            if ((EnemyChoiceHelper.Equals("Advance"))&&(getDistance(eneList[(mouse.Y-421)/15]) >= 2)) Advance(eneList[(mouse.Y - 421) / 15]);
                            else if ((EnemyChoiceHelper.Equals("Retreat"))&&(getDistance(eneList[(mouse.Y-421)/15]) <= 4)) Retreat(eneList[(mouse.Y - 421) / 15]);
                            curUnit.delay += 25;
                            TurnEnd();
                        }

                    }
                    break;
                default:
                    //Console.WriteLine("No User Input Required");
                    break;

            }
            if (mouse.LeftButton == ButtonState.Released) isClicking = false;

            base.Update(gameTime);
        }
示例#2
0
 protected void MonExecuteSkill(Skill ski)
 {
     ShowInfo(curUnit.name + " used " + ski.name);
     curSkill = ski;
     ExecuteSkill();
 }