Beispiel #1
0
        private void handleInputBear()
        {
            if (!Input.GetKey(Key.LEFT_SHIFT))
            {
                if ((Input.GetKeyDown(Key.W)) && _landed == true)
                {
                    _velocity.y -= _jump;
                    _landed      = false;
                }

                if (Input.GetKey(Key.A))
                {
                    _velocity.x = Utils.Clamp(_velocity.x - _speed, -5 - _topSpeed, 5 + _topSpeed);
                    this.Mirror(true, false);
                    left = true;
                    if (_attackAnimation == false)
                    {
                        walkAnimationBear();
                    }
                }

                if (Input.GetKey(Key.D))
                {
                    _velocity.x = Utils.Clamp(_velocity.x + _speed, -5 - _topSpeed, 5 + _topSpeed);
                    this.Mirror(false, false);
                    left = false;
                    if (_attackAnimation == false)
                    {
                        walkAnimationBear();
                    }
                }

                if ((!Input.GetKey(Key.D)) && (!Input.GetKey(Key.A)) && (!Input.GetKey(Key.W)) && _attackAnimation == false)
                {
                    idleTimer++;
                    if (idleTimer > 10)
                    {
                        idleBear();
                    }
                }
                else
                {
                    idleTimer = 0;
                }

                if ((Input.GetKeyDown(Key.SPACE)) && _cooldown == 0)
                {
                    BearAttack attack = new BearAttack(this);
                    _level.AddChild(attack);
                    _attackAnimation = true;
                    _cooldown        = 60;
                }
                else
                {
                    if (_cooldown > 0)
                    {
                        _cooldown--;
                    }
                }

                if (_attackAnimation == true)
                {
                    BearAttack();
                }
            }
        }
Beispiel #2
0
        private void handleInputHuman()
        {
            if (!Input.GetKey(Key.LEFT_SHIFT))
            {
                if ((Input.GetKeyDown(Key.W)) && _landed == true)
                {
                    _velocity.y -= _jump;
                    _landed      = false;
                }

                if (Input.GetKey(Key.A))
                {
                    _velocity.x = Utils.Clamp(_velocity.x - _speed, -5 - _topSpeed, 5 + _topSpeed);
                    this.Mirror(true, false);
                    left = true;
                    walkAnimationHuman();
                }

                if (Input.GetKey(Key.D))
                {
                    _velocity.x = Utils.Clamp(_velocity.x + _speed, -5 - _topSpeed, 5 + _topSpeed);
                    this.Mirror(false, false);
                    left = false;
                    walkAnimationHuman();
                }

                if ((!Input.GetKey(Key.A)) && (!Input.GetKey(Key.D)) && (!Input.GetKey(Key.W)) && (!Input.GetKey(Key.SPACE)) && _attackAnimation == false)
                {
                    idleTimer++;
                    if (idleTimer > 10)
                    {
                        idleHuman();
                    }
                }
                else
                {
                    idleTimer = 0;
                }

                if ((Input.GetKeyDown(Key.SPACE)) && _cooldown == 0)
                {
                    Projectile fireball = new Projectile(this);
                    _backgroundChanel        = _backgroundMusic.Play();
                    _backgroundChanel.Volume = 0.5f;
                    _level.AddChild(fireball);

                    _cooldown = 120;

                    if ((!Input.GetKey(Key.A)) && (!Input.GetKey(Key.D)))
                    {
                        _attackAnimation = true;
                    }
                }
                else
                {
                    if (_cooldown != 0)
                    {
                        _cooldown--;
                    }
                }

                if (_attackAnimation == true)
                {
                    if ((!Input.GetKey(Key.A)) && (!Input.GetKey(Key.D)))
                    {
                        HumanAttack();
                    }
                }
            }
        }