private void SetFireSwordEnable(bool enable) { if (Agent.Main == null) { return; } if (enable) { EquipmentIndex index = Agent.Main.GetWieldedItemIndex(Agent.HandIndex.MainHand); if (index == EquipmentIndex.None) { return; } GameEntity wieldedWeaponEntity = Agent.Main.GetWeaponEntityFromEquipmentSlot(index); MissionWeapon wieldedWeapon = Agent.Main.WieldedWeapon; int length = wieldedWeapon.GetWeaponStatsData()[0].WeaponLength; int num = (int)Math.Round(length / 10f); Skeleton skeleton = Agent.Main.AgentVisuals.GetSkeleton(); Light light = Light.CreatePointLight(FireLordConfig.FireSwordLightRadius); light.Intensity = FireLordConfig.FireSwordLightIntensity; light.LightColor = FireLordConfig.FireSwordLightColor; switch (wieldedWeapon.CurrentUsageItem.WeaponClass) { case WeaponClass.OneHandedSword: case WeaponClass.TwoHandedSword: case WeaponClass.Mace: case WeaponClass.TwoHandedMace: for (int i = 1; i < num; i++) { MatrixFrame localFrame = new MatrixFrame(Mat3.Identity, new Vec3(0, 0, 0)).Elevate(i * 0.1f); ParticleSystem particle = ParticleSystem.CreateParticleSystemAttachedToEntity("psys_game_burning_agent", wieldedWeaponEntity, ref localFrame); skeleton.AddComponentToBone(Game.Current.HumanMonster.MainHandItemBoneIndex, particle); } light.Frame = light.Frame.Elevate((num - 1) * 0.1f); break; case WeaponClass.OneHandedAxe: case WeaponClass.TwoHandedAxe: case WeaponClass.OneHandedPolearm: case WeaponClass.TwoHandedPolearm: case WeaponClass.LowGripPolearm: int fireLenth = (num > 19)? 9 :(num > 15)? 6 : (num > 12)? 5 :(num > 10) ? 4 : 3; for (int i = num - 1; i > 0 && i > num - fireLenth; i--) { MatrixFrame localFrame = new MatrixFrame(Mat3.Identity, new Vec3(0, 0, 0)).Elevate(i * 0.1f); ParticleSystem particle = ParticleSystem.CreateParticleSystemAttachedToEntity("psys_game_burning_agent", wieldedWeaponEntity, ref localFrame); skeleton.AddComponentToBone(Game.Current.HumanMonster.MainHandItemBoneIndex, particle); } light.Frame = light.Frame.Elevate((num - 1) * 0.1f); break; default: //InformationManager.DisplayMessage(new InformationMessage("当前武器无法点燃")); return; } skeleton.AddComponentToBone(Game.Current.HumanMonster.MainHandItemBoneIndex, light); //只有通过扔掉再重新捡起这把武器,才能让粒子效果出现 DropLock = true; Agent.Main.DropItem(index); SpawnedItemEntity spawnedItemEntity = wieldedWeaponEntity.GetFirstScriptOfType <SpawnedItemEntity>(); Agent.Main.OnItemPickup(spawnedItemEntity, EquipmentIndex.None, out bool removeItem); DropLock = false; _fireSwordLight = light; _fireSwordEntity = wieldedWeaponEntity; _fireSwordEnabled = true; } else { _fireSwordEnabled = false; if (_fireSwordEntity != null) { Skeleton skeleton = Agent.Main.AgentVisuals.GetSkeleton(); if (_fireSwordLight != null && skeleton != null) { skeleton.RemoveComponent(_fireSwordLight); } _fireSwordEntity.RemoveAllParticleSystems(); } } }
public override void OnMissionTick(float dt) { if (!_initialized && Mission.Current != null && Agent.Main != null) { _initialized = true; Initialize(); } //每支箭落地燃烧,4秒火势变弱,8秒熄灭(默认) if (_hitArrowFires.Count > 0) { List <ArrowFireData> _deleteitems = new List <ArrowFireData>(); foreach (ArrowFireData item in _hitArrowFires) { if (item.timer.Check(true)) { if (!item.delete) { item.delete = true; GameEntity entity = item.bigFireParticle.GetEntity(); if (entity != null) { entity.GetLight().Intensity = FireLordConfig.FireArrowLightIntensity - 35; entity.RemoveComponent(item.bigFireParticle); } } else { GameEntity entity = item.missile.Entity; if (entity != null) { entity.RemoveAllParticleSystems(); Light light = entity.GetLight(); if (light != null) { entity.RemoveComponent(light); } } _deleteitems.Add(item); } } } foreach (ArrowFireData item in _deleteitems) { _hitArrowFires.Remove(item); } } //计算每个agent的着火条,满了就点燃 if (AgentFireDatas.Count > 0) { List <Agent> _deleteAgent = new List <Agent>(); foreach (KeyValuePair <Agent, AgentFireData> item in AgentFireDatas) { Agent agent = item.Key; AgentFireData fireData = item.Value; if (fireData.isBurning) { if (FireLordConfig.IgnitionDealDamage && fireData.damageTimer.Check(true) && agent.IsActive()) { Blow blow = CreateBlow(fireData.attacker, agent); agent.RegisterBlow(blow); if (fireData.attacker == Agent.Main) { TextObject text = GameTexts.FindText("ui_delivered_burning_damage", null); text.SetTextVariable("DAMAGE", blow.InflictedDamage); InformationManager.DisplayMessage(new InformationMessage(text.ToString())); } else if (agent == Agent.Main) { TextObject text = GameTexts.FindText("ui_received_burning_damage", null); text.SetTextVariable("DAMAGE", blow.InflictedDamage); InformationManager.DisplayMessage(new InformationMessage(text.ToString(), Color.ConvertStringToColor("#D65252FF"))); } } if (fireData.burningTimer.Check()) { if (fireData.fireEntity != null) { foreach (ParticleSystem particle in fireData.particles) { fireData.fireEntity.RemoveComponent(particle); } if (fireData.fireLight != null) { fireData.fireLight.Intensity = 0; Skeleton skeleton = agent.AgentVisuals.GetSkeleton(); if (skeleton != null) { skeleton.RemoveComponent(fireData.fireLight); } } fireData.fireEntity = null; fireData.fireLight = null; } fireData.firebar = 0; fireData.isBurning = false; } } else { if (fireData.firebar >= FireLordConfig.IgnitionBarMax) { fireData.isBurning = true; fireData.burningTimer = new MissionTimer(FireLordConfig.IgnitionDurationInSecond); fireData.damageTimer = new MissionTimer(1f); EquipmentIndex index = agent.GetWieldedItemIndex(Agent.HandIndex.MainHand); if (index == EquipmentIndex.None) { return; } GameEntity wieldedWeaponEntity = agent.GetWeaponEntityFromEquipmentSlot(index); Skeleton skeleton = agent.AgentVisuals.GetSkeleton(); if (skeleton == null) { return; } fireData.particles = new ParticleSystem[_ignitionBoneIndexes.Length]; for (byte i = 0; i < _ignitionBoneIndexes.Length; i++) { MatrixFrame localFrame = new MatrixFrame(Mat3.Identity, new Vec3(0, 0, 0)); ParticleSystem particle = ParticleSystem.CreateParticleSystemAttachedToEntity("psys_campfire", wieldedWeaponEntity, ref localFrame); skeleton.AddComponentToBone(_ignitionBoneIndexes[i], particle); fireData.particles[i] = particle; } //只有通过扔掉再重新捡起这把武器,才能让粒子效果出现 FireSwordLogic.DropLock = true; agent.DropItem(index); SpawnedItemEntity spawnedItemEntity = wieldedWeaponEntity.GetFirstScriptOfType <SpawnedItemEntity>(); agent.OnItemPickup(spawnedItemEntity, EquipmentIndex.None, out bool removeItem); fireData.fireEntity = wieldedWeaponEntity; FireSwordLogic.DropLock = false; Light light = Light.CreatePointLight(FireLordConfig.IgnitionLightRadius); light.Intensity = FireLordConfig.IgnitionLightIntensity; light.LightColor = FireLordConfig.IgnitionLightColor; skeleton.AddComponentToBone(0, light); fireData.fireLight = light; } else { fireData.firebar -= dt * FireLordConfig.IgnitionDropPerSecond; fireData.firebar = Math.Max(fireData.firebar, 0); if (!agent.IsActive()) { _deleteAgent.Add(agent); } } } } foreach (Agent agent in _deleteAgent) { AgentFireData fireData = AgentFireDatas[agent]; GameEntity entity = fireData.fireEntity; if (entity != null) { entity.RemoveAllParticleSystems(); } Skeleton skeleton = agent.AgentVisuals.GetSkeleton(); if (skeleton != null && fireData.fireLight != null) { skeleton.RemoveComponent(fireData.fireLight); } AgentFireDatas.Remove(agent); } } }