Exemplo n.º 1
0
 /// <summary>
 /// Make this character shoot in some direction.
 /// </summary>
 /// <param name="target">If default - target is mouse position.</param>
 public void Shoot(Vector3 target = default)
 {
     if (!readyToShoot)
     {
         if (EquipedWeapon.Settings.HoldingType != WeaponHoldingType.Sword)
         {
             StartCustomCoroutine(() =>
             {
                 AnimationModule.SetAnimationTrigger("Aim" + EquipedWeapon.Settings.HoldingType.ToString());
                 readyToShootTimer -= 0.03f;
             }, -1, 0.03f, () => { return(readyToShootTimer <= 0); }, () =>
             {
                 readyToShoot   = true;
                 headLookingPos = InputManager.Instance.MouseWorldPosition;
                 EquipedWeapon.Shoot();
                 readyToShootTimer = 0.25f;
             }
                                  );
         }
         else
         {
             EquipedWeapon.Shoot();
             readyToShootTimer = EquipedWeapon.Settings.AttackInterval;
         }
     }
     else
     {
         AnimationModule.SetAnimationTrigger("Aim" + EquipedWeapon.Settings.HoldingType.ToString());
         headLookingPos = InputManager.Instance.MouseWorldPosition;
         EquipedWeapon.Shoot();
     }
 }
Exemplo n.º 2
0
 public void ShootInActor(Actor target)
 {
     if (target != null)
     {
         EquipedWeapon.Shoot(target.BodyCenter.position);
     }
 }
Exemplo n.º 3
0
    /// <summary>
    /// Unity update.
    /// </summary>
    private void Update()
    {
        var lastDirection = movePlayerScript.Direction.x;

        if (lastDirection > 0)
        {
            lastFacingDirection = 1;
        }
        else if (lastDirection < 0)
        {
            lastFacingDirection = -1;
        }

        if ((Input.GetKey(KeyCode.LeftControl) && PlayerIndex == PlayerIndex.One) ||
            (Input.GetButton(Buttons.Player2Shoot) && PlayerIndex == PlayerIndex.Two))
        {
            if (EquipedWeapon != null)
            {
                EquipedWeapon.Shoot(new Vector2(lastFacingDirection, 0));
            }
        }
    }