private void Register(string username, string password) { Prompt(REGISTERING_PROMPT); Dictionary <string, string> postParams = new Dictionary <string, string>(); postParams.Add(USERNAME_PARAM, username); postParams.Add(PASSWORD_PARAM, password); StartCoroutine(Auth.AsyncPost( SessionManager.Instance.host, REGISTER_DIR, postParams, RegisterCallback)); }
private void Login(string username, string password) { Prompt(LOGGING_IN_PROMPT); Dictionary <string, string> postParams = new Dictionary <string, string>(); postParams.Add(USERNAME_PARAM, username); postParams.Add(PASSWORD_PARAM, password); StartCoroutine(Auth.AsyncPost( SessionManager.Instance.host, LOGIN_DIR, postParams, LoginCallback)); }
public void OnPublish() { // Prepare GET params Dictionary <string, string> postParams = new Dictionary <string, string>(); postParams.Add(USERNAME_PARAM, SessionManager.Instance.Username); postParams.Add(SESSION_ID_PARAM, SessionManager.Instance.SessionId); postParams.Add(LEVEL_NAME_PARAM, levelNameField.text); postParams.Add(LEVEL_METADATA_PARAM, SiteManager.Instance.GenerateLevelMetadata().ToString()); StartCoroutine(Auth.AsyncPost( SessionManager.Instance.host, CREATE_LEVEL_DIR, postParams, PublishCallback)); }
private void FetchLevels() { Prompt(FETCHING_LEVELS_PROMPT); Dictionary <string, string> postParams = new Dictionary <string, string>(); postParams.Add(USERNAME_PARAM, SessionManager.Instance.Username); postParams.Add(SESSION_ID_PARAM, SessionManager.Instance.SessionId); // Request for level list from the server StartCoroutine(Auth.AsyncPost( SessionManager.Instance.host, LEVELS_DIR, postParams, FetchLevelsCallback)); }
public void FetchAttempts(int levelId) { Prompt(FETCHING_ATTEMPTS_PROMPT); Dictionary <string, string> postParams = new Dictionary <string, string>(); postParams.Add(USERNAME_PARAM, SessionManager.Instance.Username); postParams.Add(SESSION_ID_PARAM, SessionManager.Instance.SessionId); postParams.Add(LEVEL_ID_PARAM, levelId.ToString()); // Request for attempt list from the server StartCoroutine(Auth.AsyncPost( SessionManager.Instance.host, ATTEMPTS_DIR, postParams, FetchAttemptsCallback)); }
public void Publish(float avgSpeed, float budgetReq, float score) { // Prepare GET params Dictionary <string, string> postParams = new Dictionary <string, string>(); postParams.Add(USERNAME_PARAM, SessionManager.Instance.Username); postParams.Add(SESSION_ID_PARAM, SessionManager.Instance.SessionId); postParams.Add(LEVEL_ID_PARAM, SessionManager.Instance.LevelId.ToString()); postParams.Add(ATTEMPT_METADATA_PARAM, SiteManager.Instance.GenerateAttemptMetadata().ToString()); postParams.Add(AVERAGE_SPEED_PARAM, avgSpeed.ToString()); postParams.Add(BUDGET_REQUIRED_PARAM, budgetReq.ToString()); postParams.Add(SCORE_PARAM, score.ToString()); StartCoroutine(Auth.AsyncPost( SessionManager.Instance.host, CREATE_ATTEMPT_DIR, postParams, PublishCallback)); }
private IEnumerator SimulateCoroutine() { UIManager.Instance.Prompt("Simulation started"); uiTabGroup.SelectTab(simulationTabId); simulationStats = new SimulationStats(); // Describes the currently simulated in-game time (in hours, from 0.00f to 24.00f) float inGameTime = 0.0f; while (inGameTime <= 24.0f) { SiteManager.Instance.trafficManager.SimulateAtTime(inGameTime); inGameTime += Time.deltaTime * simulationTimescale / 3600.0f; simulationStats.TotalSimulationTime += Time.deltaTime; if (inGameTime >= 3.0f && inGameTime <= 9.0f) { clockDayBackground.color = new Color( clockDayBackground.color.r, clockDayBackground.color.g, clockDayBackground.color.b, (inGameTime - 3.0f) / 6.0f ); clockNightBackground.color = new Color( clockNightBackground.color.r, clockNightBackground.color.g, clockNightBackground.color.b, (9.0f - inGameTime) / 6.0f ); } else if (inGameTime >= 15.0f && inGameTime <= 21.0f) { clockDayBackground.color = new Color( clockDayBackground.color.r, clockDayBackground.color.g, clockDayBackground.color.b, (21.0f - inGameTime) / 6.0f ); clockNightBackground.color = new Color( clockNightBackground.color.r, clockNightBackground.color.g, clockNightBackground.color.b, (inGameTime - 15.0f) / 6.0f ); } clockHand.rotation = Quaternion.Euler(0.0f, 0.0f, inGameTime * -30.0f); trafficQualitySlider.value = simulationStats.TrafficQuality; yield return(null); } while (simulationStats.NumVehiclesReachedExit != simulationStats.NumVehiclesSpawned) { simulationStats.TotalSimulationTime += Time.deltaTime; trafficQualitySlider.value = simulationStats.TrafficQuality; yield return(null); } uiTabGroup.SelectTab(defaultTabId); UIManager.Instance.Prompt("Simulation ended"); OpenSimulationStats(); Dictionary <string, string> postParams = new Dictionary <string, string>(); postParams.Add(USERNAME_PARAM, SessionManager.Instance.Username); postParams.Add(SESSION_ID_PARAM, SessionManager.Instance.SessionId); postParams.Add(LEVEL_ID_PARAM, SessionManager.Instance.LevelId.ToString()); postParams.Add(SCORE_PARAM, simulationStats.Score.ToString()); StartCoroutine(Auth.AsyncPost( SessionManager.Instance.host, ATTEMPT_RANK_DIR, postParams, FetchRankCallback)); }