Example #1
0
        private void clickNode(object sender, EventArgs e)
        {
            switch (currentState)
            {
            case MapState.CONNECT:
                currentNode = (NodeButton)sender;
                setState(MapState.CONNECTING);
                break;

            case MapState.CONNECTING:
                if (sender == currentNode)
                {
                    return;
                }
                currentNode.children.Add((NodeButton)sender);
                currentNode.UpdateChildren(nodes);
                setState(MapState.CONNECT);
                mapArea.Refresh();
                break;

            case MapState.DISCONNECT:
                currentNode = (NodeButton)sender;
                setState(MapState.DISCONNECTING);
                break;

            case MapState.DISCONNECTING:
                currentNode.children.Remove((NodeButton)sender);
                currentNode.UpdateChildren(nodes);
                setState(MapState.DISCONNECT);
                mapArea.Refresh();
                break;

            case MapState.MOVE:
                currentNode = (NodeButton)sender;
                setState(MapState.MOVING);
                break;

            case MapState.MOVING:
                setState(MapState.MOVE);
                break;

            case MapState.EDIT:
                new FormEditNode(((NodeButton)sender)).ShowDialog();
                break;
            }
        }
Example #2
0
 private void addNode_Click(object sender, EventArgs e)
 {
     if (!CanSwitchState())
     {
         return;
     }
     if (campaign.info.mapPositions.Count >= campaign.challenges.Count)
     {
         ShowDialog("You cannot have more nodes than challenges, if you wish to add more ndoes, add the challenges for those ndoes first.", "Error");
         return;
     }
     setState(MapState.ADD);
     currentNode      = new NodeButton();
     currentNode.Text = nodes.Count + "";
     mapArea.Controls.Add(currentNode);
     currentNode.Click += placeNode;
     //this.Controls.Add(button);
 }
Example #3
0
 public void PrepareMap()
 {
     foreach (NodeButton node in nodes)
     {
         node.Parent.Controls.Remove(node);
     }
     foreach (GateButton gate in gates)
     {
         gate.Parent.Controls.Remove(gate);
     }
     nodes.Clear();
     gates.Clear();
     UpdateMapHeight(campaign.info.mapHeight);
     foreach (CampainMapPosition mapPos in campaign.info.mapPositions)
     {
         currentNode = new NodeButton();
         mapArea.Controls.Add(currentNode);
         currentNode.mapPosition = mapPos;
         currentNode.Location    = new Point((int)mapPos.x - currentNode.Width / 2 + (currentNode.Parent.Bounds.Width) / 2, (int)mapPos.y - currentNode.Height / 2);
         currentNode.Text        = nodes.Count + "";
         currentNode.Click      += clickNode;
         nodes.Add(currentNode);
     }
     foreach (CampaignUnlockGate gate in campaign.info.unlockGate)
     {
         currentGate = new GateButton();
         mapArea.Controls.Add(currentGate);
         currentGate.unlockGate = gate;
         currentGate.Location   = new Point((int)gate.x - currentGate.Width / 2 + (currentGate.Parent.Bounds.Width) / 2, (int)gate.y - currentGate.Height / 2);
         currentGate.Text       = "UNLOCK GATE";
         currentGate.Click     += clickGate;
         gates.Add(currentGate);
     }
     foreach (NodeButton node in nodes)
     {
         List <NodeButton> children = new List <NodeButton>();
         foreach (int i in node.mapPosition.childNodes)
         {
             children.Add(nodes[i]);
         }
         node.children = children;
     }
     mapArea.Refresh();
 }
 public FormEditNode(NodeButton nodeButton)
 {
     InitializeComponent();
     this.mapPosition = nodeButton.mapPosition;
     this.nodeButton  = nodeButton;
 }