示例#1
0
    public void SwitchWeaponTo(Transform wp, Vector3 pos, Quaternion rot)
    {
        WeaponInfo WeaponInf = wp.GetComponent <WeaponInfo>();

        if (WeaponInf.WeaponType == "Primary" || WeaponInf.WeaponType == "Special")
        {
            if (PrimaryWeapon != "")
            {
                oldItem       = CurrentWeapon.GetComponent <WeaponInfo>().w_Model;
                PrimaryWeapon = null;
                Transform oldGun = Instantiate(oldItem, pos, rot);
                oldGun.name = "item";
                Destroy(CurrentWeapon.gameObject);
            }

            PrimaryWeapon    = wp.name;
            WeaponInf.Player = transform;
            Transform newGun = Instantiate(wp, Hand);
            newGun.localPosition = WeaponInf.DefaultPosition;
            newGun.localRotation = Quaternion.Euler(WeaponInf.DefaultRotation.x, WeaponInf.DefaultRotation.y, WeaponInf.DefaultRotation.z);
            newGun.name          = WeaponInf.WeaponName;
            CurrentWeapon        = newGun;
            WeaponInf.Draw();
            AmmoReserve = WeaponInf.AmmoType;
            newGun.GetComponent <Animation>().Play(WeaponInf.WeaponName + "_draw");
        }
    }