// called from changefieldstateonclick when space is pressed on a field that is in the players's influence area, but does not have a specialisation yet. public void openMenu(Vector3 pos, GameObject hex, ChangeFieldStateOnClick script) { if ((hex.GetComponent<HexField>().owner == 1 && Network.isServer) || (hex.GetComponent<HexField>().owner == 2 && Network.isClient)) { this.pos = pos; selectedHexagon = hex; buttonCallbackListener createMilitaryNodeButton = button1_Action; buttonCallbackListener createEconomyNodeButton = button3_Action; //Create new Buttonelements and add them to the gazeUI gazeUI.Add(new GazeButton(new Rect(pos.x - 100, pos.y - 150, 220, 200), "150 \n CREATE \n MILITARY NODE", myStyle, createMilitaryNodeButton)); gazeUI.Add(new GazeButton(new Rect(pos.x - 100 , pos.y + 50, 220, 200), "100 \n CREATE \n ECONOMY NODE", myStyle, createEconomyNodeButton)); } menuOpen = true; }
// called from changefieldstateonclick when space is pressed on a military or base node public void openMenu(Vector3 pos, GameObject hex, ChangeFieldStateOnClick script) { selectedHexagon = hex; //Set the Actions of the Buttons buttonCallbackListener attackButton = button1_Action; buttonCallbackListener moveButton = button2_Action; buttonCallbackListener buildButton = button3_Action; buttonCallbackListener moving = button4_Action; buttonCallbackListener attacking = button5_Action; buttonCallbackListener canceling = button6_Action; buttonCallbackListener laser = button7_Action; buttonCallbackListener protons = button8_Action; buttonCallbackListener emp = button9_Action; bool isSending = mainController.isSending()>0; //Create new Buttonelements and add them to the gazeUI if (!isSending && ((hex.GetComponent<HexField>().owner == 1 && Network.isServer) || (hex.GetComponent<HexField>().owner == 2 && Network.isClient))) { // troops are not sent and player tries to open popupmenu on his own military or base node if (!(hex.GetComponent<HexField>().spec is BaseSpecialisation)) { // military node if (((MilitarySpecialisation)hex.GetComponent<HexField>().spec).WeaponType == 0) { // Military node not specialised yet. show specialisation options showInfoPanel = false; gazeUI.Add(new GazeButton(new Rect(pos.x - 110, pos.y - 180, 220, 200), "LASER \n FLEET", myStyle, laser)); gazeUI.Add(new GazeButton(new Rect(pos.x + 20, pos.y, 220, 200), " PROTON \n TORPEDO FLEET", myStyle, protons)); gazeUI.Add(new GazeButton(new Rect(pos.x - 240, pos.y, 220, 200), " EMP \n FLEET", myStyle, emp)); } else { // military node is already specialised. show info panel showInfoPanel = true; if (((MilitarySpecialisation)hex.GetComponent<HexField>().spec).Troops < 100) { // troop max not reached. recruiting is possible attackingHex = selectedHexagon; if (((MilitarySpecialisation)hex.GetComponent<HexField>().spec).RecruitCounter == 0) { gazeUI.Add(new GazeButton(new Rect(pos.x - 110, pos.y + 50, 220, 200), "ATTACK", myStyle, attackButton)); gazeUI.Add(new GazeButton(new Rect(pos.x + 40, pos.y - 80, 220, 200), " \n MOVE TROOPS", myStyle, moveButton)); gazeUI.Add(new GazeButton(new Rect(pos.x - 260, pos.y - 80, 220, 200), "150 \n BUILD SHIPS", myStyle, buildButton)); } } else { gazeUI.Add(new GazeButton(new Rect(pos.x - 260, pos.y - 80, 220, 200), "ATTACK", myStyle, attackButton)); gazeUI.Add(new GazeButton(new Rect(pos.x + 40, pos.y - 80, 220, 200), " \n MOVE TROOPS", myStyle, moveButton)); } } } // Base node. only info panel is shown else showInfoPanel = true; } else if (isSending && hex.GetComponent<HexField>().InRange) { // troops are being sent if ((hex.GetComponent<HexField>().owner == 2 && Network.isServer) || (hex.GetComponent<HexField>().owner == 1 && Network.isClient)) { // player opened menu on enemy node gazeUI.Add(new GazeButton(new Rect(pos.x - 100, pos.y - 150, 220, 200), "ATACK HERE", myStyle, attacking)); } else { // player opened menu on own node if (!(hex == attackingHex)) gazeUI.Add(new GazeButton(new Rect(pos.x - 100, pos.y - 150, 220, 200), "MOVE HERE", myStyle, moving)); } showInfoPanel = false; gazeUI.Add(new GazeButton(new Rect(pos.x - 100, pos.y + 50, 220, 200), "CANCEL", myStyle, canceling)); } if (isSending && hex == attackingHex) { // plaver opened menu on the node from which he is moving/attacking. enable cancel showInfoPanel = false; gazeUI.Add(new GazeButton(new Rect(pos.x - 100, pos.y + 50, 220, 200), "CANCEL", myStyle, canceling)); } menuOpen = true; }