Beispiel #1
0
        public void Update(GameTime gameTime, int HeroMP)
        {
            if (inPanel)
            {
                Button.Update(gameTime);
            }

            for (int i = 0; i < Effect.Length; i++)
            {
                Effect[i].Update(gameTime);
            }

            if (!Active)
            {
                KDRemaind.Update(gameTime);
                TimeActiveRemaind.Update(gameTime);
                CheckActive(gameTime, HeroMP);

                if (KD - KDRemaind.GetSS() != 0)
                {
                    LabelKD.Text = Convert.ToString(KD - KDRemaind.GetSS());
                }
                else
                {
                    LabelKD.Text = "";
                }

                if (TimeActive - TimeActiveRemaind.GetSS() != 0)
                {
                    LabelTimeActive.Text = Convert.ToString(TimeActive - TimeActiveRemaind.GetSS());
                }
                else
                {
                    LabelTimeActive.Text = "";
                }
            }

            if (Button.ButtonUp && Active)
            {
                Active = false;

                Sound.Play();

                for (int i = 0; i < Effect.Length; i++)
                {
                    Effect[i].isStart = true;
                    Effect[i].Update(gameTime);
                }

                KDRemaind         = new ProgramTimer(KD);
                TimeActiveRemaind = new ProgramTimer(TimeActive);

                if (Shot != null)
                {
                    Shot.Start = true;
                }

                Sound.Play();
            }
        }
Beispiel #2
0
        public void Update(GameTime gameTime)
        {
            if (isStart)
            {
                TimeRemaind = new ProgramTimer(Time);
            }

            if (TimeRemaind != null)
            {
                if (!TimeRemaind.Closed)
                {
                    TimeRemaind.Update(gameTime);
                }
                if (TimeRemaind.isEnd && !isEnd)
                {
                    isEnd              = true;
                    TimeRemaind.isEnd  = false;
                    TimeRemaind.Closed = true;
                }

                if (isEnd)
                {
                    TimeRemaind.isEnd  = false;
                    TimeRemaind.Closed = true;
                }
            }
        }
Beispiel #3
0
        public void BattleUpdate(GameTime gameTime)
        {
            if (!GameIsEnd)
            {
                Level.Text = "Уровень " + (CurrentLevel + 1).ToString();
            }

            if (CurrentLevel == 2 && TimeIsRemind && !LevelIsEnd)
            {
                TimeRemind   = 20;
                TimerRemind  = new ProgramTimer(20);
                TimeIsRemind = false;
            }
            if (TimerRemind != null && !LevelIsEnd)
            {
                TimerRemind.Update(gameTime);
                TimeRemindLabel.Text = Convert.ToString(TimeRemind - TimerRemind.GetSS());

                if (TimerRemind.isEnd)
                {
                    Hero.HP = 0;
                }
            }


            ButtonContinue.Update(gameTime);
            ButtonSaveAndExit.Update(gameTime);

            if (!LevelIsEnd)
            {
                ButtonContinue.Visible    = false;
                ButtonSaveAndExit.Visible = false;

                if (Hero.isDeath)
                {
                    //Поражение

                    ButtonSaveAndExit.Visible = true;

                    if (ButtonSaveAndExit.ButtonUp)
                    {
                        SaveResult();
                        RestartGame();
                    }

                    Enemy.CurrentFrame = 0;
                    GameIsEnd          = true;
                }
                else
                {
                    //Обновление состояния Бафов
                    for (int i = 0; i < Skill.Length; i++)
                    {
                        BuffUpdate(Skill[i], gameTime);
                    }

                    GameTimer.Update(gameTime);
                    Hero.Update(Window, gameTime);

                    if (Hero.State == 3)
                    {
                        if (SoundOnes)
                        {
                            MediaPlayer.Pause();
                            HeroDeath.Play();
                            SoundOnes = false;
                        }
                    }

                    if (Hero.onJump)
                    {
                        Hero.State = 4;
                        Hero.Jump();
                    }

                    if (Hero.State == 2)
                    {
                        Hero.Animate(gameTime);
                    }

                    //протиуник может умереть от шота
                    if (Enemy.HP <= 0 && Enemy.State != 3)
                    {
                        GoldCount.Text     = (Convert.ToInt32(GoldCount.Text) + 1).ToString();
                        Enemy.State        = 3;
                        Enemy.CurrentFrame = 0;
                        Enemy.CurrentTime  = 0;
                    }

                    if (Enemy.State != 3)
                    {
                        CanRunLeft = CanRunRight = true;

                        // Взаимодействие персонажа и противника
                        if (Enemy.Rectangle.Intersects(Hero.Rectangle))
                        {
                            CheckRun();
                            Enemy.DoAttack(Window, gameTime);
                            if (Enemy.CurrentFrame == 11 && Enemy.State == 2) //При завершении анимации заверщаем удар
                            {
                                EnemyAttack.Play();
                                if (Enemy.Attack > Hero.Def)
                                {
                                    Hero.HP -= Enemy.Attack - Hero.Def;
                                }
                                else
                                {
                                    Hero.HP--;
                                }

                                StatHero.Stats.Text = Hero.HP + "    " + Hero.MP + "       " + Hero.Attack + "            " + Hero.Def + "               " + Hero.Speed + "                 " + Hero.AttackSpeed;
                                Enemy.CurrentFrame  = 0;
                            }
                            if (Hero.CurrentFrame == 11 && Hero.State == 2) //При завершении анимации заверщаем удар
                            {
                                HeroAttack.Play();
                                if (Hero.Attack > Enemy.Def)
                                {
                                    Enemy.HP -= Hero.Attack - Enemy.Def;
                                }
                                else
                                {
                                    Enemy.HP--;
                                }
                                Hero.CurrentFrame = 0;
                                if (Enemy.HP <= 0)
                                {
                                    GoldCount.Text = (Convert.ToInt32(GoldCount.Text) + 1).ToString();
                                    Enemy.State    = 3;
                                }
                            }
                        }
                        else
                        {
                            CheckRotate();
                            Enemy.DoMove(Window, gameTime);
                        }
                    }
                    else
                    {
                        Enemy.Animate(gameTime);
                    }
                }
            }
            else
            {
                //Уровень завершен
                if (SoundOnes)
                {
                    MediaPlayer.Play(SoundWin);

                    if (!GameIsEnd)
                    {
                        ButtonContinue.Visible = true;
                    }
                    ButtonSaveAndExit.Visible = true;

                    SoundOnes = false;
                }

                if (ButtonContinue.ButtonUp)
                {
                    MediaPlayer.Play(MainTheme);
                    WindowState = WindowState.Skill;
                    SkillWindow.SkillPoint++;
                    LevelIsEnd = false;
                    SoundOnes  = true;
                }

                if (ButtonSaveAndExit.ButtonUp)
                {
                    SaveResult();
                    RestartGame();
                }
            }

            //Обновлняем статы персонажекй
            StatTextUpdate();

            base.Update(gameTime);

            //Если противник умер и произошла анимация падения
            if (Enemy.State == 3 && Enemy.CurrentFrame == 11)
            {
                NextEnemy(gameTime);
            }
        }