示例#1
0
        public Enemy(Vector3 pos, VoxelSprite sprite)
        {
            Position = pos;
            //Position.Z = 5f;

            spriteSheet = sprite;
        }
示例#2
0
        public Enemy(Vector3 pos, VoxelSprite sprite)
        {
            Position = pos;
            //Position.Z = 5f;

            spriteSheet = sprite;
        }
示例#3
0
 public Asteroid(Vector3 pos, VoxelSprite sprite)
     : base(pos, sprite)
 {
     numFrames = 1;
     rotSpeed = new Vector3(Helper.RandomFloat(-0.1f, 0.1f), 0f, Helper.RandomFloat(-0.1f, 0.1f));//Helper.RandomFloat(-0.1f, 0.1f));
     Speed.X = Helper.RandomFloat(-1f, -0.3f);
     Speed.Y = Helper.RandomFloat(-0.2f, 0.2f);
     Health = 3f;
 }
示例#4
0
 public Asteroid(Vector3 pos, VoxelSprite sprite)
     : base(pos, sprite)
 {
     numFrames = 1;
     rotSpeed  = new Vector3(Helper.RandomFloat(-0.1f, 0.1f), 0f, Helper.RandomFloat(-0.1f, 0.1f));//Helper.RandomFloat(-0.1f, 0.1f));
     Speed.X   = Helper.RandomFloat(-1f, -0.3f);
     Speed.Y   = Helper.RandomFloat(-0.2f, 0.2f);
     Health    = 3f;
 }
示例#5
0
 public Squid(Vector3 pos, VoxelSprite sprite)
     : base(pos, sprite)
 {
     numFrames = 4;
     rotSpeed = new Vector3(0.1f, 0f, 0f);//Helper.RandomFloat(-0.1f, 0.1f));
     //Speed.X = Helper.RandomFloat(-0.5f, -0.3f);
     //Speed.Y = Helper.RandomFloat(-0.2f, 0.2f);
     Health = 25f;
     attackRate = 1000 + (double)Helper.Random.Next(2000);
 }
示例#6
0
 public Omega(Vector3 pos, VoxelSprite sprite)
     : base(pos, sprite)
 {
     numFrames = 1;
     rotSpeed  = new Vector3(0.1f, 0f, 0f);//Helper.RandomFloat(-0.1f, 0.1f));
     //Speed.X = Helper.RandomFloat(-0.5f, -0.3f);
     //Speed.Y = Helper.RandomFloat(-0.2f, 0.2f);
     Health     = 10f;
     attackRate = 1000 + (double)Helper.Random.Next(2000);
 }
示例#7
0
        public void LoadContent(ContentManager content, GraphicsDevice gd)
        {
            shipSprite = new VoxelSprite(15, 15, 15);
            LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "ship.vxs"), ref shipSprite);

            drawEffect = new BasicEffect(gd)
            {
                VertexColorEnabled = true
            };

            collisionBoxSize = new Vector3(10, 4f, 2f);
            CollisionBox     = new BoundingBox();
        }
示例#8
0
        public Turret(Vector3 pos, VoxelSprite sprite, bool inverted)
            : base(pos, sprite)
        {
            numFrames = 1;

            Inverted = inverted;

            if (Inverted) Rotation.Z = MathHelper.Pi;

            Speed = Vector3.Zero;
            Health = 50f;

            attackRate = 1000;
        }
示例#9
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            font = Content.Load<SpriteFont>("font");
            hudTex = Content.Load<Texture2D>("hud");

            tilesSprite = new VoxelSprite(16, 16, 16);
            LoadVoxels.LoadSprite(Path.Combine(Content.RootDirectory, "tiles.vxs"), ref tilesSprite);

            gameMap = Content.Load<Map>("1");
            tileLayer = (TileLayer)gameMap.GetLayer("tiles");
            MapObjectLayer spawnLayer = (MapObjectLayer)gameMap.GetLayer("spawns");

            gameWorld = new VoxelWorld(gameMap.Width, 11, 1);

            for(int yy=0;yy<11;yy++)
                for(int xx=0;xx<12;xx++)
                    if(tileLayer.Tiles[xx,yy]!=null) gameWorld.CopySprite(xx*Chunk.X_SIZE, yy*Chunk.Y_SIZE, 0, tilesSprite.AnimChunks[tileLayer.Tiles[xx,yy].Index-1]);

            scrollColumn = 12;

            gameCamera = new Camera(GraphicsDevice, GraphicsDevice.Viewport);
            gameCamera.Position = new Vector3(0f, gameWorld.Y_SIZE * Voxel.HALF_SIZE, 0f);
            gameCamera.Target = gameCamera.Position;

            gameHero = new Hero();
            gameHero.LoadContent(Content, GraphicsDevice);

            enemyController = new EnemyController(GraphicsDevice);
            enemyController.LoadContent(Content, spawnLayer);
            projectileController = new ProjectileController(GraphicsDevice);
            projectileController.LoadContent(Content);
            particleController = new ParticleController(GraphicsDevice);
            powerupController = new PowerupController(GraphicsDevice);
            powerupController.LoadContent(Content);
            gameStarfield = new Starfield(GraphicsDevice);

            drawEffect = new BasicEffect(GraphicsDevice)
            {
                World = gameCamera.worldMatrix,
                View = gameCamera.viewMatrix,
                Projection = gameCamera.projectionMatrix,
                VertexColorEnabled = true,
            };
        }
