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); }
/// <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; } }
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)); }
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)); }
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)); }
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(); } }
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); }
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); }
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); }
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); }
protected IInjectionBinding Bind <T> () { return(CocoRoot.Bind <T> (ID)); }
protected ICommandBinding BindCommand <T, TCommand> () { return(CocoRoot.BindCommand <T, TCommand> ()); }
protected void Unbind <T> () { CocoRoot.Unbind <T> (ID); }
protected IInjectionBinding StuffBind <T> () { return(CocoRoot.StuffBind <T> (ID)); }
protected IInjectionBinding StuffBindValue <T> (T value) { return(CocoRoot.StuffBindValue(value, ID)); }
protected IInjectionBinding StuffBindType <T> (Type type) { return(CocoRoot.StuffBindType <T> (type, ID)); }
protected IInjectionBinding StuffBindType <T, TType> () { return(CocoRoot.StuffBindType <T, TType> (ID)); }