342 lines
8.6 KiB
C#
342 lines
8.6 KiB
C#
using UnityEditor;
|
||
using UnityEngine;
|
||
|
||
using System;
|
||
using Newtonsoft.Json;
|
||
using System.Collections.Generic;
|
||
|
||
|
||
[Serializable]
|
||
public class GMActorBaseProp
|
||
{
|
||
public uint id;
|
||
public uint prop;
|
||
}
|
||
|
||
[Serializable]
|
||
public class GMActorBase
|
||
{
|
||
public string account_id;
|
||
public string nickname;
|
||
public GMActorBaseProp[] props;
|
||
|
||
public void OnGUI()
|
||
{
|
||
EditorGUILayout.LabelField("基础属性:");
|
||
GUILayout.BeginHorizontal();
|
||
EditorGUILayout.LabelField("账号:" + account_id);
|
||
EditorGUILayout.LabelField("昵称:" + nickname);
|
||
GUILayout.EndHorizontal();
|
||
|
||
EditorGUILayout.Space(5);
|
||
|
||
for (int i = 0; i < props.Length; i++)
|
||
{
|
||
EditorGUILayout.LabelField($"{((NLDPB.ActorProp)props[i].id).ToString()} : {props[i].prop}");
|
||
}
|
||
}
|
||
}
|
||
|
||
[Serializable]
|
||
public class GMActorItemInfo
|
||
{
|
||
public uint id;
|
||
public uint count;
|
||
|
||
public void OnGUI()
|
||
{
|
||
EditorGUILayout.LabelField($"ID:{id}, 数量:{count}");
|
||
}
|
||
}
|
||
|
||
[Serializable]
|
||
public class GMActorItem
|
||
{
|
||
public GMActorItemInfo[] infos;
|
||
|
||
public void OnGUI()
|
||
{
|
||
EditorGUILayout.LabelField("物品数据:");
|
||
|
||
int PerRowCount = 5;
|
||
int rowCount = Mathf.CeilToInt((float)infos.Length / PerRowCount);
|
||
|
||
for (int r = 0; r < rowCount; r++)
|
||
{
|
||
EditorGUILayout.BeginHorizontal();
|
||
|
||
for (int c = 0; c < PerRowCount; c++)
|
||
{
|
||
int cIndex = r * PerRowCount + c;
|
||
if (cIndex >= infos.Length)
|
||
break;
|
||
|
||
infos[cIndex].OnGUI();
|
||
}
|
||
|
||
EditorGUILayout.EndHorizontal();
|
||
EditorGUILayout.Space(5);
|
||
}
|
||
}
|
||
}
|
||
|
||
[Serializable]
|
||
public class GMActorCharacterInfo
|
||
{
|
||
public uint id;
|
||
public uint exp;
|
||
public uint level;
|
||
public uint break_level;
|
||
public uint awake_level;
|
||
public uint likely_exp;
|
||
public uint likely_level;
|
||
public uint ultra_skill_level;
|
||
public uint skin_id;
|
||
|
||
private Texture2D imageHead;
|
||
private string Nickname;
|
||
|
||
public cfg.CharacterCfg.DataCharacterAttri Init()
|
||
{
|
||
var cfg = Framework.EditorTableManager.instance.tables.CharacterAttri.Get((int)id);
|
||
if(cfg != null)
|
||
{
|
||
var skinCfg= Framework.EditorTableManager.instance.tables.SkinCfg.Get(Framework.Constants.DEFULT_SKINID,(int)id);
|
||
imageHead = AssetDatabase.LoadAssetAtPath<Texture2D>($"Assets/Art/UI/Texture/Icon/HeadPic/{skinCfg.PIcHeadPath}.png");
|
||
Nickname = cfg.NickName;
|
||
}
|
||
else
|
||
{
|
||
Debug.LogError("GMActorCharacterInfo Init Character cfg not exist, id=" + id);
|
||
}
|
||
|
||
return cfg;
|
||
}
|
||
|
||
public void OnGUI()
|
||
{
|
||
if(imageHead == null)
|
||
{
|
||
GUILayout.BeginVertical();
|
||
EditorGUILayout.LabelField("角色ID:" + id);
|
||
EditorGUILayout.LabelField("昵称:" + Nickname);
|
||
EditorGUILayout.LabelField("经验:" + exp);
|
||
EditorGUILayout.LabelField("等级:" + level);
|
||
EditorGUILayout.LabelField("突破等级:" + break_level);
|
||
EditorGUILayout.LabelField("觉醒等级:" + awake_level);
|
||
EditorGUILayout.LabelField("好感度经验:" + likely_exp);
|
||
EditorGUILayout.LabelField("好感度等级:" + likely_level);
|
||
EditorGUILayout.LabelField("主动技能等级:" + ultra_skill_level);
|
||
EditorGUILayout.LabelField("皮肤ID:" + skin_id);
|
||
GUILayout.EndVertical();
|
||
}
|
||
else
|
||
{
|
||
|
||
GUILayout.BeginHorizontal();
|
||
GUILayout.Label(imageHead, GUILayout.Width(imageHead.width), GUILayout.Height(imageHead.height));
|
||
|
||
GUILayout.BeginVertical();
|
||
EditorGUILayout.LabelField("角色ID:" + id);
|
||
EditorGUILayout.LabelField("昵称:" + Nickname);
|
||
EditorGUILayout.LabelField("经验:" + exp);
|
||
EditorGUILayout.LabelField("等级:" + level);
|
||
EditorGUILayout.LabelField("突破等级:" + break_level);
|
||
EditorGUILayout.LabelField("觉醒等级:" + awake_level);
|
||
EditorGUILayout.LabelField("好感度经验:" + likely_exp);
|
||
EditorGUILayout.LabelField("好感度等级:" + likely_level);
|
||
EditorGUILayout.LabelField("主动技能等级:" + ultra_skill_level);
|
||
EditorGUILayout.LabelField("皮肤ID:" + skin_id);
|
||
GUILayout.EndVertical();
|
||
GUILayout.EndHorizontal();
|
||
}
|
||
|
||
}
|
||
}
|
||
|
||
[Serializable]
|
||
public class GMActorCharacter
|
||
{
|
||
public GMActorCharacterInfo[] infos;
|
||
|
||
public void Init()
|
||
{
|
||
GMPart.CharacterSelectList = new List<GMCharacterSelect>();
|
||
List<string> names = new List<string>();
|
||
|
||
for(int i = 0; i < infos.Length; i ++)
|
||
{
|
||
var cfg = infos[i].Init();
|
||
if(cfg != null)
|
||
{
|
||
GMCharacterSelect select = new GMCharacterSelect();
|
||
select.ID = infos[i].id;
|
||
select.Name = cfg.NickName;
|
||
GMPart.CharacterSelectList.Add(select);
|
||
|
||
names.Add(select.Name);
|
||
}
|
||
}
|
||
|
||
GMPart.CharacterSelectNames = names.ToArray();
|
||
}
|
||
|
||
public void OnGUI()
|
||
{
|
||
EditorGUILayout.LabelField("角色数据:");
|
||
int characterRow = 3;
|
||
int rowCount = Mathf.CeilToInt((float)infos.Length / characterRow);
|
||
|
||
for (int r = 0; r < rowCount; r++)
|
||
{
|
||
EditorGUILayout.BeginHorizontal();
|
||
|
||
for (int c = 0; c < characterRow; c++)
|
||
{
|
||
int cIndex = r * characterRow + c;
|
||
if (cIndex >= infos.Length)
|
||
break;
|
||
|
||
infos[cIndex].OnGUI();
|
||
}
|
||
|
||
EditorGUILayout.EndHorizontal();
|
||
EditorGUILayout.Space(5);
|
||
}
|
||
}
|
||
}
|
||
|
||
[Serializable]
|
||
public class GMActorLogicCount
|
||
{
|
||
public uint id;
|
||
public uint value;
|
||
}
|
||
|
||
[Serializable]
|
||
public class GMActorLogic
|
||
{
|
||
public GMActorLogicCount[] count_list;
|
||
}
|
||
|
||
[Serializable]
|
||
public class GMActorTask
|
||
{
|
||
public uint id;
|
||
public uint count;
|
||
public uint total;
|
||
public uint count_id;
|
||
public bool is_claimed;
|
||
}
|
||
|
||
[Serializable]
|
||
public class GMActorTaskContainer
|
||
{
|
||
public uint type;
|
||
public uint id;
|
||
public uint time;
|
||
public GMActorTask[] tasks;
|
||
}
|
||
|
||
[Serializable]
|
||
public class GMActorTasks
|
||
{
|
||
public uint version;
|
||
public GMActorTaskContainer[] containers;
|
||
}
|
||
|
||
[Serializable]
|
||
public class GMActor
|
||
{
|
||
public GMActorBase abase;
|
||
public GMActorItem items;
|
||
public GMActorCharacter characters;
|
||
public GMActorLogic logic;
|
||
public GMActorTasks task;
|
||
|
||
Vector2 scrollPosition;
|
||
|
||
public void Init()
|
||
{
|
||
characters.Init();
|
||
}
|
||
|
||
public void OnGUI()
|
||
{
|
||
scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);
|
||
GUILayout.BeginVertical();
|
||
abase.OnGUI();
|
||
|
||
EditorGUILayout.Space(5);
|
||
items.OnGUI();
|
||
|
||
EditorGUILayout.Space(5);
|
||
characters.OnGUI();
|
||
GUILayout.EndVertical();
|
||
EditorGUILayout.EndScrollView();
|
||
}
|
||
}
|
||
|
||
[Serializable]
|
||
public class ActorInfoResult
|
||
{
|
||
public uint code;
|
||
public GMActor result;
|
||
public string message;
|
||
}
|
||
|
||
|
||
public class GMPartActorInfo : GMPart
|
||
{
|
||
ActorInfoResult aiResult;
|
||
|
||
public override void Init()
|
||
{
|
||
|
||
}
|
||
|
||
public override string GetName()
|
||
{
|
||
return "查询账号数据";
|
||
}
|
||
|
||
public override void OnTabGUI()
|
||
{
|
||
|
||
}
|
||
|
||
public override void OnOKGUI()
|
||
{
|
||
aiResult.result.OnGUI();
|
||
}
|
||
|
||
public override string GetURL(string token, string ip, string actor)
|
||
{
|
||
return $"http://{ip}/gm?actor_id={actor}&command=ActorInfo&gm_token={token}";
|
||
}
|
||
|
||
public override uint DoJsonDeserialize(string json, out string message)
|
||
{
|
||
uint code;
|
||
try
|
||
{
|
||
aiResult = JsonConvert.DeserializeObject<ActorInfoResult>(json);
|
||
|
||
GMPart.Actor = aiResult.result;
|
||
GMPart.Actor.Init();
|
||
|
||
message = aiResult.message;
|
||
code = aiResult.code;
|
||
}
|
||
catch
|
||
{
|
||
Debug.LogError("json error, json=" + json);
|
||
message = "json error, json=" + json;
|
||
code = 1000;
|
||
}
|
||
|
||
return code;
|
||
}
|
||
|
||
}
|