示例#1
0
        public override void OnAgentShootMissile(Agent shooterAgent, EquipmentIndex weaponIndex, Vec3 position, Vec3 velocity, Mat3 orientation, bool hasRigidBody, int forcedMissileIndex)
        {
            if (!_fireArrowEnabled)
            {
                return;
            }

            bool          allowed = false;
            MissionWeapon weapon  = shooterAgent.Equipment[weaponIndex];

            switch (weapon.CurrentUsageItem.WeaponClass)
            {
            case WeaponClass.Arrow:
            case WeaponClass.Bolt:
            case WeaponClass.Bow:
            case WeaponClass.Crossbow:
                allowed = true;
                break;

            case WeaponClass.ThrowingAxe:
            case WeaponClass.ThrowingKnife:
            case WeaponClass.Javelin:
                allowed = FireLordConfig.AllowFireThrownWeapon;
                break;
            }
            if (allowed)
            {
                foreach (Mission.Missile missile in Mission.Current.Missiles)
                {
                    if (!_missileParticles.ContainsKey(missile))
                    {
                        MatrixFrame    localFrame = new MatrixFrame(Mat3.Identity, new Vec3(0, 0, 0));
                        ParticleSystem particle   = ParticleSystem.CreateParticleSystemAttachedToEntity(
                            "psys_game_burning_agent", missile.Entity, ref localFrame);
                        Light light = Light.CreatePointLight(FireLordConfig.FireArrowLightRadius);
                        light.Intensity  = FireLordConfig.FireArrowLightIntensity;
                        light.LightColor = FireLordConfig.FireArrowLightColor;
                        missile.Entity.AddLight(light);
                        _missileParticles.Add(missile, particle);
                    }
                }
            }
        }
示例#2
0
        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();
                }
            }
        }
示例#3
0
        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);
                }
            }
        }
示例#4
0
        public override void OnMissileCollisionReaction(Mission.MissileCollisionReaction collisionReaction, Agent attacker, Agent victim, sbyte attachedBoneIndex)
        {
            if (!_fireArrowEnabled)
            {
                return;
            }

            Dictionary <Mission.Missile, ParticleSystem> existMissiles = new Dictionary <Mission.Missile, ParticleSystem>();

            foreach (Mission.Missile missile in Mission.Current.Missiles)
            {
                if (_missileParticles.ContainsKey(missile))
                {
                    existMissiles.Add(missile, _missileParticles[missile]);
                    _missileParticles.Remove(missile);
                }
            }
            foreach (KeyValuePair <Mission.Missile, ParticleSystem> item in _missileParticles)
            {
                Mission.Missile missile = item.Key;
                Light           light   = missile.Entity.GetLight();

                //击中敌人箭矢必须熄灭,因为插在Agent身上的箭的粒子效果是无法显示的
                if (victim != null)
                {
                    missile.Entity.RemoveAllParticleSystems();
                    if (light != null)
                    {
                        missile.Entity.RemoveComponent(light);
                    }
                }
                else
                {
                    ParticleSystem particle   = item.Value;
                    MatrixFrame    localFrame = particle.GetLocalFrame().Elevate(0.6f);
                    particle.SetLocalFrame(ref localFrame);
                    if (light != null)
                    {
                        light.Frame     = light.Frame.Elevate(0.15f);
                        light.Intensity = FireLordConfig.FireArrowLightIntensity;
                    }

                    ArrowFireData fireData = new ArrowFireData();

                    localFrame = new MatrixFrame(Mat3.Identity, new Vec3(0, 0, 0)).Elevate(0.6f);
                    fireData.bigFireParticle = ParticleSystem.CreateParticleSystemAttachedToEntity("psys_campfire", missile.Entity, ref localFrame);
                    fireData.timer           = new MissionTimer(FireLordConfig.StickedArrowsBurningTime / 2);
                    fireData.missile         = missile;
                    _hitArrowFires.Add(fireData);
                }

                if (FireLordConfig.IgniteTargetWithFireArrow && victim != null && victim.IsHuman)
                {
                    if (AgentFireDatas.ContainsKey(victim))
                    {
                        AgentFireData fireData = AgentFireDatas[victim];
                        if (!fireData.isBurning)
                        {
                            fireData.firebar += FireLordConfig.IgnitionPerFireArrow;
                            fireData.attacker = attacker;
                        }
                    }
                    else
                    {
                        AgentFireData fireData = new AgentFireData();
                        fireData.firebar += FireLordConfig.IgnitionPerFireArrow;
                        fireData.attacker = attacker;
                        AgentFireDatas.Add(victim, fireData);
                    }
                }
            }
            _missileParticles = existMissiles;
        }