81 lines
2.0 KiB
C#
81 lines
2.0 KiB
C#
using ET;
|
|
using ET;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
|
|
namespace ET
|
|
{
|
|
|
|
public class TeamCpomponentAwakeSystem : AwakeSystem<TeamComponent>
|
|
{
|
|
public override void Awake(TeamComponent self)
|
|
{
|
|
|
|
}
|
|
}
|
|
public static class TeamComponentSystem
|
|
{
|
|
public static Team CreateTeam(this TeamComponent self,long id)
|
|
{
|
|
Team team = EntityFactory.CreateWithParent<Team>(self);
|
|
team.Id = id;
|
|
team.leaderId = id;
|
|
self.Add(team);
|
|
return team;
|
|
}
|
|
public static Team CreateEnermyTeam(this TeamComponent self)
|
|
{
|
|
Team team = self.GetEnermyTeam();
|
|
if (!team)
|
|
{
|
|
team = EntityFactory.CreateWithParent<Team>(self);
|
|
self.AddEnermyTeam(team);
|
|
}
|
|
team.RemoveAll();
|
|
return team;
|
|
}
|
|
public static void Clear(this TeamComponent self)
|
|
{
|
|
foreach (Team item in self.TeamDic.Values)
|
|
{
|
|
item.Dispose();
|
|
}
|
|
self.TeamDic.Clear();
|
|
if (self.enermyTeam != null)
|
|
{
|
|
self.enermyTeam.Dispose();
|
|
self.enermyTeam = null;
|
|
}
|
|
}
|
|
}
|
|
public class TeamComponent:Entity
|
|
{
|
|
public Dictionary<long, Team> TeamDic = new Dictionary<long, Team>();
|
|
public Team enermyTeam;
|
|
|
|
public void Add(Team team)
|
|
{
|
|
TeamDic.Add(team.Id, team);
|
|
}
|
|
public Team Get(long id)
|
|
{
|
|
TeamDic.TryGetValue(id, out Team team);
|
|
return team;
|
|
}
|
|
public IEnumerable<Team> GetAll()
|
|
{
|
|
return TeamDic.Values;
|
|
}
|
|
public void AddEnermyTeam(Team team)
|
|
{
|
|
enermyTeam= team;
|
|
}
|
|
public Team GetEnermyTeam()
|
|
{
|
|
return enermyTeam;
|
|
}
|
|
}
|
|
}
|