public void RequestAd() { #if UNITY_EDITOR ((EditorInterstitialAd)ad).fireError = generateError.isOn; #endif // set the status prior so that if there is an error the error comes later status.text = "requesting..."; ad.Request(appId, nextAd, AdType.Video); }
private void GameState_StatusChanged(object sender, GameStatusChangedEventArgs e) { if (e.NewState == GameState.GameStatus.GetReadyCompleted) { Debug.Assert(e.OldState == GameState.GameStatus.GetReady); GotoPlaying(); } else if (e.NewState == GameState.GameStatus.Restarting) { SoundManager.Instance.PlayLifeLost(); } else if (e.NewState == GameState.GameStatus.GameOver) { SoundManager.Instance.PlayGameOver(); } else if (e.NewState == GameState.GameStatus.Win) { boardManager.BroadcastMessage("WinAchieved"); //NOTE: it is important that we do PLayWin () as that triggers next step.. (lame!!) #if SHOWADS if ((GameState.Instance.CurrentLevel % adsFrequency) == (adsFrequency - 1)) { SoundManager.Instance.PlayWin(); if (MicrosoftAdsBridge.InterstitialAdFactory != null) { if (ad == null) { ad = MicrosoftAdsBridge.InterstitialAdFactory.CreateAd(); ad.AddCallback(AdCallback.Completed, adCompleted); ad.AddCallback(AdCallback.Cancelled, adCancelled); #if UNITY_EDITOR EditorInterstitialAd eiad = ad as EditorInterstitialAd; if (eiad != null) { eiad.canvas = GameObject.Find("Hud").GetComponent <Canvas>(); eiad.syncMonoBehaviour = this; } #endif } ad.Request(appId, GetNextAdUnitId(AdType.Video), AdType.Video); } } else if ((GameState.Instance.CurrentLevel % adsFrequency == 0) && (ad != null) && (ad.State == InterstitialAdState.Ready)) { GameState.Instance.SetState(GameState.GameStatus.PlayingAdvertisement); SoundManager.Instance.PauseBackgroundMusic(); ad.Show(); } else #endif { SoundManager.Instance.PlayWin(); } } else if (e.NewState == GameState.GameStatus.AdvertisementCompleted || e.NewState == GameState.GameStatus.WinCompleted) { if (e.NewState == GameState.GameStatus.AdvertisementCompleted) { SoundManager.Instance.UnPauseBackgroundMusic(); } int next = GameState.Instance.GetNextLevel(); boardManager.InstantiateLevel(next, GameState.Instance.GetLevel(next), new MonsterGame.DefaultMazeConfig(boardManager.transform.position)); GotoGetReady(); HandleLevelCompleted(next); } else if (e.NewState == GameState.GameStatus.Paused) { #if USEPAUSE if (!isPauseShowing && hasGameStarted) { Debug.Log("Show pause"); Application.LoadLevelAdditive("Pause"); isPauseShowing = true; } #endif } else if (e.NewState == GameState.GameStatus.WinCompleted) { } else if (e.NewState == GameState.GameStatus.LifeLostCompleted) { Debug.Assert(GameState.Instance.HasLives); boardManager.UseNextLive(); GotoGetReady(); } else if (e.NewState == GameState.GameStatus.GameOverCompleted) { GoBack(); } if (e.OldState == GameState.GameStatus.Paused) { #if USEPAUSE if (isPauseShowing) { Application.UnloadLevel("Pause"); } isPauseShowing = false; #endif } }