<commit_before>﻿using UnityEngine;
using UnityEngine.UI;

public class InterstitialUI : MonoBehaviour
{

	public GameObject PreviousScreen;
	public Button BackButton;
	
	private GameObject _interstitialsBack;
	private GameObject _background;
	private Image _interstitialScreen;
	private int _interstitialScreenCount;

	private GameObject _interstitialsParent;

	private Sprite[] _interstitialImages;

	private Button _nextButton;
	private Button _playButton;

	private bool _animating;
	
	private GameObject _oldBack;

	
	public void OpenLevelInterstitial(int level)
	{
		GameConfig.CurrentLevel = level;
		
		_background = transform.Find("Background").gameObject;
		_interstitialScreen = _background.transform.Find("Image").gameObject.GetComponent<Image>();
		_interstitialScreenCount = 0;
		
		_nextButton = transform.Find("NextButton").gameObject.GetComponent<Button>();
		_playButton = transform.Find("PlayButton").gameObject.GetComponent<Button>();
		_nextButton.gameObject.SetActive(true);
		_playButton.gameObject.SetActive(false);
		
		_oldBack = GameObject.Find("MenuUI/ChaptersLevels/Buttons/Back");
		if (_oldBack != null)
			_oldBack.gameObject.SetActive(false);
		
		switch (GameConfig.CurrentChapter)
		{
			case 0:
				_interstitialImages = Resources.LoadAll<Sprite>("ChapOneInterstitials");
				break;
				
			case 1:
				_interstitialImages = Resources.LoadAll<Sprite>("ChapTwoInterstitials");
				break;
				
			case 2:
				_interstitialImages = Resources.LoadAll<Sprite>("ChapThreeInterstitials");
				break;
		}
		_interstitialScreen.sprite = _interstitialImages[_interstitialScreenCount];
		
		if(BackButton != null)
			iTween.ScaleTo(BackButton.gameObject, iTween.Hash("scale", Vector3.one, "time", 1, "easetype", iTween.EaseType.easeInElastic));
		
		iTween.MoveTo(gameObject, iTween.Hash("position", new Vector3(0, 970, 0), "time", .01f, "islocal", true));
		gameObject.SetActive(true);
		iTween.MoveTo(PreviousScreen, iTween.Hash("position", new Vector3(540, 0, 0), "time", 1, "islocal", true, "easetype", iTween.EaseType.easeInBack, "oncomplete", "PreviousFinished", "oncompletetarget", gameObject));
		
	}

	private void PreviousFinished()
	{
		
		iTween.MoveTo(gameObject, iTween.Hash("position", Vector3.zero, "time", 1, "islocal", true, "easetype", iTween.EaseType.easeOutBack));
		
	}

	public void NextInterstitial()
	{
		if (_animating || _interstitialScreenCount == _interstitialImages.Length - 1)
			return;

		_animating = true;
		
		_interstitialScreenCount++;
		iTween.MoveTo(_background, iTween.Hash("position", new Vector3(540, 0, 0), "time", .5f, "islocal", true, "easetype", iTween.EaseType.easeInBack, "oncomplete", "InterstitialSwap", "oncompletetarget", gameObject));
	}

	private void InterstitialSwap()
	{
		
		_interstitialScreen.GetComponent<Image>().sprite = _interstitialImages[_interstitialScreenCount];

		if (_interstitialScreenCount == _interstitialImages.Length - 1) // Final screen 
		{
			// Show play button
			_playButton.gameObject.SetActive(true);
			_nextButton.gameObject.SetActive(false);
		}

		iTween.MoveTo(_background, iTween.Hash("position", new Vector3(0, 0, 0), "time", .5f, "islocal", true, "easetype", iTween.EaseType.easeOutBack, "oncomplete", "EndAnimation", "oncompletetarget", gameObject));

	}

	private void EndAnimation()
	{
		_animating = false;
	}
	
}<commit_msg>make buttons un-interactable on interstitial animations<commit_after>﻿using UnityEngine;
using UnityEngine.UI;

public class InterstitialUI : MonoBehaviour
{

	public GameObject PreviousScreen;
	public Button BackButton;
	
