Example #1
0
 public RailGunBullet()
     : base()
 {
     Shape = Shape.Rectangle;
     Rectangle = new PhysicalRectangle();
     Explosive = true;
 }
 public CelestialBodyExplosion()
 {
     Handler = new IntegerHandler(CheckEnemiesHit);
     Output = new Dictionary<int, Enemy>();
     CelestialBodyRectangle = new PhysicalRectangle();
     CelestiablBodyRange = new Circle(Vector3.Zero, 0);
 }
Example #3
0
 public BasicBullet()
     : base()
 {
     Shape = Shape.Rectangle;
     Rectangle = new PhysicalRectangle();
     Deflectable = true;
 }
Example #4
0
        public static bool LineRectangleCollision(Line line, PhysicalRectangle rectangle)
        {
            Vector2 debut = line.DebutV2;
            Vector2 fin = line.FinV2;

            return LineRectangleCollision(ref debut, ref fin, rectangle);
        }
Example #5
0
        public Bubble(CommanderScene scene, PhysicalRectangle dimension, double visualPriority)
        {
            Scene = scene;
            Dimension = dimension;
            FilterAlpha = 200;

            Bla = new Image("bulleBlabla")
            {
                VisualPriority = visualPriority,
                Origin = Vector2.Zero
            };

            Filter = new Image("PixelBlanc")
            {
                Color = new Color(0, 0, 0, FilterAlpha),
                VisualPriority = visualPriority + 0.000002,
                Origin = Vector2.Zero
            };

            Corners = new List<Image>();
            Edges = new List<Image>();

            for (int i = 0; i < 4; i++)
            {
                Corners.Add(new Image("bulleCoin") { VisualPriority = visualPriority + 0.000001 });
                Edges.Add(new Image("PixelBlanc") { VisualPriority = visualPriority + 0.000001, Origin = Vector2.Zero });
            }

            Color = Color.White;
        }
Example #6
0
 public GunnerBullet()
     : base()
 {
     Speed = 0;
     Rectangle = new PhysicalRectangle();
     CanonRotation = new Matrix();
 }
 public BulletsDeflected()
 {
     Output = new List<KeyValuePair<Enemy, Bullet>>();
     Handler = new IntegerHandler(CheckBulletIsDeflected);
     CurrentBullet = null;
     CurrentBulletRectangle = new PhysicalRectangle();
     CurrentBulletDeflectRange = new Circle(Vector3.Zero, 0);
 }
 public SlowMotionBullet()
     : base()
 {
     Speed = 0;
     Shape = Shape.Circle;
     Circle = new Circle(Vector3.Zero, 0);
     Rectangle = new PhysicalRectangle();
 }
Example #9
0
 public EnemyInRange()
 {
     Output = new List<KeyValuePair<Turret, Enemy>>();
     Handler = new IntegerHandler(CheckEnemyIsInRange);
     CurrentTurret = null;
     CurrentTurretRectangle = new PhysicalRectangle();
     CurrentTurretRange = new Circle(Vector3.Zero, 0);
 }
Example #10
0
        public bool Intersects(PhysicalRectangle autre)
        {
            bool resultat;

            RectanglePrimitif.Intersects(ref autre.RectanglePrimitif, out resultat);

            return resultat;
        }
Example #11
0
 public MissileBullet()
     : base()
 {
     Shape = Shape.Rectangle;
     Rectangle = new PhysicalRectangle();
     Explosive = true;
     Deflectable = true;
 }
Example #12
0
        public bool Includes(PhysicalRectangle other)
        {
            bool result;

            RectanglePrimitif.Contains(ref other.RectanglePrimitif, out result);

            return result;
        }
Example #13
0
 public NanobotsBullet()
     : base()
 {
     Shape = Shape.Circle;
     Circle = new Core.Physics.Circle(Vector3.Zero, 0);
     Rectangle = new PhysicalRectangle();
     Explosive = true;
 }
Example #14
0
 public BoostedTurrets()
 {
     Output = new List<KeyValuePair<Turret, Turret>>();
     Handler = new IntegerHandler(CheckTurretIsBoosted);
     CurrentTurret = null;
     CurrentTurretRectangle = new PhysicalRectangle();
     CurrentTurretRange = new Circle(Vector3.Zero, 0);
 }
