You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
PlumberUltimateAds/Assets/Scripts/GameScene.cs

158 lines
3.8 KiB
C#

2 months ago
/*
http://www.cgsoso.com/forum-211-1.html
CG Unity3d Unity3d VIP
CGSOSO CG
daily assets update for try.
U should buy the asset from home store if u use it in your project!
*/
using MS;
using TMPro;
2 months ago
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class GameScene : MonoBehaviour
{
[Header("Menu")]
public Text coinLbl;
public TMP_Text titleLevelGroupLbl;
2 months ago
public TMP_Text titleLevelNoLbl;
2 months ago
2 months ago
public Popup gameOverPopup;
2 months ago
public TMP_Text rewardValueText;
2 months ago
2 months ago
public TMP_Text coinForHintText;
2 months ago
public GameObject skipCoinObj;
2 months ago
// public GameObject skipTextObj;
2 months ago
2 months ago
public TMP_Text skipCoinValueText;
2 months ago
public static GameScene instance;
private void Start()
{
instance = this;
rewardValueText.text = "+" + GameConfig.instance.rewardedVideoAmount;
coinForHintText.text = GameConfig.instance.numCoinForHint.ToString();
skipCoinValueText.text = GameConfig.instance.numCoinForSkipGame.ToString();
Music.instance.Play(Music.Type.MainMusic);
//IronSource.Agent.loadBanner(IronSourceBannerSize.SMART, IronSourceBannerPosition.BOTTOM);
2 months ago
}
public void UpdateUI()
{
coinLbl.text = GameManager.Coin + string.Empty;
titleLevelGroupLbl.text = GameManager.currentLevelGroup.LevelGroupName;
titleLevelNoLbl.text = GameManager.CurrentLevelNo + string.Empty;
titleLevelNoLbl.color = GameManager.currentLevelGroup.bgColor;
// titleBG.sprite = GameManager.currentLevelGroup.LevelHeaderBG;
2 months ago
}
public void OnBackBtn()
{
if (!GamePlayManager.instance.isGameOver || GamePlayManager.instance.closeGameOver)
{
Sound.instance.PlayButton(Sound.Button.Back);
GameManager.openLevelSelection = true;
SceneManager.LoadScene("HomeScene");
}
}
public void ShowMenuPopup()
{
2 months ago
// bool flag = GameManager.CurrentLevelNo > GameManager.currentLevelGroup.CompletedLevel;
// skipCoinObj.SetActive(flag);
// Transform transform = skipTextObj.transform;
// float x = (!flag) ? 12 : (-19);
// Vector3 localPosition = skipTextObj.transform.localPosition;
// transform.localPosition = new Vector3(x, localPosition.y);
2 months ago
Sound.instance.PlayButton();
}
public void OnGameOverCloseBtn()
{
Sound.instance.PlayButton(Sound.Button.Back);
gameOverPopup.Close();
GamePlayManager.instance.closeGameOver = true;
}
public void OnHomeBtn()
{
if (!GamePlayManager.instance.isGameOver || GamePlayManager.instance.closeGameOver)
{
Sound.instance.PlayButton();
SceneManager.LoadScene("HomeScene");
}
}
public void OnVideoRewarded()
{
int rewardedVideoAmount = GameConfig.instance.rewardedVideoAmount;
GameManager.Coin += rewardedVideoAmount;
UpdateUI();
Toast.instance.ShowMessage($"You got {rewardedVideoAmount} free coins");
AchievementManager.instance.AddAchievementProgress(GameConstants.Ach_WatchedAds, 1);
2 months ago
}
public bool debugHints = false;
2 months ago
public void OnHintBtn()
{
if (!GamePlayManager.instance.isGameOver)
{
if (!debugHints)
2 months ago
{
Sound.instance.PlayButton();
if (GameManager.Coin < GameConfig.instance.numCoinForHint)
{
Toast.instance.ShowMessage("You don't have enough coins");
return;
}
2 months ago
}
GameManager.Coin -= GameConfig.instance.numCoinForHint;
UpdateUI();
GamePlayManager.instance.GiveHint();
}
}
public void OnUndoBtn()
{
if (!GamePlayManager.instance.isGameOver)
{
Sound.instance.PlayButton();
GamePlayManager.instance.Undo();
}
}
public void OnRestart()
{
if (!GamePlayManager.instance.isGameOver || GamePlayManager.instance.closeGameOver)
{
Sound.instance.PlayButton();
SceneManager.LoadScene("GameScene");
}
}
public void PlayButton()
{
Sound.instance.PlayButton();
}
public void PlayBackButton()
{
Sound.instance.PlayButton(Sound.Button.Back);
}
}