Beispiel #1
0
        public static bool HeavyAttack(Location location, IDescription description)
        {
            LivingEntity le = description as LivingEntity;

            if (le == null)
            {
                return(false);
            }

            le.animations.Push(new AnimationChain(
                                   AnimationManager.Instance[$"-heavy"].MakeInterruptable().MakePausing(),
                                   AnimationManager.Instance[$"heavy"].MakeInterruptable().MakePausing(),
                                   AnimationManager.Instance["attackmove"].MakeInterruptable().Trigger(pd => ((LivingEntity)le).Distance(le.Target) < 20 && !le.Target.IsBeingKnockedBack())));

            return(true);
        }
Beispiel #2
0
 protected void Attack(LivingEntity entity, Location location, string attackName)
 {
     Target = entity;
     if (ActiveSkill == null)
     {
         int index = attackName == "punch" ? 1 : this.combo.Attack + 1;
         animations.Push(new AnimationChain(
                             AnimationManager.Instance[$"-{attackName}{index}"].MakeInterruptable().MakePausing(),
                             AnimationManager.Instance[$"{attackName}{index}"].MakeInterruptable().MakePausing(),
                             AnimationManager.Instance["attackmove"].MakeInterruptable().Trigger(le => ((LivingEntity)le).Distance(Target) < 20 && !Target.IsBeingKnockedBack())));
     }
     else
     {
         ActiveSkill.Cooldown();
         ActiveSkill.SAction(location, this);
     }
 }
Beispiel #3
0
        public static void Combo(IDescription d)
        {
            LivingEntity le = d as LivingEntity;

            if (le == null)
            {
                return;
            }

            if (le.combo.CanChain())
            {
                le.combo.Advance();
            }
            else
            {
                le.combo.Reset();
            }
        }
Beispiel #4
0
        public new void Tick(Location location, Entity entity)
        {
            if (base.Tick(location, entity))
            {
                return;
            }

            Marker markerD = Program.Engine.Location.GetEntities <Marker>().First();

            if (Program.Engine.Controllers[keyController][(int)Actions.TARGET].State == HoldState.PRESS)
            {
                LockTarget = GetLivingEntityNearestMouse(location);
            }
            else if (Program.Engine.Controllers[keyController][(int)Actions.TARGET].State == HoldState.RELEASE)
            {
                LockTarget = null;
            }

            for (int i = (int)Actions.HOTBAR1; i <= (int)Actions.HOTBAR4; i++)
            {
                if (Program.Engine.Controllers[keyController][i].State == HoldState.PRESS)
                {
                    Skill skill = Hotbar[i - (int)Actions.HOTBAR1] as Skill;
                    if (skill != null && skill.CooldownTime == 0)
                    {
                        stamina          -= skill.Stamina;
                        this.PreppedSkill = null;
                        this.ActiveSkill  = null;
                        Hotbar.Execute(i - (int)Actions.HOTBAR1, this);
                    }
                }
            }

            MouseControllerInfo mci;
            MouseControllerInfo info = Program.Engine.Controllers[mouseController][(int)Actions.CANCEL].Info as MouseControllerInfo;


            if (Program.Engine.Controllers[mouseController][(int)Actions.CANCEL].IsDown())
            {
                if (info.X > X - 4 && info.X < X + 4 && info.Y > Y - 24 && info.Y < Y - 16)
                {
                    if (Program.Engine.Controllers[mouseController][(int)Actions.CANCEL].IsPress())
                    {
                        base.CancelSkill();
                    }
                }
                else
                {
                    if (Program.Engine.Controllers[keyController][(int)Actions.TARGET].IsDown())
                    {
                        if (LockTarget != null)
                        {
                            markerD.SetCoords(LockTarget.X, LockTarget.Y);

                            if (animations.Any() && animations.Peek().Peek().Name.Contains("move"))
                            {
                                animations.Pop();
                            }

                            if (stamina > 2)
                            {
                                Attack(LockTarget, location, "sword");
                            }
                            else
                            {
                                Attack(LockTarget, location, "punch");
                            }
                        }
                    }
                    else
                    {
                        LivingEntity selected = GetLivingEntityAtMouse(location);
                        if (selected != null)
                        {
                            if (animations.Any() && animations.Peek().Peek().Name.Contains("move"))
                            {
                                animations.Pop();
                            }

                            if (stamina > 2)
                            {
                                Attack(selected, location, "sword");
                            }
                            else
                            {
                                Attack(selected, location, "punch");
                            }
                        }
                    }
                }
            }

            if (Program.Engine.Controllers[mouseController][(int)Actions.MOVE].IsDown())
            {
                mci = Program.Engine.Controllers[mouseController][(int)Actions.MOVE].Info as MouseControllerInfo;
                Point p = new Point(mci.X, mci.Y);

                if (p.Y > Program.SCREENHEIGHT - 16 * 2 && p.Y < Program.SCREENHEIGHT - 16)
                {
                    int i = p.X / 16;
                    if (Program.Engine.Controllers[mouseController][(int)Actions.MOVE].IsPress())
                    {
                        Skill skill = Hotbar[i] as Skill;
                        if (skill != null && skill.CooldownTime == 0 && stamina >= skill.Stamina)
                        {
                            stamina          -= skill.Stamina;
                            this.PreppedSkill = null;
                            this.ActiveSkill  = null;
                            Hotbar.Execute(i, this);
                        }
                    }
                }
                else
                {
                    while (animations.Any() && animations.Peek().Peek().Name.Contains("move"))
                    {
                        animations.Pop();
                    }

                    markerD.SetCoords(p.X, p.Y);
                    this.MoveTarget = p;
                    animations.Push(new AnimationChain(
                                        AnimationManager.Instance["move"].MakeInterruptable().Trigger(pd => ((Player)pd).Distance(((Player)pd).MoveTarget) < 1)));
                    combo.Reset();
                }
            }
        }
