示例#1
0
 public GameObject GetGunPrefab(eGunType type)
 {
     if (DicGunPrefab.ContainsKey(type) == true)
     {
         return(DicGunPrefab[type]);
     }
     else
     {
         Debug.LogError(type.ToString() + " prefab missing");
         return(null);
     }
 }
示例#2
0
    public void EquipGun(eGunType type)
    {
        Gun gunToEquip = WeaponManager.Instance.GetGunPrefab(type).GetComponent <Gun>();



        if (equippedGun != null)
        {
            Destroy(equippedGun.gameObject);
        }

        //weaponHold transform have Gun's position and rotation.(not local)
        Transform gunPosRot = weaponHold.GetChild((int)type);

        equippedGun = Instantiate(gunToEquip, gunPosRot.position, gunPosRot.rotation) as Gun;
        equippedGun.transform.parent = this.transform;

        IK.rightHandObj = equippedGun.RightGrabPosition;
        if (type == eGunType.Rifle || type == eGunType.Shotgun)
        {
            IK.leftHandObj = equippedGun.LeftGrabPosition;
        }

        IK.gunType = type;
        actor.gun  = equippedGun.GetComponent <Gun>();



        aimUI = UIManager.Instance.Aim.GetComponent <AimUI>();
        if (aimUI == null)
        {
            Debug.LogError("AimUI NULL");
        }
        else
        {
            Debug.Log("Aim!");
        }
    }