//using System; //using System.Collections.Generic; //using System.Text; //namespace ET //{ // public class PKTeamComponentAwakeSystem : AwakeSystem // { // public override void Awake(PKTeamComponent self) // { // PKTeamComponent.Instance = self; // } // } // public class PKTeamComponentDestroySystem : DestroySystem // { // public override void Destroy(PKTeamComponent self) // { // self.Clear(); // } // } // public static class PKTeamComponentSystem // { // /// // /// 创建PK队伍 // /// // /// // /// // /// // private static void CreatePKTeam(this PKTeamComponent self, Team teamA, Team teamB) // { // PKTeam pKTeam = EntityFactory.CreateWithParent(self); // pKTeam.teamA = teamA; // pKTeam.teamB = teamB; // self.Add(pKTeam); // } // /// // /// 初始化PK队伍 // /// // /// // /// // /// // /// // public static async ETTask InitPK(this PKTeamComponent self, Unit unit, long targetId) // { // try // { // if (!unit.IsTeamLeader) // { // return "您不是队长!"; // } // Unit targetUnit = UnitComponent.Instance.Get(targetId); // if (targetUnit == null) return "对方不在线!"; // if (unit.TeamLeaderId == targetUnit.TeamLeaderId) return "不能跟队友PK"; // Team team = TeamComponent.Instance.Get(unit.TeamLeaderId); // if (team.TeamState == TeamState.Fight) // { // Log.Error($"*【{ UserComponent.Instance.Get(unit.Id)?.NickName} ({ unit.Id})】多次进行PK战斗"); // return "系统错误"; // } // Team targetTeam = TeamComponent.Instance.Get(targetUnit.TeamLeaderId); // if (targetTeam.TeamState == TeamState.Fight) return "对方在战斗中"; // if ((unit.GetComponent().Position - targetUnit.GetComponent().Position).sqrMagnitude > PosHelper.AtkDis) // { // Log.Error($"*【{ UserComponent.Instance.Get(unit.Id)?.NickName} ({ unit.Id})】位置{unit.GetComponent().Position}错误"); // return "系统错误"; // } // //!双方设置为战斗状态 // team.ChangeState(TeamState.Fight); // targetTeam.TeamState = TeamState.Fight; // //!设置每个人的状态 // foreach (var u in team.GetUnits()) // { // await Game.EventSystem.Publish(new EventType.BattleStart { unit = u, team = team }); // } // foreach (var u in targetTeam.GetUnits()) // { // await Game.EventSystem.Publish(new EventType.BattleStart { unit = u, team = targetTeam }); // } // self.CreatePKTeam(team, targetTeam); // //!设置击破信息 // MainStoryMap.Instance.InitKillInfo(unit.TeamLeaderId, targetTeam.MemberCount); // MainStoryMap.Instance.InitKillInfo(targetUnit.TeamLeaderId, team.MemberCount); // //!初始化交互信息 // //MainStoryMap.Instance.InitBattleInteractiveInfo(unit.TeamLeaderId); // //MainStoryMap.Instance.InitBattleInteractiveInfo(targetUnit.TeamLeaderId); // //!同步血量 // await Game.EventSystem.Publish(new EventType.ChangeAllUnitCharacter { team = team }); // //!给双方通知 // var sendProto = new M2C_SendStartPK(); // sendProto.TargetIdList.AddRange(targetTeam.GetUnitIds()); // foreach (var u in team.GetUnits()) // { // MessageHelper.SendActor(u, sendProto); // } // sendProto.TargetIdList.Clear(); // sendProto.TargetIdList.AddRange(team.GetUnitIds()); // foreach (var u in targetTeam.GetUnits()) // { // MessageHelper.SendActor(u, sendProto); // } // unit.GetComponent().BattleType = BattleType.PK; // targetUnit.GetComponent().BattleType = BattleType.PK; // Log.Info($"\n{team.GetMemberName()}开始PK战斗\n" + // $"对方队伍 name= {targetTeam.GetMemberName()}"); // //!开启玩家和怪物的AI // targetTeam.GetComponent().StartBattle().Coroutine(); // team.GetComponent().StartBattle().Coroutine(); // return string.Empty; // } // catch (Exception e) // { // Log.Error(e); // } // return string.Empty; // } // } //}