	private GameObject _interstitialsBack;
	private GameObject _background;
	private Image _interstitialScreen;
	private int _interstitialScreenCount;

	private GameObject _interstitialsParent;

	private Sprite[] _interstitialImages;

	private Button _nextButton;
	private Button _playButton;

	private bool _animating;
	
	private GameObject _oldBack;

	
	public void OpenLevelInterstitial(int level)
	{
		GameConfig.CurrentLevel = level;
		
		_background = transform.Find("Background").gameObject;
		_interstitialScreen = _background.transform.Find("Image").gameObject.GetComponent<Image>();
		_interstitialScreenCount = 0;
		
		_nextButton = transform.Find("NextButton").gameObject.GetComponent<Button>();
		_playButton = transform.Find("PlayButton").gameObject.GetComponent<Button>();
		_nextButton.gameObject.SetActive(true);
		_playButton.gameObject.SetActive(false);
		
		_oldBack = GameObject.Find("MenuUI/ChaptersLevels/Buttons/Back");
		if (_oldBack != null)
			_oldBack.gameObject.SetActive(false);
		
		switch (GameConfig.CurrentChapter)
		{
			case 0:
				_interstitialImages = Resources.LoadAll<Sprite>("ChapOneInterstitials");
				break;
				
			case 1:
				_interstitialImages = Resources.LoadAll<Sprite>("ChapTwoInterstitials");
				break;
				
			case 2:
				_interstitialImages = Resources.LoadAll<Sprite>("ChapThreeInterstitials");
				break;
		}
		_interstitialScreen.sprite = _interstitialImages[_interstitialScreenCount];
		
		if(BackButton != null)
			iTween.ScaleTo(BackButton.gameObject, iTween.Hash("scale", Vector3.one, "time", 1, "easetype", iTween.EaseType.easeInElastic));
		
		iTween.MoveTo(gameObject, iTween.Hash("position", new Vector3(0, 970, 0), "time", .01f, "islocal", true));
		gameObject.SetActive(true);
		iTween.MoveTo(PreviousScreen, iTween.Hash("position", new Vector3(540, 0, 0), "time", 1, "islocal", true, "easetype", iTween.EaseType.easeInBack, "oncomplete", "PreviousFinished", "oncompletetarget", gameObject));
		
	}

	private void PreviousFinished()
	{
		
		iTween.MoveTo(gameObject, iTween.Hash("position", Vector3.zero, "time", 1, "islocal", true, "easetype", iTween.EaseType.easeOutBack));
		
	}

	public void NextInterstitial()
	{
		if (_animating || _interstitialScreenCount == _interstitialImages.Length - 1)
			return;
		
		_animating = true;
		
		_nextButton.interactable = false;
		_playButton.interactable = false;
		BackButton.interactable = false;
		
		_interstitialScreenCount++;
		iTween.MoveTo(_background, iTween.Hash("position", new Vector3(540, 0, 0), "time", .5f, "islocal", true, "easetype", iTween.EaseType.easeInBack, "oncomplete", "InterstitialSwap", "oncompletetarget", gameObject));
	}

	private void InterstitialSwap()
	{
		
		_interstitialScreen.GetComponent<Image>().sprite = _interstitialImages[_interstitialScreenCount];

		if (_interstitialScreenCount == _interstitialImages.Length - 1) // Final screen 
		{
			// Show play button
			_playButton.gameObject.SetActive(true);
			_nextButton.gameObject.SetActive(false);
		}

		iTween.MoveTo(_background, iTween.Hash("position", new Vector3(0, 0, 0), "time", .5f, "islocal", true, "easetype", iTween.EaseType.easeOutBack, "oncomplete", "EndAnimation", "oncompletetarget", gameObject));

	}

	private void EndAnimation()
	{
		_animating = false;
		_nextButton.interactable = true;
		_playButton.interactable = true;
		BackButton.interactable = true;
	}
	
}
{'fraction_non_alphanumeric': 0.1227338129496403, 'fraction_numerical': 0.010647482014388488, 'mean_word_length': 5.460037174721189, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '645731', 'n_tokens_mistral': 2635, 'n_tokens_neox': 2178, 'n_words': 417}