Ejemplo n.º 1
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;
        }