From 6eb915c129fc90c6f4c82ae097dd6ffad5239efc Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 25 Jan 2021 14:28:30 +0800 Subject: +scripts --- .../Scripts/XMainClient/UI/XSelectCharView.cs | 318 +++++++++++++++++++++ 1 file changed, 318 insertions(+) create mode 100644 Client/Assets/Scripts/XMainClient/UI/XSelectCharView.cs (limited to 'Client/Assets/Scripts/XMainClient/UI/XSelectCharView.cs') diff --git a/Client/Assets/Scripts/XMainClient/UI/XSelectCharView.cs b/Client/Assets/Scripts/XMainClient/UI/XSelectCharView.cs new file mode 100644 index 00000000..c0cee4dd --- /dev/null +++ b/Client/Assets/Scripts/XMainClient/UI/XSelectCharView.cs @@ -0,0 +1,318 @@ +using System; +using KKSG; +using UILib; +using UnityEngine; +using XMainClient.UI.UICommon; +using XUpdater; +using XUtliPoolLib; + +namespace XMainClient.UI +{ + internal class XSelectCharView : DlgBase + { + public int SelectCharIndex + { + get + { + return this._currentSelectedIndex; + } + set + { + this._currentSelectedIndex = value; + } + } + + public override string fileName + { + get + { + return "SelectChar/DNSelectCharDlg"; + } + } + + public override int layer + { + get + { + return 1; + } + } + + private XSelectCharacterDocument _doc = null; + + private int _currentSelectedIndex = 0; + + public RandomName _randomNameReader = null; + + private bool _playForward = true; + + private bool _enterWorld = true; + + protected override void Init() + { + this._doc = XDocuments.GetSpecificDocument(XSelectCharacterDocument.uuID); + this._doc.View = this; + this._doc.CurrentProf = 0; + base.uiBehaviour.m_Version.SetText("v" + XSingleton.singleton.Version); + } + + protected override void OnShow() + { + base.OnShow(); + XSingleton.singleton.ShowLoginReconnect(); + } + + public override void RegisterEvent() + { + base.uiBehaviour.m_enterworld.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnEnterworldButtonClick)); + base.uiBehaviour.m_return.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnReturnClick)); + base.uiBehaviour.m_createRandom.RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnRandomNameClick)); + for (int i = 0; i < XGame.RoleCount; i++) + { + base.uiBehaviour.m_create_profp[i].RegisterSpriteClickEventHandler(new SpriteClickEventHandler(this.OnProfSelect)); + } + base.uiBehaviour.m_profTween.RegisterOnFinishEventHandler(new OnTweenFinishEventHandler(this.OnProfTweenFinish)); + } + + protected int FindSlotByUIIndex(int index) + { + return -1; + } + + private bool OnEnterworldButtonClick(IXUIButton go) + { + base.uiBehaviour.m_SelectTween.PlayTween(true, -1f); + this._doc.OnEnterWorld(); + return true; + } + + private bool OnReturnClick(IXUIButton go) + { + this._doc.OnSelectCharBack(); + return true; + } + + private void OnProfSelect(IXUISprite sp) + { + this._currentSelectedIndex = (int)sp.ID; + XSelectcharStage xselectcharStage = XSingleton.singleton.CurrentStage as XSelectcharStage; + bool flag = xselectcharStage != null; + if (flag) + { + xselectcharStage.ShowCharacter(this._currentSelectedIndex); + } + } + + private void OnProfTweenFinish(IXUITweenTool tween) + { + bool flag = !base.IsVisible(); + if (!flag) + { + this._playForward = !this._playForward; + bool flag2 = !this._playForward; + if (flag2) + { + this.SetProfIntro(this._doc.CurrentProf); + base.uiBehaviour.m_profTween.PlayTween(this._playForward, -1f); + } + } + } + + private void SetIntroPoint(int oplevel) + { + base.uiBehaviour.m_AttrPoint.FakeReturnAll(); + float x = base.uiBehaviour.m_AttrPoint.TplPos.x; + float y = base.uiBehaviour.m_AttrPoint.TplPos.y; + float num = (float)base.uiBehaviour.m_AttrPoint.TplWidth; + int @int = XSingleton.singleton.GetInt("ProfOperateLevelMax"); + for (int i = 0; i < @int; i++) + { + GameObject gameObject = base.uiBehaviour.m_AttrPoint.FetchGameObject(false); + IXUISprite ixuisprite = gameObject.transform.Find("Light").GetComponent("XUISprite") as IXUISprite; + gameObject.transform.localPosition = new Vector3(x + (float)i * num, y); + ixuisprite.SetAlpha((float)((i < oplevel) ? 1 : 0)); + } + base.uiBehaviour.m_AttrPoint.ActualReturnAll(false); + } + + private void SetProfIntro(int prof) + { + base.uiBehaviour.m_profName.spriteName = XSingleton.singleton.GetProfNameIcon(prof); + base.uiBehaviour.m_profDetail.SetText(XSingleton.singleton.GetProfIntro(prof)); + base.uiBehaviour.m_profType.SetText(XSingleton.singleton.GetProfTypeIntro(prof)); + this.SetIntroPoint((int)XSingleton.singleton.GetProfOperateLevel(prof)); + } + + public void SwitchProfession(int profID) + { + bool activeInHierarchy = base.uiBehaviour.m_selectFrame.gameObject.activeInHierarchy; + if (activeInHierarchy) + { + bool flag = this._doc.CurrentProf > 0; + if (flag) + { + this._playForward = true; + base.uiBehaviour.m_create_profp[this._doc.CurrentProf - 1].gameObject.transform.Find("Select").gameObject.SetActive(false); + } + else + { + this.SetProfIntro(profID); + this._playForward = false; + } + this._doc.CurrentProf = profID; + bool flag2 = this._doc.CurrentProf > 0; + if (flag2) + { + base.uiBehaviour.m_create_profp[this._doc.CurrentProf - 1].gameObject.transform.Find("Select").gameObject.SetActive(true); + base.uiBehaviour.m_profTween.PlayTween(this._playForward, -1f); + } + } + } + + private bool OnCreateCharButtonClick(IXUIButton go) + { + string text = base.uiBehaviour.m_createName.GetText(); + bool flag = text.Length == 0; + bool result; + if (flag) + { + result = true; + } + else + { + bool flag2 = XSingleton.singleton.HasNoRoleOnBackFlowServer(); + if (flag2) + { + string label = XSingleton.singleton.ReplaceReturn(XStringDefineProxy.GetString("FirstRoleOnBackServerTip")); + string @string = XStringDefineProxy.GetString("CREATE"); + string string2 = XStringDefineProxy.GetString("COMMON_CANCEL"); + XSingleton.singleton.ShowModalDialog(label, @string, string2, new ButtonClickEventHandler(this.CreateBackRole)); + } + else + { + XSingleton.singleton.CreateChar(text, (RoleType)this._doc.CurrentProf); + } + result = true; + } + return result; + } + + private bool CreateBackRole(IXUIButton button) + { + XSingleton.singleton.CloseModalDlg(); + XSingleton.singleton.CreateChar(base.uiBehaviour.m_createName.GetText(), (RoleType)this._doc.CurrentProf); + return true; + } + + public void SetCreateNameVisable(bool state) + { + base.uiBehaviour.m_createNameFrame.gameObject.SetActive(state); + } + + public void SetEnterGameVisable(bool state) + { + base.uiBehaviour.m_enterworld.SetVisible(state); + } + + private void OnRandomNameClick(IXUISprite uiSprite) + { + bool flag = this._randomNameReader == null; + if (flag) + { + this._randomNameReader = new RandomName(); + XSingleton.singleton.ReadFile("Table/RandomName", this._randomNameReader); + } + string text = ""; + string text2 = ""; + while (text == "") + { + int key = XSingleton.singleton.RandomInt(1, this._randomNameReader.Table.Length); + text = this._randomNameReader.GetByID(key).FirstName; + } + while (text2 == "") + { + int key2 = XSingleton.singleton.RandomInt(1, this._randomNameReader.Table.Length); + text2 = this._randomNameReader.GetByID(key2).LastName; + } + string text3 = text + text2; + base.uiBehaviour.m_createName.SetText(text3); + } + + public void ShowSelectCharGerenal() + { + base.uiBehaviour.m_return.SetVisible(true); + base.uiBehaviour.m_selectFrame.gameObject.SetActive(true); + base.uiBehaviour.m_createNameFrame.SetActive(false); + base.uiBehaviour.m_enterworld.gameObject.SetActive(false); + base.uiBehaviour.m_playerNameFrame.gameObject.SetActive(false); + this._enterWorld = true; + base.uiBehaviour.m_enterworld.SetEnable(true, false); + } + + public void ShowSelectCharSelected(string name, int level) + { + base.uiBehaviour.m_return.SetVisible(true); + base.uiBehaviour.m_selectFrame.gameObject.SetActive(true); + base.uiBehaviour.m_createNameFrame.SetActive(false); + base.uiBehaviour.m_enterworld.gameObject.SetActive(true); + base.uiBehaviour.m_enterworld.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnEnterworldButtonClick)); + base.uiBehaviour.m_enterWorldLabel.SetText(XStringDefineProxy.GetString("START_GAME")); + base.uiBehaviour.m_playerNameFrame.gameObject.SetActive(true); + base.uiBehaviour.m_playerNameLabel.SetText(name); + base.uiBehaviour.m_playerLevelLabel.SetText(string.Format("Lv.{0}", level)); + this._enterWorld = true; + base.uiBehaviour.m_enterworld.SetEnable(true, false); + } + + public void ShowSelectCharCreated() + { + base.uiBehaviour.m_return.SetVisible(true); + base.uiBehaviour.m_selectFrame.gameObject.SetActive(true); + base.uiBehaviour.m_enterworld.gameObject.SetActive(true); + base.uiBehaviour.m_enterworld.RegisterClickEventHandler(new ButtonClickEventHandler(this.OnCreateCharButtonClick)); + base.uiBehaviour.m_enterWorldLabel.SetText(XStringDefineProxy.GetString("CREATE_CHAR")); + base.uiBehaviour.m_playerNameFrame.gameObject.SetActive(false); + base.uiBehaviour.m_preLevel.SetText(""); + bool flag = XSingleton.singleton.HasNoRoleOnBackFlowServer(); + if (flag) + { + base.uiBehaviour.m_preLevel.SetText(string.Format("Lv.{0}", XSingleton.singleton.LoginExData.backflow_level)); + } + bool flag2 = !base.uiBehaviour.m_createName.IsVisible(); + if (flag2) + { + bool flag3 = base.uiBehaviour.m_createName.GetText().Length == 0; + if (flag3) + { + bool flag4 = XSingleton.singleton.playerInfo != null; + if (flag4) + { + string nickName = XSingleton.singleton.playerInfo.data.nickName; + base.uiBehaviour.m_createName.SetText(nickName); + } + else + { + this.OnRandomNameClick(null); + } + } + } + base.uiBehaviour.m_createNameFrame.SetActive(true); + } + + public override void OnUpdate() + { + base.OnUpdate(); + bool flag = base.uiBehaviour.m_createNameFrame != null && base.uiBehaviour.m_createNameFrame.activeSelf; + if (flag) + { + bool flag2 = base.uiBehaviour.m_createName.GetText().Length != 0; + bool flag3 = this._enterWorld != flag2; + if (flag3) + { + this._enterWorld = flag2; + base.uiBehaviour.m_enterworld.SetEnable(this._enterWorld, false); + } + } + } + } +} -- cgit v1.1-26-g67d0