Exemplo n.º 1
0
 public override void UpdateMovement(GameTime _GameTime, CInput _Input)
 {
     if (GlobalValue.GET_FLAG && m_Flag == null)
     {
         m_Flag = new CastleFlag(new Vector2(this.Position.X + 40 - 4, this.Position.Y), IDObject.MISC_STAR_FLAG_CASTLE);
     }
     if (m_Flag != null)
     {
         m_Flag.UpdateMovement(_GameTime, _Input);
         m_Firework1.UpdateAnimation(_GameTime);
         m_Firework2.UpdateAnimation(_GameTime);
     }
     base.UpdateMovement(_GameTime, _Input);
 }
Exemplo n.º 2
0
        public override void HandleInput(GameTime gameTime, CInput _Input)
        {
            if (Mario.Status != IDStatus.MARIO_STOP)
            {
                PlayedTime           += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                GlobalValue.TIME_LEFT = (int)(210 - PlayedTime / 1000);
            }

            if (PlayedTime > 180000 && !IsWarning)
            {
                SoundManager.PlaySound(ESound.SFX_WARNING);
                IsWarning = true;
            }

            if (PlayedTime > 210000)
            {
                --GlobalValue.MARIO_LIFE;
                StateManager.getInst().ExitScreen();
                StateManager.getInst().AddScreen(new TimeUp(IDGameState.TIME_UP));
            }

            Icon.UpdateAnimation(gameTime);
            Mario.UpdateAnimation(gameTime, m_input);
            if (!Mario.IsMarioFreeze)
            {
                Mario.UpdateMovement(gameTime, m_input);
                if (Mario.Position.X < 0)
                {
                    Mario.Position = new Vector2(0, Mario.Position.Y);
                }
                if (Mario.Position.X + Mario.GetBound().Width >= map.m_WidthMap)
                {
                    Mario.Position = new Vector2(map.m_WidthMap - Mario.GetBound().Width, Mario.Position.Y);
                }
            }
            if (_Input.KeyDown(Keys.Back))
            {
                StateManager.getInst().ExitScreen();
                StateManager.getInst().AddScreen(new MenuState(IDGameState.MENU));
            }
            cam.Update(Mario, map.m_WidthMap, map.m_HeightMap);
            quadTree.InsertListObjectView(cam.Rectangle, quadTree.RootNode);
            if (GlobalValue.KillBoss)
            {
                for (int i = 0; i < list.Count; ++i)
                {
                    if (list[i].IDObject == IDObject.ENEMY_BOSS)
                    {
                        list[i].Status = IDStatus.DIE;
                    }
                }
            }
            for (int i = 0; i < GlobalValue.List_Of_Bullet.Count; i++)
            {
                GlobalValue.List_Of_Bullet[i].UpdateAnimation(gameTime, _Input);
                GlobalValue.List_Of_Bullet[i].UpdateMovement(gameTime, _Input);
                Mario.UpdateCollision(GlobalValue.List_Of_Bullet[i]);
                GlobalValue.List_Of_Bullet[i].UpdateCollision(Mario);
                if (GlobalValue.List_Of_Bullet[i].Status == IDStatus.DIE)
                {
                    GlobalValue.List_Of_Bullet.Remove(GlobalValue.List_Of_Bullet[i]);
                }
            }
            list = quadTree.ListObjectsInView;
            for (int i = 0; i < list.Count; ++i)
            {
                if (list[i].Status == IDStatus.DIE)
                {
                    //m_QuadTree.Tree.RemoveObject(list[i]);
                    //list[i] = null;
                    quadTree.RemoveObject(list[i], quadTree.RootNode);
                    list.Remove(list[i]);
                }
                else
                {
                    Mario.UpdateCollision(list[i]);
                    list[i].UpdateCollision(Mario);
                    for (int j = 0; j < list.Count; ++j)
                    {
                        list[j].UpdateCollision(list[i]);
                    }
                    if (!Mario.IsWorldFreeze)
                    {
                        list[i].UpdateAnimation(gameTime, m_input);
                        list[i].UpdateMovement(gameTime, m_input);
                    }
                }
            }

            if (Mario.Position.Y > GlobalValue.SCREEN_HEIGHT)
            {
                Mario.Status = IDStatus.DIE;
            }

            if (Mario.Status == IDStatus.DIE)
            {
                MediaPlayer.Stop();
                GlobalValue.MARIO_IDOBJECT = IDObject.SMALL_MARIO;
                m_StopTime1 += (float)gameTime.ElapsedGameTime.Milliseconds;

                for (int i = 0; i < GlobalValue.List_Of_Bullet.Count; i++)
                {
                    GlobalValue.List_Of_Bullet.Remove(GlobalValue.List_Of_Bullet[i]);
                }

                if (m_StopTime1 >= 2000.0f)
                {
                    --GlobalValue.MARIO_LIFE;
                    if (GlobalValue.MARIO_LIFE > 0)
                    {
                        StateManager.getInst().ExitScreen();
                        StateManager.getInst().AddScreen(new LoadGame(IDGameState.LOAD));
                    }
                    else
                    {
                        StateManager.getInst().ExitScreen();
                        StateManager.getInst().AddScreen(new GameOverState(IDGameState.GAMEOVER));
                    }
                }
            }

            if (Mario.Status == IDStatus.MARIO_STOP)
            {
                delayFlag += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                if (GlobalValue.TIME_LEFT > 0 && delayFlag > 50)
                {
                    GlobalValue.MARIO_SCORE += 200;
                    GlobalValue.TIME_LEFT   -= 2;
                    delayFlag = 0;
                    SoundManager.PlaySound(ESound.SFX_COIN);
                }
            }

            if (GlobalValue.TIME_LEFT <= 0)
            {
                GlobalValue.GET_FLAG = true;
            }

            if (GlobalValue.GET_FLAG)
            {
                delayStage += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
                if (delayStage > 3000)
                {
                    delayStage           = 0;
                    GlobalValue.GET_FLAG = false;
                    GlobalSetting.m_IDLevel++;
                    GlobalValue.MARIO_IDOBJECT = Mario.IDObject;
                    if (GlobalSetting.m_IDLevel < 3)
                    {
                        StateManager.getInst().ExitScreen();
                        StateManager.getInst().AddScreen(new LoadGame(IDGameState.LOAD));
                    }
                    else
                    {
                        StateManager.getInst().ExitScreen();
                        StateManager.getInst().AddScreen(new WinState(IDGameState.WIN));
                    }
                }
            }

            base.HandleInput(gameTime, _Input);
        }