SFX added
This commit is contained in:
@@ -1,158 +1,158 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GoogleMobileAds.Api;
|
||||
using UnityEngine;
|
||||
|
||||
public class AdsManager : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
|
||||
public static AdsManager instance;
|
||||
void Awake(){
|
||||
if(instance!= null){Destroy(gameObject);}
|
||||
instance = this;
|
||||
}
|
||||
|
||||
const string intAdId = "ca-app-pub-3966734202864173/9071918772";
|
||||
const string rewardedAdId = "ca-app-pub-3966734202864173/7802288880";
|
||||
void Start()
|
||||
{
|
||||
DontDestroyOnLoad(gameObject);
|
||||
// Initialize the Google Mobile Ads SDK.
|
||||
MobileAds.Initialize(initStatus => { Debug.Log("admob Init status : " + initStatus.ToString());});
|
||||
|
||||
StartCoroutine(ReloadAds(true));
|
||||
}
|
||||
|
||||
private InterstitialAd interstitialAd;
|
||||
|
||||
/// <summary>
|
||||
/// Loads the interstitial ad.
|
||||
/// </summary>
|
||||
public void LoadInterstitialAd()
|
||||
{
|
||||
// Clean up the old ad before loading a new one.
|
||||
if (interstitialAd != null)
|
||||
{
|
||||
interstitialAd.Destroy();
|
||||
interstitialAd = null;
|
||||
}
|
||||
|
||||
Debug.Log("Loading the interstitial ad.");
|
||||
|
||||
// create our request used to load the ad.
|
||||
var adRequest = new AdRequest.Builder()
|
||||
.AddKeyword("unity-admob-sample")
|
||||
.Build();
|
||||
|
||||
// send the request to load the ad.
|
||||
InterstitialAd.Load(intAdId, adRequest,
|
||||
(InterstitialAd ad, LoadAdError error) =>
|
||||
{
|
||||
// if error is not null, the load request failed.
|
||||
if (error != null || ad == null)
|
||||
{
|
||||
Debug.LogError("interstitial ad failed to load an ad " +
|
||||
"with error : " + error);
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log("Interstitial ad loaded with response : "
|
||||
+ ad.GetResponseInfo());
|
||||
|
||||
interstitialAd = ad;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void ShowIntAd()
|
||||
{
|
||||
if (interstitialAd != null && interstitialAd.CanShowAd())
|
||||
{
|
||||
Debug.Log("Showing interstitial ad.");
|
||||
interstitialAd.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Interstitial ad is not ready yet.");
|
||||
}
|
||||
StartCoroutine(ReloadAds(false));
|
||||
|
||||
}
|
||||
|
||||
|
||||
private RewardedAd rewardedAd;
|
||||
|
||||
/// <summary>
|
||||
/// Loads the rewarded ad.
|
||||
/// </summary>
|
||||
public void LoadRewardedAd()
|
||||
{
|
||||
// Clean up the old ad before loading a new one.
|
||||
if (rewardedAd != null)
|
||||
{
|
||||
rewardedAd.Destroy();
|
||||
rewardedAd = null;
|
||||
}
|
||||
|
||||
Debug.Log("Loading the rewarded ad.");
|
||||
|
||||
// create our request used to load the ad.
|
||||
var adRequest = new AdRequest.Builder().Build();
|
||||
|
||||
// send the request to load the ad.
|
||||
RewardedAd.Load(rewardedAdId, adRequest,
|
||||
(RewardedAd ad, LoadAdError error) =>
|
||||
{
|
||||
// if error is not null, the load request failed.
|
||||
if (error != null || ad == null)
|
||||
{
|
||||
Debug.LogError("Rewarded ad failed to load an ad " +
|
||||
"with error : " + error);
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log("Rewarded ad loaded with response : "
|
||||
+ ad.GetResponseInfo());
|
||||
|
||||
rewardedAd = ad;
|
||||
|
||||
rewardedAd.OnAdPaid += OnRewardSuccess;
|
||||
});
|
||||
}
|
||||
|
||||
private void OnRewardSuccess(AdValue obj)
|
||||
{
|
||||
// GameManager.AdWatched();
|
||||
}
|
||||
|
||||
public void ShowRewardedAd()
|
||||
{
|
||||
const string rewardMsg =
|
||||
"Rewarded ad rewarded the user. Type: {0}, amount: {1}.";
|
||||
|
||||
if (rewardedAd != null && rewardedAd.CanShowAd())
|
||||
{
|
||||
rewardedAd.Show((Reward reward) =>
|
||||
{
|
||||
// TODO: Reward the user.
|
||||
Debug.Log(String.Format(rewardMsg, reward.Type, reward.Amount));
|
||||
});
|
||||
}
|
||||
|
||||
StartCoroutine(ReloadAds(true));
|
||||
}
|
||||
|
||||
|
||||
IEnumerator ReloadAds(bool rewarded){
|
||||
yield return new WaitForSeconds(2);
|
||||
LoadInterstitialAd();
|
||||
if(rewarded){
|
||||
LoadRewardedAd();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using GoogleMobileAds.Api;
|
||||
using UnityEngine;
|
||||
|
||||
public class AdsManager : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
|
||||
public static AdsManager instance;
|
||||
void Awake(){
|
||||
if(instance!= null){Destroy(gameObject);}
|
||||
instance = this;
|
||||
}
|
||||
|
||||
const string intAdId = "ca-app-pub-3966734202864173/9071918772";
|
||||
const string rewardedAdId = "ca-app-pub-3966734202864173/7802288880";
|
||||
void Start()
|
||||
{
|
||||
DontDestroyOnLoad(gameObject);
|
||||
// Initialize the Google Mobile Ads SDK.
|
||||
MobileAds.Initialize(initStatus => { Debug.Log("admob Init status : " + initStatus.ToString());});
|
||||
|
||||
StartCoroutine(ReloadAds(true));
|
||||
}
|
||||
|
||||
private InterstitialAd interstitialAd;
|
||||
|
||||
/// <summary>
|
||||
/// Loads the interstitial ad.
|
||||
/// </summary>
|
||||
public void LoadInterstitialAd()
|
||||
{
|
||||
// Clean up the old ad before loading a new one.
|
||||
if (interstitialAd != null)
|
||||
{
|
||||
interstitialAd.Destroy();
|
||||
interstitialAd = null;
|
||||
}
|
||||
|
||||
Debug.Log("Loading the interstitial ad.");
|
||||
|
||||
// create our request used to load the ad.
|
||||
var adRequest = new AdRequest.Builder()
|
||||
.AddKeyword("unity-admob-sample")
|
||||
.Build();
|
||||
|
||||
// send the request to load the ad.
|
||||
InterstitialAd.Load(intAdId, adRequest,
|
||||
(InterstitialAd ad, LoadAdError error) =>
|
||||
{
|
||||
// if error is not null, the load request failed.
|
||||
if (error != null || ad == null)
|
||||
{
|
||||
Debug.LogError("interstitial ad failed to load an ad " +
|
||||
"with error : " + error);
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log("Interstitial ad loaded with response : "
|
||||
+ ad.GetResponseInfo());
|
||||
|
||||
interstitialAd = ad;
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void ShowIntAd()
|
||||
{
|
||||
if (interstitialAd != null && interstitialAd.CanShowAd())
|
||||
{
|
||||
Debug.Log("Showing interstitial ad.");
|
||||
interstitialAd.Show();
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError("Interstitial ad is not ready yet.");
|
||||
}
|
||||
StartCoroutine(ReloadAds(false));
|
||||
|
||||
}
|
||||
|
||||
|
||||
private RewardedAd rewardedAd;
|
||||
|
||||
/// <summary>
|
||||
/// Loads the rewarded ad.
|
||||
/// </summary>
|
||||
public void LoadRewardedAd()
|
||||
{
|
||||
// Clean up the old ad before loading a new one.
|
||||
if (rewardedAd != null)
|
||||
{
|
||||
rewardedAd.Destroy();
|
||||
rewardedAd = null;
|
||||
}
|
||||
|
||||
Debug.Log("Loading the rewarded ad.");
|
||||
|
||||
// create our request used to load the ad.
|
||||
var adRequest = new AdRequest.Builder().Build();
|
||||
|
||||
// send the request to load the ad.
|
||||
RewardedAd.Load(rewardedAdId, adRequest,
|
||||
(RewardedAd ad, LoadAdError error) =>
|
||||
{
|
||||
// if error is not null, the load request failed.
|
||||
if (error != null || ad == null)
|
||||
{
|
||||
Debug.LogError("Rewarded ad failed to load an ad " +
|
||||
"with error : " + error);
|
||||
return;
|
||||
}
|
||||
|
||||
Debug.Log("Rewarded ad loaded with response : "
|
||||
+ ad.GetResponseInfo());
|
||||
|
||||
rewardedAd = ad;
|
||||
|
||||
rewardedAd.OnAdPaid += OnRewardSuccess;
|
||||
});
|
||||
}
|
||||
|
||||
private void OnRewardSuccess(AdValue obj)
|
||||
{
|
||||
// GameManager.AdWatched();
|
||||
}
|
||||
|
||||
public void ShowRewardedAd()
|
||||
{
|
||||
const string rewardMsg =
|
||||
"Rewarded ad rewarded the user. Type: {0}, amount: {1}.";
|
||||
|
||||
if (rewardedAd != null && rewardedAd.CanShowAd())
|
||||
{
|
||||
rewardedAd.Show((Reward reward) =>
|
||||
{
|
||||
// TODO: Reward the user.
|
||||
Debug.Log(String.Format(rewardMsg, reward.Type, reward.Amount));
|
||||
});
|
||||
}
|
||||
|
||||
StartCoroutine(ReloadAds(true));
|
||||
}
|
||||
|
||||
|
||||
IEnumerator ReloadAds(bool rewarded){
|
||||
yield return new WaitForSeconds(2);
|
||||
LoadInterstitialAd();
|
||||
if(rewarded){
|
||||
LoadRewardedAd();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
92
Assets/Scripts/AppleLogin.cs
Normal file
92
Assets/Scripts/AppleLogin.cs
Normal file
@@ -0,0 +1,92 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using AppleAuth;
|
||||
using AppleAuth.Enums;
|
||||
using AppleAuth.Interfaces;
|
||||
using AppleAuth.Native;
|
||||
using UnityEngine;
|
||||
|
||||
public class AppleLogin : MonoBehaviour
|
||||
{
|
||||
public GoogleLoginManager googleLogin;
|
||||
IAppleAuthManager m_AppleAuthManager;
|
||||
public string Token { get; private set; }
|
||||
public string Error { get; private set; }
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
var deserializer = new PayloadDeserializer();
|
||||
m_AppleAuthManager = new AppleAuthManager(deserializer);
|
||||
}
|
||||
|
||||
public void Update()
|
||||
{
|
||||
if (m_AppleAuthManager != null)
|
||||
{
|
||||
m_AppleAuthManager.Update();
|
||||
}
|
||||
}
|
||||
|
||||
public void LoginToApple()
|
||||
{
|
||||
// Initialize the Apple Auth Manager
|
||||
if (m_AppleAuthManager == null)
|
||||
{
|
||||
Initialize();
|
||||
}
|
||||
|
||||
// Set the login arguments
|
||||
var loginArgs = new AppleAuthLoginArgs(LoginOptions.IncludeEmail | LoginOptions.IncludeFullName);
|
||||
|
||||
// Perform the login
|
||||
m_AppleAuthManager.LoginWithAppleId(
|
||||
loginArgs,
|
||||
credential =>
|
||||
{
|
||||
var appleIDCredential = credential as IAppleIDCredential;
|
||||
if (appleIDCredential != null)
|
||||
{
|
||||
var idToken = Encoding.UTF8.GetString(
|
||||
appleIDCredential.IdentityToken,
|
||||
0,
|
||||
appleIDCredential.IdentityToken.Length);
|
||||
Debug.Log("Sign-in with Apple successfully done. IDToken: " + idToken);
|
||||
Token = idToken;
|
||||
|
||||
if (appleIDCredential == null)
|
||||
{
|
||||
MessageDialog.instance.ShowMessage("Error", "Failed to login using Apple ID.\nError Code: A-00");
|
||||
}else if(appleIDCredential.Email == null)
|
||||
{
|
||||
MessageDialog.instance.ShowMessage("Error", "Failed to login using Apple ID.\nError Code: A-0E");
|
||||
|
||||
}
|
||||
else if (appleIDCredential.FullName == null)
|
||||
{
|
||||
MessageDialog.instance.ShowMessage("Error", "Failed to login using Apple ID.\nError Code: A-0U");
|
||||
|
||||
}
|
||||
var fullname = appleIDCredential.Email;
|
||||
Debug.Log("Email : " + appleIDCredential.Email);
|
||||
Debug.Log("User :" + fullname);
|
||||
|
||||
googleLogin.OnAppleSigninDone(fullname, appleIDCredential.Email);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("Sign-in with Apple error. Message: appleIDCredential is null");
|
||||
Error = "Retrieving Apple Id Token failed.";
|
||||
}
|
||||
},
|
||||
error =>
|
||||
{
|
||||
Debug.Log("Sign-in with Apple error. Message: " + error);
|
||||
Error = "Retrieving Apple Id Token failed.";
|
||||
}
|
||||
);
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,84 +1,102 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AudioManager : MonoBehaviour
|
||||
{
|
||||
public static AudioManager instance;
|
||||
public AudioClip explosionSFX;
|
||||
[SerializeField]public AudioSource SourceSFX;
|
||||
[SerializeField]public AudioSource SourceMusic;
|
||||
[SerializeField]public LevelAudioCombo[] levels;
|
||||
public static bool isMuteMusic {get{
|
||||
if(PlayerPrefs.HasKey("music")){
|
||||
return PlayerPrefs.GetInt("music") == 0;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}}
|
||||
public static bool isMuteSFX {get{
|
||||
if(PlayerPrefs.HasKey("sfx")){
|
||||
return PlayerPrefs.GetInt("sfx") == 0;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}}
|
||||
public static void ToggleMusic(){
|
||||
if(isMuteMusic){
|
||||
PlayerPrefs.SetInt("music",1);
|
||||
instance.SourceMusic.volume = instance.defVol;
|
||||
}else{
|
||||
PlayerPrefs.SetInt("music",0);
|
||||
instance.SourceMusic.volume = 0;
|
||||
}
|
||||
PlayerPrefs.Save();
|
||||
|
||||
}
|
||||
|
||||
float defVol;
|
||||
public static void ToggleSFX(){
|
||||
if(isMuteSFX){
|
||||
PlayerPrefs.SetInt("sfx",1);
|
||||
}else{
|
||||
PlayerPrefs.SetInt("sfx",0);
|
||||
}
|
||||
PlayerPrefs.Save();
|
||||
|
||||
}
|
||||
|
||||
void Awake(){
|
||||
instance= this;
|
||||
DontDestroyOnLoad(this);
|
||||
defVol = SourceMusic.volume;
|
||||
}
|
||||
|
||||
public static void ChangeMusicToScene(string scene){
|
||||
AudioClip chosen = instance.levels[0].clip;
|
||||
|
||||
foreach(LevelAudioCombo level in instance.levels){
|
||||
if(level.name == scene){
|
||||
chosen = level.clip;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ChangeBGMusic(chosen);
|
||||
}
|
||||
|
||||
public static void ChangeBGMusic(AudioClip clip){
|
||||
instance.SourceMusic.Stop();
|
||||
instance.SourceMusic.clip = clip;
|
||||
instance.SourceMusic.Play();
|
||||
}
|
||||
|
||||
public static void PlayExplosion(){
|
||||
if(isMuteSFX){return;}
|
||||
instance.SourceSFX.PlayOneShot(instance.explosionSFX);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class LevelAudioCombo{
|
||||
public string name;
|
||||
public AudioClip clip;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class AudioManager : MonoBehaviour
|
||||
{
|
||||
public static AudioManager instance;
|
||||
public AudioClip explosionSFX;
|
||||
public AudioClip powerupSFX;
|
||||
public AudioClip powerdownSFX;
|
||||
public AudioClip whooshSFX;
|
||||
[SerializeField]public AudioSource SourceSFX;
|
||||
[SerializeField]public AudioSource SourceMusic;
|
||||
[SerializeField]public LevelAudioCombo[] levels;
|
||||
public static bool isMuteMusic {get{
|
||||
if(PlayerPrefs.HasKey("music")){
|
||||
return PlayerPrefs.GetInt("music") == 0;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}}
|
||||
public static bool isMuteSFX {get{
|
||||
if(PlayerPrefs.HasKey("sfx")){
|
||||
return PlayerPrefs.GetInt("sfx") == 0;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}}
|
||||
public static void ToggleMusic(){
|
||||
if(isMuteMusic){
|
||||
PlayerPrefs.SetInt("music",1);
|
||||
instance.SourceMusic.volume = instance.defVol;
|
||||
}else{
|
||||
PlayerPrefs.SetInt("music",0);
|
||||
instance.SourceMusic.volume = 0;
|
||||
}
|
||||
PlayerPrefs.Save();
|
||||
|
||||
}
|
||||
|
||||
float defVol;
|
||||
public static void ToggleSFX(){
|
||||
if(isMuteSFX){
|
||||
PlayerPrefs.SetInt("sfx",1);
|
||||
}else{
|
||||
PlayerPrefs.SetInt("sfx",0);
|
||||
}
|
||||
PlayerPrefs.Save();
|
||||
|
||||
}
|
||||
|
||||
void Awake(){
|
||||
instance= this;
|
||||
DontDestroyOnLoad(this);
|
||||
defVol = SourceMusic.volume;
|
||||
}
|
||||
|
||||
public static void ChangeMusicToScene(string scene){
|
||||
AudioClip chosen = instance.levels[0].clip;
|
||||
|
||||
foreach(LevelAudioCombo level in instance.levels){
|
||||
if(level.name == scene){
|
||||
chosen = level.clip;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ChangeBGMusic(chosen);
|
||||
}
|
||||
|
||||
public static void ChangeBGMusic(AudioClip clip){
|
||||
instance.SourceMusic.Stop();
|
||||
instance.SourceMusic.clip = clip;
|
||||
instance.SourceMusic.Play();
|
||||
}
|
||||
|
||||
public static void PlayExplosion(){
|
||||
if(isMuteSFX){return;}
|
||||
instance.SourceSFX.PlayOneShot(instance.explosionSFX);
|
||||
}
|
||||
|
||||
public static void PlayPowerup(){
|
||||
if(isMuteSFX){return;}
|
||||
instance.SourceSFX.PlayOneShot(instance.powerupSFX);
|
||||
}
|
||||
public static void PlayPowerdown(){
|
||||
if(isMuteSFX){return;}
|
||||
instance.SourceSFX.PlayOneShot(instance.powerdownSFX);
|
||||
}
|
||||
public static void PlayWhoosh(){
|
||||
if(isMuteSFX){return;}
|
||||
instance.SourceSFX.PlayOneShot(instance.whooshSFX);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class LevelAudioCombo{
|
||||
public string name;
|
||||
public AudioClip clip;
|
||||
}
|
||||
@@ -1,58 +1,58 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MessageBox : MonoBehaviour
|
||||
{
|
||||
public static MessageBox instance { get; private set;}
|
||||
void Awake(){
|
||||
if(instance != null){Destroy(gameObject);}
|
||||
instance = this;
|
||||
canvasGroup = GetComponent<CanvasGroup>();
|
||||
|
||||
closeButton.onClick.AddListener(()=>{SetActive(false);});
|
||||
}
|
||||
|
||||
private CanvasGroup canvasGroup;
|
||||
[SerializeField]private Text messageTxt;
|
||||
[SerializeField]private Text titleTxt;
|
||||
[SerializeField]private Button closeButton;
|
||||
void Start()
|
||||
{
|
||||
DontDestroyOnLoad(gameObject);
|
||||
SetActive(false);
|
||||
}
|
||||
|
||||
void SetActive(bool value){
|
||||
// StartCoroutine(setActive(value));
|
||||
canvasGroup.alpha= value ? 1 : 0;
|
||||
canvasGroup.blocksRaycasts = value;
|
||||
canvasGroup.interactable = value;
|
||||
}
|
||||
private static string message;
|
||||
public static void ShowMessage(string message,string title = "Notice"){
|
||||
if(instance == null){Debug.LogError("Message was shown before message box was init");return;}
|
||||
|
||||
instance.showMessage(message,title);
|
||||
}
|
||||
|
||||
public void showMessage(string _message, string title){
|
||||
message = _message;
|
||||
titleTxt.text = title;
|
||||
StartCoroutine(_showMessage());
|
||||
SetActive(true);
|
||||
}
|
||||
|
||||
IEnumerator _showMessage(){
|
||||
messageTxt.text = "";
|
||||
closeButton.gameObject.SetActive(false);
|
||||
for(int i=0; i < message.Length; i++){
|
||||
messageTxt.text += message[i];
|
||||
|
||||
yield return new WaitForSeconds(0.01f);
|
||||
}
|
||||
closeButton.gameObject.SetActive(true);
|
||||
|
||||
}
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MessageBox : MonoBehaviour
|
||||
{
|
||||
public static MessageBox instance { get; private set;}
|
||||
void Awake(){
|
||||
if(instance != null){Destroy(gameObject);}
|
||||
instance = this;
|
||||
canvasGroup = GetComponent<CanvasGroup>();
|
||||
|
||||
closeButton.onClick.AddListener(()=>{SetActive(false);});
|
||||
}
|
||||
|
||||
private CanvasGroup canvasGroup;
|
||||
[SerializeField]private Text messageTxt;
|
||||
[SerializeField]private Text titleTxt;
|
||||
[SerializeField]private Button closeButton;
|
||||
void Start()
|
||||
{
|
||||
DontDestroyOnLoad(gameObject);
|
||||
SetActive(false);
|
||||
}
|
||||
|
||||
void SetActive(bool value){
|
||||
// StartCoroutine(setActive(value));
|
||||
canvasGroup.alpha= value ? 1 : 0;
|
||||
canvasGroup.blocksRaycasts = value;
|
||||
canvasGroup.interactable = value;
|
||||
}
|
||||
private static string message;
|
||||
public static void ShowMessage(string message,string title = "Notice"){
|
||||
if(instance == null){Debug.LogError("Message was shown before message box was init");return;}
|
||||
|
||||
instance.showMessage(message,title);
|
||||
}
|
||||
|
||||
public void showMessage(string _message, string title){
|
||||
message = _message;
|
||||
titleTxt.text = title;
|
||||
StartCoroutine(_showMessage());
|
||||
SetActive(true);
|
||||
}
|
||||
|
||||
IEnumerator _showMessage(){
|
||||
messageTxt.text = "";
|
||||
closeButton.gameObject.SetActive(false);
|
||||
for(int i=0; i < message.Length; i++){
|
||||
messageTxt.text += message[i];
|
||||
|
||||
yield return new WaitForSeconds(0.01f);
|
||||
}
|
||||
closeButton.gameObject.SetActive(true);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NearMiss : MonoBehaviour
|
||||
{
|
||||
void OnTriggerExit2D(Collider2D other){
|
||||
if(PlayerController.instance.PowerupActive){return;}
|
||||
if(other.tag == "asteroid"){
|
||||
DataManager.AddItem("add_near_miss.php");
|
||||
PlayerController.NearMissFX();
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class NearMiss : MonoBehaviour
|
||||
{
|
||||
void OnTriggerExit2D(Collider2D other){
|
||||
if(PlayerController.instance.PowerupActive){return;}
|
||||
if(other.tag == "asteroid"){
|
||||
DataManager.AddItem("add_near_miss.php");
|
||||
PlayerController.NearMissFX();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -63,6 +63,9 @@ public class PlayerController : MonoBehaviour
|
||||
|
||||
if(powerupTimer > 0){
|
||||
powerupTimer-=Time.deltaTime;
|
||||
if(powerupTimer <= 0){
|
||||
OnPowerdown();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -102,6 +105,7 @@ public class PlayerController : MonoBehaviour
|
||||
public static void NearMissFX(){
|
||||
instance.nearMissAnim.gameObject.SetActive(true);
|
||||
instance.nearMissAnim.CrossFade("txt_intro",0.01f);
|
||||
AudioManager.PlayWhoosh();
|
||||
}
|
||||
public float PowerupLife = 30;
|
||||
public float PowerupSpeedMult = 1.3f;
|
||||
@@ -109,6 +113,7 @@ public class PlayerController : MonoBehaviour
|
||||
public float powerupTimer = 0;
|
||||
public void ActivatePowerup(){
|
||||
powerupTimer = PowerupLife;
|
||||
AudioManager.PlayPowerup();
|
||||
}
|
||||
public static int AdCounter=0;
|
||||
public async void GameOver(){
|
||||
@@ -132,6 +137,10 @@ public class PlayerController : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
void OnPowerdown(){
|
||||
AudioManager.PlayPowerdown();
|
||||
}
|
||||
|
||||
public void SpawnExplosionFX(Vector3 pos){
|
||||
Instantiate(ExplosionFX,pos, Quaternion.identity);
|
||||
AudioManager.PlayExplosion();
|
||||
|
||||
Reference in New Issue
Block a user