using UnityEngine; using Ability; using UnityEngine.SceneManagement; using TMPro; using Equip; using UnityEngine.Advertisements; #if UNITY_IOS || UNITY_ANDROID using Facebook.Unity; #endif public class EntryPoint : MonoBehaviour { [SerializeField] SimpleProgressBar _loadingProgress; [SerializeField] TextMeshProUGUI _loadingLabel; bool m_inited = false; bool m_needLoadScene = true; float m_loadingTime = 4f; float m_currentLoadingTime = 0f; //------------------------------------------------------------------------------------------ void Awake() { Init(); } //------------------------------------------------------------------------------------------ void Init() { UnbiasedTime.Instance.Now(); InitUser(); InitAds(); InitGameText(); InitAbilities(); LoadResources(); InitStoreOffersInfo(); InitPurchaser(); InitSkinsInfo(); InitEuqipedItemsSettings(); InitFacebookSDK(); if (_loadingProgress) { _loadingProgress.Init(); _loadingProgress.SetProgress(0f); } if (_loadingLabel) _loadingLabel.text = "0%"; m_inited = true; } //------------------------------------------------------------------- void InitFacebookSDK() { #if UNITY_IOS || UNITY_ANDROID if (!FB.IsInitialized) FB.Init(InitCallback, OnHideUnity); else FB.ActivateApp(); #endif } //------------------------------------------------------------------- private void InitCallback() { #if UNITY_IOS || UNITY_ANDROID if (FB.IsInitialized) FB.ActivateApp(); else Debug.Log("Failed to Initialize the Facebook SDK"); #endif } //------------------------------------------------------------------- private void OnHideUnity(bool isGameShown) { if (!isGameShown) Time.timeScale = 0; else Time.timeScale = 1; } //------------------------------------------------------------------------------------------ void InitEuqipedItemsSettings() { EquipSettings.Init(); } //------------------------------------------------------------------------------------------ void InitSkinsInfo() { SkinsInfo info1 = new SkinsInfo(); info1.m_type = SkinType.RACCOON; info1.m_nameTextId = 160; info1.m_skillTextId = 163; info1.m_infoTextId = 166; GlobalsVar.gSkinsInfo.Add(info1); SkinsInfo info2 = new SkinsInfo(); info2.m_type = SkinType.FOX; info2.m_nameTextId = 161; info2.m_skillTextId = 164; info2.m_infoTextId = 167; GlobalsVar.gSkinsInfo.Add(info2); SkinsInfo info3 = new SkinsInfo(); info3.m_type = SkinType.SKUNK; info3.m_nameTextId = 162; info3.m_skillTextId = 165; info3.m_infoTextId = 168; GlobalsVar.gSkinsInfo.Add(info3); } //------------------------------------------------------------------------------------------ void InitAds() { #if UNITY_IOS Advertisement.Initialize( "3715574", false ); #elif UNITY_ANDROID Advertisement.Initialize("3715575", false); #endif } //------------------------------------------------------------------------------------------ void InitStoreOffersInfo() { StoreOffersInfo coins1 = new StoreOffersInfo(); coins1.m_sku = "com.apelsingames.furfurycoins5000"; coins1.m_count = 5000; coins1.m_price = "0.99$"; GlobalsVar.gStoreOffersInfo.Add(coins1.m_sku, coins1); StoreOffersInfo coins2 = new StoreOffersInfo(); coins2.m_sku = "com.apelsingames.furfurycoins18000"; coins2.m_count = 18000; coins2.m_price = "4.99$"; GlobalsVar.gStoreOffersInfo.Add(coins2.m_sku, coins2); StoreOffersInfo coins3 = new StoreOffersInfo(); coins3.m_sku = "com.apelsingames.furfurycoins64000"; coins3.m_count = 64000; coins3.m_price = "9.99$"; GlobalsVar.gStoreOffersInfo.Add(coins3.m_sku, coins3); StoreOffersInfo gems1 = new StoreOffersInfo(); gems1.m_sku = "com.apelsingames.furfurygems100"; gems1.m_count = 100; gems1.m_price = "0.99$"; GlobalsVar.gStoreOffersInfo.Add(gems1.m_sku, gems1); StoreOffersInfo gems2 = new StoreOffersInfo(); gems2.m_sku = "com.apelsingames.furfurygems600"; gems2.m_count = 600; gems2.m_price = "4.99$"; GlobalsVar.gStoreOffersInfo.Add(gems2.m_sku, gems2); StoreOffersInfo gems3 = new StoreOffersInfo(); gems3.m_sku = "com.apelsingames.furfurygems1300"; gems3.m_count = 1300; gems3.m_price = "9.99$"; GlobalsVar.gStoreOffersInfo.Add(gems3.m_sku, gems3); } //------------------------------------------------------------------------------------------ void InitPurchaser() { GlobalsVar.gPurchaser = GameObject.Find("Purchaser").GetComponent(); DontDestroyOnLoad(GlobalsVar.gPurchaser); GlobalsVar.gPurchaser.InitializePurchasing(); } //------------------------------------------------------------------------------------------ void InitGameText() { GlobalsVar.gGameTextMng = new GameTextManager(); } //------------------------------------------------------------------------------------------ void InitUser() { GlobalsVar.gUser = new User(); GlobalsVar.gUser.Load(); InitEnergyTime(GlobalsVar.gDeltaTimeFromLastSave); } //------------------------------------------------------------------- void InitEnergyTime(float delta) { if (delta > 0f) { int energyCount = (int)(delta / GlobalsVar.gTimeToRegenerateEnergy); if (energyCount > 0) { if (GlobalsVar.gUser.Energy < GlobalsVar.gMaxEnergyCount) { if (GlobalsVar.gUser.Energy + energyCount >= GlobalsVar.gMaxEnergyCount) { int deltaHearts = GlobalsVar.gMaxEnergyCount - GlobalsVar.gUser.Energy; GlobalsVar.gUser.IncEnergy(deltaHearts); return; } else { GlobalsVar.gUser.IncEnergy(energyCount); float deltaTime = delta - GlobalsVar.gTimeToRegenerateEnergy * energyCount; GlobalsVar.gCurrentTimeToRegenerateEnergy -= deltaTime; GlobalsVar.gCurrentTimeToRegenerateEnergy = CommonFunctions.ClampDown(GlobalsVar.gCurrentTimeToRegenerateEnergy, 0f); } } } else { float deltaTime = delta - GlobalsVar.gTimeToRegenerateEnergy * energyCount; GlobalsVar.gCurrentTimeToRegenerateEnergy -= deltaTime; GlobalsVar.gCurrentTimeToRegenerateEnergy = CommonFunctions.ClampDown(GlobalsVar.gCurrentTimeToRegenerateEnergy, 0f); } } } //------------------------------------------------------------------------------------------ private void InitAbilities() { GlobalsVar.gMainAbilities = new MainAbility(); GlobalsVar.gMainAbilities.Init(); GlobalsVar.gInGameAbilities = new InGameAbilities(); GlobalsVar.gInGameAbilities.Init(); } //------------------------------------------------------------------------------------------ void LoadResources() { GlobalsVar.gGrayscaleMaterial = Resources.Load("Materials/grayscale_material") as Material; } //------------------------------------------------------------------------------------------ private void Update() { m_currentLoadingTime += Time.deltaTime; if (m_currentLoadingTime > m_loadingTime) m_currentLoadingTime = m_loadingTime; float progress = m_currentLoadingTime / m_loadingTime; _loadingProgress.SetProgress(progress); _loadingLabel.text = ((int)(progress * 100)).ToString() + "%"; if (!m_inited) return; if (m_needLoadScene && m_currentLoadingTime >= m_loadingTime) { m_needLoadScene = false; SceneManager.LoadScene("Scenes/MainMenu"); } } }