Beispiel #5
0
 public void Action(LivingEntity entity)
 {
     entity.SetPreppedSkill(this);
 }
Beispiel #6
0
 public static bool CheckSkill(LivingEntity target, string name)
 {
     return(name != null && (target?.PreppedSkill?.Name == name || target?.ActiveSkill?.Name == name) ||
            name == null && (target?.PreppedSkill?.Name == null && target?.ActiveSkill?.Name == null));
 }
Beispiel #7
0
 public static void DoSkill(LivingEntity livingEntity, Skill skill)
 {
     livingEntity.ActiveSkill = skill;
 }
Beispiel #8
0
        public void Hit(Description2D hitter, bool finisher, int balanceDiff, int damage)
        {
            if (this is Enemy)
            {
                this.Target = hitter as LivingEntity;
            }

            LivingEntity leHitter = hitter as LivingEntity;

            if (leHitter != null && ActiveSkill != null)
            {
                if (ActiveSkill.Name == "block")
                {
                    Program.Frame.PlaySound("Sounds.GAME_MENU_SCORE_SFX001755.wav");
                    ActiveSkill.Cooldown();
                    if (balanceDiff != 100)
                    {
                        ActiveSkill = null;
                        health     -= damage;
                        leHitter.animations.Queue(new AnimationChain(AnimationManager.Instance["blocked"].MakeInterruptable().MakePausing()));

                        return;
                    }
                }
                else if (ActiveSkill.Name == "counter")
                {
                    ActiveSkill.Cooldown();
                    leHitter.Hit(this, true, 100, damage);
                    ActiveSkill = null;
                    return;
                }
            }

            Program.Frame.PlaySound("Sounds.GAME_MENU_SCORE_SFX001771.wav");
            this.PreppedSkill = null;
            this.skillActivation?.Reset();
            stun        = 15;
            DrawOffsetX = 0;
            DrawOffsetY = 0;
            if (animations.Any() && animations.Peek().Peek().IsInterruptable())
            {
                animations.Pop();
                combo.Reset();
            }

            ActiveSkill = null;
            health     -= damage;
            balance    -= balanceDiff;
            if (balance <= 0 || IsDead())
            {
                if (animations.Any())
                {
                    animations.Pop();
                }

                if (!IsDead())
                {
                    animations.Push(new AnimationChain(AnimationManager.Instance["getup"].MakeInterruptable().MakePausing()));
                }

                animations.Push(new AnimationChain(AnimationManager.Instance[finisher || IsDead() ? "knockback" : "slideback"].MakeInterruptable().MakePausing()));
                knockbackFrom = hitter.Position;
                stun          = 0;
            }
        }
Beispiel #9
0
 public void Execute(int action, LivingEntity entity)
 {
     actions[action]?.Action(entity);
 }
