示例#1
0
    void WeaponAssetLoaded(AssetBundle asset, ParamData data)
    {
        CallBackPack pack = loadedPack_[data.iParam];

        if (pack.actorObj_ == null)
        {
            return;
        }

        Transform bindPoint = null;

        if (EntityAssetsData.GetData((int)pack.weaponAssetId_).bindPoint_.Contains("L"))
        {
            bindPoint = pack.actorObj_.GetComponent <WeaponHand>().weaponLeftHand_;
        }
        else
        {
            bindPoint = pack.actorObj_.GetComponent <WeaponHand>().weaponRightHand_;
        }

        pack.weaponObj_ = (GameObject)GameObject.Instantiate(asset.mainAsset, bindPoint.position, bindPoint.rotation) as GameObject;
        WeaponAssetMgr.DeleteAsset(asset, false);
        pack.weaponObj_.transform.parent = bindPoint;
        pack.actorObj_.GetComponent <UpdateEquiptListener>().SetWeapon(pack.weaponObj_, pack.data_, pack.layerName_);

        NGUITools.SetLayer(pack.actorObj_, LayerMask.NameToLayer(pack.layerName_));
        NGUITools.SetChildLayer(pack.actorObj_.transform, LayerMask.NameToLayer(pack.layerName_));
        if (pack.actorCallBack_ != null)
        {
            pack.actorCallBack_(pack.actorObj_, pack.data_);
        }
        loadedPack_.Remove(pack.uid_);
        pack.actorObj_.SetActive(true);
    }
示例#2
0
    public void UpdateHandler(ENTITY_ID weaponAssetId)
    {
        if ((int)weaponAssetId == 0)
        {
            return;
        }

        weaponAssId_ = weaponAssetId;
        WeaponAssetMgr.LoadAsset((ENTITY_ID)dressAssId_, weaponAssId_, (AssetBundle bundle, ParamData data) =>
        {
            if (hasDestroy)
            {
                WeaponAssetMgr.DeleteAsset(bundle, false);
                return;
            }
            if (weapon_ != null)
            {
                Destroy(weapon_);
                weapon_ = null;
            }
            if (EntityAssetsData.GetData((int)weaponAssetId).bindPoint_.Contains("L"))
            {
                bindPoint_ = gameObject.GetComponent <WeaponHand>().weaponLeftHand_;
            }
            else
            {
                bindPoint_ = gameObject.GetComponent <WeaponHand>().weaponRightHand_;
            }

            weapon_ = (GameObject)GameObject.Instantiate(bundle.mainAsset, bindPoint_.position, bindPoint_.rotation) as GameObject;
            WeaponAssetMgr.DeleteAsset(bundle, false);
            weapon_.transform.parent = bindPoint_;
            //weapon_.transform.localScale = Vector3.one;
            NGUITools.SetChildLayer(transform, LayerMask.NameToLayer(layerName_));
        }, null);
    }