public Reward GetReward()
 {
     if (Type != RewardTypes.reward)
     {
         return(null);
     }
     return(RewardSystemManager.GetConfig().Rewards.Find(r => r.ID == ItemID));
 }
 /// <summary>
 /// Charges the category list.
 /// </summary>
 void chargeCategoryList()
 {
     foreach (var reward in RewardSystemManager.GetConfig().Rewards)
     {
         if (!categoryList.Contains(reward.Category))
         {
             categoryList.Add(reward.Category);
         }
     }
 }
        public string GetRewardCategory()
        {
            if (Type != RewardTypes.reward)
            {
                return(string.Empty);
            }
            Reward reward = RewardSystemManager.GetConfig().Rewards.Find(r => r.ID == ItemID);

            if (reward != null)
            {
                return(reward.Category);
            }
            return(string.Empty);
        }
예제 #4
0
        void LoadRewarsList(string _position = "")
        {
            ClearList();
            List <Reward> rewards;

            if (_position != "")
            {
                rewards = RewardSystemManager.GetConfig().Rewards.FindAll(r => r.BoneAttach == _position);
            }
            else
            {
                rewards = RewardSystemManager.GetConfig().Rewards;
            }

            foreach (Reward reward in rewards)
            {
                Button b = Instantiate <Button>(ElementPrefab.GetComponent <Button>());
                b.transform.SetParent(ElementContainer.transform);
                b.GetComponentInChildren <Text>().text = reward.RewardName;
                b.onClick.AddListener(delegate { OnClickButton(b.GetComponentInChildren <Text>().text); });
            }
        }
        /// <summary>
        /// Loads the reward on model.
        /// </summary>
        /// <param name="_id">The identifier.</param>
        /// <returns></returns>
        public GameObject LoadRewardOnAntura(RewardPack _rewardPack)
        {
            Reward reward = RewardSystemManager.GetConfig().Rewards.Find(r => r.ID == _rewardPack.ItemID);

            if (reward == null)
            {
                Debug.LogFormat("Reward {0} not found!", _rewardPack.ItemID);
                return(null);
            }
            // Check if already charged reward of this category
            LoadedModel loadedModel = LoadedModels.Find(lm => lm.Reward.GetRewardCategory() == reward.Category);

            if (loadedModel != null)
            {
                Destroy(loadedModel.GO);
                LoadedModels.Remove(loadedModel);
            }

            // Load Model
            string     boneParent      = reward.BoneAttach;
            Transform  transformParent = transform;
            GameObject rewardModel     = null;

            switch (boneParent)
            {
            case "dog_head":
                transformParent = Dog_head;
                //if (Dog_head_pointer)
                //    Destroy(Dog_head_pointer.gameObject);
                //Dog_head_pointer = ModelsManager.MountModel(reward.ID, transformParent).transform;
                rewardModel = ModelsManager.MountModel(reward.ID, transformParent);
                break;

            case "dog_spine01":
                transformParent = Dog_spine01;
                //if (Dog_spine01_pointer)
                //    Destroy(Dog_spine01_pointer.gameObject);
                //Dog_spine01_pointer = ModelsManager.MountModel(reward.ID, transformParent).transform;
                rewardModel = ModelsManager.MountModel(reward.ID, transformParent);
                break;

            case "dog_jaw":
                transformParent = Dog_jaw;
                //if (Dog_jaw_pointer)
                //    Destroy(Dog_jaw_pointer.gameObject);
                //Dog_jaw_pointer = ModelsManager.MountModel(reward.ID, transformParent).transform;
                rewardModel = ModelsManager.MountModel(reward.ID, transformParent);
                break;

            case "dog_Tail4":
                transformParent = Dog_Tail3;
                //if (Dog_Tail3_pointer)
                //    Destroy(Dog_Tail3_pointer.gameObject);
                //Dog_Tail3_pointer = ModelsManager.MountModel(reward.ID, transformParent).transform;
                rewardModel = ModelsManager.MountModel(reward.ID, transformParent);
                break;

            case "dog_R_ear04":
                transformParent = Dog_R_ear04;
                //if (dog_R_ear04_pointer)
                //    Destroy(dog_R_ear04_pointer.gameObject);
                //dog_R_ear04_pointer = ModelsManager.MountModel(reward.ID, transformParent).transform;
                rewardModel = ModelsManager.MountModel(reward.ID, transformParent);
                break;

            case "dog_L_ear04":
                transformParent = Dog_L_ear04;
                //if (dog_L_ear04_pointer)
                //    Destroy(dog_L_ear04_pointer.gameObject);
                //dog_L_ear04_pointer = ModelsManager.MountModel(reward.ID, transformParent).transform;
                rewardModel = ModelsManager.MountModel(reward.ID, transformParent);
                break;

            default:
                break;
            }

            // Set materials
            ModelsManager.SwitchMaterial(rewardModel, _rewardPack.GetMaterialPair());

            // Save on LoadedModel List
            LoadedModels.Add(new LoadedModel()
            {
                Reward = _rewardPack, GO = rewardModel
            });
            return(rewardModel);
        }