Ejemplo n.º 1
0
        public override void UpdateMovement(GameTime _GameTime, CInput _Input)
        {
            Sprite.Depth = GlobalValue.ENEMY_SPRITE_DEPTH;
            // Gia tốc trọng trường
            if (m_Status == IDStatus.ALIVE)
            {
                m_Accel = new Vector2(0, 0.0098f);
                if (m_Direction == IDDir.LEFT)
                {
                    m_Velocity = new Vector2(-0.03f, m_Velocity.Y);
                }
                else if (m_Direction == IDDir.RIGHT)
                {
                    m_Velocity = new Vector2(0.03f, m_Velocity.Y);
                }
            }

            CheckShooted(_GameTime);

            if (CoolDown > 600)
            {
                Status = IDStatus.DIE;
            }

            if (m_Status == IDStatus.SPIN)
            {
                if (m_Direction == IDDir.LEFT)
                {
                    m_Velocity = new Vector2(-0.1f, m_Velocity.Y);
                }
                else if (m_Direction == IDDir.RIGHT)
                {
                    m_Velocity = new Vector2(0.1f, m_Velocity.Y);
                }
            }

            if (m_Status == IDStatus.HIDE)
            {
                m_Velocity = new Vector2(0, m_Velocity.Y);
            }
            //if (_Input.KeyDown(Microsoft.Xna.Framework.Input.Keys.Space))
            //{
            //    m_Status = IDStatus.DIE_CAN_ATTACK;
            //}
            if (m_Velocity.Y > 1.0f)
            {
                m_Velocity.Y = 1.0f;
            }

            if (m_Velocity.X > 1f)
            {
                m_Velocity.X = 1f;
            }

            if (m_Velocity.X < -1f)
            {
                m_Velocity.X = -1f;
            }
            base.Update(_GameTime, _Input);
        }
Ejemplo n.º 2
0
 public override void UpdateAnimation(GameTime _GameTime, CInput _Input)
 {
     m_Sprite.Animation.FrameStart    = 0;
     m_Sprite.Animation.FrameEnd      = 3;
     m_Sprite.Animation.TimeAnimation = 80.0f;
     base.UpdateAnimation(_GameTime, _Input);
 }
Ejemplo n.º 3
0
        public override void UpdateMovement(GameTime _GameTime, CInput _Input)
        {
            if (m_Status == IDStatus.ACTIVATE)
            {
                m_Velocity = new Vector2(0, -0.05f);
            }

            if (oldPosition.Y - m_Position.Y > Sprite.FrameHeight - 1 && m_Status == IDStatus.ACTIVATE)// && Status != IDStatus.UNACTIVATE)//dung animation chay len
            {
                m_Status   = IDStatus.RUN;
                m_Velocity = Vector2.Zero;
                Direction  = IDDir.RIGHT;
            }

            if (Status == IDStatus.RUN)
            {
                m_Accel.Y = 0.00098f;
                if (Direction == IDDir.LEFT)
                {
                    //m_Status = IDStatus.RUN;
                    m_Velocity = new Vector2(-0.1f, m_Velocity.Y);
                }

                if (Direction == IDDir.RIGHT)
                {
                    //m_Status = IDStatus.RUN;
                    m_Velocity = new Vector2(0.1f, m_Velocity.Y);
                }
            }

            base.Update(_GameTime, _Input);
        }
Ejemplo n.º 4
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)
        {
            CMasterControl.gameTime = gameTime;

            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
            {
                this.Exit();
            }
            //Exit when Escape is pressed(Dunno if this iterferes with the editor?)
            if (Keyboard.GetState(PlayerIndex.One).IsKeyDown(Keys.Escape))
            {
                this.Exit();
            }

            CInput input = Master.GetInputManager().GetCurrentInputHandler() as CInput;

            if (input.getInputRelease(Microsoft.Xna.Framework.Input.Keys.B))
            {
                CActor.showHitBox = !CActor.showHitBox;
            }
            _benchmarker.Start();

            Master.Update(gameTime);
            //CMasterControl.mapManager.updateMap(gameTime);
            _benchmarker.Stop();
            //CMasterControl.audioPlayer.Update();
            base.Update(gameTime);
        }
Ejemplo n.º 5
0
 public void HandleInput(GameTime gameTime, CInput Input)
 {
     if (getListState().Count != 0)
     {
         getListState()[getListState().Count - 1].HandleInput(gameTime, Input);
     }
 }
