示例#1
0
        public Bullet(MainAsteroidsScene scene, int collideLayer) : base(scene)
        {
            polygonCollider            = new PolygonCollider(this, Core.Resources.Resources.Polygones.Bullet, scene.collidersWorld, collideLayer);
            polygonCollider.Tag        = "Bullet";
            polygonCollider.OnCollide += PolygonCollider_OnCollide;

            physic = new PhysicCore(this);

            polygonRender = new PolygonRender(this, Core.Resources.Resources.Polygones.Bullet);
            spriteRender  = new SpriteRender(this, Core.Resources.Resources.Sprites.Bullet);
            spriteRender.SetActive(false);
        }
示例#2
0
        public Asteroid(MainAsteroidsScene scene, SpriteInfo spriteInfo, Polygon polygon) : base(scene)
        {
            this.scene   = scene;
            SpriteRender = new SpriteRender(this, spriteInfo);
            SpriteRender.SetActive(false);

            PolygonRender = new PolygonRender(this, polygon);

            collider2D            = new PolygonCollider(this, polygon, scene.collidersWorld, 1);
            collider2D.OnCollide += Collider2D_OnCollide;
            collider2D.Tag        = "Asteroid";
            Physic = new PhysicCore(this);
        }
示例#3
0
        public LaserRay(MainAsteroidsScene scene, SpaceShip space) : base(scene)
        {
            this.spaceShip = space;
            var   polygon = new Polygon(Resources.Polygones.Bullet);
            float maxDim  = Math.Max(scene.Dimensions.X, scene.Dimensions.Y);

            polygon.Scale(new Vector2(4, maxDim));
            polygon.Center      = new Vector2(0, maxDim);
            polygonCollider     = new PolygonCollider(this, polygon, scene.collidersWorld, 0);
            polygonCollider.Tag = "Bullet";
            PolygonRender       = new PolygonRender(this, polygon);

            var li        = Resources.Sprites.Laser;
            var origin    = new Vector2(li.Rect.Width / 2, li.Rect.Height);
            var spritInfo = new SpriteInfo(li.Texture, li.Rect, origin.ToVector2f());

            SpriteRender       = new SpriteRender(this, spritInfo);
            SpriteRender.Scale = new Vector2(1, maxDim / spritInfo.Rect.Height);
            SpriteRender.SetActive(false);
        }
示例#4
0
        public UFO(MainAsteroidsScene scene, SpaceShip spaceShip) : base(scene)
        {
            this.scene     = scene;
            this.spaceShip = spaceShip;
            Name           = "UFO";
            physic         = new PhysicCore(this);
            gun            = new Gun(scene, this, 0, physic, 1);

            gun.BulletSpeed    = 450;
            gun.BulletLifeTime = 1.5f;
            gun.FireRate       = 1.5f;

            var plgn = Core.Resources.Resources.Polygones.UFO;

            polygonCollider            = new PolygonCollider(this, plgn, scene.collidersWorld, 1);
            polygonCollider.OnCollide += PolygonCollider_OnCollide;
            polygonCollider.Tag        = Name;
            PolygonRender              = new PolygonRender(this, plgn);
            SpriteRender = new SpriteRender(this, Core.Resources.Resources.Sprites.UFO);
            SpriteRender.SetActive(false);
        }