Example #1
0
        public TreeVertexCollection(GameSession.GameStorage storage)
        {
            this.MapSize = storage.ReadVector4();
            _topSize     = (int)this.MapSize.X - 1;
            _halfSize    = _topSize / 2;
            _vertexCount = (int)(this.MapSize.X * this.MapSize.Y);

            int vertexCount = storage.ReadInt();

            //Initialize our array to hold the vertices
            Vertices = new VertexMultitextured[_vertexCount];

            //Our method to populate the vertex collection
            // VertexMultitextured[] Vertices;
            for (int i = 0; i < this.Vertices.Length; i++)
            {
                this.Vertices[i] = storage.ReadVertexMultiTextured();
            }

            // int[] sector;
            sector = new int[storage.ReadInt()];
            for (int i = 0; i < sector.Length; i++)
            {
                sector[i] = storage.ReadInt();
            }

            // ResourceCell[] resources;
            resources = new ResourceCell[storage.ReadInt()];
            for (int i = 0; i < this.resources.Length; i++)
            {
                resources[i] = new ResourceCell();
                resources[i].Restore(storage);
            }

            //Our method to  calculate the normals for all vertices
            CalculateAllNormals();
        }