示例#10
0
        public Turret(Vector3 pos, VoxelSprite sprite, bool inverted)
            : base(pos, sprite)
        {
            numFrames = 1;

            Inverted = inverted;

            if (Inverted)
            {
                Rotation.Z = MathHelper.Pi;
            }

            Speed  = Vector3.Zero;
            Health = 50f;

            attackRate = 1000;
        }
示例#11
0
        public void LoadContent(ContentManager content, MapObjectLayer spawnLayer)
        {
            VoxelSprite asteroid = new VoxelSprite(16, 16, 16);

            LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "enemies", "asteroids.vxs"), ref asteroid);
            spriteSheets.Add("Asteroid", asteroid);
            VoxelSprite omega = new VoxelSprite(15, 15, 15);

            LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "enemies", "omega.vxs"), ref omega);
            spriteSheets.Add("Omega", omega);
            VoxelSprite turret = new VoxelSprite(15, 15, 15);

            LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "enemies", "turret.vxs"), ref turret);
            spriteSheets.Add("Turret", turret);
            VoxelSprite squid = new VoxelSprite(15, 15, 15);

            LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "enemies", "squid.vxs"), ref squid);
            spriteSheets.Add("Squid", squid);

            foreach (MapObject o in spawnLayer.Objects)
            {
                Spawns.Add(o);
            }
        }
示例#12
0
        public void LoadContent(ContentManager content, GraphicsDevice gd)
        {
            shipSprite = new VoxelSprite(15, 15, 15);
            LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "ship.vxs"), ref shipSprite);

            drawEffect = new BasicEffect(gd)
            {
                VertexColorEnabled = true
            };

            collisionBoxSize = new Vector3(10, 4f, 2f);
            CollisionBox = new BoundingBox();
        }
 public void LoadContent(ContentManager content)
 {
     projectileStrip = new VoxelSprite(5, 5, 5);
     LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "projectiles.vxs"), ref projectileStrip);
 }
示例#14
0
        public void LoadContent(ContentManager content, MapObjectLayer spawnLayer)
        {
            VoxelSprite asteroid = new VoxelSprite(16,16,16);
            LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "enemies", "asteroids.vxs"), ref asteroid);
            spriteSheets.Add("Asteroid", asteroid);
            VoxelSprite omega = new VoxelSprite(15,15,15);
            LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "enemies", "omega.vxs"), ref omega);
            spriteSheets.Add("Omega", omega);
            VoxelSprite turret = new VoxelSprite(15, 15, 15);
            LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "enemies", "turret.vxs"), ref turret);
            spriteSheets.Add("Turret", turret);
            VoxelSprite squid = new VoxelSprite(15, 15, 15);
            LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "enemies", "squid.vxs"), ref squid);
            spriteSheets.Add("Squid", squid);

            foreach (MapObject o in spawnLayer.Objects) Spawns.Add(o);
        }
示例#15
0
        public static void LoadSprite(string fn, ref VoxelSprite sprite)
        {
            byte[] buffer;

            using (FileStream gstr = new FileStream(fn, FileMode.Open))
            {
                byte[] lb = new byte[4];
                gstr.Position = gstr.Length - 4;
                gstr.Read(lb, 0, 4);
                int msgLength = BitConverter.ToInt32(lb, 0);

                buffer = new byte[msgLength];

                gstr.Position = 0;

                using (GZipStream str = new GZipStream(gstr, CompressionMode.Decompress))
                {

                    str.Read(buffer, 0, msgLength);
                }
            }

            int pos = 0;

            int xs = buffer[0];
            int ys = buffer[1];
            int zs = buffer[2];
            int frames = buffer[3];
            sprite = new VoxelSprite(xs, ys, zs);
            sprite.AnimChunks.Clear();
            sprite.ChunkRTs.Clear();

            pos = 4;

            for (int i = 0; i < 10; i++)
            {
                // don't need swatches in game!
                pos += 3;
            }

            for (int frame = 0; frame < frames; frame++)
            {
                sprite.AddFrame(false);

                AnimChunk c = sprite.AnimChunks[frame];

                while (pos < buffer.Length)
                {
                    if (Convert.ToChar(buffer[pos]) != 'c')
                    {
                        //str.Seek(-1, SeekOrigin.Current);
                        //str.Read(ba, 0, 10);
                        int vx = buffer[pos];
                        int vy = buffer[pos + 1];
                        int vz = buffer[pos + 2];
                        Color top = new Color(buffer[pos + 3], buffer[pos + 4], buffer[pos + 5]);

                        c.SetVoxel(vx, vy, vz, true, top);
                        pos += 6;

                    }
                    else
                    {
                        pos++;
                        break;
                    }

                }

                c.UpdateMesh();

            }

            GC.Collect();
        }
