Пример #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
    void ActorAssetLoaded(AssetBundle asset, ParamData data)
    {
        CallBackPack pack = loadedPack_[data.iParam];

        pack.actorObj_ = (GameObject)GameObject.Instantiate(asset.mainAsset) as GameObject;
        //PlayerAsseMgr.DeleteAsset(asset, false);
        //不忽略武器更新
        if (!data.bParam)
        {
            UpdateEquiptListener ueListener = pack.actorObj_.AddComponent <UpdateEquiptListener>();
            ueListener.data_ = pack.data_ == null ? null : pack.data_.Clone();
            if (pack.data_ != null && pack.data_.bParam)
            {
                ueListener.data_.iParam = 0;
            }
            if (pack.hasDress_)
            {
                ueListener.dressAssId_ = (int)pack.playerAssetId_;
            }
            ueListener.layerName_ = pack.layerName_;
            ueListener.SetWeapon(pack.weaponObj_, ueListener.data_, pack.layerName_);
            if (!GlobalValue.isBattleScene(StageMgr.Scene_name))
            {
                GamePlayer.Instance.WearEquipEvent += new WearEquipEventHandler(ueListener.UpdateHandler);
                GamePlayer.Instance.DelEquipEvent  += new DelEquipEventHandler(ueListener.RemoveWeaponHandler);
            }
        }

        Transform shadow = pack.actorObj_.transform.FindChild("Plane01");

        if (shadow != null)
        {
            shadow.gameObject.SetActive(pack.layerName_.Equals("Default"));
        }

        if (!pack.hasWeapon_)
        {
            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_);
        }
        else
        {
            pack.actorObj_.SetActive(false);
            WeaponAssetMgr.LoadAsset(pack.hasDress_? pack.playerAssetId_: (ENTITY_ID)0, pack.weaponAssetId_, WeaponAssetLoaded, new ParamData(pack.uid_));
        }
    }
Пример #3
0
    public void  GetActorClone(ENTITY_ID assetId, ENTITY_ID weaponId, EntityType type, CallBackPack.ActorLoadedCallBack callback, ParamData data = null, string layerName = "3D", int dressId = 0)
    {
        CallBackPack pack = new CallBackPack();

        pack.actorCallBack_ = callback;
        pack.data_          = data;
        ENTITY_ID AssId   = 0;
        ENTITY_ID WeassId = weaponId;

        if (dressId != 0)
        {
            AssId = (ENTITY_ID)dressId;
        }
        else
        {
            AssId = assetId;
        }
        pack.playerAssetId_ = AssId;
        pack.weaponAssetId_ = WeassId;
        pack.hasDress_      = dressId != 0;
        pack.layerName_     = layerName;
        pack.uid_           = GenerateUid;
        if (loadedPack_ == null)
        {
            loadedPack_ = new Dictionary <int, CallBackPack>();
        }

        loadedPack_.Add(pack.uid_, pack);

        bool ignoreWeaponUpdate = (type != EntityType.ET_Player);

        if (!ignoreWeaponUpdate)
        {
            pack.hasWeapon_ = weaponId != 0;
        }

        if (PlayerAsseMgr.LoadAsset(AssId, ActorAssetLoaded, new ParamData(pack.uid_, ignoreWeaponUpdate)) == false)
        {
            ClientLog.Instance.LogError("EntityAssetID: " + (int)AssId + " has not found!");
        }
    }