Beispiel #1
0
 private static bool AttackTriggered(InputComponent input, AttackComponent attack)
 {
     return(input.PrimaryAttack && attack.Type == AttackType.Primary || input.SecondaryAttack && attack.Type == AttackType.Secondary);
 }
Beispiel #2
0
        private void SpawnAttackProjectile(InputComponent input, Point cursor, AttackBehaviorComponent attackBehavior, AttackComponent attack, GameTime gameTime)
        {
            Vector2 cursorDelta;

            if (attack.CursorType == CursorType.Absolute)
            {
                cursorDelta = new Vector2(cursor.X, cursor.Y) - attack.SourcePos.Vector2;
            }
            else //Relative
            {
                cursorDelta = new Vector2(cursor.X, cursor.Y);
            }
            _ecs.RegisterEntity(_ecs.CreateEntity(attack.Projectile,
                                                  position: new Vector2Ref(attack.SourcePos.Vector2 + new Coord2(cursorDelta).ChangePolarLength(attack.PosOffsetInDirection).Cartesian),
                                                  speed: new Coord2(cursorDelta).ChangePolarLength(attack.StartSpeed),
                                                  gameTime: gameTime, allegiance: attack.Allegiance));


            attackBehavior.RemainingAttackCooldownMilliseconds = attack.AttackCooldownMilliseconds;

            if (attack.BlockInput)
            {
                BlockInput(input, gameTime, attack.BlockInputDurationMilliseconds);
            }
            if (attack.SelfKnockback != 0)
            {
                ApplySelfKnockback(input, attack.SelfKnockback, cursorDelta);
            }

            attackBehavior.DelayedAttack = null;
        }
Beispiel #3
0
        private void StartAttack(InputComponent input, AttackBehaviorComponent attackBehavior, AttackComponent attack, GameTime gameTime)
        {
            PlaceCursorInBehavior(input, attackBehavior, attack);

            if (attack.IsDelayedAttack)
            {
                attackBehavior.DelayedAttack = new AttackBehaviorComponent.DelayedAttackClass(attack.AttackDelayMilliseconds, attack, attackBehavior.Cursor);
                if (attack.BlockInput)
                {
                    BlockInput(input, gameTime, attack.BlockInputDurationMilliseconds);
                }
            }
            else
            {
                SpawnAttackProjectile(input, attackBehavior.Cursor, attackBehavior, attack, gameTime);
            }
        }
Beispiel #4
0
 private void PlaceCursorInBehavior(InputComponent input, AttackBehaviorComponent attackBehavior, AttackComponent attack)
 {
     if (attack.CursorType == CursorType.Absolute)
     {
         attackBehavior.Cursor = input.CursorPoint;
     }
     else //Relative
     {
         Point cursor = input.CursorPoint;
         Point source = new Point((int)attack.SourcePos.Vector2.X, (int)attack.SourcePos.Vector2.Y);
         Point delta  = cursor - source;
         attackBehavior.Cursor = delta;
     }
 }
Beispiel #5
0
 public DelayedAttackClass(double remainingAttackDelayMilliseconds, AttackComponent attack, Point cursor)
 {
     RemainingAttackDelayMilliseconds = remainingAttackDelayMilliseconds;
     Attack = attack;
     Cursor = cursor;
 }