Ejemplo n.º 1
0
        public void ImportVertices(GridSquare gridSquare)
        {
            for (int ii = 0; ii < 4; ii++)
            {
                this._vertices[ii] = gridSquare.Vertices[ii];
            }

            for (int ii = 0; ii < 6; ii++)
            {
                this._indices[ii] = gridSquare.Indices[ii];
            }
        }
Ejemplo n.º 2
0
        private void updatePosition()
        {
            GridSquare gridSquare = _grid.GetGridSquare(
                (uint)Math.Round(_gridPosition.X), (uint)Math.Round(_gridPosition.Y)
                );

            _overlay.ImportVertices(gridSquare);

            _cursor.Height         = gridSquare.Height + 1.0f;
            _cursor.GridPosition.X = _gridPosition.X;
            _cursor.GridPosition.Y = _gridPosition.Y;
            _cursor.CalculateVertices();
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Creates an empty map of X by Z size
        /// </summary>
        /// <param name="xSize">Number of unit grids along the X axis</param>
        /// <param name="zSize">Number of unit grids along the Z axis</param>
        public Grid(int xSize, int zSize, string texture)
        {
            _xSize       = xSize;
            _zSize       = zSize;
            _textureName = texture;

            _grid = new GridSquare[_xSize, _zSize];
            for (int xx = 0; xx < xSize; xx++)
            {
                for (int zz = 0; zz < zSize; zz++)
                {
                    float height = 0.01f;
                    _grid[xx, zz]          = new GridSquare(xx, zz, height);
                    _grid[xx, zz].TopAngle = 0.0f;
                    _grid[xx, zz].CompileVertices();
                }
            }

            this.initializeGraphics(texture);
            this.compileVertices();
            this.registerWithScripter();
        }
Ejemplo n.º 4
0
        public static Grid Load(XmlDocument xmlDocument, XmlNode rootNode)
        {
            int    xSize       = Convert.ToInt32(rootNode.Attributes["xSize"].Value);
            int    zSize       = Convert.ToInt32(rootNode.Attributes["zSize"].Value);
            string textureName = rootNode.Attributes["texture"].Value;
            Grid   NewGrid     = new Grid(xSize, zSize, "Textures/red");

            NewGrid._grid = new GridSquare[xSize, zSize];
            XmlNodeList gridSquareList = rootNode.ChildNodes;

            foreach (XmlNode node in gridSquareList)
            {
                int xIndex = Convert.ToInt32(node.Attributes["xIndex"].Value);
                int zIndex = Convert.ToInt32(node.Attributes["zIndex"].Value);

                bool    isWalkable = Convert.ToBoolean(node["IsWalkable"].InnerText);
                float   height     = (float)Convert.ToDouble(node["Height"].InnerText);
                Vector3 topUp      = (new Vector3()).GetFromString(node["TopUp"].InnerText);
                float   topAngle   = (float)Convert.ToDouble(node["TopAngle"].InnerText);

                GridSquare curGS = new GridSquare(xIndex, zIndex, height);
                NewGrid._grid[xIndex, zIndex] = curGS;

                curGS.IsWalkable = isWalkable;
                curGS.Height     = height;
                curGS.TopUp      = topUp;
                curGS.TopAngle   = topAngle;

                curGS.CompileVertices();
            }

            NewGrid.initializeGraphics(textureName);
            NewGrid.compileVertices();

            return(NewGrid);
        }