134 lines
3.3 KiB
C#
134 lines
3.3 KiB
C#
using System;
|
|
using Newtonsoft.Json;
|
|
using UnityEngine;
|
|
using UnityEditor;
|
|
using System.Collections.Generic;
|
|
|
|
|
|
public class GMPartCharacterBreak : GMPart
|
|
{
|
|
CommonResult result;
|
|
|
|
List<GMCharacterParam> setList;
|
|
public override string GetName()
|
|
{
|
|
return "角色突破";
|
|
}
|
|
|
|
public override void Init()
|
|
{
|
|
if(GMPart.CharacterSelectList == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
if(GMPart.CharacterSelectList.Count <= 0)
|
|
return;
|
|
|
|
setList = new List<GMCharacterParam>();
|
|
setList.Add(GMPart.NewCharacterParam());
|
|
}
|
|
|
|
public override void OnTabGUI()
|
|
{
|
|
if(GMPart.CharacterSelectList == null)
|
|
{
|
|
EditorGUILayout.LabelField("请先执行查询账号数据");
|
|
return;
|
|
}
|
|
|
|
if(GMPart.CharacterSelectList.Count <= 0)
|
|
{
|
|
EditorGUILayout.LabelField("当前还没有角色数据,请先添加角色");
|
|
return;
|
|
}
|
|
|
|
for (int i = 0; i < setList.Count; )
|
|
{
|
|
GUILayout.BeginHorizontal();
|
|
|
|
EditorGUILayout.LabelField("角色:", GUILayout.Width(100f));
|
|
var select = EditorGUILayout.Popup(setList[i].select, GMPart.CharacterSelectNames);
|
|
if(select != setList[i].select)
|
|
{
|
|
setList[i].select = select;
|
|
setList[i].id = GMPart.CharacterSelectList[select].ID;
|
|
}
|
|
|
|
EditorGUILayout.Space(20);
|
|
|
|
string levelStr = EditorGUILayout.TextField("突破等级:", setList[i].level.ToString());
|
|
try
|
|
{
|
|
uint level = Convert.ToUInt32(levelStr);
|
|
if (level != setList[i].level)
|
|
setList[i].level = level;
|
|
}
|
|
catch
|
|
{
|
|
|
|
}
|
|
|
|
if (GUILayout.Button("删除"))
|
|
{
|
|
setList.RemoveAt(i);
|
|
}
|
|
else
|
|
{
|
|
i++;
|
|
}
|
|
|
|
GUILayout.EndHorizontal();
|
|
}
|
|
|
|
if (GUILayout.Button("增加"))
|
|
{
|
|
setList.Add(GMPart.NewCharacterParam());
|
|
}
|
|
}
|
|
|
|
public override void OnOKGUI()
|
|
{
|
|
EditorGUILayout.LabelField(result.message);
|
|
}
|
|
|
|
public override string GetURL(string token, string ip, string actor)
|
|
{
|
|
if (setList.Count <= 0)
|
|
return null;
|
|
|
|
string param = "";
|
|
for (int i = 0; i < setList.Count; i++)
|
|
{
|
|
if (setList[i].id <= 0 || setList[i].level <= 0)
|
|
return null;
|
|
|
|
if (string.IsNullOrEmpty(param))
|
|
param = $"{setList[i].id},{setList[i].level}";
|
|
else
|
|
param += $",{setList[i].id},{setList[i].level}";
|
|
}
|
|
|
|
return $"http://{ip}/gm?actor_id={actor}&gm_token={token}&command=SetCharacterBreak¶m={param}";
|
|
}
|
|
|
|
public override uint DoJsonDeserialize(string json, out string message)
|
|
{
|
|
uint code;
|
|
try
|
|
{
|
|
result = JsonConvert.DeserializeObject<CommonResult>(json);
|
|
message = result.message;
|
|
code = result.code;
|
|
}
|
|
catch
|
|
{
|
|
Debug.LogError("json error, json=" + json);
|
|
message = "json error, json=" + json;
|
|
code = 1000;
|
|
}
|
|
|
|
return code;
|
|
}
|
|
}
|