Ejemplo n.º 1
0
        public void Refresh()
        {
            if (UnityEngine.Object.op_Equality((UnityEngine.Object) this.ItemSlotTemplate, (UnityEngine.Object)null) || this.ShowUnusedSlots && UnityEngine.Object.op_Equality((UnityEngine.Object) this.UnusedSlotTemplate, (UnityEngine.Object)null))
            {
                return;
            }
            this.mCurrentUnit = this.Unit == null ? MonoSingleton <GameManager> .Instance.Player.FindUnitDataByUniqueID((long)GlobalVars.SelectedUnitUniqueID) : this.Unit;

            if (this.mCurrentUnit == null)
            {
                return;
            }
            GameUtility.DestroyGameObjects(this.mItems);
            this.mItems.Clear();
            DataSource.Bind <UnitData>(((Component)this).get_gameObject(), this.mCurrentUnit);
            GameParameter.UpdateAll(((Component)this).get_gameObject());
            string      key           = (string)null;
            bool        flag          = this.mCurrentUnit.CheckUnitRarityUp();
            RecipeParam currentRecipe = this.GetCurrentRecipe(this.mCurrentUnit);

            DataSource.Bind <RecipeParam>(((Component)this).get_gameObject(), currentRecipe);
            if (key == null && currentRecipe != null && currentRecipe.cost > MonoSingleton <GameManager> .Instance.Player.Gold)
            {
                key  = "sys.GOLD_NOT_ENOUGH";
                flag = false;
            }
            if (key == null && this.mCurrentUnit.Lv < this.mCurrentUnit.GetRarityLevelCap(this.mCurrentUnit.Rarity))
            {
                key  = "sys.LEVEL_NOT_ENOUGH";
                flag = false;
            }
            if (currentRecipe != null)
            {
                for (int index = 0; index < currentRecipe.items.Length; ++index)
                {
                    RecipeItem recipeItem = currentRecipe.items[index];
                    if (recipeItem == null || string.IsNullOrEmpty(recipeItem.iname))
                    {
                        if (this.ShowUnusedSlots)
                        {
                            GameObject gameObject = (GameObject)UnityEngine.Object.Instantiate <GameObject>((M0)this.UnusedSlotTemplate);
                            gameObject.get_transform().SetParent((Transform)this.ListParent, false);
                            this.mItems.Add(gameObject);
                            gameObject.SetActive(true);
                        }
                    }
                    else
                    {
                        ListItemEvents listItemEvents = (ListItemEvents)UnityEngine.Object.Instantiate <ListItemEvents>((M0)this.ItemSlotTemplate);
                        ((Component)listItemEvents).get_transform().SetParent((Transform)this.ListParent, false);
                        this.mItems.Add(((Component)listItemEvents).get_gameObject());
                        listItemEvents.OnSelect = new ListItemEvents.ListItemEvent(this.OnItemSelect);
                        ((Component)listItemEvents).get_gameObject().SetActive(true);
                        ItemParam itemParam = MonoSingleton <GameManager> .Instance.GetItemParam(recipeItem.iname);

                        JobEvolutionRecipe data = new JobEvolutionRecipe();
                        data.Item       = itemParam;
                        data.RecipeItem = recipeItem;
                        data.Amount     = MonoSingleton <GameManager> .Instance.Player.GetItemAmount(recipeItem.iname);

                        data.RequiredAmount = recipeItem.num;
                        if (data.Amount < data.RequiredAmount)
                        {
                            flag = false;
                            if (key == null)
                            {
                                key = "sys.ITEM_NOT_ENOUGH";
                            }
                        }
                        DataSource.Bind <JobEvolutionRecipe>(((Component)listItemEvents).get_gameObject(), data);
                    }
                }
            }
            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.HelpText, (UnityEngine.Object)null))
            {
                ((Component)this.HelpText).get_gameObject().SetActive(key != null);
                if (key != null)
                {
                    this.HelpText.set_text(LocalizedText.Get(key));
                }
            }
            if (!UnityEngine.Object.op_Inequality((UnityEngine.Object) this.EvolveButton, (UnityEngine.Object)null))
            {
                return;
            }
            ((Selectable)this.EvolveButton).set_interactable(flag);
        }
