public KeyCode[] RandomizeButtons(bool Player1) { KeyCode[] NewControls = new KeyCode[4]; Image[] NewGUI = new Image[4]; for (int i = 0; i < 4; i++) { if (Player1) { Control temp = Player1Controls[i]; int ran = Random.Range(i, Player1Controls.Length); Player1Controls[i] = Player1Controls[ran]; NewControls[i] = Player1Controls[ran].ButtonKeyCode; NewGUI[i] = Player1Controls[ran].ButtonImage; Player1Controls[ran] = temp; } else { Control temp = Player2Controls[i]; int ran = Random.Range(i, Player2Controls.Length); Player2Controls[i] = Player2Controls[ran]; NewControls[i] = Player2Controls[ran].ButtonKeyCode; NewGUI[i] = Player2Controls[ran].ButtonImage; Player2Controls[ran] = temp; } } if (Player1) { Player1GUI.SetImages(NewGUI); } else { Player2GUI.SetImages(NewGUI); } return(NewControls); }
public void SetupImages(bool Player1, KeyCode[] Controls) { Image[] NewGUI = new Image[4]; for (int i = 0; i < 4; i++) { if (Player1) { NewGUI[i] = Player1Controls[i].ButtonImage; } else { NewGUI[i] = Player2Controls[i].ButtonImage; } } if (Player1) { Player1GUI.SetImages(NewGUI); } else { Player2GUI.SetImages(NewGUI); } }