public void buddyStatsPanelCancelClicked() { buddyScrollCurrentlySelected = null; selectBuddyPanel.SetActive(false); buddyStatsPanel.SetActive(false); buddyScrollView.SetActive(false); startButtonObject.SetActive(true); playCanvasBackButton.SetActive(true); }
//This will open a panel that displays the buddy's stats and such public void initialBuddyScrollButtonClicked(PlayerBuddy buddy) { buddyScrollCurrentlySelected = buddy; buddyStatsImage.sprite = buddyImages [buddy.buddyId]; if (!buddy.isUnlocked) { buddyStatsImage.color = Color.black; } else { buddyStatsImage.color = Color.white; } buddyStatsName.text = buddy.buddyName; buddyStatsTitle.text = buddy.buddyTitle; selectBuddyPanel.SetActive(false); buddyScrollView.SetActive(false); buddyStatsPanel.SetActive(true); }
// This will actually be the buddy CONFIRMATION Button function //Instead, pass an int as well to represent the image index public void buddyStatsPanelConfirmClicked() { Debug.Log("added player buddy object:" + buddyScrollCurrentlySelected.name); buddyCurrentlySelected.GetComponent <ChosenBuddy> ().buddy = buddyScrollCurrentlySelected; buddyCurrentlySelected.GetComponent <Button> ().image.sprite = buddyImages [buddyScrollCurrentlySelected.buddyId]; //Cycles through the chosen buddies and sees if the selected buddy is a duplicate and removes it from the chosen list. foreach (GameObject chosenBuddyButton in chosenBuddyButtons) { if ((chosenBuddyButton != buddyCurrentlySelected) && (chosenBuddyButton.GetComponent <ChosenBuddy> ().buddy == buddyCurrentlySelected.GetComponent <ChosenBuddy> ().buddy)) { chosenBuddyButton.GetComponent <ChosenBuddy> ().buddy = null; chosenBuddyButton.GetComponent <Button> ().image.sprite = null; } } buddyScrollCurrentlySelected = null; selectBuddyPanel.SetActive(false); buddyStatsPanel.SetActive(false); buddyScrollView.SetActive(false); startButtonObject.SetActive(true); playCanvasBackButton.SetActive(true); }
//used? public void copyValues(PlayerBuddy copiedBuddy) { copiedBuddy.buddyId = buddyId; }
void Awake() { //TODO Currently when returning to the scene, all of this stuff needs to be reloaded //Is this the proper way to do this? //What about when someone level's up their buddy? //Just change that buddy in the list? /** * Set all of the canvas's camera components to the main camera * and set them all not active */ resetCanvasesAndCameras(); currentCanvasObj = mainCanvasObj; //Setup/Get PlayerPrefs //Setup saved chosen buddies //If they have chronologist as buddy 1, keep it buddy 1. //Will Only happen once if (PlayerPrefs.GetInt("Player_FirstTimePlaying", 1) == 1) { setupInitialPlayerPrefs(); } //Probably put this in a function that can also be called when a player levels up a buddy // or unlocks a buddy float xIncrement = 0f; for (int i = 0; i < SceneConstants.NUMBER_OF_PLAYER_BUDDIES; i++) { GameObject newObject = new GameObject(); PlayerBuddy playerBuddy = newObject.AddComponent <PlayerBuddy> (); playerBuddy.buddyId = i; playerBuddy.buddySkillEnum = (BuddySkillEnum)i; newObject.name = playerBuddy.buddySkillEnum.ToString(); playerBuddy.getBuddyStats(); playerBuddyCatalog.Add(playerBuddy); //Button Setup for Buddy Select bool topRow = true; if (i % 2 == 1) { topRow = false; } GameObject newPlayerBuddy = Instantiate(buddySelectButtonPrefab, new Vector3(0, 0, 0), Quaternion.identity) as GameObject; newPlayerBuddy.name = "ButtonSelect" + i; newPlayerBuddy.GetComponent <RectTransform> ().SetParent(buddyScrollViewContent.transform, false); if (topRow) { newPlayerBuddy.GetComponent <RectTransform> ().anchorMin = new Vector2(0f + xIncrement, 0.5f); newPlayerBuddy.GetComponent <RectTransform> ().anchorMax = new Vector2(0.1f + xIncrement, 1.0f); } else { newPlayerBuddy.GetComponent <RectTransform> ().anchorMin = new Vector2(0f + xIncrement, 0.0f); newPlayerBuddy.GetComponent <RectTransform> ().anchorMax = new Vector2(0.1f + xIncrement, 0.5f); } if (!topRow) { xIncrement += 0.1f; } //Set Image of this button //If not unlocked, have different sprite and not clickable newPlayerBuddy.GetComponent <Button>().image.sprite = buddyImages[i]; if (!playerBuddy.isUnlocked) { newPlayerBuddy.GetComponent <Button>().image.color = Color.black; } //The Newlw created button references the buddy created from this script newPlayerBuddy.GetComponent <Button> ().onClick.AddListener(() => { initialBuddyScrollButtonClicked(playerBuddy); }); } }