コード例 #1
0
        public void ResetDressItem(List <string> itemIds, System.Action <List <CocoDressItemHolder> > endAction = null)
        {
            if (DressIsLoading)
            {
                return;
            }

            List <CocoDressItemHolder> itemHolders = new List <CocoDressItemHolder> (itemIds.Count);

            itemIds.ForEach(itemId => {
                CocoDressItemModelSet modelSet = m_DressData.GetDress(itemId);
                if (modelSet != null)
                {
                    itemHolders.Add(modelSet.ItemHolder);
                }
            });

            m_ItemLoader.LoadItemDict(itemHolders, itemModelsDic => {
                itemModelsDic.Keys.ForEach(itemHolder => RemoveDressModelSet(itemHolder.id));
                AddDressModelSets(itemModelsDic, null);
                DressIsLoading = false;

                if (endAction != null)
                {
                    endAction(itemHolders);
                }
            });
        }
コード例 #2
0
        void AddDressModelSet(CocoDressItemHolder itemHolder, List <GameObject> itemModels)
        {
            CocoDressItemModelSet modelSet = new CocoDressItemModelSet(itemHolder);

            modelSet.ItemRenderers = new List <SkinnedMeshRenderer> ();
            itemModels.ForEach(model => {
                RebindModelBone(model);

                SkinnedMeshRenderer[] smrs = model.GetComponentsInChildren <SkinnedMeshRenderer> ();
                smrs.ForEach(smr => {
                    smr.transform.SetParent(m_RootBone, false);
                    smr.gameObject.layer = m_RootBone.gameObject.layer;
                    modelSet.ItemRenderers.Add(smr);

                    if (OnRendererChanged != null)
                    {
                        OnRendererChanged(smr, true);
                    }
                });

                Destroy(model);
            });

            m_DressData.AddDress(modelSet);
        }
コード例 #3
0
        public void AddDressItem(List <string> itemIds, Action <List <CocoDressItemModelSet> > endAction = null)
        {
            if (DressIsLoading)
            {
                return;
            }

            // check if already added
            List <string> shouldAddedItemIds = new List <string> ();
            List <CocoDressItemModelSet> addedItemModelSets = new List <CocoDressItemModelSet> ();

            itemIds.ForEach(itemId => {
                CocoDressItemModelSet modelSet = m_DressData.GetDress(itemId);
                if (modelSet == null)
                {
                    shouldAddedItemIds.Add(itemId);
                }
                else
                {
                    addedItemModelSets.Add(modelSet);
                }
            });

            // all already added, return them
            if (shouldAddedItemIds.Count <= 0)
            {
                if (endAction != null)
                {
                    endAction(addedItemModelSets);
                }
                return;
            }

            // load should added items
            DressIsLoading = true;

            // get real should added items
            List <CocoDressItemConflictData> conflictDatas = null;

            shouldAddedItemIds = m_DressData.PrepareAddDressItems(shouldAddedItemIds, out conflictDatas);

            m_ItemLoader.LoadItemDict(shouldAddedItemIds, itemModelsDic => {
                AddDressModelSets(itemModelsDic, conflictDatas);
                DressIsLoading = false;

                if (endAction != null)
                {
                    shouldAddedItemIds.ForEach(itemId => {
                        CocoDressItemModelSet modelSet = m_DressData.GetDress(itemId);
                        if (modelSet != null)
                        {
                            addedItemModelSets.Add(modelSet);
                        }
                    });

                    endAction(addedItemModelSets);
                }
            });
        }
コード例 #4
0
        public void RemoveDressItem(List <string> itemIds, Action endAction = null)
        {
            if (DressIsLoading)
            {
                return;
            }

            // check if dressed
            List <string> shouldRemoveItemIds = new List <string> ();

            itemIds.ForEach(itemId => {
                CocoDressItemModelSet modelSet = m_DressData.GetDress(itemId);
                if (modelSet != null)
                {
                    shouldRemoveItemIds.Add(itemId);
                }
            });

            // all no dressed, return
            if (shouldRemoveItemIds.Count <= 0)
            {
                if (endAction != null)
                {
                    endAction();
                }
                return;
            }

            // get real should added items
            List <CocoDressItemConflictData> conflictDatas = null;
            List <string> shouldAddedItemIds = m_DressData.PrepareRemoveDressItems(shouldRemoveItemIds, out conflictDatas);

            // no need to added
            if (shouldAddedItemIds.Count <= 0)
            {
                AddDressModelSets(null, conflictDatas);
                if (endAction != null)
                {
                    endAction();
                }
                return;
            }

            // load should added items
            DressIsLoading = true;

            m_ItemLoader.LoadItemDict(shouldAddedItemIds, modelSets => {
                AddDressModelSets(modelSets, conflictDatas);
                DressIsLoading = false;

                if (endAction != null)
                {
                    endAction();
                }
            });
        }
