void MakeWindow(int id) { Functions.DrawBackground(new Rect(0, 0, width, height), bgTexture); GUIStyle style = new GUIStyle(GUI.skin.label); style.alignment = TextAnchor.UpperCenter; style.font = font; style.fontSize = 16; GUI.Label(new Rect((windowRect.width - 100) / 2, 0, 100, 30), "Convergence Game", style); if (GUI.Button(new Rect(windowRect.width - 100 - bufferBorder, 0, 100, 30), "Logout")) { NetworkManager.Send(LogoutProtocol.Prepare(0), ProcessLogout); } GUI.BeginGroup(new Rect(bufferBorder, 0, windowRect.width, 100)); style.alignment = TextAnchor.LowerLeft; style.fontSize = 14; GUI.Label(new Rect(0, 0, 300, 30), "Select Ecosystem:", style); GUI.SetNextControlName("ecosystem_idx_field"); int new_idx; new_idx = GUI.SelectionGrid(new Rect(0, 35, windowRect.width - 20, 30), ecosystem_idx, ecosysDescripts, ecosysDescripts.Length); GUI.EndGroup(); if (!isProcessing && new_idx != ecosystem_idx) { //Debug.Log ("Updating selected ecosystem."); SetIsProcessing(true); new_ecosystem_idx = new_idx; new_ecosystem_id = GetEcosystemId(new_ecosystem_idx); GetPriorAttempts(); } if (graphs != null) { graphs.DrawGraphs(); } GUIStyle styleEdit = new GUIStyle(GUI.skin.textArea); styleEdit.wordWrap = true; //data entry fields DrawParameterFields(style); if (isInitial && GUI.GetNameOfFocusedControl() == "") { GUI.FocusControl("ecosystem_idx_field"); isInitial = false; } string buttonTitle = isProcessing ? "Processing" : "Submit"; if (!(isProcessing && !blinkOn)) { if (GUI.Button(new Rect(bufferBorder, height - 30 - bufferBorder, 100, 30), buttonTitle) && !isProcessing) { //make sure new config is distinct from prior attempts and initial value currAttempt.UpdateConfig(); //update config based on user data entry changes ConvergeAttempt prior = attemptList.Find(entry => entry.config == currAttempt.config); if (prior == null && currAttempt.ParamsUpdated()) { Submit(); SetIsProcessing(true); } else if (!showPopup) { int prior_idx = attemptList.FindIndex(entry => entry.config == currAttempt.config); if (prior_idx == Constants.ID_NOT_SET) { popupMessage = "Duplicate configuration to initial ecosystem. Please try again."; } else { popupMessage = "Duplicate configuration to prior attempt (#" + (prior_idx + 1) + "). Please try again."; } //Debug.Log (popupMessage); showPopup = true; } } } if (GUI.Button(new Rect(bufferBorder + 110, height - 30 - bufferBorder, 110, 30), "Progress Report")) { GenerateBarGraph(); } int screenOffset = 0; if (currAttempt != null && currAttempt.allow_hints) { screenOffset += bufferBorder + 110; if (GUI.Button(new Rect(bufferBorder * 2 + 110 * 2, height - 30 - bufferBorder, 110, 30), "Get Hint")) { //only give new hint if one hasn't been provided during this session. if (currAttempt.hint_id == Constants.ID_NOT_SET) { int hintId = GetRandomHint(true); if (hintId == Constants.ID_NOT_SET) { popupMessage = "Sorry, no new hints are available."; } else { popupMessage = hintDict[hintId]; currAttempt.hint_id = hintId; } } else { if (hintDict.ContainsKey(currAttempt.hint_id)) { popupMessage = hintDict[currAttempt.hint_id] + "\n[Only one hint is provided per attempt.]"; } else { Debug.LogError("Invalid hint for current attempt, ID = " + currAttempt.hint_id); popupMessage = "Error, hint not available."; } } if (priorHintIdList.Count > 0) { popupMessage += "\n\nPrior Hints:"; } for (int i = 0; i < priorHintIdList.Count; i++) { popupMessage += "\n\n" + hintDict[priorHintIdList[i]]; } //Debug.Log (popupMessage); showPopup = true; } } DrawResetButtons(screenOffset, style); }
void MakeWindow (int id) { Functions.DrawBackground (new Rect (0, 0, width, height), bgTexture); GUIStyle style = new GUIStyle (GUI.skin.label); style.alignment = TextAnchor.UpperCenter; style.font = font; style.fontSize = 16; GUI.Label (new Rect ((windowRect.width - 200) / 2, 0, 200, 30), "Multiplayer Convergence", style); if (GUI.Button (new Rect (windowRect.width - 100 - bufferBorder, 0, 100, 30), "Return to Lobby")) { Destroy (this); Destroy (foodWeb); GameState gs = GameObject.Find ("Global Object").GetComponent<GameState> (); Species[] s = gs.GetComponents<Species>(); foreach (Species sp in s) Destroy (sp); //destroy the "species" objects Game.SwitchScene("World"); } /* Player does not select Ecosystem here. Host selects at beginning. GUI.BeginGroup (new Rect (bufferBorder, 0, windowRect.width, 100)); style.alignment = TextAnchor.LowerLeft; style.fontSize = 14; GUI.Label (new Rect (0, 0, 300, 30), "Select Ecosystem:", style); GUI.SetNextControlName ("ecosystem_idx_field"); int new_idx; new_idx = GUI.SelectionGrid (new Rect (0, 35, windowRect.width - 20, 30), ecosystem_idx, ecosysDescripts, ecosysDescripts.Length); GUI.EndGroup (); if (!isProcessing && new_idx != ecosystem_idx) { //Debug.Log ("Updating selected ecosystem."); SetIsProcessing (true); new_ecosystem_idx = new_idx; new_ecosystem_id = GetEcosystemId (new_ecosystem_idx); GetPriorAttempts (); } */ if (graphs != null) { graphs.DrawGraphs (); } GUIStyle styleEdit = new GUIStyle (GUI.skin.textArea); styleEdit.wordWrap = true; //data entry fields DrawParameterFields (style); /* DH change. Not using ecosystem selection by player if (isInitial && GUI.GetNameOfFocusedControl () == "") { GUI.FocusControl ("ecosystem_idx_field"); isInitial = false; } */ // DH change // Add in time remaining label if (timeRemain < 0) timeRemain = 0; remainLabel = "Bidding Time Remaining: "; if (windowClosed) { remainLabel += "Bidding Now Closed"; } else if (simRunning) { remainLabel += "Simulation Running"; } else { remainLabel = remainLabel + timeRemain + " seconds"; } GUI.Label (new Rect (bufferBorder, height - 70 - bufferBorder, 400, 30), remainLabel, style); // Add in money balance and bid amount GUI.Label (new Rect (bufferBorder + 450, height/2 + bufferBorder + 110, 200, 30), "Balance: $" + balance, style); GUI.Label (new Rect (bufferBorder + 450, height/2 + bufferBorder + 150, 200, 30), "Bet: $" + bet, style); if (betAccepted) { GUI.Label (new Rect (bufferBorder + 450, height/2 + bufferBorder + 190, 300, 30), "Please wait for results of betting.", style); } else if (results) { if (won == 1) { GUI.Label (new Rect (bufferBorder + 450, height / 2 + bufferBorder + 190, 300, 30), "Congratulations - you won last round!", style); } else if (won == 0) { GUI.Label (new Rect (bufferBorder + 450, height / 2 + bufferBorder + 190, 300, 30), "Sorry - you lost last round.", style); } else { GUI.Label (new Rect (bufferBorder + 450, height / 2 + bufferBorder + 190, 300, 30), "You did not play last round.", style); } } if (betAccepted) { buttonTitle = "Bet Entered"; } else { buttonTitle = windowClosed ? "Closed" : "Accept"; } if (true) { if (GUI.Button (new Rect (bufferBorder, height - 30 - bufferBorder, 100, 30), buttonTitle) && !betAccepted && !windowClosed) { //make sure new config is distinct from prior attempts and initial value currAttempt.UpdateConfig (); //update config based on user data entry changes ConvergeAttempt prior = attemptList.Find (entry => entry.config == currAttempt.config); if (prior == null && currAttempt.ParamsUpdated ()) { betAccepted = true; Submit (); // SetIsProcessing (true); } else if (!showPopup) { int prior_idx = attemptList.FindIndex (entry => entry.config == currAttempt.config); if (prior_idx == Constants.ID_NOT_SET) { popupMessage = "Duplicate configuration to initial ecosystem. Please try again."; } else { popupMessage = "Duplicate configuration to prior attempt (#" + (prior_idx + 1) + "). Please try again."; } //Debug.Log (popupMessage); showPopup = true; } } } if (GUI.Button (new Rect (bufferBorder + 110, height - 30 - bufferBorder, 110, 30), "Progress Report")) { GenerateBarGraph (); } // Display buttons with opponent bet status // ****** Color savedColor2 = GUI.color; float topLeft = topGraph; int id2; string buttonText; Debug.Log ("Other player button routine"); foreach (DictionaryEntry entry in playerNames) { // do something with entry.Value or entry.Key id2 = (int) entry.Key; if ((id2 > 0 ) && (betStatusList.Contains(id2))) { if (((short) betStatusList [id2]) == 1) { // bet placed GUI.color = Color.green; buttonText = ((string)entry.Value) + " Entered Bet"; } else { // bet not placed GUI.color = Color.red; buttonText = ((string)entry.Value) + " No Bet"; } Debug.Log ("other player button: " + (bufferBorder + width - 170) + " " + topLeft + " " + buttonWidth); Debug.Log ("Button text: " + buttonText); GUI.Button (new Rect (bufferBorder + width - 150, topLeft, buttonWidth, 30), buttonText); topLeft += 45; } } GUI.color = savedColor2; int screenOffset = 0; /* Not doing hints in multiplayer game - initially if (currAttempt != null && currAttempt.allow_hints) { screenOffset += bufferBorder + 110; if (GUI.Button (new Rect (bufferBorder * 2 + 110 * 2, height - 30 - bufferBorder, 110, 30), "Get Hint")) { //only give new hint if one hasn't been provided during this session. if (currAttempt.hint_id == Constants.ID_NOT_SET) { int hintId = GetRandomHint (true); if (hintId == Constants.ID_NOT_SET) { popupMessage = "Sorry, no new hints are available."; } else { popupMessage = hintDict[hintId]; currAttempt.hint_id = hintId; } } else { if (hintDict.ContainsKey (currAttempt.hint_id)) { popupMessage = hintDict[currAttempt.hint_id] + "\n[Only one hint is provided per attempt.]"; } else { Debug.LogError ("Invalid hint for current attempt, ID = " + currAttempt.hint_id); popupMessage = "Error, hint not available."; } } if (priorHintIdList.Count > 0) { popupMessage += "\n\nPrior Hints:"; } for (int i = 0; i < priorHintIdList.Count; i++) { popupMessage += "\n\n" + hintDict[priorHintIdList[i]]; } //Debug.Log (popupMessage); showPopup = true; } } */ DrawResetButtons (screenOffset, style); }