Beispiel #10
0
        private static void SetupAnimations()
        {
            new Animation(
                "attackmove",
                -1,
                tick: LivingEntity.AttackMove,
                final: LivingEntity.EndMove);

            new Animation(
                "move",
                -1,
                tick: LivingEntity.Move,
                final: LivingEntity.EndMove);

            new AttackAnimation(
                "punch1",
                30,
                first: LivingEntity.StartAttack,
                tick: Player.Swing,
                final: d2d => LivingEntity.Strike(d2d, false, 0, 40, 5)
                );

            new AttackAnimation(
                "-punch1",
                45,
                first: LivingEntity.StartAttack,
                tick: Player.Swing,
                final: LivingEntity.ResetToAttackPosition
                );

            new AttackAnimation(
                "sword1",
                24,
                first: LivingEntity.StartAttack,
                tick: Player.Swing,
                final: d2d => LivingEntity.Strike(d2d, false, 2, 40, 20));

            new AttackAnimation(
                "-sword1",
                6,
                tick: Player.BackSwing,
                final: d2d => { LivingEntity.Combo(d2d); LivingEntity.ResetToAttackPosition(d2d); });

            new AttackAnimation(
                "sword2",
                12,
                first: LivingEntity.StartAttack,
                tick: Player.Swing,
                final: d2d => LivingEntity.Strike(d2d, false, 2, 40, 15));

            new AttackAnimation(
                "-sword2",
                3,
                tick: Player.BackSwing,
                final: d2d => { LivingEntity.Combo(d2d); LivingEntity.ResetToAttackPosition(d2d); });

            new AttackAnimation(
                "sword3",
                20,
                first: LivingEntity.StartAttack,
                tick: Player.Swing,
                final: d2d => LivingEntity.Strike(d2d, true, 2, 80, 30));

            new AttackAnimation(
                "-sword3",
                15,
                tick: Player.BackSwing,
                final: d2d => { LivingEntity.Combo(d2d); LivingEntity.ResetToAttackPosition(d2d); });

            new Animation(
                "knockback",
                15,
                tick: LivingEntity.KnockBack);

            new Animation(
                "slideback",
                15,
                tick: LivingEntity.SlideBack);

            new Animation(
                "getup",
                15,
                final: LivingEntity.GetUp);

            new AttackAnimation(
                "bite1",
                10,
                first: LivingEntity.StartAttack,
                tick: Enemy.Bite,
                final: d2d => LivingEntity.Strike(d2d, false, 2, 40, 5));

            new AttackAnimation(
                "-bite1",
                8,
                tick: Enemy.BiteRecovery,
                final: d2d => { LivingEntity.Combo(d2d); LivingEntity.ResetToAttackPosition(d2d); });

            new AttackAnimation(
                "bite2",
                10,
                first: LivingEntity.StartAttack,
                tick: Enemy.FastBite,
                final: d2d => LivingEntity.Strike(d2d, false, 2, 40, 2));

            new AttackAnimation(
                "-bite2",
                3,
                tick: Enemy.BiteRecovery,
                final: d2d => { LivingEntity.Combo(d2d); LivingEntity.ResetToAttackPosition(d2d); });

            new AttackAnimation(
                "bite3",
                30,
                first: LivingEntity.StartAttack,
                tick: Enemy.FastBite,
                final: d2d => LivingEntity.Strike(d2d, false, 2, 40, 2));

            new AttackAnimation(
                "-bite3",
                15,
                tick: Enemy.BiteRecovery,
                final: d2d => { LivingEntity.Combo(d2d); LivingEntity.ResetToAttackPosition(d2d); });

            new AttackAnimation(
                "heavy",
                24,
                first: LivingEntity.StartAttack,
                tick: LivingEntity.HeavyAnimation,
                final: d2d => { LivingEntity.Strike(d2d, true, 0, 100, 50); LivingEntity.CombatSkillEnd(d2d); });

            new AttackAnimation(
                "-heavy",
                6,
                tick: Player.HeavyBackAnimation,
                final: d2d => { LivingEntity.Combo(d2d); LivingEntity.ResetToAttackPosition(d2d); });

            new Animation(
                "blocked",
                30);

            new Animation(
                "activateskill",
                30,
                final: LivingEntity.ActivateSkill);
        }