311 lines
11 KiB
C#
311 lines
11 KiB
C#
using Cal.DataTable;
|
|
using ET.EventType;
|
|
using ET;
|
|
using FairyGUI;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using Sirenix.Utilities;
|
|
|
|
namespace ET
|
|
{
|
|
public class GMUIAwakeSyatem: AwakeSystem<GMUI>
|
|
{
|
|
public override void Awake(GMUI self)
|
|
{
|
|
self.Awake();
|
|
}
|
|
}
|
|
|
|
public class GMUIDestroySyatem: DestroySystem<GMUI>
|
|
{
|
|
public override void Destroy(GMUI self)
|
|
{
|
|
self.Destroy();
|
|
}
|
|
}
|
|
|
|
public class GMUI: Entity
|
|
{
|
|
public FUI_GMUI ui;
|
|
private Dictionary<string, long> dic;
|
|
private bool canSend;
|
|
private GMConfig gMConfig;
|
|
private ItemType itemType;
|
|
private bool isSearchUid;
|
|
private StringBuilder sb;
|
|
private Scene zoneScene;
|
|
|
|
public void Awake()
|
|
{
|
|
sb = new StringBuilder();
|
|
canSend = false;
|
|
isSearchUid = false;
|
|
AwakeAsync().Coroutine();
|
|
}
|
|
|
|
private async ETVoid AwakeAsync()
|
|
{
|
|
zoneScene = this.ZoneScene();
|
|
ui = GetParent<FUI_GMUI>();
|
|
ui.m_comType.self.selectedIndex = 0;
|
|
Register();
|
|
Load();
|
|
|
|
await ETTask.CompletedTask;
|
|
}
|
|
|
|
private void Register()
|
|
{
|
|
ui.m_inpUid.onSubmit.Set(() => { GetCharacter().Coroutine(); });
|
|
ui.m_btnUid.self.onClick.Set(() => { GetCharacter().Coroutine(); });
|
|
ui.m_comType.self.onChanged.Set(Load);
|
|
ui.m_comOp.self.onChanged.Set(() => { ShowOptionExampleText(ui.m_comOp.self.value); });
|
|
//发送
|
|
ui.m_btnSend.self.onClick.Set(async () =>
|
|
{
|
|
if (!ui.m_inpCmd.text.IsNullOrEmpty())
|
|
{
|
|
M2C_SendGMCMD ret_ = await zoneScene.GetComponent<SessionComponent>()
|
|
.Call<M2C_SendGMCMD>(new C2M_SendGMCMD { cmd = ui.m_inpCmd.text });
|
|
if (!ret_.Message.IsNullOrEmpty())
|
|
{
|
|
TipHelper.OpenUI(ret_.Message);
|
|
return;
|
|
}
|
|
|
|
return;
|
|
}
|
|
|
|
if (!canSend) return;
|
|
if (gMConfig == null) return;
|
|
if (gMConfig.ParamCount == 1)
|
|
{
|
|
if (ui.m_inpParam1.text.IsNullOrEmpty())
|
|
return;
|
|
}
|
|
else if (gMConfig.ParamCount == 2)
|
|
{
|
|
if (ui.m_inpParam1.text.IsNullOrEmpty())
|
|
return;
|
|
if (ui.m_inpParam2.text.IsNullOrEmpty())
|
|
return;
|
|
}
|
|
|
|
string cmd = null;
|
|
if (ui.m_comType.self.value == "othercmd")
|
|
{
|
|
cmd = $"othercmd/{ui.m_inpUid.text}/{ui.m_comOp.self.value}/{ui.m_inpParam1.text}/{ui.m_inpParam2.text}";
|
|
}
|
|
else
|
|
{
|
|
cmd = $"cmd/{ui.m_comOp.self.value}/{ui.m_inpParam1.text}/{ui.m_inpParam2.text}";
|
|
}
|
|
|
|
canSend = false;
|
|
M2C_SendGMCMD ret = await zoneScene.GetComponent<SessionComponent>().Call<M2C_SendGMCMD>(new C2M_SendGMCMD { cmd = cmd });
|
|
if (!ret.Message.IsNullOrEmpty())
|
|
{
|
|
TipHelper.OpenUI(ret.Message);
|
|
return;
|
|
}
|
|
});
|
|
ui.m_btnCheck.self.onClick.Set(() => { ShowResult(); });
|
|
ui.m_comItemType.self.onChanged.Set(() =>
|
|
{
|
|
if (int.TryParse(ui.m_comItemType.self.value, out int index))
|
|
{
|
|
if (index == 4)
|
|
{
|
|
isSearchUid = true;
|
|
return;
|
|
}
|
|
|
|
isSearchUid = false;
|
|
itemType = (ItemType) index;
|
|
}
|
|
});
|
|
ui.m_btnSearch.self.onClick.Set(async () =>
|
|
{
|
|
if (ui.m_inpSearch.text.IsNullOrEmpty())
|
|
return;
|
|
String itemName = ui.m_inpSearch.text;
|
|
sb.Clear();
|
|
if (isSearchUid)
|
|
{
|
|
var ret = await this.zoneScene.GetComponent<SessionComponent>()
|
|
.Call<M2C_GetUIDByName>(new C2M_GetUIDByName() { name = itemName });
|
|
if (!ret.Message.IsNullOrEmpty())
|
|
{
|
|
TipHelper.OpenUI(ret.Message);
|
|
return;
|
|
}
|
|
|
|
foreach (KV_string_int32 kv in ret.map)
|
|
{
|
|
sb.Append($"{kv.key} {kv.value}\n");
|
|
}
|
|
|
|
ui.m_inpSearchRet.text = this.sb.ToString();
|
|
return;
|
|
}
|
|
|
|
switch (itemType)
|
|
{
|
|
case ItemType.NoneItem:
|
|
break;
|
|
case ItemType.EquipItem:
|
|
foreach (EquipBase item in EquipBaseCategory.Instance.GetByName(itemName))
|
|
{
|
|
sb.Append($"{item.Name} {item.Id}\n");
|
|
}
|
|
|
|
ui.m_inpSearchRet.text = sb.ToString();
|
|
break;
|
|
case ItemType.GoodsItem:
|
|
foreach (GoodsBase item in GoodsBaseCategory.Instance.GetByName(itemName))
|
|
{
|
|
sb.Append($"{item.Name} {item.Id}\n");
|
|
}
|
|
|
|
ui.m_inpSearchRet.text = sb.ToString();
|
|
break;
|
|
case ItemType.MaterialsItem:
|
|
foreach (MaterialBase item in MaterialBaseCategory.Instance.GetByName(itemName))
|
|
{
|
|
sb.Append($"{item.Name} {item.Id}\n");
|
|
}
|
|
|
|
ui.m_inpSearchRet.text = sb.ToString();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
});
|
|
}
|
|
|
|
private void Load()
|
|
{
|
|
dic = GMConfigCategory.Instance.configByTypeDic[ui.m_comType.self.value];
|
|
string[] arr = dic.Keys.ToArray();
|
|
ui.m_comOp.self.values = arr;
|
|
for (int i = 0; i < arr.Length; i++)
|
|
{
|
|
string item = arr[i];
|
|
long id = dic[item];
|
|
GMConfig gMConfig = GMConfigCategory.Instance.Get(id);
|
|
arr[i] = gMConfig.Name;
|
|
}
|
|
|
|
ui.m_comOp.self.items = arr;
|
|
ShowOptionExampleText(ui.m_comOp.self.value);
|
|
}
|
|
|
|
private void ShowResult()
|
|
{
|
|
if (gMConfig == null) return;
|
|
canSend = true;
|
|
string ret = gMConfig.Result;
|
|
switch (ui.m_comOp.self.value)
|
|
{
|
|
default:
|
|
break;
|
|
case "sys":
|
|
ret = ret.Replace("{1}", ui.m_inpParam1.text);
|
|
break;
|
|
case "addItem":
|
|
{
|
|
if (!int.TryParse(ui.m_inpParam1.text, out int itemId)) return;
|
|
if (!int.TryParse(ui.m_inpParam2.text, out int count)) return;
|
|
ret = ret.Replace("{1}", BagHelper.GetIconName(itemId).Item1);
|
|
ret = ret.Replace("{2}", count.ToString());
|
|
}
|
|
break;
|
|
case "addLevel":
|
|
ret = ret.Replace("{1}", ui.m_inpParam1.text);
|
|
break;
|
|
case "addAllItem":
|
|
{
|
|
if (!int.TryParse(ui.m_inpParam1.text, out int itemId)) return;
|
|
if (!int.TryParse(ui.m_inpParam2.text, out int count)) return;
|
|
ret = ret.Replace("{1}", BagHelper.GetIconName(itemId).Item1);
|
|
ret = ret.Replace("{2}", count.ToString());
|
|
}
|
|
break;
|
|
case "modifyPwd":
|
|
{
|
|
ret = ret.Replace("{1}", ui.m_inpParam1.text);
|
|
ret = ret.Replace("{2}", ui.m_inpParam2.text);
|
|
}
|
|
break;
|
|
case "TransLevel":
|
|
ret.Replace("{1}", ui.m_inpParam1.text);
|
|
break;
|
|
case "passLevel":
|
|
{
|
|
if (!int.TryParse(ui.m_inpParam1.text, out int mapId)) return;
|
|
int sceneId = mapId / 100;
|
|
Sys_Scene sys_Scene = Sys_SceneCategory.Instance.Get(sceneId);
|
|
if (sys_Scene == null)
|
|
return;
|
|
int layer = mapId % 100;
|
|
if (layer > sys_Scene.Layers)
|
|
return;
|
|
ret = ret.Replace("{1}", sceneId.ToString());
|
|
ret = ret.Replace("{2}", layer.ToString());
|
|
}
|
|
break;
|
|
case "transJob":
|
|
if (int.TryParse(ui.m_inpParam1.text, out int job))
|
|
{
|
|
ret = ret.Replace("{1}", TabHelper.GetStrJob(job));
|
|
}
|
|
|
|
break;
|
|
}
|
|
|
|
if (ui.m_comType.self.value == "othercmd")
|
|
{
|
|
ret = "发给玩家:\n" + ui.m_txtInfo.text + "\n\n" + ret;
|
|
}
|
|
|
|
ui.m_txtResult.text = ret;
|
|
}
|
|
|
|
private async ETVoid GetCharacter()
|
|
{
|
|
if (!int.TryParse(ui.m_inpUid.text, out int id))
|
|
{
|
|
return;
|
|
}
|
|
|
|
M2C_GetUserInfo ret = await zoneScene.GetComponent<SessionComponent>().Call<M2C_GetUserInfo>(new C2M_GetUserInfo { Id = id });
|
|
if (!ret.Message.IsNullOrEmpty())
|
|
{
|
|
TipHelper.OpenUI(ret.Message);
|
|
return;
|
|
}
|
|
|
|
ui.m_txtInfo.text = $"uid:{id} 昵称:{ret.Name} 等级:{ret.Level} 职业:{CharacterHelper.GetJobTypeById(ret.JobId)}";
|
|
}
|
|
|
|
private void ShowOptionExampleText(string value)
|
|
{
|
|
if (!dic.TryGetValue(value, out long id))
|
|
{
|
|
ui.m_txtOp.text = $"未找到配置:{value}";
|
|
}
|
|
|
|
gMConfig = GMConfigCategory.Instance.Get(id);
|
|
ui.m_txtOp.text = gMConfig.Example;
|
|
ui.m_txtTip1.text = gMConfig.Param1Tip;
|
|
ui.m_txtTip.text = gMConfig.Param2Tip;
|
|
}
|
|
|
|
public void Destroy()
|
|
{
|
|
}
|
|
}
|
|
} |