// Update is called once per frame void Update() { if (gameState == GameState.Preparation) { } else if (gameState == GameState.CountDown) { countDownTimer -= Time.deltaTime; if (countDownTimer < 1) { gameState = GameState.Playing; StartCoroutine(SampleLogger()); populationManager.StartInfection(currentLevel.numberOfInfectedOnStart); onGameCountDown.Invoke((int)countDownTimer); onGameStateChanged.Invoke(gameTime, gameState); Dictionary <string, object> eventLog = new Dictionary <string, object>() { { "Event", "Game" + System.Enum.GetName(typeof(GameState), gameState) }, { "EventType", "GameEvent" }, { "LevelPlayID", levelPlayID }, }; eventLogger.Log("Event", eventLog); } else if ((int)countDownTimer != prevTime) { Dictionary <string, object> eventLog = new Dictionary <string, object>() { { "Event", "Countdown" + ((int)countDownTimer - 1).ToString() }, { "EventType", "GameEvent" }, { "LevelPlayID", levelPlayID }, }; eventLogger.Log("Event", eventLog); onGameCountDown.Invoke((int)countDownTimer); prevTime = (int)countDownTimer; } } else if (gameState == GameState.Playing) { gameTime += Time.deltaTime; newInfectionTimer += Time.deltaTime; if (newInfectionTimer > currentLevel.newInfectionSeconds) { populationManager.AddNewInfected(); newInfectionTimer = 0f; Dictionary <string, object> eventLog = new Dictionary <string, object>() { { "Event", "AddNewInfected" }, { "EventType", "SubjectEvent" }, { "LevelPlayID", levelPlayID }, }; eventLogger.Log("Event", eventLog); } if (subjectsInfectedScore - subjectsIsolationScore < 1) { Debug.Log("There are no infected subjects left, create new infections and people."); Dictionary <string, object> eventLog = new Dictionary <string, object>() { { "Event", "OutOfInfected" }, { "EventType", "SubjectEvent" }, { "LevelPlayID", levelPlayID }, }; eventLogger.Log("Event", eventLog); populationManager.StartInfection(1); populationManager.StartPopulation(1); currentLevel.numberOfSubjects++; eventLog = new Dictionary <string, object>() { { "Event", "AddNewInfected" }, { "EventType", "SubjectEvent" }, { "LevelPlayID", levelPlayID }, }; eventLogger.Log("Event", eventLog); } if (populationScore > 0) { //Debug.Log("Gametime: " + gameTime.ToString()); if (populationScore < currentLevel.gameOverScore) { gameState = GameState.GameLost; onGameOver.Invoke(GetGameStats(), gameState); Dictionary <string, object> eventLog = new Dictionary <string, object>() { { "Event", System.Enum.GetName(typeof(GameState), gameState) }, { "EventType", "GameEvent" }, { "LevelPlayID", levelPlayID }, }; eventLogger.Log("Event", eventLog); eventLogger.SaveLog("Event"); eventLogger.SaveLog("Sample"); eventLogger.ClearLog("Event"); eventLogger.ClearLog("Sample"); } bool didWin = gameTime > currentLevel.gameWonScore; //Debug.Log("gameTime: " + gameTime + " gameWonScore: " + gameWonScore + "won: " + didWin ); if (gameTime > currentLevel.gameWonScore) { Debug.Log("Game Won!"); gameState = GameState.GameWon; onGameOver.Invoke(GetGameStats(), gameState); Dictionary <string, object> eventLog = new Dictionary <string, object>() { { "Event", System.Enum.GetName(typeof(GameState), gameState) }, { "EventType", "GameEvent" }, { "LevelPlayID", levelPlayID }, }; eventLogger.Log("Event", eventLog); eventLogger.SaveLog("Event"); eventLogger.SaveLog("Sample"); eventLogger.ClearLog("Event"); eventLogger.ClearLog("Sample"); } } } else if (gameState == GameState.GameLost) { } else if (gameState == GameState.GameWon) { } else if (gameState == GameState.Stopped) { //onGameStateChanged.Invoke(gameTime, gameState); //ResetGame(); } }