Example #1
0
        private void InitWithItemModel(ItemModel itemModel)
        {
            this.itemType = ItemType.UnlockScroll;

            this.unlockedItemId = itemModel.itemId;

            if (unlockedItemId >= 0 && unlockedItemId < 100)
            {
                this.unlockScrollType = UnlockScrollType.Equipment;
            }
            else if (unlockedItemId >= 100 && unlockedItemId < 200)
            {
                this.unlockScrollType = UnlockScrollType.Consumables;
            }

            this.spriteName = "unlockScroll";

            this.itemName          = itemModel.itemName;
            this.itemNameInEnglish = itemModel.itemNameInEnglish;

            this.itemId = itemModel.itemId + 200;

            this.itemGeneralDescription  = itemModel.itemGeneralDescription;
            this.itemPropertyDescription = itemModel.itemPropertyDescription;

            this.itemCount = 1;

                        #warning 解锁卷轴的价格全部定为5
            this.price = 5;

            this.unlocked = false;
        }
        public void SetUpUnlockedItemsView()
        {
//			SoundManager.Instance.PlayAudioClip ("UI/sfx_UI_Click");
//			IEnumerator coroutine = SetUpViewAfterDataReady ();
//			StartCoroutine (coroutine);
//
//		}
//
//
//		private IEnumerator SetUpViewAfterDataReady(){
//
//			bool dataReady = false;
//
//			while (!dataReady) {
//				dataReady = GameManager.Instance.gameDataCenter.CheckDatasReady (new GameDataCenter.GameDataType[] {
//					GameDataCenter.GameDataType.UISprites,
//					GameDataCenter.GameDataType.ItemModels,
//					GameDataCenter.GameDataType.ItemSprites
//				});
//				yield return null;
//			}
            currentSelectedType = UnlockScrollType.Equipment;
            unlockedItemsView.InitUnlockedItemView();
            unlockedItemsView.SetUpUnlockedItemsView(currentSelectedType);
        }
 public void OnUnlockedConsumablesButtonClick()
 {
     if (currentSelectedType == UnlockScrollType.Consumables)
     {
         return;
     }
     currentSelectedType = UnlockScrollType.Consumables;
     unlockedItemsView.SetUpUnlockedItemsView(currentSelectedType);
 }
 public void OnUnlockedEqiupmentButtonClick()
 {
     if (currentSelectedType == UnlockScrollType.Equipment)
     {
         return;
     }
     currentSelectedType = UnlockScrollType.Equipment;
     unlockedItemsView.SetUpUnlockedItemsView(currentSelectedType);
 }
        public void SetUpUnlockedItemsView(UnlockScrollType unlockScrollType)
        {
            switch (unlockScrollType)
            {
            case UnlockScrollType.Equipment:
                unlockEquipmentTitle.GetComponent <Image> ().sprite         = selectedSprite;
                unlockEquipmentTitle.GetComponentInChildren <Text> ().color = new Color(
                    CommonData.selectedColor.x,
                    CommonData.selectedColor.y,
                    CommonData.selectedColor.z);
                unlockConsumablesTitle.GetComponent <Image> ().sprite        = normalSprite;
                unlockConsumablesTitle.GetComponentInChildren <Text>().color = new Color(
                    CommonData.deselectedColor.x,
                    CommonData.deselectedColor.y,
                    CommonData.deselectedColor.z);
                break;

            case UnlockScrollType.Consumables:
                unlockConsumablesTitle.GetComponent <Image> ().sprite         = selectedSprite;
                unlockConsumablesTitle.GetComponentInChildren <Text> ().color = new Color(
                    CommonData.selectedColor.x,
                    CommonData.selectedColor.y,
                    CommonData.selectedColor.z);
                unlockEquipmentTitle.GetComponent <Image> ().sprite        = normalSprite;
                unlockEquipmentTitle.GetComponentInChildren <Text>().color = new Color(
                    CommonData.deselectedColor.x,
                    CommonData.deselectedColor.y,
                    CommonData.deselectedColor.z);
                break;
            }

            unlockedItemsPool.AddChildInstancesToPool(unlockedItemsContainer);

            for (int i = 0; i < Player.mainPlayer.allUnlockScrollsInBag.Count; i++)
            {
                UnlockScroll unlockScroll = Player.mainPlayer.allUnlockScrollsInBag [i];
                if (unlockScroll.unlocked && unlockScroll.unlockScrollType == unlockScrollType)
                {
                    Transform unlockedItem = unlockedItemsPool.GetInstance <Transform> (unlockedItemModel.gameObject, unlockedItemsContainer);
                    SetUpUnlockedItem(unlockedItem, unlockScroll);
                }
            }

            GetComponent <Canvas> ().enabled = true;
        }