コード例 #5
0
        public void SetDressItemsActive(string itemId, bool active)
        {
            CocoDressItemModelSet modelSet = GetDressItem(itemId);

            if (modelSet == null)
            {
                return;
            }

            modelSet.IsActive = active;
        }
コード例 #6
0
        public void RemoveDress(string itemid)
        {
            CocoDressItemModelSet modelSet = m_CurrDressModelSetDic.GetValue(itemid);

            if (modelSet == null)
            {
                return;
            }

            CheckChangeForRemoveItem(modelSet);
            m_CurrDressModelSetDic.Remove(itemid);
        }
コード例 #7
0
 void CheckChangeForAddItem(CocoDressItemModelSet modelSet)
 {
     modelSet.ItemRenderers.ForEach(smr => {
         if (m_RendererDic.ContainsKey(smr.name))
         {
             m_RendererDic [smr.name] = smr;
         }
         else
         {
             m_RendererDic.Add(smr.name, smr);
         }
     });
 }
コード例 #8
0
 public void AddDressItem(string itemId, Action <CocoDressItemModelSet> endAction = null)
 {
     AddDressItem(new List <string> (1)
     {
         itemId
     }, modelSets => {
         if (endAction != null)
         {
             CocoDressItemModelSet modelSet = null;
             if (modelSets.Count > 0)
             {
                 modelSet = modelSets [0];
             }
             endAction(modelSet);
         }
     });
 }
コード例 #9
0
        void RemoveDressModelSet(string itemId)
        {
            CocoDressItemModelSet modelSet = m_DressData.GetDress(itemId);

            if (modelSet == null)
            {
                return;
            }

            // destroy smrs
            modelSet.ItemRenderers.ForEach(smr => {
                if (OnRendererChanged != null)
                {
                    OnRendererChanged(smr, false);
                }

                Destroy(smr.gameObject);
            });
            //modelSet.ItemHolder.UnloadAsset ();

            m_DressData.RemoveDress(itemId);
        }
コード例 #10
0
        void CheckChangeForRemoveItem(CocoDressItemModelSet modelSet)
        {
            modelSet.ItemRenderers.ForEach(smr => {
                if (m_RendererDic.ContainsKey(smr.name))
                {
                    m_RendererDic.Remove(smr.name);
                }
            });

            CocoDressItemHolder     itemHolder     = modelSet.ItemHolder;
            CocoDressCategoryHolder categoryHolder = (CocoDressCategoryHolder)itemHolder.ParentHolder;

            if (!categoryHolder.isMain)
            {
                return;
            }

            // record last item, in order to resume it
            var layer = itemHolder.CoverLayer;

            if (m_LastCoverItemHolderDic.ContainsKey(layer))
            {
                m_LastCoverItemHolderDic [layer] = itemHolder;
                int index = m_SortedLastCovers.IndexOf(layer);
                for (int i = index + 1; i < m_SortedLastCovers.Count; i++)
                {
                    m_SortedLastCovers [i - 1] = m_SortedLastCovers [i];
                }
                m_SortedLastCovers [m_SortedLastCovers.Count - 1] = layer;
                //Debug.LogError ("update " + layer + " -> " + itemHolder.id);
            }
            else
            {
                m_LastCoverItemHolderDic.Add(layer, itemHolder);
                //Debug.LogError ("add " + layer + " -> " + itemHolder.id);
                m_SortedLastCovers.Add(layer);
            }
        }
コード例 #11
0
 public void AddDress(CocoDressItemModelSet modelSet)
 {
     m_CurrDressModelSetDic.Add(modelSet.ItemHolder.id, modelSet);
     CheckChangeForAddItem(modelSet);
 }