Combreal icon

CancelOnClick01.cs

Combreal | PRO | 04/11/20 01:58:47 PM UTC | 0 ⭐ | 1256 👁️ | Never ⏰ | []
C# |

2.53 KB

|

None

|

0 👍

/

0 👎

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;  
    }
}

Comments

  •  icon
    01/01/70 12:00:00 AM UTC
    Plain Text |

    0 B

    |

    👍

    /

    👎