Example #1
0
    /// <summary>
    /// Used to respawn the character
    /// </summary>
    /// <param name="spawnpoint"></param>
    public void Respawn(Vector3 spawnpoint)
    {
        if (IsDead)
        {
            IsDead = false;
            anim.SetBool("Dead", false);

            LockMovement(false);
            col.enabled    = true;
            rb.isKinematic = false;

            if (primaryWeapon)
            {
                primaryWeapon.gameObject.SetActive(true);
                primaryWeapon.Reset();
            }

            stats.ModifyHealth(int.MaxValue);
            if (currentWeapon != baseWeapon)
            {
                ChangeWeapon();
            }
            transform.position = spawnpoint;
        }
    }
Example #2
0
    void ChangeWeapon()
    {
        RangedWeapon otherWeapon;

        if (currentWeapon == primaryWeapon && baseWeapon != null)
        {
            otherWeapon = baseWeapon;
            anim.SetBool("Primary", false);
        }
        else if (currentWeapon == baseWeapon && primaryWeapon != null)
        {
            otherWeapon = primaryWeapon;
            anim.SetBool("Primary", true);
        }
        else
        {
            return;
        }

        //Deactivate current weapon
        currentWeapon.OnAmmoChanaged -= CurrentWeapon_AmmoChanged;
        currentWeapon.IsBeingUsed(false);

        currentWeapon = otherWeapon;

        //Activate new weapon
        currentWeapon.Reset();
        currentWeapon.OnAmmoChanaged += CurrentWeapon_AmmoChanged;
        currentWeapon.IsBeingUsed(true);
        OnAmmoChanged?.Invoke(CurrentWeapon.Magazine);
    }