void OnGUI () { // Background //GUI.DrawTexture (new Rect (0, 0, Screen.width, Screen.height), background, ScaleMode.ScaleAndCrop); // Client Version Label GUI.Label (new Rect (Screen.width - 75, Screen.height - 30, 65, 20), "v" + Constants.CLIENT_VERSION + " Beta"); if ((!windowClosed) && (!simRunning)) { moment = DateTime.Now; timeNowNew = moment.Millisecond; int delta = timeNowNew - timeNow; Debug.Log ("New Time/Delta = " + timeNowNew + " " + delta); // check if more than 300 msec have passed if ((delta < 0) || (delta > 400)) { timeNow = timeNowNew; GetTime(); // Update bet time // On the multiples of 5 seconds, get the names if ((timeRemain % 10) == 5) { GetNames(); } } } // Check if betting window closed and no bet entered if (!betAccepted && windowClosed && !closedResponseSent) { short betEntered = 0; int improveValue = 0; closedResponseSent = true; NetworkManager.Send ( ConvergeBetUpdateProtocol.Prepare ( betEntered, improveValue ), ProcessConvergeBetUpdate ); } // Converge Game Interface if (isActive) { windowRect = GUI.Window (window_id, windowRect, MakeWindow, "Multiplayer Converge", GUIStyle.none); //if (Event.current.type == EventType.KeyUp && Event.current.keyCode == KeyCode.Return) { // Submit(); //} } GUI.skin.label.fontSize = 12; //for legend series labels if (showPopup) { GUI.Window (Constants.CONVERGE_POPUP_WIN, popupRect, ShowPopup, "Error", GUIStyle.none); } }
public void ProcessConvergeNewAttempt (NetworkResponse response) { ConvergeAttempt attempt; ResponseConvergeNewAttempt args = response as ResponseConvergeNewAttempt; attempt = args.attempt; //if the submission resulted in a valid attempt, add to attempt list and reinitialize //currAttempt for next attempt. Otherwise, keep current attempt if (attempt != null && attempt.attempt_id != Constants.ID_NOT_SET) { currAttempt.attempt_id = attempt.attempt_id; currAttempt.SetCSV (attempt.csv_string); attemptList.Add (currAttempt); attemptCount = attemptList.Count; //calculate score and send back to server. CSVObject target = ecosystemList[ecosystem_idx].csv_target_object; int score = currAttempt.csv_object.CalculateScore (target); NetworkManager.Send ( ConvergeNewAttemptScoreProtocol.Prepare ( player_id, ecosystem_id, attempt.attempt_id, score ), ProcessConvergeNewAttemptScore ); //update pertinent variables with new data if (currAttempt.hint_id != Constants.ID_NOT_SET) { priorHintIdList.Add (currAttempt.hint_id); } //need to recalc reset slider config due to additional attempt isResetSliderInitialized = false; if (barGraph != null) { barGraph.InputToCSVObject (currAttempt.csv_string, manager); } currAttempt = new ConvergeAttempt ( player_id, ecosystem_id, attempt.attempt_id + 1, allowHintsMaster, Constants.ID_NOT_SET, attempt.config, null //manager ); FinalizeAttemptUpdate (attemptCount - 1, false); // DH change // Send response server with client improvement int improveValue = barGraph.Improvement(); Debug.Log ("MC send improvement: " + improveValue); // ConvergeBetUpdate: // short - 1 = bet entered, 0 = no bet entered // integer = improveValue, improvement for this round; 0 if no bet short betEntered = 1; NetworkManager.Send ( ConvergeBetUpdateProtocol.Prepare ( betEntered, improveValue ), ProcessConvergeBetUpdate ); } else { Debug.LogError ("Submission of new attempt failed to produce results."); // betAccepted = false; // SetIsProcessing (false); } }