예제 #1
0
        public List <T> GetRandomSuitItems <T> (Dictionary <string, List <CocoRoleDressItemHolder> > categoryItemHolders,
                                                System.Func <CocoRoleDressItemHolder, T> extractFunc, bool onlyOwned = false)
        {
            var suitItems = new List <T> ();

            var configHolder      = (CocoAssetConfigHolder)ParentHolder;
            var suitCategoryIds   = configHolder.GetRandomSuitCategoryIds(categoryItemHolders.Keys);
            var count             = suitCategoryIds.Count;
            var randomIdGenerator = new CocoRandomIdGenerator(count);
            var stateModel        = onlyOwned ? CocoRoot.GetInstance <CocoDressStateModel> () : null;

            for (var i = 0; i < count; i++)
            {
                var categoryId = suitCategoryIds [randomIdGenerator.RandomId];
                var currCategoryItemHolders = categoryItemHolders [categoryId];

                CocoRoleDressItemHolder itemHolder;
                if (!onlyOwned)
                {
                    itemHolder = CocoData.GetRandomItem(currCategoryItemHolders);
                }
                else
                {
                    var ownedItemHolders = GetOwnedItemHoldersInList(currCategoryItemHolders, stateModel);
                    itemHolder = CocoData.GetRandomItem(ownedItemHolders);
                }
                if (itemHolder != null)
                {
                    suitItems.Add(extractFunc(itemHolder));
                }
            }

            return(suitItems);
        }
예제 #2
0
        /// <summary>
        /// Raises the application focus event.
        /// </summary>
        /// <param name="focusStatus">If set to <c>true</c> focus status.</param>
        private void OnApplicationFocus(bool focusStatus)
        {
            if (focusStatus)
            {
#if ABTEST
                var recordModele = CocoRoot.GetInstance <CocoGlobalRecordModel>();
                if (recordModele.CurGPType != GPType.Test_B)
                {
                    if ((System.DateTime.Now - m_LoseFocusTime).TotalMinutes > 5)
                    {
                                                #if COCO_FAKE
                        CocoRoot.GetInstance <CocoGlobalData>().ClearRvRelease();
                                                #else
                        CocoRoot.GetInstance <Game.GameGlobalData>().ClearRvRelease();
                                                #endif
                        updateRvStatusSignal.Dispatch();
                    }
                }
#else
                if ((DateTime.Now - m_LoseFocusTime).TotalMinutes > 5)
                {
#if COCO_FAKE
                    CocoRoot.GetInstance <CocoGlobalData>().ClearRvRelease();
#else
                    CocoRoot.GetInstance <Game.GameGlobalData> ().ClearRvRelease();
#endif
                    updateRvStatusSignal.Dispatch();
                }
#endif
            }
            else
            {
                m_LoseFocusTime = DateTime.Now;
            }
        }
예제 #3
0
        public CocoRoleDressItemHolder GetRandomItemHolder(bool onlyOwned = false)
        {
            if (!onlyOwned)
            {
                return(CocoData.GetRandomItem(itemHolders));
            }

            var stateModel          = CocoRoot.GetInstance <CocoDressStateModel> ();
            var randomInItemHolders = ((CocoRoleDressHolder)ParentHolder).GetOwnedItemHoldersInList(itemHolders, stateModel);

            return(CocoData.GetRandomItem(randomInItemHolders));
        }
예제 #4
0
        public List <CocoRoleDressItemHolder> GetUnOwnedItemHolders(string sceneId, List <string> categoryIds, bool containTempOwned = true)
        {
            var sceneHolder = GetSceneHolder(sceneId);

            if (sceneHolder == null)
            {
                return(null);
            }

            var stateModel = CocoRoot.GetInstance <CocoDressStateModel> ();

            return(GetUnOwnedItemHolders(sceneHolder, categoryIds, stateModel, containTempOwned));
        }
예제 #5
0
        public CocoRoleDressItemHolder GetRandomItemHolder(string categoryId, bool onlyOwned = false)
        {
            var categoryItemHolders = m_CategoryItemHolderDic.GetValue(categoryId);

            if (!onlyOwned)
            {
                return(CocoData.GetRandomItem(categoryItemHolders));
            }

            var stateModel          = CocoRoot.GetInstance <CocoDressStateModel> ();
            var randomInItemHolders = ((CocoRoleDressHolder)ParentHolder).GetOwnedItemHoldersInList(categoryItemHolders, stateModel);

            return(CocoData.GetRandomItem(randomInItemHolders));
        }
