public void SetActiveBlocks(Dictionary <string, CategoryBlocks> activeCategories, Dictionary <string, PopUpData> categoriesTutorials = null) { this.activeCategories = activeCategories; nActiveCategories = activeCategories.Keys.Count; TutorialTrigger trigger = GetComponent <TutorialTrigger>(); if (trigger != null) { trigger.enabled = nActiveCategories > 0; } Block.blocksAvailable = new Dictionary <string, int>(); int priority = 400; //Activate the category if it's not in the active list foreach (var category in mConfig.BlockCategoryList) { bool active = activeCategories.ContainsKey(category.CategoryName.ToLower()); mMenuList[category.CategoryName].gameObject.SetActive(active); if (categoriesTutorials != null && categoriesTutorials.ContainsKey(category.CategoryName)) { TutorialTrigger categoryTrigger = mMenuList[category.CategoryName].gameObject.AddComponent <TutorialTrigger>(); categoryTrigger.isSaveCheckpoint = true; categoryTrigger.priority = priority++; categoryTrigger.highlightObject = true; categoryTrigger.info = categoriesTutorials[category.CategoryName]; } //Set Block Count if (active) { mMenuList[category.CategoryName].gameObject.SetActive(true); List <string> blockTypes = mConfig.GetBlockCategory(category.CategoryName).BlockList; foreach (string blockType in blockTypes) { CategoryBlocks info = activeCategories[category.CategoryName.ToLower()]; if (info.activate == (info.activeBlocks.ContainsKey(blockType))) { int value = (info.activeBlocks.ContainsKey(blockType) ? info.activeBlocks[blockType] : Int16.MaxValue); Block.blocksAvailable[blockType] = value; } } } } }
protected void SetBlockCount(BlockView block) { //Deactivate the block if it's not in the active list bool active = false; string blockType = block.BlockType; if (activeCategories != null && mActiveCategory != null && activeCategories.ContainsKey(mActiveCategory.ToLower())) { CategoryBlocks info = activeCategories[mActiveCategory.ToLower()]; active = info.activate == (info.activeBlocks.ContainsKey(blockType)); int value = (Block.blocksAvailable.ContainsKey(blockType) ? Block.blocksAvailable[blockType] : Int16.MaxValue); if (value <= 0) { block.enabled = false; block.ChangeBgColor(Color.grey); } } block.gameObject.SetActive(allActive || active); block.UpdateCount(); }