160 lines
4.7 KiB
C#
160 lines
4.7 KiB
C#
using ET;
|
|
using ET;
|
|
using libx;
|
|
using Sirenix.OdinInspector;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using UnityEditor;
|
|
using UnityEngine;
|
|
|
|
namespace Cal
|
|
{
|
|
[ExecuteInEditMode]
|
|
[CreateAssetMenu]
|
|
public class Setup : Sirenix.OdinInspector.SerializedScriptableObject
|
|
{
|
|
public string key;
|
|
public string keyIV;
|
|
public static byte[] xorKey;
|
|
public string _xorKey;
|
|
public string XorKey => _xorKey;
|
|
|
|
|
|
private Setuper setuper;
|
|
|
|
[Button("启动"),PropertyOrder(-1)]
|
|
[PropertySpace(SpaceAfter = 35)]
|
|
private void Start()
|
|
{
|
|
setuper = new Setuper(key,keyIV,_xorKey);
|
|
}
|
|
|
|
[Button("开始游戏"),PropertyOrder(0)]
|
|
private void StartGame()
|
|
{
|
|
Updater updater = Game.Scene.GetComponent<Updater>();
|
|
updater.StartUpdate();
|
|
zoneScene = Game.Scene.Get(1);
|
|
}
|
|
public int sceneId = 1;
|
|
[Button("创建新zoneScene"), PropertyOrder(0)]
|
|
private void CreateScene()
|
|
{
|
|
zoneScene = SceneFactory.CreateZoneScene( sceneId, "机器人"+sceneId);
|
|
sceneDic.Add(zoneScene.Id, zoneScene);
|
|
sceneSelectedId = sceneId;
|
|
Game.EventSystem.Publish(new ET.EventType.DownloadInitResourceFinish
|
|
{
|
|
|
|
}).Coroutine();
|
|
sceneId++;
|
|
}
|
|
public Dictionary<long,Scene> sceneDic = new Dictionary<long,Scene>();
|
|
private IEnumerable<long> GetScene()
|
|
{
|
|
return sceneDic.Keys;
|
|
}
|
|
private void SetScene()
|
|
{
|
|
zoneScene = sceneDic[sceneSelectedId];
|
|
}
|
|
[LabelText("场景选择"), PropertyOrder(1)]
|
|
[ValueDropdown("GetScene")]
|
|
[OnValueChanged("SetScene")]
|
|
public long sceneSelectedId;
|
|
private Scene zoneScene;
|
|
[LabelText("帐号"),PropertyOrder(1)]
|
|
public string acc;
|
|
[LabelText("密码"),PropertyOrder(1)]
|
|
public string pwd;
|
|
[Button("登录"),PropertyOrder(2)]
|
|
[ButtonGroup("Login")]
|
|
private void Login()
|
|
{
|
|
LoginHelper.OnLoginAsync(zoneScene, acc, pwd, LoginType.Editor).Coroutine();
|
|
}
|
|
[Button("进入游戏"), PropertyOrder(3)]
|
|
[ButtonGroup("Login")]
|
|
private void EnterGame()
|
|
{
|
|
EnterGameHelper.EnterGameAsync(zoneScene).Coroutine();
|
|
}
|
|
|
|
[Button("托管"), PropertyOrder(3)]
|
|
[ButtonGroup("Battle")]
|
|
private async void AutoBattle()
|
|
{
|
|
EnterGameHelper.EnterGameAsync(zoneScene).Coroutine();
|
|
var ret = await SessionComponent.Instance.Call<M2C_AutoBattle>(new C2M_AutoBattle());
|
|
if (!ret.Message.IsNullOrEmpty())
|
|
{
|
|
ET.Log.Error($"{ret.Message}");
|
|
return;
|
|
}
|
|
}
|
|
[LabelText("挂机章节")]
|
|
public int idleBattleSceneId = 1;
|
|
[Button("开始战斗"), PropertyOrder(2)]
|
|
[ButtonGroup("Battle")]
|
|
private async void StartBattle()
|
|
{
|
|
var ret = await SessionComponent.Instance.Call<M2C_StartBattleIdleFight>(new C2M_StartBattleIdleFight { SceneId = idleBattleSceneId });
|
|
if (!ret.Message.IsNullOrEmpty())
|
|
{
|
|
ET.Log.Error($"{ret.Message}");
|
|
return;
|
|
}
|
|
}
|
|
[Button("结束战斗"), PropertyOrder(3)]
|
|
[ButtonGroup("Battle")]
|
|
private async void EndBattle()
|
|
{
|
|
var ret = await SessionComponent.Instance.Call<M2C_EndBattleIdleFight>(new C2M_EndBattleIdleFight {});
|
|
if (!ret.Message.IsNullOrEmpty())
|
|
{
|
|
ET.Log.Error($"{ret.Message}");
|
|
return;
|
|
}
|
|
}
|
|
[PropertySpace(35)]
|
|
[Button("关闭"),PropertyOrder(100)]
|
|
private void End()
|
|
{
|
|
try
|
|
{
|
|
sceneDic.Clear();
|
|
sceneId = 2;
|
|
setuper.Close();
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
finally
|
|
{
|
|
try
|
|
{
|
|
var arr = GameObject.Find("Global").GetComponentsInChildren<ComponentView>();
|
|
for (int i = arr.Length - 1; i >= 0; i--)
|
|
{
|
|
DestroyImmediate(arr[i].gameObject);
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
throw;
|
|
}
|
|
}
|
|
EditorUtility.SetDirty(this);
|
|
AssetDatabase.Refresh();
|
|
}
|
|
|
|
}
|
|
}
|