예제 #1
0
        private void btnUpdate_Click(object sender, EventArgs e)
        {
            if (!mapCheck())
            {
                return;
            }                                                                                                    //proceed if map is open

            if (currentSelection == null)                                                                        //check if this node has an entry already
            {
                addNode(txtHexName.Text, txtHexComments.Text, currentTempPos.Item1, currentTempPos.Item2, true); //update data
                displayHex(currentTempPos.Item1, currentTempPos.Item2);                                          //update display
            }
            else
            {
                currentSelection.setName(txtHexName.Text);                                    //update data
                currentSelection.setComment(txtHexComments.Text);
                displayHex(currentSelection.getPos().Item1, currentSelection.getPos().Item2); //update display
            }
        }
예제 #2
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);
        }
예제 #3
0
 public ConnectionNode(HexNode connectedTo, string description)
 {
     this.connectedTo = connectedTo.getPos();
     this.description = description;
 }