/** * Update UI to match updated population data */ private void UpdatePopulationData(List <FishGenome> activeGenomes, List <FishGenome> successfulGenomes, List <FishGenome> deadGenomes) { populationGraph.UpdateGraph(successfulGenomes.Count, activeGenomes.Count, deadGenomes.Count); int numMales = FishGenomeUtilities.FindMaleGenomes(successfulGenomes).Count + FishGenomeUtilities.FindMaleGenomes(activeGenomes).Count; int numFemales = FishGenomeUtilities.FindFemaleGenomes(successfulGenomes).Count + FishGenomeUtilities.FindFemaleGenomes(activeGenomes).Count; sexGraph.UpdateGraph(numFemales, numMales); int numSmall = FishGenomeUtilities.FindSmallGenomes(successfulGenomes).Count + FishGenomeUtilities.FindSmallGenomes(activeGenomes).Count; int numMedium = FishGenomeUtilities.FindMediumGenomes(successfulGenomes).Count + FishGenomeUtilities.FindMediumGenomes(activeGenomes).Count; int numLarge = FishGenomeUtilities.FindLargeGenomes(successfulGenomes).Count + FishGenomeUtilities.FindLargeGenomes(activeGenomes).Count; sizeGraph.UpdateGraph(numSmall, numMedium, numLarge); }
/** * Update the data that will be displayed on the panel */ private void UpdatePanelData(List <FishGenome> parentGenomes, List <FishGenome> offspringGenomes) { // display the previous turn (because that's what titleText.text = "Turn " + (GameManager.Instance.Turn - 1).ToString() + " Summary"; // if a full turn has been done, do the typical update if (GameManager.Instance.Turn > 1) { // parent genome can be null if this is the initial generation and there are no parents // have to treat these two cases differently if (parentGenomes != null) { parentSmallText.text = smallDescriptor + divider + FishGenomeUtilities.FindSmallGenomes(parentGenomes).Count.ToString(); parentMediumText.text = mediumDescriptor + divider + FishGenomeUtilities.FindMediumGenomes(parentGenomes).Count.ToString(); parentLargeText.text = largeDescriptor + divider + FishGenomeUtilities.FindLargeGenomes(parentGenomes).Count.ToString(); } else { Debug.LogError("Error -- no parent genomes! should not happen!"); } offspringSmallText.text = smallDescriptor + divider + FishGenomeUtilities.FindSmallGenomes(offspringGenomes).Count.ToString(); offspringMediumText.text = mediumDescriptor + divider + FishGenomeUtilities.FindMediumGenomes(offspringGenomes).Count.ToString(); offspringLargeText.text = largeDescriptor + divider + FishGenomeUtilities.FindLargeGenomes(offspringGenomes).Count.ToString(); offspringFemaleText.text = femaleDescriptor + divider + FishGenomeUtilities.FindFemaleGenomes(offspringGenomes).Count.ToString(); offspringMaleText.text = maleDescriptor + divider + FishGenomeUtilities.FindMaleGenomes(offspringGenomes).Count.ToString(); } // otherwise, do the first-turn specific update else if (GameManager.Instance.Turn == 1) { parentSmallText.text = "N/A"; parentMediumText.text = "N/A"; parentLargeText.text = "N/A"; offspringSmallText.text = smallDescriptor + divider + FishGenomeUtilities.FindSmallGenomes(offspringGenomes).Count.ToString(); offspringMediumText.text = mediumDescriptor + divider + FishGenomeUtilities.FindMediumGenomes(offspringGenomes).Count.ToString(); offspringLargeText.text = largeDescriptor + divider + FishGenomeUtilities.FindLargeGenomes(offspringGenomes).Count.ToString(); offspringFemaleText.text = femaleDescriptor + divider + FishGenomeUtilities.FindFemaleGenomes(offspringGenomes).Count.ToString(); offspringMaleText.text = maleDescriptor + divider + FishGenomeUtilities.FindMaleGenomes(offspringGenomes).Count.ToString(); } }
private static int currentSaveIndex = 0; //< The current index in the Saves list to save games to //private static GameManager gameManager; //< Reference to the gameManager which speaks with the TowerManager /* * Creates a Save object and stores the object in the list of saves */ public static void SaveGame() { Save currentTurn = new Save(); // Loop through every tower and save that data in the currentTurn's save foreach (TowerBase tower in GameManager.Instance.GetTowerList()) { // General Tower Info that all towers must save float[] position = new float[3]; position[0] = tower.transform.position.x; position[1] = tower.transform.position.y; position[2] = tower.transform.position.z; float[] rotation = new float[3]; rotation[0] = tower.transform.rotation.x; rotation[1] = tower.transform.rotation.y; rotation[2] = tower.transform.rotation.z; currentTurn.towerPositions.Add(position); currentTurn.towerRotations.Add(rotation); // Determine the type of Tower we are saving and save its data accordingly to our Save structure if (tower is AnglerTower) { AnglerTower towerScript = tower.GetComponent <AnglerTower>(); currentTurn.towerTypes.Add(0); currentTurn.anglerPlaced.Add(tower.turnPlaced); currentTurn.caughtFish.Add(towerScript.fishCaught); float[] catchRates = new float[3]; catchRates[0] = towerScript.smallCatchRate; catchRates[1] = towerScript.mediumCatchRate; catchRates[2] = towerScript.largeCatchRate; currentTurn.anglerCatchRates.Add(catchRates); } else if (tower is RangerTower) { RangerTower towerScript = tower.GetComponent <RangerTower>(); currentTurn.towerTypes.Add(1); currentTurn.rangerPlaced.Add(tower.turnPlaced); float[] regulationRates = new float[3]; regulationRates[0] = towerScript.slowdownEffectSmall; regulationRates[1] = towerScript.slowdownEffectMedium; regulationRates[2] = towerScript.slowdownEffectLarge; currentTurn.rangerRegulateRates.Add(regulationRates); } else if (tower is SealionTower) { SealionTower towerScript = tower.GetComponent <SealionTower>(); currentTurn.towerTypes.Add(4); currentTurn.sealionAppeared.Add(tower.turnPlaced); float[] catchRates = new float[2]; catchRates[0] = towerScript.maleCatchRate; catchRates[1] = towerScript.femaleCatchRate; currentTurn.sealionCatchRates.Add(catchRates); } else if (tower is Dam) { currentTurn.towerTypes.Add(2); currentTurn.damPlaced = 1; } else if (tower is DamLadder) { currentTurn.towerTypes.Add(3); currentTurn.ladderType = 0; } } // Save the current generation of salmon List <FishGenome> allFish = GameManager.Instance.school.GetFish(); // Find all the male and female fish List <FishGenome> females = FishGenomeUtilities.FindFemaleGenomes(allFish); List <FishGenome> males = FishGenomeUtilities.FindMaleGenomes(allFish); // Count and save each size / gender pair currentTurn.smallMale = FishGenomeUtilities.FindSmallGenomes(males).Count; currentTurn.mediumMale = FishGenomeUtilities.FindMediumGenomes(males).Count; currentTurn.largeMale = FishGenomeUtilities.FindLargeGenomes(males).Count; currentTurn.smallFemale = FishGenomeUtilities.FindSmallGenomes(females).Count; currentTurn.mediumFemale = FishGenomeUtilities.FindMediumGenomes(females).Count; currentTurn.largeFemale = FishGenomeUtilities.FindLargeGenomes(females).Count; //Push the currentTurn's data to the list of saves saves.Insert(currentSaveIndex, currentTurn); currentSaveIndex++; }