public void phase2(GameObject button) { resultPhases.SetActive(true); //Voting phase Debug.Log("Voting"); voting.InvokeVoting(button); if (FinalVeredict.color == Color.green) { alineacion align = button.GetComponent <C_Project>().projectAl; switch (align) { case alineacion.Economico: doneEconomic++; break; case alineacion.Humanista: doneHumanista++; break; case alineacion.Patriota: donePatriotic++; break; } } //Asignando valores para visualizar aPatriotic.text = donePatriotic.ToString(); aEconomic.text = doneEconomic.ToString(); aHumanist.text = doneHumanista.ToString(); generator.DisableButtons(); Invoke("phase3", 1f); }
public alineacion GetDominantType() //Alineación mayor de la mesa { Dictionary <alineacion, int> _nType = new Dictionary <alineacion, int> { //Cantidad de ministros por tipo { alineacion.Economico, 0 }, { alineacion.Humanista, 0 }, { alineacion.Patriota, 0 } }; foreach (GameObject minister in GameObject.FindGameObjectsWithTag("Minister")) { _nType[minister.GetComponent <C_Minister>().myAlineacion]++; } alineacion _keyOfMaxValue = _nType.Aggregate((x, y) => x.Value > y.Value ? x : y).Key; return(_keyOfMaxValue); }
public void GenerateProject() //Instanciar el Prefab con alineación { alineacion domType = GetDominantType(); alineacion[] ListaAElegir = new alineacion[bProject.Count()]; int cantDom = 0; for (int x = 0; x < bProject.Count(); x++) { alineacion adding = (alineacion)UnityEngine.Random.Range(0, 3); if (adding == domType) { if (cantDom >= 1) { do { adding = (alineacion)UnityEngine.Random.Range(0, 3); } while (adding == domType); } cantDom++; } ListaAElegir[x] = adding; } foreach (var i in ListaAElegir) { //Debug.Log("There is " + i); } int a = 0; foreach (GameObject button in bProject) { button.GetComponent <C_Project>().projectName = SetName(); button.GetComponent <C_Project>().projectAl = ListaAElegir[a]; a++; switch (button.GetComponent <C_Project>().projectAl) { //Asign color to proyect button case alineacion.Economico: button.GetComponent <Image>().color = Color.green; break; case alineacion.Humanista: button.GetComponent <Image>().color = Color.blue; break; case alineacion.Patriota: button.GetComponent <Image>().color = Color.red; break; default: button.GetComponent <Image>().color = Color.black; break; } if (domType == button.GetComponent <C_Project>().projectAl) { //Block button of dominant type button.GetComponent <Image>().color = Color.black; button.GetComponent <Button>().interactable = false; } else { button.GetComponent <Button>().interactable = true; } } }