骑砍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天芒传奇Ⅱ·前传-序章
骑砍2霸主·骑砍2霸主mod开发·天芒传奇ⅱ·天芒传奇·少年包青天·骑砍2霸主mod·霸主mod
霸王•吕布5 个月前
骑砍2霸主MOD开发(18)-多人联机模式开发环境搭建
骑砍2霸主·骑砍2霸主多人联机·骑砍2霸主多人联机模式·骑砍2霸主联机·骑砍2霸主专用服务器搭建·骑砍2霸主专用服务器·自定义联机
霸王•吕布8 个月前
骑砍2霸主MOD开发(8)-action_sets.xml骨骼动画
骨骼动画·骑砍2霸主·action_sets.xml·骑砍2霸主mod开发·骨架·骨骼·绑定骨骼