Exemple #1
0
        public void Refresh(ConfOfficer ori_info_, OfficerInfo server_info_ = null, bool with_effect_ = false)
        {
            m_body_tex.TextureName = ori_info_.portrait;
            m_body_tex.SetGray(false);
            this.m_officer_id        = ori_info_.id;
            this.m_officer_server_id = null == server_info_ ? -1 : server_info_.PlayerOfficerId;

            int lvl = null == server_info_ ? 0 : server_info_.Level;

            m_level_icon.Sprite = PoliceUILogicAssist.GetPoliceRankIcon(lvl);
            m_name_title.Text   = LocalizeModule.Instance.GetString(ori_info_.name);

            ConfCombineFormula next_level_combine_info = PoliceUILogicAssist.GetCombineInfo(ori_info_, lvl + 1);

            if (null != next_level_combine_info)
            {
                //tool
                List <string> tool_icon_names = new List <string>();
                tool_icon_names.Add(ConfProp.Get(next_level_combine_info.propId1).icon);
                tool_icon_names.Add(ConfProp.Get(next_level_combine_info.propId2).icon);
                tool_icon_names.Add(ConfProp.Get(next_level_combine_info.propId3).icon);
                tool_icon_names.Add(ConfProp.Get(next_level_combine_info.propId4).icon);
                tool_icon_names.Add(ConfProp.Get(next_level_combine_info.propId5).icon);

                List <long> tool_ids = new List <long>();
                tool_ids.Add(next_level_combine_info.propId1);
                tool_ids.Add(next_level_combine_info.propId2);
                tool_ids.Add(next_level_combine_info.propId3);
                tool_ids.Add(next_level_combine_info.propId4);
                tool_ids.Add(next_level_combine_info.propId5);

                bool lock_officer = false;

                for (int i = 0; i < m_tool_icons.Count; ++i)
                {
                    bool disable = !GlobalInfo.MY_PLAYER_INFO.Bag_infos.ContainsKey(tool_ids[i]);
                    if (disable)
                    {
                        lock_officer = true;
                    }
                    m_tool_icons[i].Refresh(tool_icon_names[i], disable);
                }

                ToolData t_d1 = new ToolData
                {
                    m_tool_id        = next_level_combine_info.propId1,
                    m_tool_count     = GlobalInfo.MY_PLAYER_INFO.Bag_infos.ContainsKey(next_level_combine_info.propId1) ? GlobalInfo.MY_PLAYER_INFO.Bag_infos[next_level_combine_info.propId1].Count : 0,
                    m_tool_max_count = 1
                };

                ToolData t_d2 = new ToolData
                {
                    m_tool_id        = next_level_combine_info.propId2,
                    m_tool_count     = GlobalInfo.MY_PLAYER_INFO.Bag_infos.ContainsKey(next_level_combine_info.propId2) ? GlobalInfo.MY_PLAYER_INFO.Bag_infos[next_level_combine_info.propId2].Count : 0,
                    m_tool_max_count = 1
                };
                ToolData t_d3 = new ToolData
                {
                    m_tool_id        = next_level_combine_info.propId3,
                    m_tool_count     = GlobalInfo.MY_PLAYER_INFO.Bag_infos.ContainsKey(next_level_combine_info.propId3) ? GlobalInfo.MY_PLAYER_INFO.Bag_infos[next_level_combine_info.propId3].Count : 0,
                    m_tool_max_count = 1
                };
                ToolData t_d4 = new ToolData
                {
                    m_tool_id        = next_level_combine_info.propId4,
                    m_tool_count     = GlobalInfo.MY_PLAYER_INFO.Bag_infos.ContainsKey(next_level_combine_info.propId4) ? GlobalInfo.MY_PLAYER_INFO.Bag_infos[next_level_combine_info.propId4].Count : 0,
                    m_tool_max_count = 1
                };
                ToolData t_d5 = new ToolData
                {
                    m_tool_id        = next_level_combine_info.propId5,
                    m_tool_count     = GlobalInfo.MY_PLAYER_INFO.Bag_infos.ContainsKey(next_level_combine_info.propId5) ? GlobalInfo.MY_PLAYER_INFO.Bag_infos[next_level_combine_info.propId5].Count : 0,
                    m_tool_max_count = 1
                };
                m_tool_datas = new List <ToolData>()
                {
                    t_d1,
                    t_d2,
                    t_d3,
                    t_d4,
                    t_d5
                };



                //item
                List <string> item_icon_names = new List <string>();
                item_icon_names.Add(ConfProp.Get(next_level_combine_info.specialPropId1).icon);
                item_icon_names.Add(ConfProp.Get(next_level_combine_info.specialPropId2).icon);
                item_icon_names.Add(ConfProp.Get(next_level_combine_info.specialPropId3).icon);
                item_icon_names.Add(ConfProp.Get(next_level_combine_info.specialPropId4).icon);

                List <long> item_ids = new List <long>();
                item_ids.Add(next_level_combine_info.specialPropId1);
                item_ids.Add(next_level_combine_info.specialPropId2);
                item_ids.Add(next_level_combine_info.specialPropId3);
                item_ids.Add(next_level_combine_info.specialPropId4);

                List <int> item_nums = new List <int>();
                item_nums.Add(next_level_combine_info.special1Count);
                item_nums.Add(next_level_combine_info.special2Count);
                item_nums.Add(next_level_combine_info.special3Count);
                item_nums.Add(next_level_combine_info.special4Count);

                m_item_datas = new List <ToolData>();

                for (int i = 0; i < item_ids.Count; ++i)
                {
                    m_items[i].Sprite          = item_icon_names[i];
                    m_items[i].gameObject.name = i.ToString();

                    PlayerPropMsg cur_item_in_bag;
                    int           cur_num = 0;
                    if (GlobalInfo.MY_PLAYER_INFO.Bag_infos.TryGetValue(item_ids[i], out cur_item_in_bag))
                    {
                        cur_num = cur_item_in_bag.Count;
                    }
                    m_items_nums[i].Text           = cur_num.ToString();
                    m_items_max_nums[i].Text       = item_nums[i].ToString();
                    m_item_progress[i].FillAmmount = (float)(((float)cur_num) / item_nums[i]);

                    if (cur_num < item_nums[i])
                    {
                        lock_officer = true;
                    }

                    ToolData t_d = new ToolData
                    {
                        m_tool_id        = item_ids[i],
                        m_tool_count     = cur_num,
                        m_tool_max_count = item_nums[i]
                    };

                    m_item_datas.Add(t_d);
                }

                if (0 == lvl)
                {
                    if (!lock_officer)
                    //   this.m_employ_btn.Visible = true;
                    {
                        SwitchUpgradAndEmployBtn(ENUM_BTN_TYPE.E_EMPLOY_ENABLE);
                    }
                    else
                    //this.m_employ_btn.Visible = false;
                    {
                        //TimeModule.Instance.SetTimeout(() => SwitchUpgradAndEmployBtn(ENUM_BTN_TYPE.E_EMPLOY_DISABLE), 0.5f);
                        SwitchUpgradAndEmployBtn(ENUM_BTN_TYPE.E_EMPLOY_DISABLE);
                    }

                    this.m_upgrade_btn.Visible = false;
                    m_body_tex.SetGray(true);
                }
                else
                {
                    if (!lock_officer)
                    {
                        //this.m_upgrade_btn.Visible = true;
                        SwitchUpgradAndEmployBtn(ENUM_BTN_TYPE.E_UPGRADE_ENABLE);
                    }
                    else
                    {
                        //this.m_upgrade_btn.Visible = false;
                        //TimeModule.Instance.SetTimeout(() => SwitchUpgradAndEmployBtn(ENUM_BTN_TYPE.E_UPGRADE_DISABLE), 0.5f);
                        SwitchUpgradAndEmployBtn(ENUM_BTN_TYPE.E_UPGRADE_DISABLE);
                    }
                }

                m_tool_icons.ForEach((tool) => { tool.Visible = true; });
                m_item_roots.ForEach((tool) => { tool.Visible = true; });
            }
            else
            {
                m_tool_icons.ForEach((tool) => { tool.Visible = false; });
                m_item_roots.ForEach((tool) => { tool.Visible = false; });


                this.SwitchUpgradAndEmployBtn(ENUM_BTN_TYPE.E_ALL_DISABLE);
            }


            if (with_effect_)
            {
                ShowUpgradeEffect(lvl);
            }
        }