예제 #1
0
    public void SetCurrentWeapon(PlayerWeaponType weaponType)
    {
        if (weaponType == PlayerWeaponType.None)
        {
            if (m_currentWeapon)
            {
                m_currentWeapon.gameObject.SetActive(false);
            }
            m_currentWeapon = null;
            return;
        }

        WeaponBase wb = GetWeapon(weaponType);

        if (wb)
        {
            if (m_currentWeapon)
            {
                m_currentWeapon.gameObject.SetActive(false);
            }
            m_currentWeapon = wb;
            m_currentWeapon.gameObject.SetActive(true);
            m_currentWeapon.OnEquip();
        }
    }
예제 #2
0
    public static void SelectWeapon(PlayerWeaponType weaponType)
    {
        switch (weaponType)
        {
        case PlayerWeaponType.KNIFE:
            myslf.knifeSelector.SetActive(true);
            myslf.gunSelector.SetActive(false);
            break;

        case PlayerWeaponType.PISTOL:
            myslf.knifeSelector.SetActive(false);
            myslf.gunSelector.SetActive(true);
            break;
        }
    }
예제 #3
0
    public WeaponBase GetWeapon(PlayerWeaponType weaponType)
    {
        if (weaponType == PlayerWeaponType.None)
        {
            Debug.LogError("Searching for WeaponType.None.");
            return(null);
        }

        foreach (WeaponBase wb in m_allweapons)
        {
            if (wb.WeaponType == weaponType)
            {
                return(wb);
            }
        }

        Debug.LogError("Unknown weapon: " + weaponType.ToString());
        return(null);
    }
예제 #4
0
    void SetWeapon(PlayerWeaponType weaponType)
    {
        if (weaponType != currentWeapon)
        {
            currentWeapon = weaponType;
            animator.SetTrigger("WeaponChange");
            switch (weaponType)
            {
            case PlayerWeaponType.KNIFE:
                attackTime = 0.4f;
                animator.SetInteger("WeaponType", 0);
                break;

            case PlayerWeaponType.PISTOL:
                attackTime = 0.1f;
                animator.SetInteger("WeaponType", 3);
                break;
            }
        }
        GameManager.SelectWeapon(weaponType);
    }
예제 #5
0
 public static PlayerWeaponType GetRandomWeaponType(this PlayerWeaponType weapType)
 {
     return((PlayerWeaponType)Random.Range(0, (int)PlayerWeaponType.NumOfWeapons));
 }
예제 #6
0
 public static bool IsAmmoUsingWeapon(this PlayerWeaponType weapType)
 {
     return(weapType == PlayerWeaponType.MachineGun || weapType == PlayerWeaponType.Pistol ||
            weapType == PlayerWeaponType.RocketLauncher);
 }
예제 #7
0
 public virtual void Init(PlayerWeaponType type)
 {
     this.type = type;
 }
예제 #8
0
 public override void Init(PlayerWeaponType type)
 {
     base.Init(type);
 }