Swing() public method

public Swing ( ) : void
return void
示例#1
0
文件: Player.cs 项目: minz1/zGame
 public override void _Input(InputEvent @event)
 {
     if (@event.IsActionPressed("slash"))
     {
         _Sword.Swing();
     }
 }
示例#2
0
 protected void Attack()
 {
     if (sword)
     {
         sword.Swing();
         stamina = Mathf.Max(stamina - sword.swingCost, 0);
         UpdateStamina();
     }
 }
 public void Attack()
 {
     StopAgent();
     transform.LookAt(player.position);
     if (sword)
     {
         sword.Swing();
     }
 }
示例#4
0
        //

        private static void Main()
        {
            IWeapon sword = new Sword(new FlyingEnchantment());

            sword.Wield();
            sword.Swing();
            sword.Unwield();

            IWeapon hammer = new Hammer(new SoulEatingEnchantment());

            hammer.Wield();
            hammer.Swing();
            hammer.Unwield();
        }
示例#5
0
    public void Swing(bool isRun)
    {
        attack = true;
        sword.Swing();

        if (isRun)
        {
            ChangeLayersWeight(AnimationStatus.HitRunning);
        }
        else
        {
            ChangeLayersWeight(AnimationStatus.HitStay);
        }

        userAnimator.SetBool(blockCode, false);
        userAnimator.SetBool(swingCode, true);
    }
示例#6
0
    void Update()
    {
        // Make sure we aren't frozen
        if (Hitstop.current.Hitstopped)
        {
            GetComponent <Rigidbody2D>().simulated = false;
            return;
        }
        else
        {
            GetComponent <Rigidbody2D>().simulated = true;
        }

        // Dying
        if (dying)
        {
            return;
        }

        // Recovering from damage
        if (invincible)
        {
            if (Time.timeSinceLevelLoad > invincible_stop_time)
            {
                invincible = false;
            }
        }

        // Shift
        if (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.Space))
        {
            if (Time.timeSinceLevelLoad > last_shift + shift_cooldown)
            {
                TimeChange.current.Switch();
                last_shift = Time.timeSinceLevelLoad;
            }
        }

        // Attack
        if (ArrowKeyPressed())
        {
            // Gun
            if (TimeChange.current.dimension == Dimension.Blue &&
                (Time.timeSinceLevelLoad > last_shot + shot_cooldown))
            {
                last_shot = Time.timeSinceLevelLoad;

                GameObject bullet = PlayerBulletPool.current.GetPooledBullet();
                bullet.SetActive(true);
                bullet.transform.position = transform.position + new Vector3(0, -0.1f, 0);

                bullet.GetComponent <Bullet>().side = BulletSide.Player;
                bullet.GetComponent <Bullet>().SetSpriteAndSpeed();

                bullet.GetComponent <Rigidbody2D>().velocity = GetDirectionOfArrowKey() * bullet.GetComponent <Bullet>().speed + GetComponent <Rigidbody2D>().velocity / 1.2f;

                GetComponent <PlayerSprite>().ForceSpriteForTime(0.2f);
                GetComponent <PlayerAudio>().Shoot();
            }
            else if (TimeChange.current.dimension == Dimension.Orange &&
                     (Time.timeSinceLevelLoad > last_swing + swing_cooldown))
            {
                last_swing = Time.timeSinceLevelLoad;
                sword.Swing();

                GetComponent <PlayerAudio>().Slash();
            }
        }

        if (!knockback_state && WASDKeyPressed())
        {
            GetComponent <PlayerSprite>().moving = true;

            // Movement
            if (Input.GetKey(KeyCode.W))
            {
                y_speed = Mathf.Clamp(y_speed + acceleration, -max_speed, max_speed);
            }
            if (Input.GetKey(KeyCode.A))
            {
                x_speed = Mathf.Clamp(x_speed - acceleration, -max_speed, max_speed);
            }
            if (Input.GetKey(KeyCode.D))
            {
                x_speed = Mathf.Clamp(x_speed + acceleration, -max_speed, max_speed);
            }
            if (Input.GetKey(KeyCode.S))
            {
                y_speed = Mathf.Clamp(y_speed - acceleration, -max_speed, max_speed);
            }

            x_speed *= (1 - friction);
            y_speed *= (1 - friction);

            GetComponent <Rigidbody2D>().AddForce(new Vector2(x_speed * Time.deltaTime, y_speed * Time.deltaTime));
        }
        else if (!knockback_state)
        {
            GetComponent <PlayerSprite>().moving = false;

            x_speed *= (1 - friction);
            y_speed *= (1 - friction);
        }
    }