Esempio n. 1
0
        public bool Perform(Creature performer, Vector3 pos, Voxel other, DwarfTime time, float bonus, string faction)
        {
            if (other == null)
            {
                return(false);
            }

            switch (TriggerMode)
            {
            case AttackTrigger.Timer:
                RechargeTimer.Update(time);
                if (!RechargeTimer.HasTriggered)
                {
                    return(false);
                }
                break;

            case AttackTrigger.Animation:
                if (performer.Sprite.CurrentAnimation == null || performer.Sprite.CurrentAnimation.CurrentFrame != TriggerFrame)
                {
                    return(false);
                }
                break;
            }

            switch (Mode)
            {
            case AttackMode.Melee:
            {
                other.Health -= DamageAmount + bonus;
                PlayNoise(other.Position);
                if (HitParticles != "")
                {
                    PlayState.ParticleManager.Trigger(HitParticles, other.Position, Color.White, 5);
                }

                if (HitAnimation != null)
                {
                    HitAnimation.Reset();
                    HitAnimation.Play();
                    IndicatorManager.DrawIndicator(HitAnimation, other.Position + Vector3.One * 0.5f, 0.6f, 2.0f, MathFunctions.RandVector2Circle(), Color.White, MathFunctions.Rand() > 0.5f);
                }
                break;
            }

            case AttackMode.Ranged:
            {
                LaunchProjectile(pos, other.Position, faction);
                break;
            }
            }
            return(true);
        }
Esempio n. 2
0
        public bool PerformNoDamage(Creature performer, DwarfTime time, Vector3 pos)
        {
            switch (TriggerMode)
            {
            case AttackTrigger.Timer:
                RechargeTimer.Update(time);
                if (!RechargeTimer.HasTriggered)
                {
                    HasTriggered = false;
                    return(false);
                }
                break;

            case AttackTrigger.Animation:
                if (performer.Sprite.CurrentAnimation == null ||
                    performer.Sprite.CurrentAnimation.CurrentFrame != TriggerFrame)
                {
                    HasTriggered = false;
                    return(false);
                }
                break;
            }
            if (Mode == AttackMode.Melee)
            {
                if (HitParticles != "")
                {
                    performer.Manager.World.ParticleManager.Trigger(HitParticles, pos, Color.White, 5);
                }


                if (HitAnimation != null && !HasTriggered)
                {
                    HitAnimation.Reset();
                    HitAnimation.Play();
                    IndicatorManager.DrawIndicator(HitAnimation.Clone(), pos, 10.0f, 1.0f, MathFunctions.RandVector2Circle(), Color.White, MathFunctions.Rand() > 0.5f);
                    PlayNoise(pos);
                }
            }
            HasTriggered = true;
            return(true);
        }
Esempio n. 3
0
        public void PerformNoDamage(Creature performer, DwarfTime time, Vector3 pos)
        {
            switch (TriggerMode)
            {
            case AttackTrigger.Timer:
                RechargeTimer.Update(time);
                if (!RechargeTimer.HasTriggered)
                {
                    return;
                }
                break;

            case AttackTrigger.Animation:
                if (performer.Sprite.CurrentAnimation == null ||
                    performer.Sprite.CurrentAnimation.CurrentFrame != TriggerFrame)
                {
                    return;
                }
                break;
            }

            if (Mode == AttackMode.Melee)
            {
                PlayNoise(pos);
                if (HitParticles != "")
                {
                    PlayState.ParticleManager.Trigger(HitParticles, pos, Color.White, 5);
                }


                if (HitAnimation != null)
                {
                    HitAnimation.Reset();
                    HitAnimation.Play();
                    IndicatorManager.DrawIndicator(HitAnimation, pos, 0.6f, 2.0f, MathFunctions.RandVector2Circle(), Color.White, MathFunctions.Rand() > 0.5f);
                }
            }
        }
Esempio n. 4
0
        public bool Perform(Creature performer, Body other, DwarfTime time, float bonus, Vector3 pos, string faction)
        {
            switch (TriggerMode)
            {
            case AttackTrigger.Timer:
                RechargeTimer.Update(time);
                if (!RechargeTimer.HasTriggered)
                {
                    return(false);
                }
                break;

            case AttackTrigger.Animation:
                if (performer.Sprite.CurrentAnimation == null ||
                    performer.Sprite.CurrentAnimation.CurrentFrame != TriggerFrame)
                {
                    return(false);
                }
                break;
            }
            switch (Mode)
            {
            case AttackMode.Melee:
            case AttackMode.Dogfight:
            {
                Health health = other.GetRootComponent().GetChildrenOfType <Health>(true).FirstOrDefault();
                if (health != null)
                {
                    health.Damage(DamageAmount + bonus);
                }

                PlayNoise(other.GlobalTransform.Translation);
                if (HitParticles != "")
                {
                    PlayState.ParticleManager.Trigger(HitParticles, other.LocalTransform.Translation, Color.White, 5);
                }

                if (HitAnimation != null)
                {
                    HitAnimation.Reset();
                    HitAnimation.Play();
                    IndicatorManager.DrawIndicator(HitAnimation.Clone(), other.BoundingBox.Center(), 10.0f, 1.0f, MathFunctions.RandVector2Circle(), Color.White, MathFunctions.Rand() > 0.5f);
                }

                Physics physics = other as Physics;

                if (physics != null)
                {
                    Vector3 force = other.Position - pos;

                    if (force.LengthSquared() > 0.01f)
                    {
                        force.Normalize();
                        physics.ApplyForce(force * Knockback, 1.0f);
                    }
                }

                break;
            }

            case AttackMode.Ranged:
            {
                PlayNoise(other.GlobalTransform.Translation);
                LaunchProjectile(pos, other.Position, other);
                break;
            }
            }

            return(true);
        }
Esempio n. 5
0
        public IEnumerable <Act.Status> Perform(Creature performer, Vector3 pos, Voxel other, DwarfTime time, float bonus, string faction)
        {
            while (true)
            {
                if (other == null)
                {
                    yield return(Act.Status.Fail);

                    yield break;
                }

                switch (TriggerMode)
                {
                case AttackTrigger.Timer:
                    RechargeTimer.Update(time);
                    if (!RechargeTimer.HasTriggered)
                    {
                        yield return(Act.Status.Running);

                        continue;
                    }
                    break;

                case AttackTrigger.Animation:
                    if (performer.Sprite.CurrentAnimation == null ||
                        performer.Sprite.CurrentAnimation.CurrentFrame != TriggerFrame)
                    {
                        if (performer.Sprite.CurrentAnimation != null)
                        {
                            performer.Sprite.CurrentAnimation.Play();
                        }
                        yield return(Act.Status.Running);

                        continue;
                    }
                    break;
                }

                switch (Mode)
                {
                case AttackMode.Melee:
                {
                    other.Health -= DamageAmount + bonus;
                    PlayNoise(other.Position);
                    if (HitParticles != "")
                    {
                        PlayState.ParticleManager.Trigger(HitParticles, other.Position, Color.White, 5);
                    }

                    if (HitAnimation != null)
                    {
                        HitAnimation.Reset();
                        HitAnimation.Play();
                        IndicatorManager.DrawIndicator(HitAnimation.Clone(), other.Position + Vector3.One * 0.5f,
                                                       10.0f, 1.0f, MathFunctions.RandVector2Circle() * 10, HitColor, MathFunctions.Rand() > 0.5f);
                    }
                    break;
                }

                case AttackMode.Ranged:
                {
                    LaunchProjectile(pos, other.Position, null);
                    break;
                }
                }
                yield return(Act.Status.Success);

                yield break;
            }
        }