protected override void OnEnter(ProcedureOwner procedureOwner) { base.OnEnter(procedureOwner); m_ProcedureOwner = procedureOwner; //初始化数据 InitData(); //显示第一个职业 GameEntry.Entity.ShowPoseRole(m_WarriorData); m_SelectRoleTypeId = (int)EntityTypeId.PlayerWarrior; //打开创建角色界面 RoleCreateFormParams data = new RoleCreateFormParams(); IDataTable <DRRoleName> nameDt = GameEntry.DataTable.GetDataTable <DRRoleName>(); DRRoleName[] allNames = nameDt.GetAllDataRows(); Queue <string> namesQueue = new Queue <string>(); for (int i = 0; i < allNames.Length; i++) { namesQueue.Enqueue(allNames[i].RoleName); } data.RandomNameQueue = namesQueue; data.OnClickRoleType = OnClickRoleType; data.OnClickCreateRole = OnClickCreateRole; GameEntry.UI.OpenUIForm(UIFormId.CreateRoleForm, data); }
protected override void OnOpen(object userData) { base.OnOpen(userData); RoleCreateFormParams data = (RoleCreateFormParams)userData; if (data == null) { Log.Warning("RoleCreateFormParams is invalid."); return; } m_WarriorButton.onClick.Add(() => { m_RoleInfoCtrl.selectedIndex = 0; if (data.OnClickRoleType != null) { data.OnClickRoleType.Invoke(1); } }); m_MagicButton.onClick.Add(() => { m_RoleInfoCtrl.selectedIndex = 1; if (data.OnClickRoleType != null) { data.OnClickRoleType.Invoke(2); } }); m_ArcherButton.onClick.Add(() => { m_RoleInfoCtrl.selectedIndex = 2; if (data.OnClickRoleType != null) { data.OnClickRoleType.Invoke(3); } }); m_RandomNames = data.RandomNameQueue; m_NameInput.text = GetName(); m_DiceButton.onClick.Add(() => { m_DiceButton.TweenRotate(360, 0.5f); m_DiceButton.rotation = 0; m_NameInput.text = GetName(); }); m_CreateRoleButton.onClick.Add(() => { if (m_NameInput.text == string.Empty) { Log.Warning("Name is invalid."); return; } if (data.OnClickCreateRole != null) { data.OnClickCreateRole.Invoke(m_NameInput.text); } }); }