void OnTriggerEnter(Collider other) { if (other.name.Contains("Player")) { cont.AddResource(typeNum); Destroy(gameObject); } }
IEnumerator MutatorMiniGame() { string[] sequence = new string[6]; System.Random rnd = new System.Random(); int lastButton = 0; for (int i = 0; i < sequence.Length; i++) { int button = rnd.Next(0, 4); if (i > 0) { if (lastButton == button) { button = (lastButton + 1) % 4; } } lastButton = button; if (button == 0) { sequence[i] = "A"; } else if (button == 1) { sequence[i] = "B"; } else if (button == 2) { sequence[i] = "X"; } else { sequence[i] = "Y"; } } string[] seqcop = sequence; print(sequence[0] + ", " + sequence[1] + ", " + sequence[2] + ", " + sequence[3]); if (menuController.isPlayer1Focused) { while (Input.GetButton("P1_A") || Input.GetButton("P1_B") || Input.GetButton("P1_X") || Input.GetButton("P1_Y")) { yield return(null); } } else { while (Input.GetButton("P2_A") || Input.GetButton("P2_B") || Input.GetButton("P2_X") || Input.GetButton("P2_Y")) { yield return(null); } } foreach (string s in sequence) { RectTransform[] buttons = generateMinigameUI(seqcop, seqcop.Length); if (menuController.isPlayer1Focused) { while (!Input.GetButtonDown("P1_" + s)) { yield return(null); } } else { while (!Input.GetButtonDown("P2_" + s)) { yield return(null); } } foreach (RectTransform rt in buttons) { Destroy(rt.gameObject); } if (seqcop.Length > 0) { string[] newseqcop = new string[seqcop.Length - 1]; for (int i = 1; i < seqcop.Length; i++) { newseqcop[i - 1] = seqcop[i]; } seqcop = newseqcop; } } inventoryManager.AddResource(input[0] + input[1] - 1); menuController.Unfocus(); }