Пример #1
0
        public SkinControlAsyncLoadingObj AllocSkinControlAsyncLoadingObj(int nSkinID)
        {
            SkinControlAsyncLoadingObj result = null;

            if (!allocedAsyncObjTable.TryGetValue(nSkinID, out result))
            {
                result = new SkinControlAsyncLoadingObj();
                result.Clear();
                allocedAsyncObjTable.Add(nSkinID, result);
            }

            return(result);
        }
Пример #2
0
        //private void TestOnSkinChanged(CreatureProperty property, SkinInstance sk, int nOtherValue)
        //{
        //    BaseStateMachine fsm = property.Master.StateMachine;
        //    fsm.gameObject.name = sk.SrcSkin.ResSkinObj.AssetName + "(entityID:" + fsm.entityID + ")";
        //    if (fsm)
        //    {
        //        fsm.OnSkinChanged(property.Master, sk, nOtherValue);
        //    }


        //}

        private void UpdateLoadingSkin()
        {
            if (m_ChangeSkinData.Count <= 0 || (isCull && SkinManager.enabledSkinCull))
            {
                return;
            }

            LoadCompleteList.Clear();
            foreach (int id in m_ChangeSkinData.Keys)
            {
                SkinControlAsyncLoadingObj asyncojb = AllocSkinControlAsyncLoadingObj(id);
                if (!asyncojb.loadFinish)
                {
                    continue;
                }

                if (asyncojb.nSkinID != id)
                {
                    continue;
                }
                List <ChangeSkinData> dataList = null;
                if (!m_ChangeSkinData.TryGetValue(id, out dataList))
                {
                    Debug.LogError("PersonSkinControl重大错误--UpdateLoadingSkin");
                    continue;
                }
                LoadCompleteList.Add(id);
            }

            foreach (int id in LoadCompleteList)
            {
                List <ChangeSkinData> dataList = null;
                m_ChangeSkinData.TryGetValue(id, out dataList);

                SkinControlAsyncLoadingObj list = AllocSkinControlAsyncLoadingObj(id);

                m_ChangeSkinData.Remove(id);

                for (int i = 0; i < dataList.Count; i++)
                {
                    InvokeSkinChangedEvent(m_currentLoadedSkinInstance, dataList[i].nPart);
                }
                list.Clear();
            }
        }
Пример #3
0
        private void PushToCallBack(int nSkinID, int nPart)
        {
            SkinControlAsyncLoadingObj obj      = AllocSkinControlAsyncLoadingObj(nSkinID);
            List <ChangeSkinData>      dataList = null;

            if (!m_ChangeSkinData.TryGetValue(nSkinID, out dataList))
            {
                dataList = new List <ChangeSkinData>();
                m_ChangeSkinData.Add(nSkinID, dataList);

                obj.Clear();

                obj.nSkinID    = nSkinID;
                obj.loadFinish = false;
            }
            else
            {
                dataList = m_ChangeSkinData[nSkinID];
            }
            ChangeSkinData data = new ChangeSkinData();

            data.nPart = nPart;
            dataList.Add(data);
        }
