コード例 #1
0
	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);
		}
	}