|
@@ -2,33 +2,30 @@
|
|
|
using CommonAI.ZoneClient;
|
|
|
using CommonLang;
|
|
|
using ET.Client;
|
|
|
-using Microsoft.Cci;
|
|
|
-using System;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Data;
|
|
|
using System.IO;
|
|
|
-using System.Net;
|
|
|
-using System.Runtime.InteropServices.ComTypes;
|
|
|
-using XmdsCommon.Message;
|
|
|
|
|
|
namespace ET
|
|
|
{
|
|
|
+ [FriendOf(typeof(UnitListComponent))]
|
|
|
public class BattleMgr : Singleton<BattleMgr>, ISingletonUpdate, ILayerClient
|
|
|
{
|
|
|
private bool isInited = false;
|
|
|
public ZoneLayer Layer;
|
|
|
private readonly MemoryStream writeBuffer = new MemoryStream(2048);
|
|
|
+ private EventDispatcher eventDispather;
|
|
|
|
|
|
public async ETTask InitAsync()
|
|
|
{
|
|
|
+ eventDispather = new EventDispatcher();
|
|
|
+ registerEventHandler();
|
|
|
Layer = TemplateManager.Factory.CreateClientZoneLayer(BattleResourceMgr.Instance.GameEditorTemplates, this);
|
|
|
+ Layer.ActorSyncMode = SyncMode.ForceByServer;
|
|
|
|
|
|
- Layer.LayerInit += OnLayerInit;
|
|
|
- Layer.ObjectEnter += OnObjectEnter;
|
|
|
- Layer.ObjectLeave += OnObjectLeave;
|
|
|
- Layer.PlayerLeave += RemovePlayerInfo;
|
|
|
- //Layer.MessageReceived += xxLayer_MessageReceived;
|
|
|
- Layer.DecorationChanged += Layer_DecorationChanged;
|
|
|
+ Layer.LayerInit += LayerEvent_Init;
|
|
|
+ Layer.ObjectEnter += LayerEvent_ObjectEnter;
|
|
|
+ Layer.ObjectLeave += LayerEvent_ObjectLeave;
|
|
|
+ Layer.MessageReceived += LayerEvent_MessageReceived;
|
|
|
+ Layer.DecorationChanged += LayerEvent_DecorationChanged;
|
|
|
isInited = true;
|
|
|
|
|
|
await ETTask.CompletedTask;
|
|
@@ -42,12 +39,14 @@ namespace ET
|
|
|
Layer.Update();
|
|
|
}
|
|
|
|
|
|
+ //ILayerClient接口实现,供layer层调用
|
|
|
+ //layer层在收到LockActorEvent消息后调用
|
|
|
void ILayerClient.BattleReady(bool bok)
|
|
|
{
|
|
|
- Log.Debug("battle ready.......");
|
|
|
- //throw new System.NotImplementedException();
|
|
|
+ Log.Debug($"battle ready......{bok}");
|
|
|
}
|
|
|
|
|
|
+ //ILayerClient接口实现,供layer层调用
|
|
|
//layer层中需要发送消息到战斗服
|
|
|
public void SendAction(CommonAI.Zone.Action action)
|
|
|
{
|
|
@@ -56,338 +55,356 @@ namespace ET
|
|
|
Log.Error("playerComponent is null");
|
|
|
return;
|
|
|
}
|
|
|
+ Log.Debug($">>>Send BattleMsg: {action.GetType()}");
|
|
|
|
|
|
writeBuffer.Position = 0;
|
|
|
if (BattleResourceMgr.Instance.BattleMsgDecoder.doEncode(writeBuffer, action))
|
|
|
{
|
|
|
- var param = new BattleEventPushToServer() { data = writeBuffer.ToArray() };
|
|
|
- PlayerComponent.Instance.ClientScene().GetComponent<SessionComponent>().Session.Send(param);
|
|
|
+ PlayerComponent.Instance.ClientScene().GetComponent<SessionComponent>().Session.Send(new BattleEventPushToServer() { data = writeBuffer.ToArray() });
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//客户端自己模拟创建消息,发送到zonelayer层处理
|
|
|
- public void PostMsg2Layer(IMessage msg)
|
|
|
+ public void PostMsg2Layer(CommonLang.Protocol.IMessage msg)
|
|
|
{
|
|
|
}
|
|
|
|
|
|
- protected void OnLayerInit(CommonAI.ZoneClient.ZoneLayer layer)
|
|
|
+ //layer层在处理好战斗服推送的ClientEnterScene消息后回调
|
|
|
+ protected void LayerEvent_Init(CommonAI.ZoneClient.ZoneLayer layer)
|
|
|
{
|
|
|
- Log.Debug("OnLayerInit");
|
|
|
+ Log.Debug($"OnLayerInit- scene template ID:{layer.Data.ID}");
|
|
|
+
|
|
|
}
|
|
|
|
|
|
//单位进入战斗
|
|
|
- protected void OnObjectEnter(ZoneLayer layer, ZoneObject obj)
|
|
|
+ protected void LayerEvent_ObjectEnter(ZoneLayer layer, ZoneObject obj)
|
|
|
{
|
|
|
Log.Debug($"OnObjectEnter: {obj.Name}");
|
|
|
+
|
|
|
+ var unit = BattleUnitFactory.Instance.Create(obj);
|
|
|
+ if(unit != null )
|
|
|
+ {
|
|
|
+ if(unit is BattleActor)
|
|
|
+ {
|
|
|
+ UnitListComponent.Instance.Actor = unit as BattleActor;
|
|
|
+ }
|
|
|
+ UnitListComponent.Instance.UnitList.Add(obj.ObjectID, unit);
|
|
|
+ unit.OnAwake(obj);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Log.Error($"unknow object enter:{obj.Name} ID:{obj.ObjectID}");
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
//单位离开战斗
|
|
|
- protected void OnObjectLeave(ZoneLayer layer, ZoneObject obj)
|
|
|
+ protected void LayerEvent_ObjectLeave(ZoneLayer layer, ZoneObject obj)
|
|
|
{
|
|
|
Log.Debug($"OnObjectLeave: {obj.Name}");
|
|
|
- }
|
|
|
- public void RemovePlayerInfo(ZoneLayer layer, ZoneObject obj)
|
|
|
- {
|
|
|
- Log.Debug($"RemovePlayerInfo: {obj.Name}");
|
|
|
- /*ComAICell cell = null;
|
|
|
- if (allUnits.TryGetValue(obj.ObjectID, out cell))
|
|
|
+
|
|
|
+ var unit = UnitListComponent.Instance.UnitList.Get(obj.ObjectID);
|
|
|
+ if(unit == null)
|
|
|
{
|
|
|
- if (!(cell is ComAIPlayer)) return;
|
|
|
- var player = cell as ComAIPlayer;
|
|
|
- var info = player.GetVirtual().GetBaseInfo();
|
|
|
- if (info == null || string.IsNullOrEmpty(info.uuid) || !allPlayers.ContainsKey(info.uuid)) return;
|
|
|
- grassStealth.DelPlayer(player);
|
|
|
- allPlayers.Remove(info.uuid);
|
|
|
- if (UnitLoadOkCallBack.ContainsKey(info.uuid)) UnitLoadOkCallBack.Remove(info.uuid);
|
|
|
- }*/
|
|
|
+ Log.Error($"LayerEvent_ObjectLeave not exist:{obj.Name}:{obj.ObjectID}");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ unit.OnSleep();
|
|
|
+ UnitListComponent.Instance.UnitList.Remove(obj.ObjectID);
|
|
|
}
|
|
|
|
|
|
- protected void Layer_DecorationChanged(CommonAI.ZoneClient.ZoneLayer layer, CommonAI.ZoneClient.ZoneEditorDecoration ed)
|
|
|
+ protected void LayerEvent_DecorationChanged(CommonAI.ZoneClient.ZoneLayer layer, CommonAI.ZoneClient.ZoneEditorDecoration ed)
|
|
|
{
|
|
|
- Log.Debug("Layer_DecorationChanged");
|
|
|
+ Log.Error("Layer_DecorationChanged");
|
|
|
/*DataMgr.Instance.RegionManager.OnDecorationChanged(ed);
|
|
|
if (mDecoMgr != null)
|
|
|
{
|
|
|
mDecoMgr.OnStateChange(ed);
|
|
|
}*/
|
|
|
}
|
|
|
- /*private void OnEventHandler(CommonAI.Zone.Event e)
|
|
|
-{
|
|
|
- if (e is SyncPosEvent || e is Pong)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
|
|
|
- if (e is ChatEvent)
|
|
|
- {
|
|
|
- var evt = (e as ChatEvent);
|
|
|
- var msg = evt.Message;
|
|
|
- var evt_param = msg.Split('|');
|
|
|
- if (evt_param.Length >= 2 && evt_param[0] == "Notice.Msg")
|
|
|
- {
|
|
|
- var dic = GameUtil.GetDBData("NoticeMsg", int.Parse(evt_param[1]));
|
|
|
- if (dic != null)
|
|
|
+ protected void LayerEvent_MessageReceived(CommonAI.ZoneClient.ZoneLayer layer, CommonLang.Protocol.IMessage msg)
|
|
|
+ {
|
|
|
+ if (!(msg is CommonAI.Zone.Event) || msg is SyncPosEvent || msg is Pong)
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ eventDispather.Notfify(msg as ObjectEvent);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void registerEventHandler()
|
|
|
+ {
|
|
|
+ /*var e = msg as CommonAI.Zone.Event;
|
|
|
+ if (e is ChatEvent)
|
|
|
+ {
|
|
|
+ var evt = (e as ChatEvent);
|
|
|
+ var message = evt.Message;
|
|
|
+ var evt_param = message.Split('|');
|
|
|
+ if (evt_param.Length >= 2 && evt_param[0] == "Notice.Msg")
|
|
|
+ {
|
|
|
+ var dic = GameUtil.GetDBData("NoticeMsg", int.Parse(evt_param[1]));
|
|
|
+ if (dic != null)
|
|
|
+ {
|
|
|
+ string result = "";
|
|
|
+ if (evt_param.Length >= 3 && evt_param[2] != null)
|
|
|
+ {
|
|
|
+ //根据参数个数 依次填值
|
|
|
+ string[] par = evt_param[2].Split('.');
|
|
|
+ if (par != null && par.Length > 0)
|
|
|
+ {
|
|
|
+ switch (par.Length)
|
|
|
+ {
|
|
|
+ case 1:
|
|
|
+ {
|
|
|
+ result = Average(dic["MsgContent"] as string, par[0]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 2:
|
|
|
+ {
|
|
|
+ result = Average(dic["MsgContent"] as string, par[0], par[1]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 3:
|
|
|
+ {
|
|
|
+ result = Average(dic["MsgContent"] as string, par[0], par[1], par[2]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 4:
|
|
|
+ {
|
|
|
+ result = Average(dic["MsgContent"] as string, par[0], par[1], par[2], par[3]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ case 5:
|
|
|
+ {
|
|
|
+ result = Average(dic["MsgContent"] as string, par[0], par[1], par[2], par[3], par[4]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //没有参数
|
|
|
+ result = (dic["MsgContent"] as string);
|
|
|
+ }
|
|
|
+ //
|
|
|
+ EventManager.Fire("Event.OnEventHandler.star", new Dictionary<string, string>() {
|
|
|
+ {"content", result}, {"keepTime", "" + (evt.KeepTimeMS/1000)}, {"content_is_text", "true"}
|
|
|
+ });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ YXJDebug.logError("config not exist >" + msg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (evt_param.Length == 2)
|
|
|
+ {
|
|
|
+ string funcName = "GlobalHooks." + evt_param[0];
|
|
|
+ object[] param = evt_param[1].Split(',');
|
|
|
+ //Client.GetMainState().GetFunction(funcName).LazyCall(param);
|
|
|
+ if (param.Length == 0)
|
|
|
+ Client.GetMainState().Call(funcName, Client.LogMiss);
|
|
|
+ else if (param.Length == 1)
|
|
|
+ Client.GetMainState().Call(funcName, param[0], Client.LogMiss);
|
|
|
+ else if (param.Length == 2)
|
|
|
+ Client.GetMainState().Call(funcName, param[0], param[1], Client.LogMiss);
|
|
|
+ else if (param.Length == 3)
|
|
|
+ Client.GetMainState().Call(funcName, param[0], param[1], param[2], Client.LogMiss);
|
|
|
+ else if (param.Length == 4)
|
|
|
+ Client.GetMainState().Call(funcName, param[0], param[1], param[2], param[3], Client.LogMiss);
|
|
|
+ else if (param.Length == 5)
|
|
|
+ Client.GetMainState().Call(funcName, param[0], param[1], param[2], param[3], param[4], Client.LogMiss);
|
|
|
+ else
|
|
|
+ {
|
|
|
+ YXJDebug.logError("BattleClientBase.OnEventHandler Error!funcName is {0}", funcName);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //位面进入退出效果
|
|
|
+ if (msg == "EnterAOI")
|
|
|
+ {
|
|
|
+ var wwe = Camera.main.GetComponent<WaterWaveEffect>();
|
|
|
+ if (wwe != null)
|
|
|
+ {
|
|
|
+ wwe.SetParam(40, -30, 3, 2);
|
|
|
+ wwe.play();
|
|
|
+ }
|
|
|
+ //GameAlertManager.Instance.setAutoAnimiVisible(false);
|
|
|
+ InAOI = true;
|
|
|
+ }
|
|
|
+ else if (msg == "LeaveAOI")
|
|
|
+ {
|
|
|
+ var wwe = Camera.main.GetComponent<WaterWaveEffect>();
|
|
|
+ if (wwe != null)
|
|
|
+ {
|
|
|
+ wwe.SetParam(40, -30, 3, 2);
|
|
|
+ wwe.play();
|
|
|
+ }
|
|
|
+ InAOI = false;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ //普通chatevent
|
|
|
+ EventManager.Fire("Event.OnEventHandler.star", new Dictionary<string, string>() {
|
|
|
+ {"content", msg}, {"isImportant", "1"}, {"keepTime", "" + (evt.KeepTimeMS/1000)}
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else if (e is CommonAI.Zone.ZoneEvent)
|
|
|
{
|
|
|
- string result = "";
|
|
|
- if (evt_param.Length >= 3 && evt_param[2] != null)
|
|
|
+ if (e is BubbleTalkEvent)
|
|
|
{
|
|
|
- //根据参数个数 依次填值
|
|
|
- string[] par = evt_param[2].Split('.');
|
|
|
- if (par != null && par.Length > 0)
|
|
|
+ BubbleTalkEvent evt = e as BubbleTalkEvent;
|
|
|
+ if (evt.TalkInfos != null)
|
|
|
{
|
|
|
- switch (par.Length)
|
|
|
+ foreach (var info in evt.TalkInfos)
|
|
|
{
|
|
|
- case 1:
|
|
|
+ System.Action callback = delegate ()
|
|
|
+ {
|
|
|
+ if (info.TalkUnit == 0)
|
|
|
{
|
|
|
- result = Average(dic["MsgContent"] as string, par[0]);
|
|
|
- break;
|
|
|
+ YXJDebug.logError("旁白气泡还没有实现>{0}", info.TalkContent);
|
|
|
+ return;
|
|
|
}
|
|
|
- case 2:
|
|
|
+
|
|
|
+ ComAIUnit unit = GetUnitById(info.TalkUnit) as ComAIUnit;
|
|
|
+ if (unit == null)
|
|
|
{
|
|
|
- result = Average(dic["MsgContent"] as string, par[0], par[1]);
|
|
|
- break;
|
|
|
+ if (info.TalkContent != "bubblechat")
|
|
|
+ {
|
|
|
+ YXJDebug.logDebug(">BubbleTalkEvent unit not exist: {0}>>{1}", info.TalkUnit, info.TalkContent);
|
|
|
+ }
|
|
|
+ return;
|
|
|
}
|
|
|
- case 3:
|
|
|
+
|
|
|
+ if (info.TalkContent == "bubblechat")
|
|
|
{
|
|
|
- result = Average(dic["MsgContent"] as string, par[0], par[1], par[2]);
|
|
|
- break;
|
|
|
+ UIBridgeManager.Instance.QuestUIBridge.BubbleTalkEventSend(unit);
|
|
|
}
|
|
|
- case 4:
|
|
|
+ else
|
|
|
{
|
|
|
- result = Average(dic["MsgContent"] as string, par[0], par[1], par[2], par[3]);
|
|
|
- break;
|
|
|
+ var txt = ConfigMgr.Instance.TxtCfg.GetTextByKey("GameEditor_" + info.TalkContent);
|
|
|
+ unit.AddBubbleChat(txt, info.TalkKeepTimeMS / 1000);
|
|
|
}
|
|
|
- case 5:
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(info.TalkActionType))
|
|
|
{
|
|
|
- result = Average(dic["MsgContent"] as string, par[0], par[1], par[2], par[3], par[4]);
|
|
|
- break;
|
|
|
+ unit.PlayAnimationWhileIdle(info.TalkActionType);
|
|
|
}
|
|
|
+ };
|
|
|
+
|
|
|
+ if (info.TalkDelayTimeMS > 0)
|
|
|
+ {
|
|
|
+ GameGlobal.Instance.StartCoroutine(WaitForSeconds(info.TalkDelayTimeMS / 1000, callback));
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ callback.Invoke();
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- else
|
|
|
+ else if (e is AddEffectEvent && battleManager != null)
|
|
|
{
|
|
|
- //没有参数
|
|
|
- result = (dic["MsgContent"] as string);
|
|
|
+ AddEffectEvent evt = e as AddEffectEvent;
|
|
|
+ if (evt.hostId == 0 || GetUnitById(evt.hostId) != null)
|
|
|
+ {
|
|
|
+ Vector3 pos = battleManager.GetU3DPosByUnitCell(evt.x, evt.y);
|
|
|
+ pos = ComAICell.AdjustHeight(pos);
|
|
|
+ Quaternion rotation = Quaternion.Euler(0, evt.direction * Mathf.Rad2Deg + 90, 0);
|
|
|
+ EffectPlayer.SetRotationOnetime(rotation); //--->这个功能加个参数不就好了 →_→
|
|
|
+ EffectPlayer.Play(evt.effect, pos, false);
|
|
|
+ }
|
|
|
}
|
|
|
- //
|
|
|
- EventManager.Fire("Event.OnEventHandler.star", new Dictionary<string, string>() {
|
|
|
- {"content", result}, {"keepTime", "" + (evt.KeepTimeMS/1000)}, {"content_is_text", "true"}
|
|
|
- });
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- YXJDebug.logError("config not exist >" + msg);
|
|
|
- }
|
|
|
- }
|
|
|
- else if (evt_param.Length == 2)
|
|
|
- {
|
|
|
- string funcName = "GlobalHooks." + evt_param[0];
|
|
|
- object[] param = evt_param[1].Split(',');
|
|
|
- //Client.GetMainState().GetFunction(funcName).LazyCall(param);
|
|
|
- if (param.Length == 0)
|
|
|
- Client.GetMainState().Call(funcName, Client.LogMiss);
|
|
|
- else if (param.Length == 1)
|
|
|
- Client.GetMainState().Call(funcName, param[0], Client.LogMiss);
|
|
|
- else if (param.Length == 2)
|
|
|
- Client.GetMainState().Call(funcName, param[0], param[1], Client.LogMiss);
|
|
|
- else if (param.Length == 3)
|
|
|
- Client.GetMainState().Call(funcName, param[0], param[1], param[2], Client.LogMiss);
|
|
|
- else if (param.Length == 4)
|
|
|
- Client.GetMainState().Call(funcName, param[0], param[1], param[2], param[3], Client.LogMiss);
|
|
|
- else if (param.Length == 5)
|
|
|
- Client.GetMainState().Call(funcName, param[0], param[1], param[2], param[3], param[4], Client.LogMiss);
|
|
|
- else
|
|
|
- {
|
|
|
- YXJDebug.logError("BattleClientBase.OnEventHandler Error!funcName is {0}", funcName);
|
|
|
- }
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //位面进入退出效果
|
|
|
- if (msg == "EnterAOI")
|
|
|
- {
|
|
|
- var wwe = Camera.main.GetComponent<WaterWaveEffect>();
|
|
|
- if (wwe != null)
|
|
|
+ else if (e is AddEffectEvent2 && battleManager != null)
|
|
|
{
|
|
|
- wwe.SetParam(40, -30, 3, 2);
|
|
|
- wwe.play();
|
|
|
+ AddEffectEvent2 evt = e as AddEffectEvent2;
|
|
|
+ if (evt.hostId == 0 || GetUnitById(evt.hostId) != null)
|
|
|
+ {
|
|
|
+ Vector3 pos = battleManager.GetU3DPosByUnitCell(evt.x, evt.y);
|
|
|
+ pos = ComAICell.AdjustHeight(pos);
|
|
|
+ Vector3 targetPos = battleManager.GetU3DPosByUnitCell(evt.TargetX, evt.TargetY);
|
|
|
+ EffectPlayer.PlayLocal(evt.effect, pos, false, 0, 0, 0, 0, evt.ET, targetPos, evt.FollowActor);
|
|
|
+ }
|
|
|
}
|
|
|
- //GameAlertManager.Instance.setAutoAnimiVisible(false);
|
|
|
- InAOI = true;
|
|
|
- }
|
|
|
- else if (msg == "LeaveAOI")
|
|
|
- {
|
|
|
- var wwe = Camera.main.GetComponent<WaterWaveEffect>();
|
|
|
- if (wwe != null)
|
|
|
+ else if (e is SyncEnvironmentVarEvent)
|
|
|
{
|
|
|
- wwe.SetParam(40, -30, 3, 2);
|
|
|
- wwe.play();
|
|
|
+ SyncEnvironmentVarEvent evt = e as SyncEnvironmentVarEvent;
|
|
|
+ UIBridgeManager.Instance.BattleUIBridge.EnvironmentVarChange(evt.Key, evt.Value);
|
|
|
}
|
|
|
- InAOI = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //普通chatevent
|
|
|
- EventManager.Fire("Event.OnEventHandler.star", new Dictionary<string, string>() {
|
|
|
- {"content", msg}, {"isImportant", "1"}, {"keepTime", "" + (evt.KeepTimeMS/1000)}
|
|
|
- });
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- else if (e is CommonAI.Zone.ZoneEvent)
|
|
|
- {
|
|
|
- if (e is BubbleTalkEvent)
|
|
|
- {
|
|
|
- BubbleTalkEvent evt = e as BubbleTalkEvent;
|
|
|
- if (evt.TalkInfos != null)
|
|
|
- {
|
|
|
- foreach (var info in evt.TalkInfos)
|
|
|
+ else if (e is ScriptCommandEvent)
|
|
|
{
|
|
|
- System.Action callback = delegate ()
|
|
|
+ ScriptCommandEvent evt = e as ScriptCommandEvent;
|
|
|
+ string[] evt_param = evt.message.Split('|');
|
|
|
+ if (evt_param.Length == 2)
|
|
|
{
|
|
|
- if (info.TalkUnit == 0)
|
|
|
- {
|
|
|
- YXJDebug.logError("旁白气泡还没有实现>{0}", info.TalkContent);
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- ComAIUnit unit = GetUnitById(info.TalkUnit) as ComAIUnit;
|
|
|
- if (unit == null)
|
|
|
- {
|
|
|
- if (info.TalkContent != "bubblechat")
|
|
|
- {
|
|
|
- YXJDebug.logDebug(">BubbleTalkEvent unit not exist: {0}>>{1}", info.TalkUnit, info.TalkContent);
|
|
|
- }
|
|
|
- return;
|
|
|
- }
|
|
|
-
|
|
|
- if (info.TalkContent == "bubblechat")
|
|
|
- {
|
|
|
- UIBridgeManager.Instance.QuestUIBridge.BubbleTalkEventSend(unit);
|
|
|
- }
|
|
|
+ object[] param = evt_param[1].Split(',');
|
|
|
+ string funcName = "GlobalHooks." + evt_param[0];
|
|
|
+ if (param.Length == 0)
|
|
|
+ Client.GetMainState().Call(funcName, Client.LogMiss);
|
|
|
+ else if (param.Length == 1)
|
|
|
+ Client.GetMainState().Call(funcName, param[0], Client.LogMiss);
|
|
|
+ else if (param.Length == 2)
|
|
|
+ Client.GetMainState().Call(funcName, param[0], param[1], Client.LogMiss);
|
|
|
+ else if (param.Length == 3)
|
|
|
+ Client.GetMainState().Call(funcName, param[0], param[1], param[2], Client.LogMiss);
|
|
|
+ else if (param.Length == 4)
|
|
|
+ Client.GetMainState().Call(funcName, param[0], param[1], param[2], param[3], Client.LogMiss);
|
|
|
+ else if (param.Length == 5)
|
|
|
+ Client.GetMainState().Call(funcName, param[0], param[1], param[2], param[3], param[4], Client.LogMiss);
|
|
|
else
|
|
|
{
|
|
|
- var txt = ConfigMgr.Instance.TxtCfg.GetTextByKey("GameEditor_" + info.TalkContent);
|
|
|
- unit.AddBubbleChat(txt, info.TalkKeepTimeMS / 1000);
|
|
|
- }
|
|
|
-
|
|
|
- if (!string.IsNullOrEmpty(info.TalkActionType))
|
|
|
- {
|
|
|
- unit.PlayAnimationWhileIdle(info.TalkActionType);
|
|
|
+ YXJDebug.logError("BattleClientBase.OnEventHandler Error!funcName is {0}", funcName);
|
|
|
}
|
|
|
- };
|
|
|
-
|
|
|
- if (info.TalkDelayTimeMS > 0)
|
|
|
- {
|
|
|
- GameGlobal.Instance.StartCoroutine(WaitForSeconds(info.TalkDelayTimeMS / 1000, callback));
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- callback.Invoke();
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- if (e is AddEffectEvent && battleManager != null)
|
|
|
- {
|
|
|
- AddEffectEvent evt = e as AddEffectEvent;
|
|
|
- if (evt.hostId == 0 || GetUnitById(evt.hostId) != null)
|
|
|
- {
|
|
|
- Vector3 pos = battleManager.GetU3DPosByUnitCell(evt.x, evt.y);
|
|
|
- pos = ComAICell.AdjustHeight(pos);
|
|
|
- Quaternion rotation = Quaternion.Euler(0, evt.direction * Mathf.Rad2Deg + 90, 0);
|
|
|
- EffectPlayer.SetRotationOnetime(rotation); //--->这个功能加个参数不就好了 →_→
|
|
|
- EffectPlayer.Play(evt.effect, pos, false);
|
|
|
- }
|
|
|
- }
|
|
|
- else if (e is AddEffectEvent2 && battleManager != null)
|
|
|
- {
|
|
|
- AddEffectEvent2 evt = e as AddEffectEvent2;
|
|
|
- if (evt.hostId == 0 || GetUnitById(evt.hostId) != null)
|
|
|
- {
|
|
|
- Vector3 pos = battleManager.GetU3DPosByUnitCell(evt.x, evt.y);
|
|
|
- pos = ComAICell.AdjustHeight(pos);
|
|
|
- Vector3 targetPos = battleManager.GetU3DPosByUnitCell(evt.TargetX, evt.TargetY);
|
|
|
- EffectPlayer.PlayLocal(evt.effect, pos, false, 0, 0, 0, 0, evt.ET, targetPos, evt.FollowActor);
|
|
|
- }
|
|
|
- }
|
|
|
- else if (e is SyncEnvironmentVarEvent)
|
|
|
- {
|
|
|
- SyncEnvironmentVarEvent evt = e as SyncEnvironmentVarEvent;
|
|
|
- UIBridgeManager.Instance.BattleUIBridge.EnvironmentVarChange(evt.Key, evt.Value);
|
|
|
- }
|
|
|
- else if (e is ScriptCommandEvent)
|
|
|
- {
|
|
|
- ScriptCommandEvent evt = e as ScriptCommandEvent;
|
|
|
- string[] evt_param = evt.message.Split('|');
|
|
|
- if (evt_param.Length == 2)
|
|
|
- {
|
|
|
- object[] param = evt_param[1].Split(',');
|
|
|
- string funcName = "GlobalHooks." + evt_param[0];
|
|
|
- if (param.Length == 0)
|
|
|
- Client.GetMainState().Call(funcName, Client.LogMiss);
|
|
|
- else if (param.Length == 1)
|
|
|
- Client.GetMainState().Call(funcName, param[0], Client.LogMiss);
|
|
|
- else if (param.Length == 2)
|
|
|
- Client.GetMainState().Call(funcName, param[0], param[1], Client.LogMiss);
|
|
|
- else if (param.Length == 3)
|
|
|
- Client.GetMainState().Call(funcName, param[0], param[1], param[2], Client.LogMiss);
|
|
|
- else if (param.Length == 4)
|
|
|
- Client.GetMainState().Call(funcName, param[0], param[1], param[2], param[3], Client.LogMiss);
|
|
|
- else if (param.Length == 5)
|
|
|
- Client.GetMainState().Call(funcName, param[0], param[1], param[2], param[3], param[4], Client.LogMiss);
|
|
|
+ else if (e is LockActorEvent)
|
|
|
+ {
|
|
|
+ LockActorEvent evt = e as LockActorEvent;
|
|
|
+ OnLockActorEvent(evt);
|
|
|
+ }
|
|
|
+ else if (e is ScriptAddUnitEventsB2C)
|
|
|
+ {
|
|
|
+ ScriptAddUnitEventsB2C evt = e as ScriptAddUnitEventsB2C;
|
|
|
+ OnScriptAddUnitEvent(evt);
|
|
|
+ }
|
|
|
+ else if (e is ScriptRemoveUnitEventsB2C)
|
|
|
+ {
|
|
|
+ ScriptRemoveUnitEventsB2C evt = e as ScriptRemoveUnitEventsB2C;
|
|
|
+ OnScriptRemoveUnitEvents(evt);
|
|
|
+ }
|
|
|
+ else if (e is PlaySoundEventB2CForAll)
|
|
|
+ {
|
|
|
+ PlaySoundEventB2CForAll evt = e as PlaySoundEventB2CForAll;
|
|
|
+ XmdsSoundManager.GetXmdsInstance().PlaySound(evt.SoundName);
|
|
|
+ }
|
|
|
+ else if (e is SyncFlagsEvent && mDecoMgr != null)
|
|
|
+ {
|
|
|
+ mDecoMgr.LoadDecos();
|
|
|
+ }
|
|
|
+ else if (e is ChangeBGMEvent)
|
|
|
+ {
|
|
|
+ XmdsSoundManager.GetXmdsInstance().ChangeBGM((e as ChangeBGMEvent).FileName);
|
|
|
+ }
|
|
|
+ else if (e is PlayDestoryEffect)
|
|
|
+ {
|
|
|
+ if (EffectPlayer == null) return;
|
|
|
+ PlayDestoryEffect destoryEffect = e as PlayDestoryEffect;
|
|
|
+ Vector3 vec = new Vector3(destoryEffect.X, destoryEffect.Y, destoryEffect.Z);
|
|
|
+ Quaternion rotation = Quaternion.Euler(0, destoryEffect.Direction * Mathf.Rad2Deg + 90, 0);
|
|
|
+ LaunchEffect effect = new LaunchEffect();
|
|
|
+ effect.Name = destoryEffect.EffectName;
|
|
|
+ EffectPlayer.SetRotationOnetime(rotation);
|
|
|
+ EffectPlayer.Play(effect, vec, true);
|
|
|
+ }
|
|
|
else
|
|
|
{
|
|
|
- YXJDebug.logError("BattleClientBase.OnEventHandler Error!funcName is {0}", funcName);
|
|
|
+ //YXJDebug.logInfo("OnEventHandler not implemented! {0}", e.ToString());
|
|
|
}
|
|
|
- }
|
|
|
- }
|
|
|
- else if (e is LockActorEvent)
|
|
|
- {
|
|
|
- LockActorEvent evt = e as LockActorEvent;
|
|
|
- OnLockActorEvent(evt);
|
|
|
- }
|
|
|
- else if (e is ScriptAddUnitEventsB2C)
|
|
|
- {
|
|
|
- ScriptAddUnitEventsB2C evt = e as ScriptAddUnitEventsB2C;
|
|
|
- OnScriptAddUnitEvent(evt);
|
|
|
- }
|
|
|
- else if (e is ScriptRemoveUnitEventsB2C)
|
|
|
- {
|
|
|
- ScriptRemoveUnitEventsB2C evt = e as ScriptRemoveUnitEventsB2C;
|
|
|
- OnScriptRemoveUnitEvents(evt);
|
|
|
- }
|
|
|
- else if (e is PlaySoundEventB2CForAll)
|
|
|
- {
|
|
|
- PlaySoundEventB2CForAll evt = e as PlaySoundEventB2CForAll;
|
|
|
- XmdsSoundManager.GetXmdsInstance().PlaySound(evt.SoundName);
|
|
|
- }
|
|
|
- else if (e is SyncFlagsEvent && mDecoMgr != null)
|
|
|
- {
|
|
|
- mDecoMgr.LoadDecos();
|
|
|
- }
|
|
|
- else if (e is ChangeBGMEvent)
|
|
|
- {
|
|
|
- XmdsSoundManager.GetXmdsInstance().ChangeBGM((e as ChangeBGMEvent).FileName);
|
|
|
- }
|
|
|
- else if (e is PlayDestoryEffect)
|
|
|
- {
|
|
|
- if (EffectPlayer == null) return;
|
|
|
- PlayDestoryEffect destoryEffect = e as PlayDestoryEffect;
|
|
|
- Vector3 vec = new Vector3(destoryEffect.X, destoryEffect.Y, destoryEffect.Z);
|
|
|
- Quaternion rotation = Quaternion.Euler(0, destoryEffect.Direction * Mathf.Rad2Deg + 90, 0);
|
|
|
- LaunchEffect effect = new LaunchEffect();
|
|
|
- effect.Name = destoryEffect.EffectName;
|
|
|
- EffectPlayer.SetRotationOnetime(rotation);
|
|
|
- EffectPlayer.Play(effect, vec, true);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- //YXJDebug.logInfo("OnEventHandler not implemented! {0}", e.ToString());
|
|
|
- }
|
|
|
- }
|
|
|
-}*/
|
|
|
+ }*/
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|