Example #1
0
    private void Update()
    {
        timebetweenattacks -= Time.deltaTime;
        timeBetweenSword   -= Time.deltaTime;

        if (Input.GetMouseButton(0))
        {
            switch (attacktodo)
            {
            case AttackToDo.melee:
            {
                if (timebetweenattacks < 0)
                {
                    MeleeAttack();
                    timebetweenattacks = starttimebetweenattacks;
                    PlayerAttacking?.Invoke();
                }
                break;
            }

            case AttackToDo.ranged:

                if (timeBetweenSword < 0)
                {
                    RangedAttack();
                    PlayerAttacking?.Invoke();
                    timeBetweenSword = startTimebetweenSword;
                }

                break;

            case AttackToDo.nothing: break;
            }
        }

        if (Input.GetMouseButtonDown(1))
        {
            //Debug.Log("Switching weapon");
            SwitchingWeapon();
        }
    }
Example #2
0
 public void Attack()
 {
     playerAttacking.Invoke(player.playerId);
 }