Ejemplo n.º 1
0
        /// <summary>
        /// Displays a hex to the form
        /// </summary>
        /// <param name="row">The row of the Hex</param>
        /// <param name="col">The column of the Hex</param>
        public void displayHex(int row, int col)
        {
            HexNode selected;

            if (map.isValid(row, col))
            {
                selected = searchHex(row, col);//if the location is valid grab the hex
            }
            else
            {
                showError("That position is invalid.");
                return;
            }

            currentSelection = selected; //store the selection

            if (selected == null)        //check if the selected node has an entry and update the display accordingly
            {
                txtHexName.Text     = HexNode.defaultName;
                txtHexComments.Text = HexNode.defaultComment;
                lblHexPos.Text      = "(" + row + "," + col + ")";
                currentTempPos      = new Tuple <int, int>(row, col); //set the temp pos
            }
            else
            {
                txtHexName.Text     = selected.getName();
                txtHexComments.Text = selected.getComment();
                lblHexPos.Text      = "(" + selected.getPos().Item1 + "," + selected.getPos().Item2 + ")";
                currentTempPos      = null;//reset the temp pos
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Adds a connection to the specified node
 /// </summary>
 /// <param name="connectedTo">The Hexnode to connect to</param>
 /// <param name="biDirectional">Whether both nodes should have a refernce of this connection</param>
 /// <param name="description">Description string of the connection</param>
 public void addConnection(HexNode connectedTo, Boolean biDirectional, string description)
 {
     this.connections.Add(new ConnectionNode(connectedTo, description));
     if (biDirectional)
     {
         connectedTo.addConnection(this, false, description);
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Tries to insert a hex into the map overwriting if specified. Otherwise checks if the space is valid and returns the sucess of the action.
        /// </summary>
        /// <param name="newHex">The hex to set</param>
        /// <param name="overwrite">Whether the map should the erase contents of a hex for the new one</param>
        /// <returns></returns>
        public bool addHex(HexNode newHex, bool overwrite)
        {
            Tuple <int, int> pos = newHex.getPos();

            if (pos.Item1 < height && pos.Item2 < width)
            {
                if (overwrite || map[pos.Item1, pos.Item2] == null)//overwite if needed otherwise check if the space if free
                {
                    map[pos.Item1, pos.Item2] = newHex;
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Resets the formm values
        /// </summary>
        public void resetForm()
        {
            //Current hex section
            txtHexName.Text        = "";
            txtRowSearchInput.Text = "";
            txtColSearchInput.Text = "";
            txtHexComments.Text    = "";

            //New hex section
            currentSelection     = null;
            currentTempPos       = null;
            lblHexPos.Text       = "";
            txtNameInput.Text    = "";
            txtRowInput.Text     = "";
            txtColInput.Text     = "";
            txtCommentInput.Text = "";
        }
Ejemplo n.º 5
0
 public ConnectionNode(HexNode connectedTo, string description)
 {
     this.connectedTo = connectedTo.getPos();
     this.description = description;
 }