public void Exit() { if (playerWon) { gameManager.prestige += currentTournamentInfo.reward; } tournamentInstance.gameObject.SetActive(false); isPlaying = false; isSimulating = false; inbetweenMatches = true; tournamentFinished = false; resultsProcessed = false; playerWon = false; currentRoundNum = 0; currentMatchNum = 0; currentMatchup = null; currentTournamentInfo = null; //tournamentUI.TournamentEndScreen(); }
public void Tick() { if (isSimulating) // && debugFrameCounter < 2) { // Check if it's all over: { if (CheckAllMatchesFinished()) { tournamentFinished = true; inbetweenMatches = true; if (!resultsProcessed) { AllMatchesComplete(); resultsProcessed = true; } //Debug.Log("Tournament Finished!"); // END } // find current match: currentMatchup = FindCurrentMatchup(); // Check if we're between matches: if (inbetweenMatches) { // ShowUI gameManager.cameraEnabled = false; } else { switch (currentMatchup.evalTicket.status) { case EvaluationTicket.EvaluationStatus.Pending: //Found it! // inbetweenMatches is false, so ready to start! Debug.Log("SetUp matchup " + currentMatchup.id.ToString()); //Debug.Log(tournamentInstance.ToString()); //Debug.Log(currentMatchup.ToString()); //Debug.Log(currentMatchup.evalTicket.ToString()); tournamentInstance.SetUpInstance(currentMatchup.evalTicket, gameManager.trainerRef.teamsConfig, gameManager.trainerRef.evaluationManager.exhibitionParticleCurves); Play(); isSimulating = true; gameManager.cameraEnabled = true; break; case EvaluationTicket.EvaluationStatus.InProgress: // do stuff // Tick tournamentInstance.Tick(); break; case EvaluationTicket.EvaluationStatus.PendingComplete: // do stuff // Save Scores for (int i = 0; i < tournamentInstance.agentGameScoresArray.Length; i++) { currentMatchup.contestantScoresArray[0] = tournamentInstance.agentGameScoresArray[0][0]; // @$#!@$# ASSUMES 1 Player at a time!! will break for Combat MiniGame!!! Debug.Log("matchup " + currentMatchup.id + ", PendingComplete, score: " + currentMatchup.contestantScoresArray[0].ToString()); // @$#!@$# ASSUMES 1 Player at a time!! will break for Combat MiniGame!!! } //tournamentInstance.agentGameScoresArray[] inbetweenMatches = true; currentMatchup.evalTicket.status = EvaluationTicket.EvaluationStatus.Complete; CalculateLiveResults(); // Cleanup? break; case EvaluationTicket.EvaluationStatus.Complete: // do stuff // shouldn't happen break; } } //Debug.Log("FixedUpdate isTraining"); /*if (singleTicket.status == EvaluationTicket.EvaluationStatus.PendingComplete) { * // Pending complete!!! * Debug.Log("PendingComplete!"); * isSimulating = false; * Exit(); * } * else { * if (tournamentInstance.currentEvalTicket.status == EvaluationTicket.EvaluationStatus.Pending) { * * } * else if (tournamentInstance.currentEvalTicket.status == EvaluationTicket.EvaluationStatus.InProgress) { * tournamentInstance.Tick(); * } * * }*/ //debugFrameCounter++; } }
public void Init1(TeamsConfig teamsConfig) { challengeType = teamsConfig.challengeType; // Temp hardcoded!!!!! competitionType = CompetitionType.Independent; competitionFormat = CompetitionFormat.HighScore; numOpponents = 1; tournamentRoundList = new List <TournamentRound>(); TournamentRound round1 = new TournamentRound(0); // MOCKUP: int[] competitorIDs = new int[1]; competitorIDs[0] = -1; // Match1 string savename = "env1"; string path = Application.dataPath + "/IndividualSaves/Environments/" + savename + ".json"; // Read the json from the file into a string string dataAsJson = File.ReadAllText(path); EnvironmentGenome loadedGenome1 = JsonUtility.FromJson <EnvironmentGenome>(dataAsJson); List <AgentGenome> agentGenomesList1 = new List <AgentGenome>(); agentGenomesList1.Add(teamsConfig.playersList[0].agentGenomeList[0]); EvaluationTicket ticket1 = new EvaluationTicket(loadedGenome1, agentGenomesList1, 1, 1000); TournamentMatchup matchup1 = new TournamentMatchup(0, ticket1, 0, competitorIDs); round1.matchupList.Add(matchup1); // Match2 savename = "env2"; path = Application.dataPath + "/IndividualSaves/Environments/" + savename + ".json"; // Read the json from the file into a string dataAsJson = File.ReadAllText(path); EnvironmentGenome loadedGenome2 = JsonUtility.FromJson <EnvironmentGenome>(dataAsJson); List <AgentGenome> agentGenomesList2 = new List <AgentGenome>(); agentGenomesList2.Add(teamsConfig.playersList[0].agentGenomeList[0]); EvaluationTicket ticket2 = new EvaluationTicket(loadedGenome2, agentGenomesList2, 1, 1000); TournamentMatchup matchup2 = new TournamentMatchup(1, ticket2, 1, competitorIDs); round1.matchupList.Add(matchup2); // Matchup3: savename = "env3"; path = Application.dataPath + "/IndividualSaves/Environments/" + savename + ".json"; // Read the json from the file into a string dataAsJson = File.ReadAllText(path); EnvironmentGenome loadedGenome3 = JsonUtility.FromJson <EnvironmentGenome>(dataAsJson); List <AgentGenome> agentGenomesList3 = new List <AgentGenome>(); agentGenomesList3.Add(teamsConfig.playersList[0].agentGenomeList[0]); EvaluationTicket ticket3 = new EvaluationTicket(loadedGenome3, agentGenomesList3, 1, 1000); TournamentMatchup matchup3 = new TournamentMatchup(2, ticket3, 2, competitorIDs); round1.matchupList.Add(matchup3); tournamentRoundList.Add(round1); }