Ejemplo n.º 6
0
        public override void UpdateAnimation(GameTime _GameTime, CInput _Input)
        {
            if (Status == IDStatus.MOVE)
            {
                Sprite.Animation.FrameStart = 2;
                Sprite.Animation.FrameEnd   = 3;
            }

            if (Status == IDStatus.FIRE)
            {
                Sprite.Animation.FrameStart = 1;
                Sprite.Animation.FrameEnd   = 3;
            }

            if (Direction == IDDir.LEFT)
            {
                Sprite.Effect = SpriteEffects.None;
            }

            if (Direction == IDDir.RIGHT)
            {
                Sprite.Effect = SpriteEffects.FlipHorizontally;
            }

            //for (int i = 0; i < List_Of_Bullet.Count; i++)
            //{
            //    List_Of_Bullet[i].UpdateAnimation(_GameTime, _Input);
            //}

            base.UpdateAnimation(_GameTime, _Input);
        }
    /// <summary>
    /// 移動相關
    /// </summary>
    /// <param name="input">Input數值</param>
    void Movement(CInput input)
    {
        m_WasGrounded = m_Controller.isGrounded;
        //暫存方向數值
        m_DesiredMovement  = new Vector3(input.horizontal, 0, input.vertical);
        m_DesiredMovement  = m_DesiredMovement.normalized;
        m_CurrentMagnitude = m_DesiredMovement.magnitude;

        Rotate(m_DesiredMovement);


        //併到Movement,除了y(重力)
        m_Movement.x = m_DesiredMovement.x * m_Speed;
        m_Movement.z = m_DesiredMovement.z * m_Speed;


        if (m_OnGround)
        {
            m_Movement.y = -2f;

            if (input.jump)
            {
                //跳躍指令來源:https://youtu.be/_QajrabyTJc?t=1297
                m_Movement.y = Mathf.Sqrt(m_JumpHeight * -2 * m_Gravity.y);
            }
        }

        m_Movement += m_Gravity * Time.deltaTime;

        m_Controller.Move(m_Movement * Time.deltaTime);

        WalkCycleAndJump();
        WalkingVFX();
    }
Ejemplo n.º 8
0
        public static bool UpdateGameLogic(CKeys Keys, CMouse Mouse)
        {
            bool _Run = true;

            _Cursor.CursorVisible = Mouse.Visible;

            Mouse.CopyEvents();
            Keys.CopyEvents();

            CSound.Update();
            CBackgroundMusic.Update();
            CInput.Update();

            if (CConfig.CoverLoading == ECoverLoading.TR_CONFIG_COVERLOADING_DYNAMIC && _CurrentScreen != EScreens.ScreenSing)
            {
                CSongs.LoadCover(30L, 1);
            }

            if (CSettings.GameState != EGameState.EditTheme)
            {
                _Run &= HandleInputs(Keys, Mouse);
                _Run &= Update();
            }
            else
            {
                _Run &= HandleInputThemeEditor(Keys, Mouse);
                _Run &= Update();
            }

            return(_Run);
        }
Ejemplo n.º 9
0
        public override void keyDown(object sender)
        {
            if (_state == "Idle" || _state == "Moving")
            {
                //Store this so we can type less
                CInput input = Master.GetInputManager().GetCurrentInputHandler() as CInput;
                if (input.keysPressed.Contains(Keys.End))
                {
                    Graphics.CGraphics.changeResolution(320, 240);
                    Master.Pop();
                }

                if (input.keysPressed.Contains(Keys.A))
                {
                    _position.X -= _velocity.X;
                    image        = _imageIndex["PlayerWalkLeft"];
                    _direction   = DIRECTION.LEFT;
                    _state       = "Moving";
                }

                if (input.keysPressed.Contains(Keys.D))
                {
                    _position.X += _velocity.X;
                    image        = _imageIndex["PlayerWalkRight"];
                    _direction   = DIRECTION.RIGHT;
                    _state       = "Moving";
                }

                if (input.keysPressed.Contains(Keys.W))
                {
                    _position.Y -= _velocity.Y;
                    image        = _imageIndex["PlayerWalkUp"];
                    _direction   = DIRECTION.UP;
                    _state       = "Moving";
                }

                if (input.keysPressed.Contains(Keys.S))
                {
                    _position.Y += _velocity.Y;
                    image        = _imageIndex["PlayerWalkDown"];
                    _direction   = DIRECTION.DOWN;
                    _state       = "Moving";
                }

                if (input.keysPressed.Contains(Keys.LeftShift) && _state == "Moving")
                {
                    _state        = "Rolling";
                    _rollReleased = false;
                    //get the F**K out of this
                    return;
                }

                if (input.keysPressed.Contains(Keys.Space))
                {
                    _state         = "Swinging";
                    _swordReleased = false;
                }
            }
        }
