Advertisement
Combreal

CancelOnClick01.cs

Apr 11th, 2020
742
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.53 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5.  
  6. public class CancelOnClick : MonoBehaviour
  7. {
  8.     public Text countText;
  9.     public GameObject thePanel;
  10.     public GameObject theCancelButton;
  11.     public GameObject theRestartButton;
  12.     public GameObject theMuteButton;
  13.     public GameObject theQuitButton;
  14.  
  15.     public void CancelAction()
  16.     {
  17.         if (GameValue.canCancel)
  18.         {
  19.             GameValue.numberOfPegsLeft++;
  20.             GameObject.Find(GameValue.InitialTriggerVolume).GetComponent<PegSlot>().freeSlot = false;
  21.             //GameValue.TokenToReactivateID
  22.             if (GameValue.firstRoundDone && GameValue.SlotInBetweenID == "" && GameValue.DestinationSlotID == "")
  23.             {
  24.                 Transform[] allChildren = GameObject.Find("Tokens").GetComponentsInChildren<Transform>(true);
  25.                 foreach (Transform child in allChildren)
  26.                 {
  27.                     if (child.name == GameValue.OldName && !child.gameObject.activeSelf)
  28.                     {
  29.                         child.gameObject.SetActive(true);
  30.                     }
  31.                 }
  32.             }
  33.             else
  34.             {
  35.                 GameObject.Find(GameValue.NewName).name = GameValue.OldName;
  36.                 Transform[] allChildren = GameObject.Find("Tokens").GetComponentsInChildren<Transform>(true);
  37.                 foreach (Transform child in allChildren)
  38.                 {
  39.                     if (child.name == "Token" + GameValue.SlotInBetweenID && !child.gameObject.activeSelf)
  40.                     {
  41.                         child.gameObject.SetActive(true);
  42.                     }
  43.                 }
  44.                 GameObject.Find("Token" + GameValue.SlotInBetweenID).transform.position = GameValue.TokenPositions[int.Parse(GameValue.SlotInBetweenID)];
  45.                 GameObject.Find("TriggerVolume" + GameValue.SlotInBetweenID).GetComponent<PegSlot>().freeSlot = false;
  46.                 GameObject.Find("TriggerVolume" + GameValue.DestinationSlotID).GetComponent<PegSlot>().freeSlot = true;
  47.  
  48.             }
  49.             GameObject.Find(GameValue.OldName).transform.position = GameValue.TokenStartingPos;
  50.             countText.text = "Peg left : " + GameValue.numberOfPegsLeft.ToString();
  51.             GameValue.canCancel = false;
  52.         }
  53.         thePanel.SetActive(false);
  54.         theRestartButton.SetActive(false);
  55.         theMuteButton.SetActive(false);
  56.         theQuitButton.SetActive(false);
  57.         GameValue.showMenu = false;  
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement