using System.Collections; using System.Collections.Generic; using UnityEngine; public class LevelComplete : WPFMonoBehaviour { private GameObject m_starOne; private GameObject m_starTwo; private GameObject m_starThree; private List m_challenges = new List(); private ObjectiveSlot m_objectiveOne; private ObjectiveSlot m_objectiveTwo; private ObjectiveSlot m_objectiveThree; private GameObject m_controlsPanel; private Vector3 m_controlsPosition; private Vector3 m_controlsHidePosition; private GameObject m_starPanel; private Vector3 m_starPanelPosition; private Vector3 m_starPanelHidePosition; private GameObject m_background; private Vector3 m_backgroundPosition; private Vector3 m_backgroundHidePosition; private BasePart.PartType m_unlockedPart; private string m_unlockedSandbox = string.Empty; public void SetChallenges(List challenges) { m_challenges = challenges; } private void OnEnable() { if (BuildCustomizationLoader.Instance.IAPEnabled) { IapManager.onPurchaseSucceeded += HandleIapManageronPurchaseSucceeded; } } private void OnDisable() { if (BuildCustomizationLoader.Instance.IAPEnabled) { IapManager.onPurchaseSucceeded -= HandleIapManageronPurchaseSucceeded; } } private void HandleIapManageronPurchaseSucceeded(IapManager.InAppPurchaseItemType type) { if (type == IapManager.InAppPurchaseItemType.UnlockFullVersion) { GameManager.Instance.LoadNextLevel(); } } private void Start() { m_starPanel = base.transform.Find("StarPanel").gameObject; m_starOne = m_starPanel.transform.FindChild("StarOne").gameObject; m_starTwo = m_starPanel.transform.FindChild("StarTwo").gameObject; m_starThree = m_starPanel.transform.FindChild("StarThree").gameObject; m_objectiveOne = m_starPanel.transform.FindChild("ObjectiveSlot1").GetComponent(); m_objectiveTwo = m_starPanel.transform.FindChild("ObjectiveSlot2").GetComponent(); m_objectiveThree = m_starPanel.transform.FindChild("ObjectiveSlot3").GetComponent(); m_controlsPanel = base.transform.FindChild("ControlsPanel").gameObject; m_controlsPosition = m_controlsPanel.transform.position; m_controlsHidePosition = m_controlsPosition + new Vector3(0f, -5f, 0f); m_controlsPanel.transform.position = m_controlsHidePosition; m_starPanelPosition = m_starPanel.transform.position; m_starPanelHidePosition = m_starPanelPosition + new Vector3(0f, 12f, 0f); m_starPanel.transform.position = m_starPanelHidePosition; m_background = base.transform.FindChild("Background").gameObject; m_backgroundPosition = m_background.transform.position; m_backgroundHidePosition = m_backgroundPosition + new Vector3(0f, 12f, 0f); m_background.transform.position = m_backgroundHidePosition; m_starOne.active = false; m_starTwo.active = false; m_starThree.active = false; AudioManager instance = AudioManager.Instance; if (m_challenges.Count >= 2 && m_challenges[1].IsCompleted() && !m_challenges[0].IsCompleted()) { Challenge value = m_challenges[0]; m_challenges[0] = m_challenges[1]; m_challenges[1] = value; } if (m_challenges.Count >= 1) { m_objectiveTwo.SetChallenge(m_challenges[0]); } if (m_challenges.Count >= 2) { m_objectiveThree.SetChallenge(m_challenges[1]); } StartCoroutine(ShowStarPanel(1.5f)); float num = 2f; int num2 = GameProgress.GetInt(Application.loadedLevelName + "_stars"); string text = "{"; string text2 = "{"; if (GameProgress.IsLevelCompleted(Application.loadedLevelName)) { StartCoroutine(PlayOldStarEffects(m_objectiveOne, m_starOne, num, true)); text += "1, "; } else { LevelCompletedForFirstTime(); num += 0.2f; StartCoroutine(PlayStarEffects(m_objectiveOne, m_starOne, null, num, instance.CommonAudioCollection.oneStar)); GameProgress.SetLevelCompleted(Application.loadedLevelName); text2 += "1, "; num2++; } num += 0.7f; if (GameProgress.GetInt(Application.loadedLevelName + "_challenge_" + m_challenges[0].Type) == 1) { StartCoroutine(PlayOldStarEffects(m_objectiveTwo, m_starTwo, num, m_challenges[0].IsCompleted())); text += "2, "; } else if (m_challenges.Count >= 1 && m_challenges[0].IsCompleted()) { StartCoroutine(PlayStarEffects(m_objectiveTwo, m_starTwo, m_challenges[0], num, instance.CommonAudioCollection.twoStar)); GameProgress.SetInt(Application.loadedLevelName + "_challenge_" + m_challenges[0].Type, 1); text2 += "2 "; num2++; } num += 0.7f; if (GameProgress.GetInt(Application.loadedLevelName + "_challenge_" + m_challenges[1].Type) == 1) { StartCoroutine(PlayOldStarEffects(m_objectiveThree, m_starThree, num, m_challenges[1].IsCompleted())); text += "3}"; } else if (m_challenges.Count >= 2 && m_challenges[1].IsCompleted()) { StartCoroutine(PlayStarEffects(m_objectiveThree, m_starThree, m_challenges[1], num, instance.CommonAudioCollection.threeStar)); GameProgress.SetInt(Application.loadedLevelName + "_challenge_" + m_challenges[1].Type, 1); text2 += "3}"; num2++; } bool flag = GameManager.Instance.CurrentLevelRowThreeStarred(); GameProgress.SetInt(Application.loadedLevelName + "_stars", num2); bool jokerLevelUnlocked = GameManager.Instance.CurrentLevelRowThreeStarred() && !flag; StartCoroutine(ShowBackground(1.5f, num - 1.5f)); if (GameManager.Instance.IsLastLevelInEpisode()) { SetCutsceneButton(); } ShowRewards(ref num, jokerLevelUnlocked); StartCoroutine(ShowControls(num)); if (BuildCustomizationLoader.Instance.Flurry) { Dictionary dictionary = new Dictionary(); dictionary.Add("ID", Application.loadedLevelName); dictionary.Add("PREVIOUS_STARS", text); dictionary.Add("NEW_STARS", text2); dictionary.Add("TIME", string.Empty + WPFMonoBehaviour.levelManager.TimeElapsed); dictionary.Add("CONTRAPTION", string.Empty + WPFMonoBehaviour.levelManager.contraptionProto.GetContraptionID()); FlurryManager.Instance.FlurryDataHolder.Add("NEW_STARS", text2); FlurryManager.Instance.FlurryDataHolder.Add("PREVIOUS_STARS", text); FlurryManager.Instance.LogEventWithParameters("Complete Level", dictionary); } if (DeviceInfo.Instance.ActiveDeviceFamily == DeviceInfo.DeviceFamily.Ios && (bool)WPFMonoBehaviour.levelManager) { CheckLevelEndAchievements(); } } private void ShowRewards(ref float delay, bool jokerLevelUnlocked) { if (m_unlockedPart != 0) { delay += 0.5f; StartCoroutine(ShowUnlockedPart(delay)); delay += 0.5f; } if (m_unlockedSandbox != string.Empty) { Button component = base.transform.FindChild("Rewards").FindChild("SandboxUnlock").FindChild("Open") .FindChild("Sandbox") .GetComponent