Esempio n. 1
0
    public void AddDecoration(VoxelSprite sprite)
    {
        if (m_DecorationCount == m_Decoration.Length)
        {
            return;
        }

        m_Decoration[m_DecorationCount] = sprite;
        m_DecorationCount++;
    }
Esempio n. 2
0
    public void AddSprite(Vector3 position, Models model)
    {
        int subChunkIndex = GetSubChunkIdFromHeight((int)position.y);

        int subChunkHeight = (int)position.y - ((int)CHUNK_SIZE * (subChunkIndex));
        var localPosition  = new Vector3(position.x, subChunkHeight, position.z);

        var mesh   = ModelLoader.GetModel(model);
        var sprite = new VoxelSprite(mesh, localPosition);

        m_SubChunks[subChunkIndex].AddDecoration(sprite);
    }
Esempio n. 3
0
        public Pong() : base()
        {
            p1   = new VoxelSprite(2, 1, 3, 3, 0, 3);
            p2   = new VoxelSprite(2, 1, 3, 3, 7, 3);
            ball = new Voxel(3, 3, 3);

            // Initial velocity
            vy = -1;
            vz = -1;

            sprites = new List <Drawable>();
            sprites.Add(p1); sprites.Add(p2); sprites.Add(ball);
        }
Esempio n. 4
0
 public void AddVoxelSprite(VoxelSprite voxelSprite)
 {
     VoxelSprite.Add(voxelSprite);
 }
Esempio n. 5
0
        private static void Main(string[] args)
        {
            Dictionary<string, bool[,]> letters = new Dictionary<string, bool[,]>();

            Console.WriteLine("Creating Sprite");
            VoxelSprite sprite = new VoxelSprite();
            sprite.Init(SPRITE_SIZE);

            // Read in letters dictionary
            Console.WriteLine("Reading Letters");
            using (TextReader tr = File.OpenText("letters.txt"))
            {
                while (true)
                {
                    string l = tr.ReadLine();
                    if (string.IsNullOrEmpty(l)) break;
                    bool[,] dots = new bool[5, 5];
                    for (int i = 0; i < 5; i++)
                    {
                        string line = tr.ReadLine();
                        for (int x = 0; x < line.Length; x++) if (line[x] == '*') dots[i, x] = true;
                    }
                    letters.Add(l, dots);
                    Console.Write(l);
                }
                Console.WriteLine();
            }

            VoxelSpriteChunk cb = new VoxelSpriteChunk();
            cb.Init(SPRITE_SIZE, SPRITE_SIZE, SPRITE_SIZE);
            sprite.Chunks.Add(cb);
            CreateBase(cb, 11);
            CreateScrews(cb, 11);

            cb = new VoxelSpriteChunk();
            cb.Init(SPRITE_SIZE, SPRITE_SIZE, SPRITE_SIZE);
            sprite.Chunks.Add(cb);
            CreateBase(cb, 46);
            CreateScrews(cb, 46);

            Console.WriteLine("Reading Buttons");
            using (TextReader tr = File.OpenText("buttons.txt"))
            {
                while (true)
                {
                    string text = tr.ReadLine();
                    if (string.IsNullOrEmpty(text)) break;
                    Console.Write(text);

                    VoxelSpriteChunk c = new VoxelSpriteChunk();
                    c.Init(SPRITE_SIZE, SPRITE_SIZE, SPRITE_SIZE);
                    sprite.Chunks.Add(c);

                    CreateBase(c, 11);
                    Console.Write(".");

                    CreateScrews(c, 11);
                    Console.Write(".");

                    CreateText(c, 11, text, letters);
                    Console.Write(".");

                    Console.WriteLine();
                }
            }

            Console.WriteLine("Saving sprite");
            sprite.Save("mainmenu.vxs");

            Console.Write("Done, press enter");
            Console.ReadLine();
        }
Esempio n. 6
0
        /// <summary>
        /// Constructor for the WorldViewScreen
        /// </summary>
        public WorldViewScreen(Game game, ScreenElement previousScreenElement) :
            base(previousScreenElement, game.GraphicsDevice)
        {
            this.content = game.Content;
            this.game    = game;

            // Set seed to build world with
            int mapSeed = 123;

            Noise.Simplex.Seed(mapSeed);

            // Load graphics resources/assets
            boxRenderer = new BoundingBoxRenderer(graphicsDevice);

            voxelEffect   = content.Load <Effect>("Effects/voxel");
            skydomeEffect = content.Load <Effect>("Effects/skydome");

            // Load initial data for the voxel sprite
            VoxelCache voxelCache = new VoxelCache(mapSeed, 32, 128);

            playerSprite = new VoxelSprite(graphicsDevice);
            playerSprite.Load(voxelCache, "chr_knight");

            // Attempt to load player save data
            gameData = new GameData();

            if (gameData.LoadGame(mapSeed))
            {
                player = new Player(playerSprite.Mesh, gameData.Player);
            }
            else
            {
                Player.PlayerData data = new Player.PlayerData()
                {
                    position    = new Vector3(200, 50, -20),
                    orientation = 0
                };
                player = new Player(playerSprite.Mesh, data);
            }

            // Set up voxel chunks and skydome
            chunkManager = new ChunkManager(graphicsDevice, 123);
            chunkManager.Initialize(graphicsDevice, player.playerData.position);
            skydome = new Skydome(graphicsDevice, content);

            // Set up cameras
            playerCamera  = new PlayerCamera(Vector3.Zero, Vector2.Zero);
            skydomeCamera = new PlayerCamera(Vector3.Zero, Vector2.Zero);

            InitializeGraphicsResources();

            // Set debug info
            debugStats = new DebugStats
            {
                vertexCount = this.vertexCount,
                cameraPos   = this.playerCamera.position,
                chunksAdded = this.chunkManager.ChunksAdded
            };

            // Testing console commands
            GUI.EntitySpawner spawner = new GUI.EntitySpawner();
            console.Command("test");

            // Set some non-standard effect parameters here
            Color skyColor = new Color(0.091f, 0.622f, 0.976f);

            voxelEffect.Parameters["skyColor"].SetValue(skyColor.ToVector3());
            voxelEffect.Parameters["skyTexture"].SetValue(skydome.Skymap);
            voxelEffect.Parameters["toggleColors"].SetValue(toggleColors);

            // Manage resources that need to be reset when graphics device is lost
            game.GraphicsDevice.DeviceReset += new EventHandler <EventArgs>(OnDeviceReset);

            // Add children screen with these stats
            children.Add(new ScreenElements.DebugViewScreen(this, content, graphicsDevice, debugStats, game));
        }