Exemple #1
0
        public void updateNormal()
        {
            move();
            triggerHelper.update();
            flipSprites();

            if (!isGrounded || !isMovingHorizontal)
            {
                animationManager.Play(Animations.PlayerIdle);
            }
            else if (isGrounded && isMovingHorizontal)
            {
                animationManager.Play(Animations.PlayerRun);
            }

            if (input.ShootButtonInput.isPressed)
            {
                Direction lr = Direction.Right;
                if (sprite.flipX)
                {
                    lr = Direction.Left;
                }
                var gs     = (GameScene)entity.scene;
                var bullet = entity.scene.addEntity(new Bullet(lr, angled, entity.position));
                shootSound.Play();
                float shakeDir = lr == Direction.Left ? 1 : -1;
                gs.CameraShake(2f, 0.9f, new Vector2(shakeDir, 0));
            }
        }
Exemple #2
0
 public void update()
 {
     if (input.Button1Input.isPressed && sprite.currentAnimation != ObjectFactory.PlayerAnims.Attack)
     {
         sprite.play(ObjectFactory.PlayerAnims.Attack);
         collider.active = true;
     }
     triggerHelper.update();
 }
Exemple #3
0
        private void MoveCharacter()
        {
            if (!_punching)
            {
                _animation = PlayerAnimationState.Idle;
                var moveDir = new Vector2(_xAxisInput.value, _yAxisInput.value);
                if (moveDir.X < 0)
                {
                    _animation             = PlayerAnimationState.Walk;
                    _animationMaster.flipX = true;
                    _velocity.X            = -_moveSpeed;
                    _punchCollider.setLocalOffset(new Vector2(-_punchXOffset, _punchYOffset));
                }
                else if (moveDir.X > 0)
                {
                    _animation             = PlayerAnimationState.Walk;
                    _animationMaster.flipX = false;
                    _velocity.X            = _moveSpeed;
                    _punchCollider.setLocalOffset(new Vector2(_punchXOffset, _punchYOffset));
                }
                if (moveDir.Y < 0)
                {
                    _animation  = PlayerAnimationState.Walk;
                    _velocity.Y = -_moveSpeed;
                }
                else if (moveDir.Y > 0)
                {
                    _animation  = PlayerAnimationState.Walk;
                    _velocity.Y = _moveSpeed;
                }
                if (moveDir != Vector2.Zero)
                {
                    if (!_animationMaster.isAnimationPlaying(_animation))
                    {
                        _animationMaster.play(_animation);
                    }
                    var movement = _velocity * _moveSpeed * Time.deltaTime;

                    CollisionResult res;
                    _mover.move(movement, out res);
                    _triggerHelper.update();
                }
                else
                {
                    if (!_animationMaster.isAnimationPlaying(PlayerAnimationState.Idle) && !_animationMaster.isAnimationPlaying(PlayerAnimationState.Punch))
                    {
                        _animation = PlayerAnimationState.Idle;
                        _animationMaster.play(_animation);
                    }
                    _velocity.X = 0;
                    _velocity.Y = 0;
                }
            }
        }
Exemple #4
0
 public void update()
 {
     triggerHelper.update();
 }