Example #15
0
 public MineBullet()
     : base()
 {
     Shape = Shape.Circle;
     Circle = new Circle(Vector3.Zero, 0);
     Rectangle = new PhysicalRectangle();
     Explosive = true;
     SfxExplosion = @"sfxMineExplose";
 }
Example #16
0
 public CommanderScene(string name)
     : base(Preferences.BackBuffer)
 {
     Name = name;
     CameraView = new PhysicalRectangle();
     CameraOuterView = new PhysicalRectangle();
     Camera.Changed += new Core.CameraHandler(DoCameraChanged);
     DoCameraChanged(Camera);
 }
Example #17
0
 private void Initialize()
 {
     Rectangle = new PhysicalRectangle();
     Position = new Vector3(0, 0, 500);
     Rotation = 0.0f;
     Origin = Vector2.Zero;
     Zoom = 1;
     Name = "Unknown";
 }
 public ContextualMenuLayout(int id, int bubbleTailId, Vector2 bubblePositionCorrection)
 {
     Id = id;
     Rectangle = new PhysicalRectangle();
     BubbleTailId = bubbleTailId;
     BubblePositionCorrection = bubblePositionCorrection;
     SubstractSizeX = false;
     SubstractSizeY = false;
 }
 public ObjectsCollisions()
 {
     Output = new List<KeyValuePair<ICollidable, ICollidable>>();
     HandlerBulletEnemy = new IntegerHandler(CheckBulletEnemy);
     HandlerBulletExplosion = new IntegerHandler(CheckBulletExplosion);
     HandlerShootingStars = new IntegerHandler(CheckShootingStars);
     HandlerShootingStarExplosion = new IntegerHandler(CheckShootingStarExplosion);
     TmpObjects = new Dictionary<int, int>();
     Rectangle = new PhysicalRectangle();
     Circle = new Circle(Vector3.Zero, 0);
 }
Example #20
0
        public ImageLabel(List<Image> images, Text text)
        {
            Images = images;

            foreach (var img in images)
                img.Origin = Vector2.Zero;
            
            Text = text;

            CanHover = false;
            Rectangle = new PhysicalRectangle();
        }
Example #21
0
        public static bool TriangleRectangleCollision(Triangle triangle, PhysicalRectangle rectangle)
        {
            Vector2 s1 = triangle.Sommet1;
            Vector2 s2 = triangle.Sommet2;
            Vector2 s3 = triangle.Sommet3;

            if (LineRectangleCollision(ref s1, ref s2, rectangle) ||
                LineRectangleCollision(ref s2, ref s3, rectangle) ||
                LineRectangleCollision(ref s3, ref s1, rectangle))
                return true;

            return false;
        }
