protected override void DoInit()
{
//根据平台开关数据分析
if (Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer || Application.platform == RuntimePlatform.WP8Player)
{
CapsConfig.EnableGA = true;
CapsConfig.EnableTalkingData = true;
Resources.Load("GA_SystemTracker");
}
else
{
CapsConfig.EnableGA = false;
CapsConfig.EnableTalkingData = false;
}
#if UNITY_ANDROID || UNITY_IPHONE
if (CapsConfig.EnableTalkingData)
{
TalkingDataPlugin.SessionStarted("8F604653A8CC694E6954B51FE6D26127", "Test");
}
#endif
m_startAppTime = Time.realtimeSinceStartup;
m_playTime = PlayerPrefs.GetFloat("PlayTime");
if (!PlayerPrefs.HasKey("Music")) //第一次运行
{
PlayerPrefs.SetInt("Music", 1);
PlayerPrefs.SetInt("SFX", 1);
GlobalVars.UseMusic = true;
GlobalVars.UseSFX = true;
}
else
{
GlobalVars.UseMusic = (PlayerPrefs.GetInt("Music") == 1);
GlobalVars.UseSFX = (PlayerPrefs.GetInt("SFX") == 1);
}
Application.targetFrameRate = 60; //
if (Application.platform == RuntimePlatform.WindowsPlayer)
{
Screen.SetResolution(480, 800, false);
}
new CapsConfig();
new ResourceManager();
UIDrawer.Singleton.AddPrefab(ResourceManager.Singleton.GetUIPrefabByName("BaseTextLabel"));
UIDrawer.Singleton.fontDefaultPrefabID = UIDrawer.Singleton.AddPrefab(ResourceManager.Singleton.GetUIPrefabByName("OutlineTextLabel"));
UIDrawer.Singleton.AddPrefab(ResourceManager.Singleton.GetUIPrefabByName("ShadowTextLabel"));
UIDrawer.Singleton.spriteDefaultPrefabID = UIDrawer.Singleton.AddPrefab(ResourceManager.Singleton.GetUIPrefabByName("BaseSpriteCommonAtlas"));
UIDrawer.Singleton.numDefaultPrefabID = UIDrawer.Singleton.AddPrefab(ResourceManager.Singleton.GetUIPrefabByName("BaseNumber"));
TextTable.Singleton.AddTextMap(@"baseText");
TextTable.Singleton.AddTextMap(@"errorcode");
ChangeState((int)StateEnum.Login);
GlobalVars.TotalStageCount = CapsConfig.Instance.TotalStageCount;
if (CapsConfig.Instance.MoveTime > 0)
{
GameLogic.MOVE_TIME = CapsConfig.Instance.MoveTime;
}
if (CapsConfig.Instance.EatTime > 0)
{
GameLogic.EATBLOCK_TIME = CapsConfig.Instance.EatTime;
}
if (CapsConfig.Instance.DropAcc > 0)
{
GameLogic.DROP_ACC = CapsConfig.Instance.DropAcc;
}
if (CapsConfig.Instance.DropSpeed > 0)
{
GameLogic.DROP_SPEED = CapsConfig.Instance.DropSpeed;
}
if (CapsConfig.Instance.SlideSpeed > 0)
{
GameLogic.SLIDE_SPEED = CapsConfig.Instance.SlideSpeed;
}
GlobalVars.ReadHeart();
UIWindowManager.Singleton.CreateWindow<UILogin>();
Timer.AddDelayFunc(0.3f, delegate()
{
UIWindowManager.Singleton.GetUIWindow<UILogin>().ShowWindow(delegate()
{
GameObject obj = GameObject.Find("FirstTimeBackground"); //为了让第一次进游戏的图平滑变化没有闪烁,先在场景里垫了一张图,现在用完了,把图删除
GameObject.Destroy(obj);
});
});
Localization.instance.currentLanguage = "Chinese"; //中文版
//初始化支付插件
if (Application.platform != RuntimePlatform.WindowsPlayer)
{
Unibiller.onBillerReady += OnUniBillInitialised;
Unibiller.Initialise();
}
if (Application.platform != RuntimePlatform.WP8Player)
{
//第一次运行时,5月份之前,送点金币
if (System.DateTime.Today.Year == 2014 && System.DateTime.Today.Month <= 5
&& !PlayerPrefs.HasKey("GiveFirstTimeMoney3"))
{
PlayerPrefs.SetInt("GiveFirstTimeMoney3", 1);
Unibiller.CreditBalance("gold", 3000); //给3000金币
}
}
}