Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class CancelOnClick : MonoBehaviour
- {
- public Text countText;
- public GameObject thePanel;
- public GameObject theCancelButton;
- public GameObject theRestartButton;
- public GameObject theMuteButton;
- public GameObject theQuitButton;
- public void CancelAction()
- {
- if (GameValue.canCancel)
- {
- GameValue.numberOfPegsLeft++;
- GameObject.Find(GameValue.InitialTriggerVolume).GetComponent<PegSlot>().freeSlot = false;
- //GameValue.TokenToReactivateID
- if (GameValue.firstRoundDone && GameValue.SlotInBetweenID == "" && GameValue.DestinationSlotID == "")
- {
- Transform[] allChildren = GameObject.Find("Tokens").GetComponentsInChildren<Transform>(true);
- foreach (Transform child in allChildren)
- {
- if (child.name == GameValue.OldName && !child.gameObject.activeSelf)
- {
- child.gameObject.SetActive(true);
- }
- }
- }
- else
- {
- GameObject.Find(GameValue.NewName).name = GameValue.OldName;
- Transform[] allChildren = GameObject.Find("Tokens").GetComponentsInChildren<Transform>(true);
- foreach (Transform child in allChildren)
- {
- if (child.name == "Token" + GameValue.SlotInBetweenID && !child.gameObject.activeSelf)
- {
- child.gameObject.SetActive(true);
- }
- }
- GameObject.Find("Token" + GameValue.SlotInBetweenID).transform.position = GameValue.TokenPositions[int.Parse(GameValue.SlotInBetweenID)];
- GameObject.Find("TriggerVolume" + GameValue.SlotInBetweenID).GetComponent<PegSlot>().freeSlot = false;
- GameObject.Find("TriggerVolume" + GameValue.DestinationSlotID).GetComponent<PegSlot>().freeSlot = true;
- }
- GameObject.Find(GameValue.OldName).transform.position = GameValue.TokenStartingPos;
- countText.text = "Peg left : " + GameValue.numberOfPegsLeft.ToString();
- GameValue.canCancel = false;
- }
- thePanel.SetActive(false);
- theRestartButton.SetActive(false);
- theMuteButton.SetActive(false);
- theQuitButton.SetActive(false);
- GameValue.showMenu = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement