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

159 lines
3.7 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 UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class GameScene : MonoBehaviour
{
[Header("Menu")]
public Text coinLbl;
public Text titleLevelGroupLbl;
public Text titleLevelNoLbl;
public Image titleBG;
public Popup gameOverPopup;
public Text rewardValueText;
public Text coinForHintText;
public GameObject skipCoinObj;
public GameObject skipTextObj;
public Text skipCoinValueText;
public static GameScene instance;
public bool hintcheck = false;
2 months ago
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);
}
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;
}
public void OnBackBtn()
{
if (!GamePlayManager.instance.isGameOver || GamePlayManager.instance.closeGameOver)
{
Sound.instance.PlayButton(Sound.Button.Back);
GameManager.openLevelSelection = true;
SceneManager.LoadScene("HomeScene1");
2 months ago
}
}
public void ShowMenuPopup()
{
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);
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("HomeScene1");
2 months ago
}
}
public void OnVideoRewarded()
{
int rewardedVideoAmount = GameConfig.instance.rewardedVideoAmount;
GameManager.Coin += rewardedVideoAmount;
UpdateUI();
Toast.instance.ShowMessage($"You got {rewardedVideoAmount} free coins");
}
public void OnHintBtn()
{
if (!GamePlayManager.instance.isGameOver)
{
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();
//hintcheck = true;
2 months ago
}
}
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);
}
public void back()
{
SceneManager.LoadScene(0);
}
2 months ago
}