133 lines
5.3 KiB
C#
133 lines
5.3 KiB
C#
|
//using System;
|
|||
|
//using System.Collections.Generic;
|
|||
|
//using System.Text;
|
|||
|
|
|||
|
//namespace ET
|
|||
|
//{
|
|||
|
|
|||
|
// public class PKTeamComponentAwakeSystem : AwakeSystem<PKTeamComponent>
|
|||
|
// {
|
|||
|
// public override void Awake(PKTeamComponent self)
|
|||
|
// {
|
|||
|
// PKTeamComponent.Instance = self;
|
|||
|
// }
|
|||
|
// }
|
|||
|
|
|||
|
// public class PKTeamComponentDestroySystem : DestroySystem<PKTeamComponent>
|
|||
|
// {
|
|||
|
// public override void Destroy(PKTeamComponent self)
|
|||
|
// {
|
|||
|
// self.Clear();
|
|||
|
// }
|
|||
|
// }
|
|||
|
// public static class PKTeamComponentSystem
|
|||
|
// {
|
|||
|
// /// <summary>
|
|||
|
// /// 创建PK队伍
|
|||
|
// /// </summary>
|
|||
|
// /// <param name="self"></param>
|
|||
|
// /// <param name="teamA"></param>
|
|||
|
// /// <param name="teamB"></param>
|
|||
|
// private static void CreatePKTeam(this PKTeamComponent self, Team teamA, Team teamB)
|
|||
|
// {
|
|||
|
// PKTeam pKTeam = EntityFactory.CreateWithParent<PKTeam>(self);
|
|||
|
// pKTeam.teamA = teamA;
|
|||
|
// pKTeam.teamB = teamB;
|
|||
|
// self.Add(pKTeam);
|
|||
|
// }
|
|||
|
|
|||
|
// /// <summary>
|
|||
|
// /// 初始化PK队伍
|
|||
|
// /// </summary>
|
|||
|
// /// <param name="self"></param>
|
|||
|
// /// <param name="unit"></param>
|
|||
|
// /// <param name="targetId"></param>
|
|||
|
// /// <returns></returns>
|
|||
|
// public static async ETTask<string> 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<UnitScene>().Position - targetUnit.GetComponent<UnitScene>().Position).sqrMagnitude > PosHelper.AtkDis)
|
|||
|
// {
|
|||
|
// Log.Error($"*【{ UserComponent.Instance.Get(unit.Id)?.NickName} ({ unit.Id})】位置{unit.GetComponent<UnitScene>().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<BattleComponent>().BattleType = BattleType.PK;
|
|||
|
// targetUnit.GetComponent<BattleComponent>().BattleType = BattleType.PK;
|
|||
|
|
|||
|
// Log.Info($"\n{team.GetMemberName()}开始PK战斗\n" +
|
|||
|
// $"对方队伍 name= {targetTeam.GetMemberName()}");
|
|||
|
// //!开启玩家和怪物的AI
|
|||
|
// targetTeam.GetComponent<PlayerSkillAIComponent>().StartBattle().Coroutine();
|
|||
|
// team.GetComponent<PlayerSkillAIComponent>().StartBattle().Coroutine();
|
|||
|
|
|||
|
// return string.Empty;
|
|||
|
// }
|
|||
|
// catch (Exception e)
|
|||
|
// {
|
|||
|
// Log.Error(e);
|
|||
|
// }
|
|||
|
// return string.Empty;
|
|||
|
// }
|
|||
|
// }
|
|||
|
//}
|