155 lines
5.2 KiB
C#
155 lines
5.2 KiB
C#
using System;
|
|
using MyGame.Scenes.Main.Scripts;
|
|
using MyGame.Scripts;
|
|
using UniRx;
|
|
using UnityEngine;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
|
|
|
|
public class FooterManager : MonoBehaviour
|
|
{
|
|
[SerializeField] private FooterButton kitchenButton;
|
|
[SerializeField] private FooterButton fieldButton;
|
|
[SerializeField] private FooterButton stockButton;
|
|
[SerializeField] private FooterButton saleButton;
|
|
[SerializeField] private FooterButton productManagementButton;
|
|
[SerializeField] private GameObject stockNotifyIcon;
|
|
[SerializeField] private GameObject kitchenNotifyIcon;
|
|
|
|
|
|
[SerializeField] private GameObject fieldCornIcon;
|
|
|
|
int refreshRewardCoin = 10;
|
|
private void Start()
|
|
{
|
|
if (!Enum.TryParse<GameScenes>(SceneManager.GetActiveScene().name, out var currentSceneName))
|
|
{
|
|
return;
|
|
}
|
|
|
|
if (PlayerPrefs.GetInt("ADJUST_FIRSTMAINPAGE", 0) == 0)
|
|
{
|
|
JoypacAnalyticsManager.Instance.LogEventToken(ConstStringKey.ADJUST_FIRSTMAINPAGE);
|
|
PlayerPrefs.SetInt("ADJUST_FIRSTMAINPAGE", 1);
|
|
}
|
|
|
|
var gameData = GameDataManager.GameData;
|
|
var isTutorial = gameData.FinishedFlags.HasFlag(TutorialFlag.FirstPlay);
|
|
|
|
if (JoypacAnalyticsManager.Push1&& isTutorial)
|
|
{
|
|
|
|
Debug.Log("JoypacAnalyticsManager.Push1");
|
|
currentSceneName = GameScenes.marketing;
|
|
|
|
TransitionManager.Instance.LoadScene(currentSceneName);
|
|
|
|
|
|
}
|
|
else if(JoypacAnalyticsManager.Push2&& isTutorial)
|
|
{
|
|
Debug.Log("JoypacAnalyticsManager.Push2");
|
|
currentSceneName = GameScenes.shopping;
|
|
|
|
TransitionManager.Instance.LoadScene(currentSceneName);
|
|
|
|
JoypacAnalyticsManager.Push2 = false;
|
|
}
|
|
else if (JoypacAnalyticsManager.Push3 && isTutorial)
|
|
{
|
|
Debug.Log("JoypacAnalyticsManager.Push3");
|
|
currentSceneName = GameScenes.Main;
|
|
|
|
TransitionManager.Instance.LoadScene(currentSceneName);
|
|
|
|
JoypacAnalyticsManager.Push3 = false;
|
|
}
|
|
|
|
|
|
kitchenButton.SetSelected(currentSceneName == GameScenes.Main);
|
|
fieldButton.SetSelected(currentSceneName == GameScenes.CornField);
|
|
stockButton.SetSelected(currentSceneName == GameScenes.shopping);
|
|
saleButton.SetSelected(currentSceneName == GameScenes.marketing);
|
|
productManagementButton.SetSelected(currentSceneName == GameScenes.ProductManagement);
|
|
Observable.Merge(
|
|
kitchenButton.ClickObservable.Select(_ => GameScenes.Main),
|
|
fieldButton.ClickObservable.Select(_ => GameScenes.CornField),
|
|
stockButton.ClickObservable.Select(_ => GameScenes.shopping),
|
|
saleButton.ClickObservable.Select(_ => GameScenes.marketing),
|
|
productManagementButton.ClickObservable.Select(_ => GameScenes.ProductManagement))
|
|
.Take(1)
|
|
.Subscribe(x =>
|
|
{
|
|
TransitionManager.Instance.LoadScene(x);
|
|
}).AddTo(this);
|
|
|
|
kitchenNotifyIcon.SetActive(AutoCookView.CheckComplete());
|
|
stockNotifyIcon.SetActive(Shopping.CheckEarnedRecipe());
|
|
if (JoypacAdManager.Instance.SwitchPageInter)
|
|
{
|
|
JoypacAdManager.Instance.ShowInterstitial((JoypacInterStatus) =>
|
|
{
|
|
if (JoypacInterStatus == JoypacIntersitialStatus.CLOSE)
|
|
{
|
|
CoinGetDialog.ShowDialog(refreshRewardCoin, () =>
|
|
{
|
|
//var gameData = GameDataManager.GameData;
|
|
CoinManager.Instance.AddCoin(refreshRewardCoin);
|
|
gameData.Coin = CoinManager.Instance.OwnCoin;
|
|
GameDataManager.SaveGameData();
|
|
JoypacAnalyticsManager.Instance.AdEvent(StaticStringsEvent.BackHomeButton, "", "", StaticStringsEvent.BackHomeInterstitial, StaticStringsEvent.Interstitial);
|
|
|
|
}, true);
|
|
}
|
|
}, ConstStringKey.JOYPAC_SDK_INTERID, StaticStringsEvent.SwitchPage);
|
|
Debug.Log("jp======Interstitial");
|
|
|
|
// StartCoroutine(JoypacAdManager.Instance.SwitchPageTime());
|
|
|
|
JoypacAdManager.Instance.startSwitchPageTime();
|
|
}
|
|
// StartCoroutine(CornFull());
|
|
|
|
}
|
|
|
|
float falshCorn = 0;
|
|
|
|
private void Update()
|
|
{
|
|
falshCorn += Time.deltaTime;
|
|
if (falshCorn >= 1)
|
|
{
|
|
falshCorn = 0;
|
|
CornFull();
|
|
|
|
}
|
|
}
|
|
public void CornFull()
|
|
{
|
|
// example
|
|
var isFulled = true;
|
|
var gameData = GameDataManager.GameData;
|
|
foreach (var seedlingProgressData in gameData.SeedlingDataList)
|
|
{
|
|
foreach (var seedlingData in seedlingProgressData.Seedlings)
|
|
{
|
|
if (1f > DateTime.Now.Subtract(seedlingData.FirstTime).TotalSeconds / seedlingData.Period)
|
|
{
|
|
isFulled = false;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
|
|
fieldCornIcon.SetActive(isFulled);
|
|
|
|
// Debug.Log(isFulled);
|
|
|
|
|
|
}
|
|
|
|
|
|
} |