Beispiel #1
0
        public AsteroidsSpawner(MainAsteroidsScene scene) : base(scene)
        {
            this.scene = scene;
            random     = new Random();

            big.polygon         = Resources.Polygones.Asteroid1;
            big.scaled          = new Vector2(1, 1);
            big.minForce        = 60;
            big.maxForce        = 80;
            big.minAngularForce = 150;
            big.maxAngularForce = 200;
            big.spriteInfo      = Resources.Sprites.Asteroid1;

            mid.minForce        = 135;
            mid.maxForce        = 200;
            mid.minAngularForce = 200;
            mid.maxAngularForce = 250;
            mid.polygon         = new Polygon(big.polygon);
            mid.scaled          = new Vector2(0.5f, 0.5f);
            mid.polygon.Scale(mid.scaled);

            small.minForce        = 250;
            small.maxForce        = 300;
            small.minAngularForce = 300;
            small.maxAngularForce = 400;
            small.polygon         = new Polygon(big.polygon);
            small.scaled          = new Vector2(0.3f, 0.3f);
            small.polygon.Scale(small.scaled);


            big.pull = new Asteroid[15];
            for (int i = 0; i < big.pull.Length; i++)
            {
                big.pull[i] = new Asteroid(scene, Resources.Sprites.Asteroid1, big.polygon);
                var aster = big.pull[i];
                aster.Name = "BigAsteroid";
                big.pull[i].OnCollideBullet += () => CollidedBullt(aster);
            }
            mid.pull = new Asteroid[20];
            for (int i = 0; i < mid.pull.Length; i++)
            {
                mid.pull[i] = new Asteroid(scene, Resources.Sprites.Asteroid1, mid.polygon);
                var aster = mid.pull[i];
                aster.Name = "MidAsteroid";
                aster.SpriteRender.Scale = mid.scaled;
                var trans = aster.Transform;
                mid.pull[i].OnCollideBullet += () => CollidedBullt(aster);
            }
            small.pull = new Asteroid[25];
            for (int i = 0; i < small.pull.Length; i++)
            {
                small.pull[i] = new Asteroid(scene, Resources.Sprites.Asteroid1, small.polygon);
                var aster = small.pull[i];
                aster.SpriteRender.Scale = small.scaled;
                aster.Name             = "SmallAsteroid";
                aster.OnCollideBullet += () => CollidedBullt(aster);
            }
            Clear();
        }
Beispiel #2
0
 public GunLaser(MainAsteroidsScene scene, SpaceShip actor, float reloadTime, float rayTime) : base(actor)
 {
     this.scene = scene;
     ReloadTime = reloadTime;
     RayTime    = rayTime;
     LaserRay   = new LaserRay(scene, actor);
     AddSubObject(LaserRay);
     LaserRay.SetActive(false);
 }
Beispiel #3
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);
        }
Beispiel #4
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);
        }
Beispiel #5
0
 public Gun(MainAsteroidsScene scene, DrawableActor actor, float fwdSpawnBulletScale, PhysicCore physic, int bulletCollideLayer) : base(actor)
 {
     drawableActor            = actor;
     this.physic              = physic;
     this.fwdBulletSpawnScale = fwdSpawnBulletScale;
     BulletLifeTime           = 1.5f;
     FireRate    = 0.1f;
     bulletsPull = new Bullet[(int)(BulletLifeTime / FireRate)];
     for (int i = 0; i < bulletsPull.Length; i++)
     {
         bulletsPull[i]          = new Bullet(scene, bulletCollideLayer);
         bulletsPull[i].LiveTime = BulletLifeTime;
         bulletsPull[i].SetActive(false);
     }
 }
Beispiel #6
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);
        }