一.火焰灼烧Timer
public class FlameCavalryTimer_1 : PLCommonBasicMissionTimer
{
private Mission _mission;
public FlameCavalryTimer_1(Mission mission, float triggerInterval, bool isTriggerOnce) : base(triggerInterval, isTriggerOnce)
{
_mission = mission;
}
public override void TriggerTimerScript()
{
try
{
BrunEnemyAround();
}
catch (Exception ex)
{
File.AppendAllLines(PLModuleConstans.ModuleCrashLogPath, new string[] { ex.ToString(), ex.Message, ex.StackTrace });
}
}
private void BrunEnemyAround()
{
_mission.Agents.ForEach(cavalryAgent =>
{
if (cavalryAgent.IsHuman && cavalryAgent.Team.IsFriendOf(_mission.PlayerTeam))
{
MBList<Agent> enemyAgentList = new MBList<Agent>();
_mission.GetNearbyEnemyAgents(new Vec2(cavalryAgent.Frame.origin.x, cavalryAgent.Frame.origin.y), 2f, cavalryAgent.Team, enemyAgentList);
foreach (Agent enemyAgent in enemyAgentList)
{
PLDamageUtilities.GiveDamageToEnemey(cavalryAgent, enemyAgent, 60);
}
}
});
}
}
二.火骑兵Timer
public class FlameCavalryTimer_2 : PLCommonBasicMissionTimer
{
private Mission _mission;
public FlameCavalryTimer_2(Mission mission, float triggerInterval, bool isTriggerOnce) : base(triggerInterval, isTriggerOnce)
{
_mission = mission;
}
public override void TriggerTimerScript()
{
try
{
InitCavalryFlame();
}
catch (Exception ex)
{
File.AppendAllLines(PLModuleConstans.ModuleCrashLogPath, new string[] { ex.ToString(), ex.Message, ex.StackTrace });
}
}
private void InitCavalryFlame()
{
InformationManager.DisplayMessage(new InformationMessage("InitCavalryFlame"));
_mission.Agents.ForEach(cavalryAgent =>
{
if (cavalryAgent.IsHuman && cavalryAgent.Team.IsFriendOf(_mission.PlayerTeam))
{
if (!MissionAgentBehavior._cavalryFlamesMap.ContainsKey(cavalryAgent))
{
GameEntity emptyEntity = GameEntity.CreateEmpty(_mission.Scene);
MatrixFrame agentFrame = cavalryAgent.Frame;
emptyEntity.SetFrame(ref agentFrame);
emptyEntity.AddParticleSystemComponent("psys_airplane_fire_2");
MissionAgentBehavior._cavalryFlamesMap.Add(cavalryAgent, emptyEntity);
}
}
});
}
}
public class FlameCavalryTimer_3 : PLCommonBasicMissionTimer
{
private Mission _mission;
public FlameCavalryTimer_3(Mission mission, float triggerInterval, bool isTriggerOnce) : base(triggerInterval, isTriggerOnce)
{
_mission = mission;
}
public override void TriggerTimerScript()
{
try
{
SyncCavalryFlame();
}
catch (Exception ex)
{
File.AppendAllLines(PLModuleConstans.ModuleCrashLogPath, new string[] { ex.ToString(), ex.Message, ex.StackTrace });
}
}
private void SyncCavalryFlame()
{
for (int i = 0; i < MissionAgentBehavior._cavalryFlamesMap.Count; i++)
{
Agent cavalryAgent = MissionAgentBehavior._cavalryFlamesMap.ElementAt(i).Key;
GameEntity flame = MissionAgentBehavior._cavalryFlamesMap.ElementAt(i).Value;
MatrixFrame agentFrame = cavalryAgent.Frame;
flame.SetFrame(ref agentFrame);
}
}
}