本文主要是介绍骑砍2霸主MOD开发(11)-瓦兰迪亚火骑兵,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一.火焰灼烧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);}}}
这篇关于骑砍2霸主MOD开发(11)-瓦兰迪亚火骑兵的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!