예제 #6
0
        public List <CocoRoleDressItemHolder> GetUnOwnedItemHolders(bool containTempOwned = true)
        {
            var unOwnedItemHolders = new List <CocoRoleDressItemHolder> ();
            var stateModel         = CocoRoot.GetInstance <CocoDressStateModel> ();

            sceneHolders.ForEach(sceneHolder => {
                var sceneItemHolders = GetUnOwnedItemHoldersInList(sceneHolder.itemHolders, stateModel, containTempOwned);
                if (sceneItemHolders != null && sceneItemHolders.Count > 0)
                {
                    unOwnedItemHolders.AddRange(sceneItemHolders);
                }
            });

            return(unOwnedItemHolders);
        }
        protected override void SwitchItem(CocoMakeupItemData oldData, CocoMakeupItemData newData)
        {
            if (newData != null)
            {
                Texture2D texture;

                CocoMakeupCategoryData categoryData = CocoRoot.GetInstance <ICocoMakeupData>().GetCategoryData(newData.Category);
                if (categoryData == null)
                {
                    return;
                }
                if (oldData == null || oldData.Category != newData.Category)
                {
                    CocoMakeupCategoryPaintData_PaintTexture paintData = (CocoMakeupCategoryPaintData_PaintTexture)categoryData.PaintData;
                    // brush
                    texture = Resources.Load <Texture2D> (paintData.paintBrushPath);
                    m_PaintKit.CurrentBrush = new CocoMakeupBrush(texture);
                    //Resources.UnloadAsset (texture);
                    // mask

                    if (!string.IsNullOrEmpty(paintData.paintMaskPath))
                    {
                        texture = Resources.Load <Texture2D> (paintData.paintMaskPath);
                        m_PaintKit.CurrentPaintMask = new CocoMakeupMask(texture);
                        //Resources.UnloadAsset (texture);
                    }
                    else
                    {
                        m_PaintKit.CurrentPaintMask = new CocoMakeupMask(Texture2D.whiteTexture);
                    }

                    // layer
                    m_PaintKit.SetCurrentCanvasLayer(paintData.paintLayerId);
                    m_PaintKit.CurrentBrush.Size = paintData.BrushSize;
                }

                if (oldData == null || oldData.m_TexturePath != newData.m_TexturePath)
                {
                    // pattern
                    texture = Resources.Load <Texture2D> (newData.m_TexturePath);
                    m_PaintKit.CurrentPattern = new CocoMakeupPattern(texture, CocoMakeupPattern.FillMode.CanvasArea);
                    //Resources.UnloadAsset (texture);
                }

                Resources.UnloadUnusedAssets();
            }
        }
예제 #8
0
        public List <CocoRoleDressItemHolder> GetUnOwnedItemHolders(List <string> categoryIds, bool containTempOwned = true)
        {
            if (categoryIds == null || categoryIds.Count <= 0)
            {
                return(null);
            }

            var unOwnedItemHolders = new List <CocoRoleDressItemHolder> ();
            var stateModel         = CocoRoot.GetInstance <CocoDressStateModel> ();

            sceneHolders.ForEach(sceneHolder => {
                var sceneUnOwnedItemHolders = GetUnOwnedItemHolders(sceneHolder, categoryIds, stateModel, containTempOwned);
                if (sceneUnOwnedItemHolders != null)
                {
                    unOwnedItemHolders.AddRange(sceneUnOwnedItemHolders);
                }
            });

            return(unOwnedItemHolders);
        }
예제 #9
0
        public void RemoveModule <TModule> (object moduleId = null) where TModule : CocoModuleBase
        {
            Dictionary <object, CocoModuleBase> moduleDic = GetModuleDic <TModule> ();
            string moduleKey = GetModuleKeyById(ref moduleId);

            if (!moduleDic.ContainsKey(moduleKey))
            {
                Debug.LogWarningFormat("{0}->RemoveModule: NOT need remove module [{1}<{2}>], because id don't exist!", GetType(), moduleId, typeof(TModule).Name);
                return;
            }

            // clean module
            CocoModuleBase module = moduleDic [moduleKey];

            module.Clean();
            CocoRoot.Unbind <TModule> (moduleId);
            moduleDic.Remove(moduleKey);

            // destroy module
            Destroy(module.gameObject);
        }
예제 #10
0
        public bool CanShowInterstitial(ApplicationLocation location)
        {
            // check debug settings
            if (CocoDebugSettingsData.Instance.IsSkipInterstitialEnabled)
            {
                return(false);
            }

#if !InsterstitialNotNeedCheckGameDuration
            // check ftue and game duration
            if (!CocoRoot.GetInstance <CocoGlobalRecordModel> ().FirstTimeFlowOver&& CocoRoot.GetInstance <CocoGlobalRecordModel> ().GameDuration < 3)
            {
                return(false);
            }
#endif
            // check no ads and location ready
//			if (CocoStoreControl.Instance.IsNoAds || !m_locationManager.IsReady (location)) {
//				return false;
//			}

            return(true);
        }
예제 #11
0
        public TModule AddModule <TModule> (CocoModuleBase module, object moduleId = null) where TModule : CocoModuleBase
        {
            Dictionary <object, CocoModuleBase> moduleDic = GetModuleDic <TModule> ();
            string moduleKey = GetModuleKeyById(ref moduleId);

            if (moduleDic.ContainsKey(moduleKey))
            {
                Debug.LogErrorFormat("{0}->AddModule: can NOT add module [{1}<{2}>], because the one with same id already exists!", GetType(), moduleId, module.GetType().Name);
                return(null);
            }

            if (module.transform.parent != transform)
            {
                CocoLoad.SetParent(module, transform);
            }

            // init module
            CocoRoot.BindValue <TModule> ((TModule)module, moduleId);
            module.Init(moduleId);
            moduleDic.Add(moduleKey, module);

            return((TModule)module);
        }
예제 #12
0
 protected IInjectionBinding Bind <T> ()
 {
     return(CocoRoot.Bind <T> (ID));
 }
예제 #13
0
 protected ICommandBinding BindCommand <T, TCommand> ()
 {
     return(CocoRoot.BindCommand <T, TCommand> ());
 }
예제 #14
0
 protected void Unbind <T> ()
 {
     CocoRoot.Unbind <T> (ID);
 }
예제 #15
0
 protected IInjectionBinding StuffBind <T> ()
 {
     return(CocoRoot.StuffBind <T> (ID));
 }
예제 #16
0
 protected IInjectionBinding StuffBindValue <T> (T value)
 {
     return(CocoRoot.StuffBindValue(value, ID));
 }
예제 #17
0
 protected IInjectionBinding StuffBindType <T> (Type type)
 {
     return(CocoRoot.StuffBindType <T> (type, ID));
 }
예제 #18
0
 protected IInjectionBinding StuffBindType <T, TType> ()
 {
     return(CocoRoot.StuffBindType <T, TType> (ID));
 }