示例#1
0
 private void addGate_Click(object sender, EventArgs e)
 {
     if (!CanSwitchState())
     {
         return;
     }
     setState(MapState.ADD_GATE);
     currentGate      = new GateButton();
     currentGate.Text = "UNLOCK GATE";
     mapArea.Controls.Add(currentGate);
     currentGate.Click += placeGate;
 }
示例#2
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();
 }
示例#3
0
        private void clickGate(object sender, EventArgs e)
        {
            switch (currentState)
            {
            case MapState.REMOVE_GATES:
                gates.Remove((GateButton)sender);
                mapArea.Controls.Remove((GateButton)sender);
                campaign.info.unlockGate.Remove(((GateButton)sender).unlockGate);
                break;

            case MapState.MOVE_GATES:
                currentGate = (GateButton)sender;
                setState(MapState.MOVING_GATE);
                break;

            case MapState.MOVING_GATE:
                setState(MapState.MOVE_GATES);
                break;

            case MapState.EDIT_GATES:
                new FormEditGate(((GateButton)sender).unlockGate).ShowDialog();
                break;
            }
        }