void IngEvalVote() { //Print out the votes for (int i = 0; i < 3; i++) { Debug.Log("Ingredient " + (i + 1) + " has " + ingVoteCounter[i] + " votes"); } //max voteCounter => spawnInfo int maxValue = ingVoteCounter.Max(); int maxIndex = ingVoteCounter.ToList().IndexOf(maxValue); //@Dorota ingSpawnInfo result = choices[maxIndex]; //Find the spawning script and spawn ingredients according to poll results GameObject ingredientsManager = GameObject.Find("IngredientsManager"); IngredientsManager ingredientSpawningScript = ingredientsManager.GetComponent <IngredientsManager>(); ingredientSpawningScript.SpawnIngredient(result.IngredientName, result.SpawnPoint); GetComponent <PlaySounds>().playSpawn(); // Debug.Log("Result: " + result.IngredientName + " " + result.SpawnPoint); // Debug.Log("-------------------------"); }
private void IngResetPoll() { //Reset CD IngCD = IngMaxCD; //Generate 3 Random Emotes for VoteCasting var result = Enumerable.Range(0, emotes.Length).OrderBy(g => Guid.NewGuid()).Take(3).ToArray(); for (int i = 0; i < 3; i++) { ingCurrentEmotes[i] = emotes[result[i]]; } //Print out current Emotes Debug.Log("Current ingVoting Emotes are: "); for (int i = 0; i < 3; i++) { Debug.Log(ingCurrentEmotes[i]); } //Generate 3 random ingredients with spawnPoints var rngIng = Enumerable.Range(0, ingredients.Length).OrderBy(g => Guid.NewGuid()).Take(3).ToArray(); var rngSpawn = Enumerable.Range(1, MaxSpawns).OrderBy(g => Guid.NewGuid()).Take(3).ToArray(); //this creates a bias towards ingredients that are used in recipes for (int i = 0; i < rngIng.Length; i++) { if (Random.Range(0, RecipeSpawnBias) == 0) { int rndRec = Random.Range(0, Game.GAME.GetFoodOrders().Length); Recipes.Recipe[] recipes = Game.GAME.GetFoodOrders(); int rndIng = Random.Range(0, 3); int ingToSpawn = -1; if (rndIng == 0) { ingToSpawn = ((int)recipes[rndRec].ingredient1) - 1; } if (rndIng == 1) { ingToSpawn = ((int)recipes[rndRec].ingredient2) - 1; } if (rndIng == 2) { ingToSpawn = ((int)recipes[rndRec].ingredient3) - 1; } if (ingToSpawn != -1) { rngIng[rndIng] = ingToSpawn; } } } for (int i = 0; i < 3; i++) { choices[i] = new ingSpawnInfo(ingredients[rngIng[i]], rngSpawn[i]); } Debug.Log("Current Choices: "); for (int i = 0; i < 3; i++) { Debug.Log(choices[i].IngredientName + " " + choices[i].SpawnPoint); } //TODO Update Images according to ing + spawnPoints & emotes for (int i = 0; i < choices.Length; i++) { SpawnPoints[i].sprite = SpawnPointTextures[choices[i].SpawnPoint - 1]; var e = Enum.Parse(typeof(Recipes.eIngredients), choices[i].IngredientName); IngredientSlot[i].sprite = IngredientTextures[(int)e - 1]; e = Enum.Parse(typeof(eEmote), ingCurrentEmotes[i]); IngEmoteSlot[i].sprite = EmoteTextures[(int)e]; } //Reset VoteCounter for (int i = 0; i < 3; i++) { ingVoteCounter[i] = 0; } UpdatePollBars(); }