Example #1
0
        public Affect Process(Character actor, Character target)
        {
            if (RandomMath.Percentage(Percentage))
            {
                if (Type == SpecialAbilityType.Attack)
                {
                    return(Affect);
                }
                else
                {
                    int x_gap = Math.Abs(actor.MapLocation.X - target.MapLocation.X);
                    int y_gap = Math.Abs(actor.MapLocation.Y - target.MapLocation.Y);
                    if (x_gap + y_gap <= Range)
                    {
                        return(Affect);
                    }
                }
            }

            return(null);
        }
Example #2
0
        override public void Update(float passedTime)
        {
            AnimatedMovement action = currentActions.Peek();

            if (IsIdle() && !Ocupied && !drawingAffects && RandomMath.Percentage(0.001f))
            {
                if (DefaultDirection == DefaultDirection.Right)
                {
                    AddAnimatedMovement(AnimationType.NoneRight);
                }
                else
                {
                    AddAnimatedMovement(AnimationType.NoneLeft);
                }

                currentActions.Peek().Origin = action.Movement.Position;
            }

            base.Update(passedTime);

            bool affectsFinished = true;

            foreach (Animation affectAnimation in affects.Values)
            {
                if (affectAnimation != null)
                {
                    if (affectAnimation.IsFinalized())
                    {
                        affectAnimation.IsVisible = false;
                    }
                    else
                    {
                        affectsFinished = false;
                    }

                    affectAnimation.Update(passedTime);
                    affectAnimation.Position   = this.Position;
                    affectAnimation.LayerDepth = this.LayerDepth - 0.03f;
                }
            }

            drawingAffects = !affectsFinished;

            if (target != null && (IsReady() || IsIdle()) && !HealthVariation.IsVisible())
            {
                target.Health.ReceiveDamage(targetDamage);

                if (target.Health.IsDead)
                {
                    if (targetAnimation == AnimationType.HitRight)
                    {
                        target.AddAnimatedMovement(AnimationType.DieRight, target.MapLocation);
                        target.AddAnimatedMovement(AnimationType.DeadRight, target.MapLocation);
                    }
                    else if (targetAnimation == AnimationType.HitLeft)
                    {
                        target.AddAnimatedMovement(AnimationType.DieLeft, target.MapLocation);
                        target.AddAnimatedMovement(AnimationType.DeadLeft, target.MapLocation);
                    }

                    target.Ocupied = true;
                }

                else
                {
                    target.AddAnimatedMovement(targetAnimation, target.MapLocation);
                    target.Ocupied = false;
                }

                target.ShowHealthVariation(targetDamage * -1.0f);

                if (targetCounterAttack)
                {
                    target.AttackCharacter(this, targetCounterDamage, false, 0);
                }

                target = null;
            }

            healthVariation.Update(passedTime);
        }