Beispiel #1
0
        public void OnTalent_ItemClick(CUIEvent uiEvent)
        {
            CUIFormScript form = Singleton <CUIManager> .GetInstance().GetForm(s_TalentFormPath);

            if (form != null)
            {
                CUIListScript[]     scriptArray = new CUIListScript[] { form.gameObject.transform.Find("Panel/PanelLeft/List1").GetComponent <CUIListScript>(), form.gameObject.transform.Find("Panel/PanelLeft/List2").GetComponent <CUIListScript>(), form.gameObject.transform.Find("Panel/PanelLeft/List3").GetComponent <CUIListScript>(), form.gameObject.transform.Find("Panel/PanelLeft/List4").GetComponent <CUIListScript>(), form.gameObject.transform.Find("Panel/PanelLeft/List5").GetComponent <CUIListScript>() };
                CUIListScript       srcWidgetBelongedListScript = uiEvent.m_srcWidgetBelongedListScript;
                stTalentEventParams talentParams = uiEvent.m_eventParams.talentParams;
                if ((uiEvent.m_srcWidgetIndexInBelongedList != -1) && (talentParams.talentInfo != null))
                {
                    for (int i = 0; i < scriptArray.Length; i++)
                    {
                        if (scriptArray[i] != srcWidgetBelongedListScript)
                        {
                            CUIListElementScript lastSelectedElement = scriptArray[i].GetLastSelectedElement();
                            if (lastSelectedElement != null)
                            {
                                lastSelectedElement.ChangeDisplay(false);
                            }
                            scriptArray[i].SelectElement(-1, true);
                        }
                    }
                    GameObject gameObject = form.gameObject.transform.Find("Panel/PanelRight").gameObject;
                    Image      component  = form.gameObject.transform.Find("Panel/PanelRight/talentCell/imgIcon").GetComponent <Image>();
                    Text       text       = form.gameObject.transform.Find("Panel/PanelRight/lblDesc").GetComponent <Text>();
                    Button     btn        = form.gameObject.transform.Find("Panel/PanelRight/btnLearn").GetComponent <Button>();
                    component.SetSprite(CUIUtility.s_Sprite_Dynamic_Talent_Dir + talentParams.talentInfo.dwIcon, form, true, false, false);
                    text.text = StringHelper.UTF8BytesToString(ref talentParams.talentInfo.szDesc);
                    if (!talentParams.isCanLearn && !talentParams.isHaveTalent)
                    {
                        text.text = Singleton <CTextManager> .instance.GetText("Talent_Buy_1");
                    }
                    btn.gameObject.CustomSetActive(true);
                    if (talentParams.isCanLearn)
                    {
                        CUICommonSystem.SetButtonEnable(btn, true, true, true);
                        btn.gameObject.transform.GetComponent <CUIEventScript>().SetUIEvent(enUIEventType.Click, enUIEventID.Talent_BtnLearnClick, uiEvent.m_eventParams);
                    }
                    else
                    {
                        CUICommonSystem.SetButtonEnable(btn, false, false, true);
                    }
                    gameObject.CustomSetActive(true);
                }
            }
        }