//--------------------------------------------------------------------------------------------------------------- private void Start() { Game.Swipe.SetLimitsVertical(20, 30); Game.Swipe.ResetLimitsHorisontal(); Game.Swipe.SetInitiaAngle(135, 25); Game.Events.GameWon.Listen(this.SessionEnd); Game.Events.GameLost.Listen(this.SessionFailed); Game.PlayRoot = this; Game.Settings.SessionMoney = 0; if (!Game.AudioManager.HasActiveMusic()) { Game.AudioManager.PlayMusic(AudioId.Music, loop: true, volume: DefaultContent.DefaultMusicVolume); } this.Things.ProcessChildrenThings(); this.TasksController.CreateTasks(); if (Game.Settings.IsFirstLaunch) { FlexiblePopUp.Instantiate("StartTip", Game.Canvas.transform, lockTime: 1.6f); Game.Settings.IsFirstLaunch = false; } }
//--------------------------------------------------------------------------------------------------------------- public static bool IsNull(this FlexiblePopUp t) { if (t == null) { return(true); } return(false); }
//--------------------------------------------------------------------------------------------------------------- public void AssignCaller(FlexiblePopUp popup) { if (popup.IsNull()) { this.gameObject.SetActive(false); return; } this.Caller = popup; }
//--------------------------------------------------------------------------------------------------------------- private void SessionFailed() { if (this.SessionEnded) { return; } Game.PlayRoot.Things.SetColliderState = false; this.SessionEnded = true; this.PauseSession(); Game.Settings.SessionMoney = 0; FlexiblePopUp.Instantiate("SessionFailed", Game.Canvas.transform, lockTime: 1f).OnClose(() => { Game.StateManager.SetState(GameState.Menu); }); Game.AudioManager.PlaySound(AudioId.ArcadeNegative07); }
//--------------------------------------------------------------------------------------------------------------- public void OnButtonPressed() { if (this.HasCaller) { this.Caller.Kill(); this.Caller = null; } if (!Game.AdsManager.IsAvailable()) { return; } Game.AdsManager.Show(VideoShown, VideoNotShown); }
//--------------------------------------------------------------------------------------------------------------- public static FlexiblePopUp Instantiate(string prefabName, Transform parent = null, string path = "", object data = null, float lockTime = DefaultLockTime) { if (path == "") { path = "Prefabs/"; } GameObject prefab = Resources.Load(path + prefabName) as GameObject; if (prefab == null) { Debug.Log("Attempt to Instantiate popup with path " + path + prefabName + ", but Resources.Load returned null."); return(null); } if (parent == null) { parent = Game.Canvas.transform; } FlexiblePopUp result = GameObject.Instantiate(prefab, parent).GetComponent <FlexiblePopUp>(); if (!result.IsNull()) { if (result.Collider == null) { result.Collider = result.GetComponent <Collider2D>(); } } result.LockTime = lockTime; result.TimerLock = true; result.LockTimer = Game.TimerManager.Start(result.LockTime, callback: () => { result.UnlockSelf(); }); if (data != null) { result.Activate(data); } return(result); }
//--------------------------------------------------------------------------------------------------------------- private void SessionEnd() { if (this.SessionEnded) { return; } Game.PlayRoot.Things.SetColliderState = false; this.SessionEnded = true; Game.Settings.GameProgress = Game.Settings.GameProgress + 1; this.PauseSession(); (int stars, int rewardPerStar)reward = this.TasksController.GetStarsAndReward(); SessionRewardScreen.SessionData sd = new SessionRewardScreen.SessionData { StartingAmount = 0, PushedAmount = Game.Settings.SessionMoney, Stars = reward.stars, RewardPerStar = reward.rewardPerStar }; FlexiblePopUp.Instantiate("SessionResult", Game.Canvas.transform, lockTime: 1f, data: sd).OnClose(() => { Game.StateManager.SetState(GameState.Menu); }); Game.AudioManager.PlaySound(AudioId.ArcadePositive08); }
//--------------------------------------------------------------------------------------------------------------- public void VideoNotShown() { this.Caller = null; Game.Events.SessionEnded.Invoke(); }
//--------------------------------------------------------------------------------------------------------------- public void VideoShown() { Game.PlayRoot.UnPauseSession(); this.Caller = null; this.gameObject.SetActive(false); }