Ejemplo n.º 2
0
        public void Refresh2()
        {
            if (UnityEngine.Object.op_Equality((UnityEngine.Object) this.ItemSlotTemplate, (UnityEngine.Object)null))
            {
                DebugUtility.LogWarning("UnitEvolutionWindow.cs => Refresh2():ItemSlotTemplate is Null or Empty!");
            }
            else if (UnityEngine.Object.op_Equality((UnityEngine.Object) this.ItemSlotRoot, (UnityEngine.Object)null))
            {
                DebugUtility.LogWarning("UnitEvolutionWindow.cs => Refresh2():ItemSlotRoot is Null or Empty!");
            }
            else if (UnityEngine.Object.op_Equality((UnityEngine.Object) this.ItemSlotBox, (UnityEngine.Object)null))
            {
                DebugUtility.LogWarning("UnitEvolutionWindow.cs => Refresh2():ItemSlotBox is Null or Empty!");
            }
            else if (UnityEngine.Object.op_Equality((UnityEngine.Object) this.SubPanel, (UnityEngine.Object)null))
            {
                DebugUtility.LogWarning("UnitEvolutionWindow.cs => Refresh2():SubPanel is Null References!");
            }
            else
            {
                this.SubPanel.SetActive(false);
                if (UnityEngine.Object.op_Equality((UnityEngine.Object) this.MainPanelCloseBtn, (UnityEngine.Object)null))
                {
                    DebugUtility.LogWarning("UnitEvolutionWindow.cs => Refresh2():MainPanelCloseBtn is Null References!");
                }
                else
                {
                    ((Component)this.MainPanelCloseBtn).get_gameObject().SetActive(true);
                    GameManager instanceDirect = MonoSingleton <GameManager> .GetInstanceDirect();

                    if (UnityEngine.Object.op_Equality((UnityEngine.Object)instanceDirect, (UnityEngine.Object)null))
                    {
                        return;
                    }
                    UnitData unitData = this.Unit == null?instanceDirect.Player.FindUnitDataByUniqueID((long)GlobalVars.SelectedUnitUniqueID) : this.Unit;

                    if (unitData == null)
                    {
                        return;
                    }
                    this.mCurrentUnit = unitData;
                    GameUtility.DestroyGameObjects(this.mItems);
                    this.mItems.Clear();
                    GameUtility.DestroyGameObjects(this.mBoxs);
                    this.mBoxs.Clear();
                    DataSource.Bind <UnitData>(((Component)this).get_gameObject(), unitData);
                    GameParameter.UpdateAll(((Component)this).get_gameObject());
                    string      key           = (string)null;
                    bool        flag          = unitData.CheckUnitRarityUp();
                    RecipeParam currentRecipe = this.GetCurrentRecipe(unitData);
                    DataSource.Bind <RecipeParam>(((Component)this).get_gameObject(), currentRecipe);
                    if (string.IsNullOrEmpty(key) && currentRecipe != null && currentRecipe.cost > instanceDirect.Player.Gold)
                    {
                        key  = "sys.GOLD_NOT_ENOUGH";
                        flag = false;
                    }
                    if (string.IsNullOrEmpty(key) && unitData.Lv < unitData.GetRarityLevelCap(unitData.Rarity))
                    {
                        key  = "sys.LEVEL_NOT_ENOUGH";
                        flag = false;
                    }
                    if (currentRecipe == null)
                    {
                        return;
                    }
                    if (currentRecipe.items == null || currentRecipe.items.Length <= 0)
                    {
                        DebugUtility.LogWarning("UnitEvolutionWindow.cs => Refresh2():recipe_param.items is Null or Count 0!");
                    }
                    else
                    {
                        int             length    = currentRecipe.items.Length;
                        GridLayoutGroup component = (GridLayoutGroup)this.ItemSlotBox.GetComponent <GridLayoutGroup>();
                        if (UnityEngine.Object.op_Equality((UnityEngine.Object)component, (UnityEngine.Object)null))
                        {
                            DebugUtility.LogWarning("UnitEvolutionWindow.cs => Refresh2():gridlayout is Not Component [GridLayoutGroup]!");
                        }
                        else
                        {
                            GameObject gameObject1 = (GameObject)UnityEngine.Object.Instantiate <GameObject>((M0)this.ItemSlotBox);
                            gameObject1.get_transform().SetParent(this.ItemSlotRoot.get_transform(), false);
                            gameObject1.SetActive(true);
                            this.mBoxs.Add(gameObject1);
                            if (length > component.get_constraintCount())
                            {
                                GameObject gameObject2 = (GameObject)UnityEngine.Object.Instantiate <GameObject>((M0)this.ItemSlotBox);
                                gameObject2.get_transform().SetParent(this.ItemSlotRoot.get_transform(), false);
                                gameObject2.SetActive(true);
                                this.mBoxs.Add(gameObject2);
                            }
                            for (int index1 = 0; index1 < length; ++index1)
                            {
                                RecipeItem recipeItem = currentRecipe.items[index1];
                                if (recipeItem != null && !string.IsNullOrEmpty(recipeItem.iname))
                                {
                                    int index2 = 0;
                                    if (length > component.get_constraintCount())
                                    {
                                        if (length % 2 == 0)
                                        {
                                            if (index1 >= component.get_constraintCount() - 1)
                                            {
                                                index2 = 1;
                                            }
                                        }
                                        else if (index1 >= component.get_constraintCount())
                                        {
                                            index2 = 1;
                                        }
                                    }
                                    ListItemEvents listItemEvents = (ListItemEvents)UnityEngine.Object.Instantiate <ListItemEvents>((M0)this.ItemSlotTemplate);
                                    ((Component)listItemEvents).get_transform().SetParent(this.mBoxs[index2].get_transform(), false);
                                    this.mItems.Add(((Component)listItemEvents).get_gameObject());
                                    listItemEvents.OnSelect = new ListItemEvents.ListItemEvent(this.OnItemSelect2);
                                    ((Component)listItemEvents).get_gameObject().SetActive(true);
                                    ItemParam itemParam = instanceDirect.GetItemParam(recipeItem.iname);
                                    if (itemParam == null)
                                    {
                                        DebugUtility.LogWarning("UnitEvolutionWindow.cs => Refresh2():item_param is Null References!");
                                        return;
                                    }
                                    DataSource.Bind <ItemParam>(((Component)listItemEvents).get_gameObject(), itemParam);
                                    JobEvolutionRecipe data = new JobEvolutionRecipe();
                                    data.Item           = itemParam;
                                    data.RecipeItem     = recipeItem;
                                    data.Amount         = instanceDirect.Player.GetItemAmount(recipeItem.iname);
                                    data.RequiredAmount = recipeItem.num;
                                    if (data.Amount < data.RequiredAmount)
                                    {
                                        flag = false;
                                        if (key == null)
                                        {
                                            key = "sys.ITEM_NOT_ENOUGH";
                                        }
                                    }
                                    DataSource.Bind <JobEvolutionRecipe>(((Component)listItemEvents).get_gameObject(), data);
                                }
                            }
                            if (UnityEngine.Object.op_Inequality((UnityEngine.Object) this.HelpText, (UnityEngine.Object)null))
                            {
                                ((Component)this.HelpText).get_gameObject().SetActive(!string.IsNullOrEmpty(key));
                                if (!string.IsNullOrEmpty(key))
                                {
                                    this.HelpText.set_text(LocalizedText.Get(key));
                                }
                            }
                            if (!UnityEngine.Object.op_Inequality((UnityEngine.Object) this.EvolveButton, (UnityEngine.Object)null))
                            {
                                return;
                            }
                            ((Selectable)this.EvolveButton).set_interactable(flag);
                        }
                    }
                }
            }
        }