Example #22
0
        public bool InBorders(CelestialBodyDescriptor descriptor, PhysicalRectangle limits)
        {
            LiteCelestialBody corpsCeleste = new LiteCelestialBody
            (
                descriptor.Path,
                descriptor.Position,
                descriptor.Rotation,
                descriptor.StartingPosition,
                descriptor.Size,
                descriptor.Speed
            );

            // au temps 0
            corpsCeleste.ActualRotationTime = 0;
            corpsCeleste.Move();
            if (!limits.Includes(corpsCeleste.Position + new Vector3((int)descriptor.Size, 0, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(-(int)descriptor.Size, 0, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(0, (int)descriptor.Size, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(0, -(int)descriptor.Size, 0)))
                return false;

            // au temps 1/4
            corpsCeleste.ActualRotationTime = corpsCeleste.RotationTime / 4;
            corpsCeleste.Move();
            if (!limits.Includes(corpsCeleste.Position + new Vector3((int)descriptor.Size, 0, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(-(int)descriptor.Size, 0, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(0, (int)descriptor.Size, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(0, -(int)descriptor.Size, 0)))
                return false;

            // au temps 1/2
            corpsCeleste.ActualRotationTime = corpsCeleste.RotationTime / 2;
            corpsCeleste.Move();
            if (!limits.Includes(corpsCeleste.Position + new Vector3((int)descriptor.Size, 0, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(-(int)descriptor.Size, 0, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(0, (int)descriptor.Size, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(0, -(int)descriptor.Size, 0)))
                return false;

            // au temps 3/4
            corpsCeleste.ActualRotationTime = corpsCeleste.RotationTime * (3.0/4.0);
            corpsCeleste.Move();
            if (!limits.Includes(corpsCeleste.Position + new Vector3((int)descriptor.Size, 0, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(-(int)descriptor.Size, 0, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(0, (int)descriptor.Size, 0)) ||
                !limits.Includes(corpsCeleste.Position + new Vector3(0, -(int)descriptor.Size, 0)))
                return false;

            return true;
        }
Example #23
0
        public static bool LineRectangleCollision(ref Vector2 lineStart, ref Vector2 lineEnd, PhysicalRectangle rectangle)
        {
            Vector2 v1 = new Vector2(rectangle.X, rectangle.Y);
            Vector2 v2 = new Vector2(rectangle.X, rectangle.Y + rectangle.Height);
            Vector2 v3 = new Vector2(rectangle.X + rectangle.Width, rectangle.Y + rectangle.Height);
            Vector2 v4 = new Vector2(rectangle.X + rectangle.Width, rectangle.Y);

            if (
             LineLineCollision(ref lineStart, ref lineEnd, ref v1, ref v2) ||
             LineLineCollision(ref lineStart, ref lineEnd, ref v1, ref v4) ||
             LineLineCollision(ref lineStart, ref lineEnd, ref v4, ref v3) ||
             LineLineCollision(ref lineStart, ref lineEnd, ref v2, ref v3))
                return true;

            return false;
        }
Example #24
0
        public bool Intersects(PhysicalRectangle rectangle)
        {
            if (Obj != null)
                Position = Obj.Position;

            // centre du cercle dans l'axe des X de rectangle (dessous, dessus)
            if (this.Position.X >= rectangle.Left && this.Position.X <= rectangle.Right &&
                this.Position.Y < rectangle.Bottom + Radius && this.Position.Y > rectangle.Top - Radius)
                return true;

            float r2 = Radius * Radius;
            float val1 = Position.X - rectangle.Left;
            val1 *= val1;
            float val2 = Position.Y - rectangle.Top;
            val2 *= val2;
            // centre du cercle dans les coins à gauche de rectangle
            if (this.Position.Y < rectangle.Top && (val1 + val2 < r2))
                return true;

            val2 = Position.Y - rectangle.Bottom;
            val2 *= val2;
            if (this.Position.Y > rectangle.Bottom && (val1 + val2 < r2))
                return true;

            // centre du cercle dans l'axe des Y de rectangle (gauche, droite)
            if ((this.Position.Y >= rectangle.Top && this.Position.Y <= rectangle.Bottom) &&
               (this.Position.X > rectangle.Left - Radius && this.Position.X < rectangle.Right + Radius))
                return true;

            val1 = Position.X - rectangle.Right;
            val1 *= val1;
            float val3 = Position.Y - rectangle.Top;
            val3 *= val3;
            // centre du cercle dans les coins à droite de rectangle
            if ((this.Position.X > rectangle.Right && this.Position.Y < rectangle.Top) && (val1 + val3 < r2))
                return true;

            if ((this.Position.X > rectangle.Right && this.Position.Y > rectangle.Bottom) && (val1 + val2 < r2))
                return true;

            // pas de collision
            return false;
        }
Example #25
0
        public GridWorld(PhysicalRectangle space, int cellSize)
        {
            this.Space = space;
            this.CellSize = cellSize;

            SpaceUpperLeft = new Vector2(Space.Left, Space.Top);

            NbRows = Space.Height / CellSize;
            NbColumns = Space.Width / CellSize;

            Grid = new List<List<List<int>>>();

            for (int i = 0; i < NbRows; i++)
            {
                Grid.Add(new List<List<int>>());

                for (int j = 0; j < NbColumns; j++)
                    Grid[i].Add(new List<int>());
            }
        }
Example #26
0
        public Enemy()
        {
            Minerals = new List<Mineral>();

            MovingEffect = null;

            AttackPoints = 1;
            PointsValue = 1;

            Shape = Shape.Rectangle;
            Rectangle = new PhysicalRectangle(0, 0, 1, 1);
            Circle = new Circle(Vector3.Zero, 1);
            Type = EnemyType.Asteroid;
            Level = 0;
            WaveId = -1;
            EndOfPathReached = false;

            CashValueText = new Text(@"Pixelite") { SizeX = 2 };
            SfxHit = "";
            SfxDie = "";
            LastHitBy = null;
        }
        public CollisionsController(Simulator simulator)
        {
            Simulator = simulator;
            Battlefield = Simulator.Scene.CameraOuterView;
            EnemiesGrid = new GridWorld(Battlefield, 50);
            TurretsGrid = new GridWorld(Battlefield, 50);
            
            HiddenEnemies = new HiddenEnemies();
            BoostedTurrets = new BoostedTurrets();
            BulletsDeflected = new BulletsDeflected();
            OutOfBounds = new OutOfBounds();
            EnemyInRange = new EnemyInRange();
            ObjectsCollisions = new ObjectsCollisions();
            PlayersCollisions = new PlayersCollisions();
            CelestialBodyExplosion = new CelestialBodyExplosion();
            StartingPathCollisions = new StartingPathCollisions();
            ShieldsCollisions = new ShieldsCollisions();

            SyncOutOfBounds = new Action(OutOfBounds.Sync);
            SyncEnemyInRange = new Action(EnemyInRange.Sync);
            SyncBoostedTurrets = new Action(BoostedTurrets.Sync);
            SyncBulletsDeflected = new Action(BulletsDeflected.Sync);
        }
Example #28
0
        public NextWaveWidget()
        {
            EnemiesImages = new Dictionary<EnemyType, Image>();

            foreach (var kvp in EnemiesFactory.ImagesEnemies)
            {
                Image im = new Image(kvp.Value)
                {
                    Origin = Vector2.Zero,
                    SizeX = 4
                };

                EnemiesImages.Add(kvp.Key, im);
            }

            Enemies = new List<Image>();
            Quantity = new Text(@"Pixelite") { SizeX = 3 };

            DistanceEnemiesX = 10;
            DistanceQuantityX = 10;

            Rectangle = new PhysicalRectangle();
        }
Example #29
0
        public IEnumerable<int> GetItems(PhysicalRectangle rectangle)
        {
            Vector2 upperLeft = new Vector2(rectangle.Left, rectangle.Top);
            Vector2.Subtract(ref upperLeft, ref SpaceUpperLeft, out upperLeft);
            Vector2.Divide(ref upperLeft, CellSize, out upperLeft);

            int lowerXIndex = (int)upperLeft.X;
            int lowerYIndex = (int)upperLeft.Y;
            int upperXIndex = lowerXIndex + rectangle.Width / CellSize;
            int upperYIndex = lowerYIndex + rectangle.Width / CellSize;

            for (int i = lowerXIndex; i <= upperXIndex; i++)
                for (int j = lowerYIndex; j <= upperYIndex; j++)
                    if (i >= 0 && i < NbColumns && j >= 0 && j < NbRows)
                        for (int k = 0; k < Grid[j][i].Count; k++)
                            yield return Grid[j][i][k];
        }
Example #30
0
        public void GetItems(PhysicalRectangle rectangle, IntegerHandler callback)
        {
            Vector2 upperLeft = new Vector2(rectangle.Left, rectangle.Top);
            Vector2.Subtract(ref upperLeft, ref SpaceUpperLeft, out upperLeft);
            Vector2.Divide(ref upperLeft, CellSize, out upperLeft);

            int lowerXIndex = (int) upperLeft.X;
            int lowerYIndex = (int) upperLeft.Y;
            int upperXIndex = lowerXIndex + rectangle.Width / CellSize;
            int upperYIndex = lowerYIndex + rectangle.Width / CellSize;

            bool wantsNext = true;

            for (int i = lowerXIndex; i <= upperXIndex; i++)
                for (int j = lowerYIndex; j <= upperYIndex; j++)
                    if (i >= 0 && i < NbColumns && j >= 0 && j < NbRows)
                        for (int k = 0; k < Grid[j][i].Count; k++)
                        {
                            if (!wantsNext)
                                return;

                            wantsNext = callback(Grid[j][i][k]);
                        }
        }