protected override void Awake()
    {
        // Grab reference
        shake = GetComponent <HitAnimation>();

        base.Awake();
    }
示例#2
0
        private async void Remove()
        {
            if (!alreadyRun)
            {
                alreadyRun = !alreadyRun;
            }

            Scheduler.CancelDelayedTasks();

            bx.Colour = Color4.Red; //TODO: Green
            Scheduler.AddDelayed(() => bx.Colour = Color4.White, this.Clear / 2);

            bx.FadeOut(this.Clear);
            bx.ScaleTo(1.1f, this.Clear, Easing.OutCirc); //TODO: InSine

            if (hitAnimation == null || !Clicked)
            {
                Click(Hit.Hitx);
                Add(hitAnimation = HitAnimation(Hit.Hitx));
            }

            await Task.Delay(hitAnimation.WaitTime);

            this.Expire(true);
        }
示例#3
0
        /// <summary>
        /// This method is used to update the projectile after it has hit the ground.
        /// This allows derived projectile types to alter the projectile's hit
        /// phase more easily.
        /// </summary>
        protected void UpdateProjectileHit(GameTimerEventArgs gameTime)
        {
            if (HitAnimation.IsActive == false)
            {
                State = ProjectileState.Destroyed;
                return;
            }

            HitAnimation.Update();
        }
示例#4
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);
        }
示例#5
0
    public void OnFinished()
    {
        tweenScale.enabled = false;
        GameObject playerObj = GameObject.Find("Player");

        if (playerObj)
        {
            HitAnimation hitA = playerObj.GetComponent <HitAnimation>();
            hitA.ResetAnimation();

            FallingAnimation fallA = playerObj.GetComponent <FallingAnimation>();
            fallA.ResetAnimation();
        }
    }
示例#6
0
        private void Load()
        {
            Child = hitAnimation = new HitAnimation(Hit.Hit300, true)
            {
                Depth  = float.MinValue,
                Anchor = Anchor.Centre,
                Origin = Anchor.Centre,
                RelativePositionAxes = Axes.Both,
            };

            AddStep("Start hit300", () => Wait(Hit.Hit300));

            AddUntilStep("Wait until hit300 finished", () => CanContinue);
            AddStep("Start hit100", () => Wait(Hit.Hit100));

            AddUntilStep("Wait until hit100 finished", () => CanContinue);
            AddStep("Start hitx", () => Wait(Hit.Hitx));
        }
示例#7
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);
        }
示例#8
0
        public void Draw(GameTimerEventArgs gameTime)
        {
            switch (State)
            {
            case ProjectileState.InFlight:
                spriteBatch.Draw(projectileTexture, projectilePosition, null,
                                 Color.White, projectileRotation,
                                 new Vector2(projectileTexture.Width / 2,
                                             projectileTexture.Height / 2),
                                 1.0f, SpriteEffects.None, 0);
                break;

            case ProjectileState.HitGround:
                HitAnimation.Draw(spriteBatch, ProjectileHitPosition,
                                  SpriteEffects.None);
                break;

            default:
                // Nothing to draw in this case
                break;
            }
        }
示例#9
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);
                }
            }
        }
示例#10
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);
        }
示例#11
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;
            }
        }