using ProtoBuf; using Thousandto.Plugins.Common; using Thousandto.Code.Center; using Thousandto.Cfg.Data; using Thousandto.Code.Global; using UnityEngine; using Thousandto.Core.Base; using Thousandto.Core.Asset; namespace Thousandto.Code.Logic.Network { /// /// 实现消息的回调方法 -- 战斗协议 /// public partial class HandleMsgResult : IHandleMsgResult { //使用技能 public void GS2U_ResUseSkill(MSG_Fight.ResUseSkill result) { Character c = GameCenter.GameSceneSystem.FindEntity(result.info.userID); if (c != null) { if (c.IsLocalPlayer()) { c.skillManager.HandleLocalPlayerUseSkill(result); } else if (c.IsLocalPet()) { c.skillManager.HandleLocalPetUseSkill(result); } else if(c.IsLocalFlySword()) { c.skillManager.HandleLocalFlySwordUseSkill(result); } else { c.skillManager.UseSkill(result); } } } //播放锁定弹道 public void GS2U_ResPlayLockTrajectory(MSG_Fight.ResPlayLockTrajectory result) { var owner = GameCenter.GameSceneSystem.FindEntity(result.info.userID); if (owner == null) return; var skillCfg = DeclareSkill.Get(result.info.skillID); if (skillCfg == null) return; var visualCfg = GameCenter.SkillVisualManager.Find(skillCfg.VisualDef); if (visualCfg == null) return; var eventInfo = visualCfg.FindEventByID(result.eventID) as PlayLockTrajectoryEventInfo; if (eventInfo == null) return; for (int i = 0; i < result.targetList.Count; ++i) { var target = GameCenter.GameSceneSystem.FindEntity(result.targetList[i]); if (target == null) { continue; } var initInfo = new LockTrajectoryObjInitInfo(owner, skillCfg, visualCfg, eventInfo, target); GameCenter.GameSceneSystem.RefreshLockTrajectoryObj(initInfo); } } //播放简单技能召唤物 public void GS2U_ResPlaySimpleSkillObject(MSG_Fight.ResPlaySimpleSkillObject result) { var owner = GameCenter.GameSceneSystem.FindEntity(result.info.userID); if (owner == null) return; var skillCfg = DeclareSkill.Get(result.info.skillID); if (skillCfg == null) return; var visualCfg = GameCenter.SkillVisualManager.Find(skillCfg.VisualDef); if (visualCfg == null) return; var eventInfo = visualCfg.FindEventByID(result.eventID) as PlaySimpleSkillObjectEventInfo; if (eventInfo == null) return; var initInfo = new SimpleSkillObjectInitInfo(result.ID, result.posX, result.posY, owner, skillCfg, visualCfg, eventInfo); GameCenter.GameSceneSystem.RefreshSimpleSkillObject(initInfo); } //播放技能召唤物 public void GS2U_ResPlaySkillObject(MSG_Fight.ResPlaySkillObject result) { var visualCfg = GameCenter.SkillVisualManager.Find(result.visualDef); if (visualCfg == null) return; var initInfo = new SkillObjectInitInfo(visualCfg, result); GameCenter.GameSceneSystem.RefreshSkillObject(initInfo); } //播放自身移动 public void GS2U_ResPlaySelfMove(MSG_Fight.ResPlaySelfMove result) { var character = GameCenter.GameSceneSystem.FindEntity(result.info.userID); if (character == null) return; var skillCfg = DeclareSkill.Get(result.info.skillID); if (skillCfg == null) return; var visCfg = GameCenter.SkillVisualManager.Find(skillCfg.VisualDef); if (visCfg == null) return; var info = visCfg.FindEventByID(result.eventID) as PlaySelfMoveEventInfo; if (info == null) return; character.Action_SkillMove(info, new Vector2(result.curPosX, result.curPosY), new Vector2(result.tarPosX, result.tarPosY)); } //播放受击效果 public void GS2U_ResPlayHitEffect(MSG_Fight.ResPlayHitEffect result) { var owner = GameCenter.GameSceneSystem.FindEntity(result.userID); if (owner == null) return; var hitInfo = HitEffectInfo.FindHitEffect(result.hitEventID); if (hitInfo == null) return; for (int i = 0; i < result.targets.Count; ++i) { var targetInfo = result.targets[i]; var target = GameCenter.GameSceneSystem.FindEntity(targetInfo.targetID); if (target == null) continue; if (owner is RemotePlayer && i == 0) { //模拟远程玩家的目标 var rp = owner as RemotePlayer; rp.SetCurSelectedTargetId(target.ID, true); } target.BeAttackedResponse(owner, hitInfo, targetInfo); } } //对象死亡 public void GS2U_ResObjDead(MSG_Fight.ResObjDead result) { NetHandler.OnResObjDead(result); } //血量改变 public void GS2U_ResHpChange(MSG_Fight.ResHpChange result) { var host = GameCenter.GameSceneSystem.FindEntity(result.ownId); if (host != null) { host.CurHP = (ulong)result.curHp; if (host.IsLocalPlayer()) { var lp = host as LocalPlayer; lp.CheckLifeHint(); } GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_HP_CHANGE,result.ownId); } } public void GS2U_ResRollMove(MSG_Fight.ResRollMove result) { Player rp = GameCenter.GameSceneSystem.FindEntity(result.userID); if (rp != null) { if (rp.IsLocalPlayer()) { GameCenter.InputSystem.RollDadgeHandler.OnServerRolldodge(); if (!rp.IsXState(EntityStateID.RollDodge)) { rp.skillManager.Clear(); rp.Action_RollDodge(new Vector2(result.moveToX, result.moveToY)); } } else { rp.skillManager.Clear(); //远程玩家翻滚,先设置到初始位置 rp.RayCastToGroundXOZ(new Vector2(result.selfX, result.selfY)); rp.Action_RollDodge(new Vector2(result.moveToX, result.moveToY)); } } } public void GS2U_ResUpdateFightState(MSG_Fight.ResUpdateFightState result) { Character c = GameCenter.GameSceneSystem.FindEntity(result.id); if (c != null) { c.StateManager.SetStateData(result.state); } else if (result.id == LocalPlayerRoot.LocalPlayerID && LocalPlayerRoot.LocalPlayer != null && LocalPlayerRoot.LocalPlayer.StateManager != null) { LocalPlayerRoot.LocalPlayer.StateManager.SetStateData(result.state); //LocalPlayerCache.StateManager.SetStateData(result.state); } } public void GS2U_ResUseSkillError(MSG_Fight.ResUseSkillError result) { } public void GS2U_ResChangeAttackDirRes(MSG_Fight.ResChangeAttackDirRes result) { //var host = GameCenter.GameSceneSystem.FindEntity(result.roleId); //if (!host.IsLocalPlayer()) //{ // host.SetDirection2d(new Vector2(result.dirX, result.dirY)); //} } //怪物护甲值改变 public void GS2U_ResMonsterHpChange(MSG_Fight.ResMonsterHpChange result) { var monster = GameCenter.GameSceneSystem.FindEntity(result.ownId); if (monster != null) { var frontArmor = monster.PropMoudle.CurArmor; monster.PropMoudle.CurArmor = result.armor; monster.CurHP = (ulong)result.curHp; if (frontArmor != result.armor && result.armor <= 0) { GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_SHOWPOJIA_EFFECT); } } } //狂轰乱炸副本特殊技能使用返回 public void GS2U_ResFlyPetCloneAttack(MSG_Fight.ResFlyPetCloneAttack result) { GameCenter.PushFixEvent(LogicEventDefine.EID_EVENT_ON_FLYPET_SKILLRESULT, result); } //同步灵力值 public void GS2U_ResWakanChange(MSG_Fight.ResWakanChange result) { var player = GameCenter.GameSceneSystem.FindEntity(result.ownId); if(player != null) { player.PropMoudle.CurLinLi = (ulong)result.curWakan; player.PropMoudle.SetBattleProp(AllBattleProp.LingLi, result.maxWakan); } } } }