コード例 #1
0
    public static MissionAchievement CreateAchievement(Dictionary <string, object> achievementData)
    {
        string missionAchievementType = (string)achievementData["Type"];

        MissionAchievement newMissionAchievement = null;

        if (missionAchievementType == "score")
        {
            newMissionAchievement = new ScoreAchievement();
        }
        else if (missionAchievementType == "shooterWin")
        {
            newMissionAchievement = new ShooterWinAchievement();
        }
        else if (missionAchievementType == "shooterEffectBonus")
        {
            newMissionAchievement = new ShooterEffectBonusAchievement();
        }
        else if (missionAchievementType == "goalkeeperWin")
        {
            newMissionAchievement = new GoalkeeperWinAchievement();
        }
        else if (missionAchievementType == "perfect")
        {
            newMissionAchievement = new PerfectAchievement();
        }
        else if (missionAchievementType == "life")
        {
            newMissionAchievement = new LifeAchievement();
        }
        else
        {
            throw new ArgumentOutOfRangeException("El tipo de objetivo ( " + missionAchievementType + " ) no existe, revisa madafaka");
        }

        newMissionAchievement.LoadData(achievementData);
        return(newMissionAchievement);
    }
コード例 #2
0
	IEnumerator Start ()
	{
		ScoreScreenController.instance.ShowBlankMode();
		InitTimer();
		while (!Caching.ready)
			yield return null;
		LogTime("Caching Ready");
		// Load the AssetBundle file from Cache if it exists with the same version or download and store it in the cache
		using(WWW www = WWW.LoadFromCacheOrDownload (ExtraInstrumentsBundleURL, oldVersion)){
			yield return www;
			if (www.error != null)
				throw new Exception("WWW download of instruments had an error:" + www.error);
			else
				Debug.Log("WWW download of instruments succeed");
			LogTime("Instruments");
			AssetBundle bundle = www.assetBundle;
			PadController.instance.LoadExtraInstruments(bundle);
			LoadExtraInstruments(bundle);
			bundle.Unload(false);
			LogTime("Instruments processing");
		}


//		AudioSettings.SetDSPBufferSize(128, 2);
		print(Social.Active);
		Social.localUser.Authenticate(delegate(bool success) {
			if (success) {
				Debug.Log ("Authentication successful");
				string userInfo = "Username: "******"\nUser ID: " + Social.localUser.id + 
						"\nIsUnderage: " + Social.localUser.underage + 
						"\nIsAuthenticated: " + Social.localUser.authenticated;
				Debug.Log (userInfo);
				Social.LoadAchievementDescriptions( delegate(UnityEngine.SocialPlatforms.IAchievementDescription[] obj) {
					if (obj == null)
						return;
					foreach(UnityEngine.SocialPlatforms.IAchievementDescription a in obj)
					{
						string scoreString = a.id.ToLower().Replace("reach", "");
						int score = -1;
						if (int.TryParse(scoreString, out score))
						{
							ScoreAchievement sa = new ScoreAchievement(score, a.id);
							scoreAchievements.Add(sa);
							Debug.Log ("Reach " + sa.score + " to unlock achievement: " + sa.id);
						}
					}
					LogTime("Social");
				});
			}
			else
				Debug.Log ("Authentication failed");
		});
		Init();
//		LoadingScreen.instance.Hide();
		ScoreScreenController.instance.BackToGameWithTime(0.8f, true);
		int latestVersion = 0;
		using(WWW www = new WWW(ExtraInstrumentsBundleVersionURL)){
			yield return www;
			LogTime("InstrumentsVersion");
			if (www.error != null)
				throw new Exception("WWW download of instruments version file had an error:" + www.error);
			else
				Debug.Log("WWW download of instruments version file succeed");
			latestVersion = int.Parse(www.text);
		}
		Debug.Log("Instrument Version = " + latestVersion);

		if (latestVersion > oldVersion)
		{
			// Load the AssetBundle file from Cache if it exists with the same version or download and store it in the cache
			using(WWW www = WWW.LoadFromCacheOrDownload (ExtraInstrumentsBundleURL, latestVersion)){
				yield return www;
				if (www.error != null)
					throw new Exception("WWW download of instruments had an error:" + www.error);
				else
					Debug.Log("WWW download of instruments succeed");
				LogTime("NonCachedInstruments");
				AssetBundle bundle = www.assetBundle;
				PadController.instance.LoadExtraInstruments(bundle);
				LoadExtraInstruments(bundle);
				bundle.Unload(false);
				LogTime("Instruments processing");
			}
			oldVersion = latestVersion;
		}
	}