Пример #4
0
        private void OnSkinLoadFinish(Skin skin)
        {
            if (skin == null)
            {
                return;
            }

            //回调的,跟当前ID不匹配,卸载这个皮肤
            if (skin.nSkinID != currentSkinId)
            {
                if (m_currentLoadedSkinInstance != null)
                {
                    if (m_currentLoadedSkinInstance.isValid)
                    {
                        //看看当前的skininstance是不是与skin的ID一样
                        if (m_currentLoadedSkinInstance.nSkinID == skin.nSkinID)
                        {
                            SkinManager.CacheSkinInstance(m_currentLoadedSkinInstance);
                            m_currentLoadedSkinInstance = null;
                        }
                    }
                }
                RemoveCallBack(skin.nSkinID);
                SkinManager.DeleteSkinAsync(skin.nSkinID, OnSkinLoadFinish, NotReleaseFromCache);
                return;
            }

            //如果已经被裁剪了,卸载这个皮肤
            if (isCull && SkinManager.enabledSkinCull)
            {
                if (m_currentLoadedSkinInstance != null)
                {
                    if (m_currentLoadedSkinInstance.isValid)
                    {
                        //看看当前的skininstance是不是与skin的ID一样
                        if (m_currentLoadedSkinInstance.nSkinID == skin.nSkinID)
                        {
                            SkinManager.CacheSkinInstance(m_currentLoadedSkinInstance);
                            m_currentLoadedSkinInstance = null;
                        }
                    }
                }
                SkinManager.DeleteSkinAsync(skin.nSkinID, OnSkinLoadFinish, NotReleaseFromCache);
                return;
            }


            if (m_currentLoadedSkinInstance != null)
            {
                if (m_currentLoadedSkinInstance.isValid)
                {
                    SkinManager.CacheSkinInstance(m_currentLoadedSkinInstance);
                    RemoveCallBack(m_currentLoadedSkinInstance.nSkinID);
                    SkinManager.DeleteSkinAsync(m_currentLoadedSkinInstance.nSkinID, OnSkinLoadFinish, NotReleaseFromCache);

                    m_currentLoadedSkinInstance = null;
                }
            }

            SkinControlAsyncLoadingObj obj = AllocSkinControlAsyncLoadingObj(skin.nSkinID);

            if (m_ChangeSkinData.ContainsKey(skin.nSkinID))
            {
                obj.loadFinish = true;
            }
            SkinInstance si = skin.Instantiate_Main();

            if (si == null)
            {
                m_currentLoadedSkinInstance = null;
                ClearPersonSkinDataFromMachine(m_machine);
                return;
            }
            GameUtil.SetLayer(m_machine.creature.gameObject.layer, si.SkinObj, true);

            m_currentLoadedSkinInstance = si;
            PersonSkinConfig psp = si.entitySkinConfig as PersonSkinConfig;

            si.SkinObj.transform.parent        = transform;
            si.SkinObj.transform.localPosition = Vector3.zero;
            si.SkinObj.transform.localRotation = Quaternion.identity;
            si.SkinObj.transform.name          = skin.ResSkinObj.AssetName + "-skin" + skin.nSkinID + "_C";;

            if (psp.AttackAnimatorLayer <= 0)
            {
                si.SkinObj_A.transform.parent = transform;
                si.SkinObj_B.transform.parent = transform;
            }

            if (si.SkinObj_A)
            {
                si.SkinObj_A.transform.parent        = transform;
                si.SkinObj_A.transform.localPosition = new Vector3(-1.0f, 0.0f, 0.0f);
                si.SkinObj_A.transform.localRotation = Quaternion.identity;
                si.SkinObj_A.name = skin.ResSkinObj.AssetName + "-skin" + skin.nSkinID + "_A";
            }

            if (si.SkinObj_B)
            {
                si.SkinObj_B.transform.parent        = transform;
                si.SkinObj_B.transform.localPosition = new Vector3(-1.0f, 0.0f, 0.0f);
                si.SkinObj_B.transform.localRotation = Quaternion.identity;
                si.SkinObj_B.name = skin.ResSkinObj.AssetName + "-skin" + skin.nSkinID + "_A";
            }

            foreach (RenderVisibleHelper skre in si.VisibleHelperList)
            {
                skre.hostSkin = null;
            }

            foreach (RenderVisibleHelper skre in si.VisibleHelperList)
            {
                skre.hostSkin = this;
            }

            ApplyStateData(m_currStateData);
            ApplyPersonSkinDataToMachine(m_machine, si);
        }
Пример #5
0
        private void OnSkinLoadFinish(Skin skin)
        {
            if (skin == null)
            {
                return;
            }
            //回调的,跟当前ID不匹配,卸载这个皮肤
            if (skin.nSkinID != currentSkinId)
            {
                if (m_currentLoadedSkinInstance != null)
                {
                    if (m_currentLoadedSkinInstance.isValid)
                    {
                        //看看当前的skininstance是不是与skin的ID一样
                        if (m_currentLoadedSkinInstance.nSkinID == skin.nSkinID)
                        {
                            SkinManager.CacheSkinInstance(m_currentLoadedSkinInstance);
                            m_currentLoadedSkinInstance = null;
                        }
                    }
                }
                RemoveCallBack(skin.nSkinID);
                SkinManager.DeleteSkinAsync(skin.nSkinID, OnSkinLoadFinish);
                return;
            }

            if (m_currentLoadedSkinInstance != null)
            {
                if (m_currentLoadedSkinInstance.isValid)
                {
                    SkinManager.CacheSkinInstance(m_currentLoadedSkinInstance);
                    RemoveCallBack(m_currentLoadedSkinInstance.nSkinID);
                    SkinManager.DeleteSkinAsync(m_currentLoadedSkinInstance.nSkinID, OnSkinLoadFinish);

                    m_currentLoadedSkinInstance = null;
                }
            }
            SkinControlAsyncLoadingObj obj = AllocSkinControlAsyncLoadingObj(skin.nSkinID);

            if (m_ChangeSkinData.ContainsKey(skin.nSkinID))
            {
                obj.loadFinish = true;
            }

            SkinInstance si = skin.Instantiate_Main();

            if (si == null)
            {
                m_currentLoadedSkinInstance = null;
                ClearMonsterSkinDataFromMachine(m_machine);
                return;
            }
            GameObject go = si.SkinObj;

            GameUtil.SetLayer(m_machine.creature.gameObject.layer, go, true);
            m_currentLoadedSkinInstance = si;
            go.transform.parent         = m_machine.creature;
            go.transform.localPosition  = Vector3.zero;
            go.transform.localRotation  = Quaternion.identity;
            go.name = skin.ResSkinObj.AssetName + "-skin" + skin.nSkinID;

            go = null;

            ApplyStateData(m_currStateData);
            ApplyMonsterSkinDataToMachine(m_machine, si);
        }