// Use this for initialization void Start() { //start at speed 1, and not in a wave startButton.setColor(defaultColor); pauseButton.setColor(defaultColor); Speed1Button.setColor(selectedColor); desiredTimeScale = speed1; Speed2Button.setColor(defaultColor); Speed3Button.setColor(defaultColor); }
//refreshes the list, highlighting the current deck void refresh(XMLDeck currentDeck) { //remove all deck buttons that no longer have a corresponding deck foreach (MenuButtonScript toRemove in buttons.FindAll(mb => (mb.buttonType == MenuButtonType.deck) && (DeckManagerScript.instance.playerDecks.decks.Contains(mb.xDeck) == false))) { buttons.Remove(toRemove); Destroy(toRemove.gameObject); } //create buttons for decks that do not have a corresponding button foreach (XMLDeck newDeck in DeckManagerScript.instance.playerDecks.decks) { if (buttons.Any(mb => mb.xDeck == newDeck) == false) { MenuButtonScript xButton = Instantiate(buttonPrefab).GetComponent <MenuButtonScript>(); xButton.SendMessage("setDeck", newDeck); //set button color Color targetColor; if (newDeck.isModded()) { targetColor = moddedColor; } else { targetColor = defaultColor; } if (newDeck == currentDeck) { targetColor = Color.Lerp(targetColor, highlightColor, 0.5f); } xButton.setColor(targetColor); xButton.transform.SetParent(this.transform, false); buttons.Add(xButton); } } }
//adds deck buttons to the list. If highlightDeck is in the list, that button is a different color void setupDeckButtons(XMLDeck highlightDeck) { //one button for each player deck foreach (XMLDeck xDeck in DeckManagerScript.instance.playerDecks.decks) { MenuButtonScript xButton = Instantiate(buttonPrefab).GetComponent <MenuButtonScript>(); xButton.setDeck(xDeck); //set button color Color targetColor; if (xDeck.isModded()) { targetColor = moddedColor; } else { targetColor = defaultColor; } if (xDeck == highlightDeck) { targetColor = Color.Lerp(targetColor, highlightColor, 0.5f); } xButton.setColor(targetColor); xButton.transform.SetParent(this.transform, false); buttons.Add(xButton); } //another button for making a new deck MenuButtonScript ndButton = Instantiate(buttonPrefab).GetComponent <MenuButtonScript>(); ndButton.setButtonText("New Deck"); ndButton.setColor(menuColor); ndButton.transform.SetParent(this.transform, false); buttons.Add(ndButton); }