Ejemplo n.º 10
0
 public bool SwipeUp()
 {
     if (CInput.MouseSpeed().y > Screen.height / 10)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 11
0
 public override void UpdateAnimation(GameTime _GameTime, CInput _Input)
 {
     //if (m_Status == IDStatus.UNACTIVATE)
     //{
     //    Sprite.Animation.CurFrame = 3;
     //}
     base.UpdateAnimation(_GameTime, _Input);
 }
Ejemplo n.º 12
0
 public bool SwipeDown()
 {
     if (CInput.MouseSpeed().y < Screen.height / -10)
     {
         return(true);
     }
     return(false);
 }
Ejemplo n.º 13
0
        //* ────────────-_______________________*
        //* constructor & destructor ───────────────────────*

        //* -----------------------------------------------------------------------*
        /// <summary>コンストラクタ。</summary>
        ///
        /// <param name="sceneName">シーン名称。</param>
        protected CSceneBase(string sceneName)
        {
            this.sceneName            = sceneName;
            inputManager              = game.inputManager;
            graphicDeviceManager      = game.graphicDeviceManager;
            contentManager            = game.Content;
            localGameComponentManager = new CGameComponentManager(game);
        }
Ejemplo n.º 14
0
 public override void HandleInput(GameTime gameTime, CInput _Input)
 {
     if (_Input.KeyPressed(Keys.Back))
     {
         StateManager.getInst().ExitScreen();
         StateManager.getInst().AddScreen(new MenuState(IDGameState.MENU));
     }
     base.HandleInput(gameTime, _Input);
 }
Ejemplo n.º 15
0
 void Awake()
 {
     playerInput   = this.GetComponent <CInput>();
     rigidbody     = this.GetComponent <Rigidbody2D>();
     myCollider    = this.GetComponent <CapsuleCollider2D>();
     shooter       = this.GetComponent <CShooter>();
     interactItems = new List <IInteractItem>();
     interactList  = new Dictionary <IInteractItem, bool>();
 }
Ejemplo n.º 16
0
        public override void UpdateMovement(GameTime _GameTime, CInput _Input)
        {
            // Gia tốc trọng trường


            //if (Status == IDStatus.SHOOTED)
            //{
            //    m_Velocity.X = 0;

            //}
            CheckShooted(_GameTime);
            #region .Nếu mushroom còn sống
            if (m_Status == IDStatus.ALIVE)
            {
                m_Accel = new Vector2(m_Accel.X, 0.0098f);
                if (Direction == IDDir.LEFT)
                {
                    m_Status   = IDStatus.ALIVE;
                    m_Velocity = new Vector2(-0.03f, m_Velocity.Y);
                }

                if (Direction == IDDir.RIGHT)
                {
                    m_Status   = IDStatus.ALIVE;
                    m_Velocity = new Vector2(0.03f, m_Velocity.Y);
                }
            }
            #endregion

            if (m_Status == IDStatus.BEFORE_DIE)
            {
                m_Velocity = Vector2.Zero;
                CoolDown  += (float)_GameTime.ElapsedGameTime.TotalMilliseconds;
            }

            if (CoolDown > 700)
            {
                m_Status = IDStatus.DIE;
            }

            if (m_Velocity.Y > 1f)
            {
                m_Velocity.Y = 1f;
            }

            if (m_Velocity.X > 0.09f)
            {
                m_Velocity.X = 0.09f;
            }

            if (m_Velocity.X < -0.09f)
            {
                m_Velocity.X = -0.09f;
            }

            base.Update(_GameTime, _Input);
        }
Ejemplo n.º 17
0
        public override void keyRelease(object sender)
        {
            CInput input = Master.GetInputManager().GetCurrentInputHandler() as CInput;

            if (_state == ACTOR_STATES.CARRY && input.keysReleased.Contains(input.getKey(CInput.KEY_ACTION)))
            {
                toss();
                _followRoot = false;
            }
        }
Ejemplo n.º 18
0
 public override void UpdateMovement(GameTime _GameTime, CInput _Input)
 {
     if (Status == IDStatus.ACTIVATE)
     {
         m_Flag.Accel = new Vector2(0, 0.00098f);
         Status       = IDStatus.UNACTIVATE;
     }
     m_Flag.Update(_GameTime, _Input);
     base.UpdateMovement(_GameTime, _Input);
 }
Ejemplo n.º 19
0
 public override void HandleInput(GameTime gameTime, CInput _Input)
 {
     CoolDown += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
     if (CoolDown > 5000)
     {
         StateManager.getInst().ExitScreen();
         StateManager.getInst().AddScreen(new MenuState(IDGameState.MENU));
     }
     base.HandleInput(gameTime, _Input);
 }
Ejemplo n.º 20
0
        public override void UpdateMovement(GameTime _GameTime, CInput _Input)
        {
            //CoolDownFire += (float)_GameTime.ElapsedGameTime.TotalMilliseconds;

            Accel = new Vector2(Accel.X, 0.00098f);

            if (m_Status == IDStatus.MOVE)
            {
                if (Direction == IDDir.LEFT)
                {
                    m_Velocity = new Vector2(-0.03f, m_Velocity.Y);
                }

                if (Direction == IDDir.RIGHT)
                {
                    m_Velocity = new Vector2(0.03f, m_Velocity.Y);
                }
            }

            if (Status == IDStatus.FIRE)
            {
                Velocity = Vector2.Zero;
                //Direction = tempDirection;
                if (CoolDown(ref CoolDownBullet, 800, _GameTime))
                {
                    //BossBullet b = new BossBullet(new Vector2(this.Position.X, GlobalValue.MARIO_POSITION.Y), this.Direction);
                    //List_Of_Bullet.Add(b);
                    BossBullet b = new BossBullet(new Vector2(this.Position.X, this.Position.Y), this.Direction);
                    GlobalValue.List_Of_Bullet.Add(b);
                }
                if (CoolDown(ref CoolDownFire, 1000, _GameTime))
                {
                    Status = IDStatus.MOVE;
                }
            }

            if (Boss_Heath_Point <= 0)
            {
                Status = IDStatus.DIE;
            }

            if (CoolDown(ref CoolDownMove, 3000, _GameTime) && CanFire)
            {
                Status = IDStatus.FIRE;
            }

            //for (int i = 0; i < List_Of_Bullet.Count; i++)
            //{
            //    List_Of_Bullet[i].UpdateMovement(_GameTime, _Input);
            //}

            base.UpdateMovement(_GameTime, _Input);
            base.Update(_GameTime, _Input);
        }
Ejemplo n.º 21
0
        public override void UpdateMovement(GameTime _GameTime, CInput _Input)
        {
            if (m_Status == IDStatus.DEACTIVATE)
            {
                //if (m_GreenMushroom.Status == IDStatus.UNACTIVATE)
                {
                    switch (Item.IDObject)
                    {
                    case IDObject.ITEM_COIN_ACTIVATED:
                        SoundManager.PlaySound(ESound.SFX_COIN);
                        GlobalValue.MARIO_SCORE += 100;
                        GlobalValue.MARIO_COIN  += 1;
                        break;

                    case IDObject.ITEM_GROW_UP:
                        SoundManager.PlaySound(ESound.SFX_ITEM_APPEAR);
                        if (IDObject.SMALL_MARIO == IDObject.SMALL_MARIO)
                        {
                            Item.IDObject = IDObject.ITEM_SUPER_MUSHROOM;
                            Item.Sprite   = new CSprite(CResourceManager.GetInstance().GetResource(IDResource.ITEM_SUPER_MUSHROOM));
                        }
                        if (GlobalValue.ID_MARIO == IDObject.SUPER_MARIO || GlobalValue.ID_MARIO == IDObject.FIRE_MARIO)
                        {
                            Item.IDObject = IDObject.ITEM_FIRE_FLOWER;
                            Item.Sprite   = new CSprite(CResourceManager.GetInstance().GetResource(IDResource.ITEM_FIRE_FLOWER));
                        }
                        break;

                    case IDObject.ITEM_1UP_MUSHROOM:
                        SoundManager.PlaySound(ESound.SFX_ITEM_APPEAR);
                        break;

                    case IDObject.ITEM_STARMAN:
                        SoundManager.PlaySound(ESound.SFX_ITEM_APPEAR);
                        break;

                    default:
                        break;
                    }
                    m_Item.Status = IDStatus.ACTIVATE;
                }
                m_Status = IDStatus.UNACTIVATE;
            }
            if (m_Item != null)
            {
                //m_RedMushroom.Update(_GameTime, _Input);
                //m_GreenMushroom.UpdateMovement(_GameTime, _Input);
                if (m_Item.Status == IDStatus.DIE)
                {
                    //m_GreenMushroom = null;
                }
            }
            //base.UpdateMovement(_GameTime, _Input);
        }
Ejemplo n.º 22
0
        //* ────________________________________*
        //* methods ───────────────────────────────-*

        //* -----------------------------------------------------------------------*
        /// <summary>初期化処理</summary>
        protected override void Initialize()
        {
            base.Initialize();
            TargetElapsedTime     = TimeSpan.FromSeconds(1.0 / ( double )(initializeData.fps));
            IsFixedTimeStep       = true;
            sceneManager.nowScene = initializeData.sceneFirst;
            gamedata = new CDataIOManager <_T>(
                initializeData.codename, initializeData.fileIOConfigure.fileConfigure);
            SStarter <_T> .SInputInitializeData iniInput = initializeData.inputConfigure;
            input = new CInput(Window.Handle, iniInput.buttons, iniInput.keyLoopStart, iniInput.keyLoopInterval);
        }
Ejemplo n.º 23
0
 public override void HandleInput(GameTime gameTime, CInput _Input)
 {
     CoolDown += (float)gameTime.ElapsedGameTime.TotalMilliseconds;
     if (CoolDown > 2000)
     {
         CoolDown = 0;
         StateManager.getInst().ExitScreen();
         StateManager.getInst().AddScreen(new MenuState(IDGameState.MENU));
     }
     GlobalValue.IS_LOCK_KEYBOARD = false;
     base.HandleInput(gameTime, _Input);
 }
Ejemplo n.º 24
0
        public override void keyRelease(object sender)
        {
            if (_state == ACTOR_STATES.HOLD)
            {
                CInput input = Master.GetInputManager().GetCurrentInputHandler() as CInput;

                if (input.keysReleased.Contains(Microsoft.Xna.Framework.Input.Keys.C))
                {
                    _shakeOffMeter++;
                }
            }
        }
Ejemplo n.º 25
0
    public void Awake()
    {
        Instance = this;
        model    = new Model.CModel(this);
        input    = new Libraries.CInput();

        playerSwipesCounter.Watch(model.player);
        opponentSwipesCounter.Watch(model.opponent);

        timer.SetTurnTime(Config.turnTime);
        timer.onEnd += OnTimerEnd;
    }
Ejemplo n.º 26
0
        protected override void Initialize()
        {
            CResourceManager.GetInstance().Init(Content);
            SoundManager.LoadContent(Content);
            _fps    = _eLapsedTime = 0;
            m_Input = new CInput();
            StateManager.getInst().Content = Content;
            StateManager.getInst().AddScreen(new IntroState(IDGameState.INTRO));
            StateManager.getInst().m_Game = this;

            base.Initialize();
        }
Ejemplo n.º 27
0
        public override void UpdateAnimation(GameTime _GameTime, CInput _Input)
        {
            if (Direction == IDDir.LEFT)
            {
                Sprite.Effect = SpriteEffects.FlipHorizontally;
            }

            if (Direction == IDDir.RIGHT)
            {
                Sprite.Effect = SpriteEffects.None;
            }
            base.UpdateAnimation(_GameTime, _Input);
        }
Ejemplo n.º 28
0
        public static void UnloadFile()
        {
            LoadedFiles();
            CFormat.JumpLine();
            CFormat.WriteLine("Please enter the number ID of the file you want to unload.", ConsoleColor.Gray);
            int id = CInput.UserPickInt(CommandManager.LoadedFileIDs.Count - 1);

            if (id == -1)
            {
                return;
            }
            CommandManager.UnloadFile(id);
        }
Ejemplo n.º 29
0
 private void UpdateBullet(GameTime _GameTime, CInput _Input)
 {
     if (m_Bullet1 != null)
     {
         m_Bullet1.UpdateAnimation(_GameTime, _Input);
         m_Bullet1.UpdateMovement(_GameTime, _Input);
     }
     if (m_Bullet2 != null)
     {
         m_Bullet2.UpdateAnimation(_GameTime, _Input);
         m_Bullet2.UpdateMovement(_GameTime, _Input);
     }
 }
Ejemplo n.º 30
0
        public override void keyDown(object sender)
        {
            CInput input = (CInput)sender;

            if (input.keysPressed.Contains(input.getKey(CInput.KEY_ACTION)))
            {
                if (MathExt.MathExt.checkPointInCircle(new Vector2(Player.CPlayer.glblX, Player.CPlayer.glblY), _position, _hearingRadius))
                {
                    _currentDialog = _DIALOG1;
                    _triggerTextEvent();
                }
            }
        }
Ejemplo n.º 31
0
 public void HandleInput(GameTime gameTime, CInput Input)
 {
     if (getListState().Count != 0)
     {
         getListState()[getListState().Count - 1].HandleInput(gameTime, Input);
     }
 }
Ejemplo n.º 32
0
 public virtual void HandleInput(GameTime gameTime, CInput _Input)
 {
 }