示例#16
0
        public static void LoadSprite(string fn, ref VoxelSprite sprite)
        {
            byte[] buffer;

            using (FileStream gstr = new FileStream(fn, FileMode.Open))
            {
                byte[] lb = new byte[4];
                gstr.Position = gstr.Length - 4;
                gstr.Read(lb, 0, 4);
                int msgLength = BitConverter.ToInt32(lb, 0);

                buffer = new byte[msgLength];

                gstr.Position = 0;

                using (GZipStream str = new GZipStream(gstr, CompressionMode.Decompress))
                {
                    str.Read(buffer, 0, msgLength);
                }
            }

            int pos = 0;

            int xs     = buffer[0];
            int ys     = buffer[1];
            int zs     = buffer[2];
            int frames = buffer[3];

            sprite = new VoxelSprite(xs, ys, zs);
            sprite.AnimChunks.Clear();
            sprite.ChunkRTs.Clear();

            pos = 4;

            for (int i = 0; i < 10; i++)
            {
                // don't need swatches in game!
                pos += 3;
            }


            for (int frame = 0; frame < frames; frame++)
            {
                sprite.AddFrame(false);

                AnimChunk c = sprite.AnimChunks[frame];

                while (pos < buffer.Length)
                {
                    if (Convert.ToChar(buffer[pos]) != 'c')
                    {
                        //str.Seek(-1, SeekOrigin.Current);
                        //str.Read(ba, 0, 10);
                        int   vx  = buffer[pos];
                        int   vy  = buffer[pos + 1];
                        int   vz  = buffer[pos + 2];
                        Color top = new Color(buffer[pos + 3], buffer[pos + 4], buffer[pos + 5]);

                        c.SetVoxel(vx, vy, vz, true, top);
                        pos += 6;
                    }
                    else
                    {
                        pos++;
                        break;
                    }
                }

                c.UpdateMesh();
            }

            GC.Collect();
        }
示例#17
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);

            font = Content.Load<SpriteFont>("font");
            hudTex = Content.Load<Texture2D>("hud");

            tilesSprite = new VoxelSprite(16, 16, 16);
            LoadVoxels.LoadSprite(Path.Combine(Content.RootDirectory, "tiles.vxs"), ref tilesSprite);

            gameMap = Content.Load<Map>("1");
            tileLayer = (TileLayer)gameMap.GetLayer("tiles");
            MapObjectLayer spawnLayer = (MapObjectLayer)gameMap.GetLayer("spawns");

            gameWorld = new VoxelWorld(gameMap.Width, 11, 1);

            for(int yy=0;yy<11;yy++)
                for(int xx=0;xx<12;xx++)
                    if(tileLayer.Tiles[xx,yy]!=null) gameWorld.CopySprite(xx*Chunk.X_SIZE, yy*Chunk.Y_SIZE, 0, tilesSprite.AnimChunks[tileLayer.Tiles[xx,yy].Index-1]);

            scrollColumn = 12;

            gameCamera = new Camera(GraphicsDevice, GraphicsDevice.Viewport);
            gameCamera.Position = new Vector3(0f, gameWorld.Y_SIZE * Voxel.HALF_SIZE, 0f);
            gameCamera.Target = gameCamera.Position;

            gameHero = new Hero();
            gameHero.LoadContent(Content, GraphicsDevice);

            enemyController = new EnemyController(GraphicsDevice);
            enemyController.LoadContent(Content, spawnLayer);
            projectileController = new ProjectileController(GraphicsDevice);
            projectileController.LoadContent(Content);
            particleController = new ParticleController(GraphicsDevice);
            powerupController = new PowerupController(GraphicsDevice);
            powerupController.LoadContent(Content);
            gameStarfield = new Starfield(GraphicsDevice);

            drawEffect = new BasicEffect(GraphicsDevice)
            {
                World = gameCamera.worldMatrix,
                View = gameCamera.viewMatrix,
                Projection = gameCamera.projectionMatrix,
                VertexColorEnabled = true,
            };
        }
示例#18
0
 public void LoadContent(ContentManager content)
 {
     projectileStrip = new VoxelSprite(5, 5, 5);
     LoadVoxels.LoadSprite(Path.Combine(content.RootDirectory, "projectiles.vxs"), ref projectileStrip);
 }