Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        //Move credits towards end point
        Credits.transform.position = Vector3.MoveTowards(Credits.transform.position, endPoint.position, Time.deltaTime * speed);


        if (!endOfCredits)
        {
            if (Credits.transform.position.y <= endPoint.position.y)
            {
                endOfCredits = true;


                // this checks if the achievement has been achieved & spits out the result in the bool
                SteamUserStats.GetAchievement("Watch Credits", out achieved);

                // if we don't have the achievement yet, we can say that we've achieved it
                if (!achieved)
                {
                    // set the achievement
                    SteamUserStats.SetAchievement("Watch Credits");
                    // store it on steam's side
                    SteamUserStats.StoreStats();
                }
            }
        }

        if (Input.GetButton("Back"))
        {
            MainMenu();
        }
    }
        /// <summary>
        /// UserStats received, normally used on the enable of this script to check the state of all achievements.
        /// this must be initialized via "DownloadUserStats()" method otherwise the achievements will not work.
        /// <para/> Also it can be used to reconcile the data if you use achievements for unlockables.
        /// </summary>
        /// <param name="_callback"></param>
        /// <param name="IOFailure"></param>
        private void OnUserStatsReceived(UserStatsReceived_t _callback, bool IOFailure)
        {
            Debug.Log("Failure - " + IOFailure + " User - " +
                      _callback.m_steamIDUser + "GameID -" + _callback.m_nGameID);

            foreach (Achievements _achiev in listOfAchievements)
            {
                bool _ret = SteamUserStats.GetAchievement(_achiev.achievementID, out _achiev.Achieved);
                if (_ret)
                {
                    _achiev.achievementName = SteamUserStats.GetAchievementDisplayAttribute(
                        _achiev.achievementID, "name");

                    _achiev.achievementDesc = SteamUserStats.GetAchievementDisplayAttribute(
                        _achiev.achievementID, "desc");

                    SteamUserStats.GetStat(_achiev.achievementID + "_STAT", out _achiev.achievementStat);

                    Debug.Log(
                        "Achievement ID - " + _achiev.achievementID + "\n" +
                        " Achievement Name - " + _achiev.achievementName + "\n" +
                        " Achievement Descri - " + _achiev.achievementDesc + "\n" +
                        " Achievement Stat - " + _achiev.achievementStat.ToString() + "\n" +
                        " Achievement Achieved - " + _achiev.Achieved + "\n"
                        );
                }
                else
                {
                    Debug.Log("SteamUserStats.GetAchievement failed for Achievement " + _achiev.achievementID + "\nIs it registered in the Steam Partner site?");
                }
            }
        }
 private void OnUserStatsReceived(UserStatsReceived_t pCallback)
 {
     if (!SteamManager.Initialized || (ulong)m_GameID != pCallback.m_nGameID)
     {
         return;
     }
     if (pCallback.m_eResult == EResult.k_EResultOK)
     {
         m_bStatsValid = true;
         unlocked.Clear();
         for (int i = 0; i < SteamAchievementMap.achievementList.Count; i++)
         {
             Achievement achievement = SteamAchievementMap.achievementList[i];
             if (SteamUserStats.GetAchievement(SteamAchievementMap.AchievementToSteam(achievement), out bool pbAchieved) && pbAchieved)
             {
                 unlocked.Add(achievement);
             }
         }
         SyncStats(write: false);
     }
     else
     {
         Debug.Log("RequestStats - failed, " + pCallback.m_eResult);
     }
 }
Beispiel #4
0
 void ComprobarDesbloqueados()
 {
     for (int i = 0; i < logrosIDs.Count; i++)
     {
         SteamUserStats.GetAchievement(logrosIDs[i].steamID, out desbloqueadosInfo[i]);
     }
 }
        public override Dictionary <string, bool> GetAchievementDictionary()
        {
            if (!SteamManager.Initialized)
            {
                Debug.LogError("Couldn't create the achievement dictionary because Steam VR is not yet initialized!");
                return(base.GetAchievementDictionary());
            }

            Dictionary <string, bool> achievements = new Dictionary <string, bool>();
            uint numAchievements = SteamUserStats.GetNumAchievements();

            for (uint i = 0; i < numAchievements; i++)
            {
                string name = SteamUserStats.GetAchievementName(i);
                bool   unlocked;
                bool   hasAchievement = SteamUserStats.GetAchievement(name, out unlocked);
                if (hasAchievement)
                {
                    achievements.Add(name, unlocked);
                }
                else
                {
                    Debug.LogError("Steamworks failed to get achievement data for " + name);
                }
            }

            return(achievements);
        }
    // CALLBACKS

    private void OnUserStatsReceived(UserStatsReceived_t i_CallbackParams)
    {
        if (m_AchievementsManager == null)
        {
            return;
        }

        if (i_CallbackParams.m_nGameID == ((ulong)m_GameId))
        {
            EResult callbackResult = i_CallbackParams.m_eResult;
            if (callbackResult == EResult.k_EResultOK)
            {
                for (int achievementIndex = 0; achievementIndex < m_AchievementsManager.achievementsCount; ++achievementIndex)
                {
                    Achievement achievement = m_AchievementsManager.GetAchievementByIndex(achievementIndex);
                    if (achievement != null)
                    {
                        string achievementSteamId = achievement.steamId;
                        bool   achieved           = false;
                        if (SteamUserStats.GetAchievement(achievementSteamId, out achieved))
                        {
                            achievement.SetAchieved(achieved);
                        }
                    }
                }
            }
        }
    }
Beispiel #7
0
 void TestSteamAchievement(string ID)
 {
     if (SteamManager.Initialized)
     {
         SteamUserStats.GetAchievement(ID, out unlockTest);
     }
 }
Beispiel #8
0
    public void IniciarFantasma(ref LevelInfo nivel)
    {
        activado              = true;
        nivelActual           = nivel;
        tiempoNivel           = 0;
        actualpos             = 0;
        tiempoFuturaGrabacion = 0;
        posTemp.Clear();

        if (GameObject.FindObjectOfType <ControllerPersonaje>() != null)
        {
            player = GameObject.FindObjectOfType <ControllerPersonaje>().gameObject;
            rb     = player.GetComponent <Rigidbody2D>();
        }

        if (!nivelActual.completado)
        {
            reproducir = false;
        }
        else
        {
            fantasma   = GameObject.Instantiate(fantasmaPrefab, player.transform.position, Quaternion.identity);
            reproducir = true;
            bool desbloq;
            SteamUserStats.GetAchievement(ManagerLogros.Instance.logrosIDs[4].steamID, out desbloq);
            if (!desbloq)
            {
                ManagerLogros.Instance.DesbloquearLogro(4);
            }
        }
    }
Beispiel #9
0
    public void CheckLastTwoTrophies()
    {
        string ID      = "";
        int    counter = 0;

        for (int i = 0; i < 41; i++)
        {
            ID = "achievement_" + (i < 10 ? "0" : "") + i.ToString();
            if (SteamManager.Initialized)
            {
                bool achieved;

                bool ret = SteamUserStats.GetAchievement(ID, out achieved);
                if (achieved)
                {
                    counter++;
                }
            }
        }

        Debug.Log("Counter " + counter);

        if (counter == 39 || counter == 40)
        {
            Debug.Log("I'm unlocking last two achievements");
            SteamUserStats.SetAchievement("achievement_38");
            SteamUserStats.SetAchievement("achievement_00");
            SteamUserStats.StoreStats();
        }
        counter = 0;
    }
Beispiel #10
0
 private void OnUserStatsReceived(UserStatsReceived_t pCallback)
 {
     if (!SteamManager.Initialized)
     {
         return;
     }
     if ((ulong)this.m_GameID == pCallback.m_nGameID)
     {
         if (pCallback.m_eResult == EResult.k_EResultOK)
         {
             Log.Info("Received stats and achievements from Steam\n");
             SteamHelper.Achievement_t[] achievements = SteamHelper.m_Achievements;
             for (int i = 0; i < achievements.Length; i++)
             {
                 SteamHelper.Achievement_t achievement_t = achievements[i];
                 bool achievement = SteamUserStats.GetAchievement(achievement_t.m_eAchievementID.ToString(), out achievement_t.m_bAchieved);
                 if (achievement)
                 {
                     achievement_t.m_strName        = SteamUserStats.GetAchievementDisplayAttribute(achievement_t.m_eAchievementID.ToString(), "name");
                     achievement_t.m_strDescription = SteamUserStats.GetAchievementDisplayAttribute(achievement_t.m_eAchievementID.ToString(), "desc");
                 }
                 else
                 {
                     Log.Error("SteamUserStats.GetAchievement failed for Achievement " + achievement_t.m_eAchievementID + "\nIs it registered in the Steam Partner site?");
                 }
             }
         }
         else
         {
             Log.Info("RequestStats - failed, " + pCallback.m_eResult);
         }
     }
 }
 public override bool IsAchievementCompleted(string name)
 {
     if (SteamUserStats.GetAchievement(name, out bool pbAchieved))
     {
         return(pbAchieved);
     }
     return(false);
 }
 public bool getAchievement(string name, out bool has)
 {
     if (name == null)
     {
         throw new ArgumentNullException("name");
     }
     return(SteamUserStats.GetAchievement(name, ref has));
 }
Beispiel #13
0
        private static void OnUserStatsReceived(UserStatsReceived_t pCallback)
        {
            if (!SteamInitialized)
            {
                return;
            }

            if (pCallback.m_nGameID != Main.SteamAppID || pCallback.m_eResult != EResult.k_EResultOK)
            {
                return;
            }

            //I'm sorry, Evan. We'll need to find somewhere nice to put this part.
            string[] cheevoNames = new string[]
            {
                "ending_a",
                "ending_b",
                "ending_c",
                "ending_d",
                "cheating_jerk",
                "pillar_crushed",
                "orbs",
                "notes",
                "flashback",
                "god_mode",
                "first_orb",
                "first_note",
                "level_editor",
            };
            string[] statNames = new string[]
            {
                "orbs_collected",
                "notes_read",
                "challenge_levels_played",
            };

            foreach (var cheevo in cheevoNames)
            {
                bool value;
                bool success = SteamUserStats.GetAchievement("cheevo_" + cheevo, out value);
                if (success)
                {
                    _achievementDictionary.Add("cheevo_" + cheevo, value);
                }
            }

            foreach (var stat in statNames)
            {
                int  value;
                bool success = SteamUserStats.GetStat("stat_" + stat, out value);
                if (success)
                {
                    _statDictionary.Add("stat_" + stat, value);
                }
            }
            StatsInitialized.Value = true;
        }
Beispiel #14
0
    //-----------------------------------------------------------------------------
    // Purpose: We have stats data from Steam. It is authoritative, so update
    //			our data with those results now.
    //-----------------------------------------------------------------------------
    private void OnUserStatsReceived(UserStatsReceived_t pCallback)
    {
        if (!SteamManager.Initialized)
        {
            return;
        }

        // we may get callbacks for other games' stats arriving, ignore them
        if ((ulong)m_GameID == pCallback.m_nGameID)
        {
            if (EResult.k_EResultOK == pCallback.m_eResult)
            {
                Debug.Log("Received stats and achievements from Steam\n");

                m_bStatsValid = true;

                // load achievements
                foreach (Achievement_t ach in m_Achievements)
                {
                    bool ret = SteamUserStats.GetAchievement(ach.m_eAchievementID.ToString(), out ach.m_bAchieved);
                    if (ret)
                    {
                        ach.m_strName        = SteamUserStats.GetAchievementDisplayAttribute(ach.m_eAchievementID.ToString(), "name");
                        ach.m_strDescription = SteamUserStats.GetAchievementDisplayAttribute(ach.m_eAchievementID.ToString(), "desc");
                    }
                    else
                    {
                        Debug.LogWarning("SteamUserStats.GetAchievement failed for Achievement " + ach.m_eAchievementID + "\nIs it registered in the Steam Partner site?");
                    }
                }



                // load stats
                for (int i = 3; i < steamMatches.Length; i++)
                {
                    SteamUserStats.GetStat("match_" + i, out steamMatches[i]);
                }
                //set other stats:
                for (int i = 1; i < steamStatKeys.Length + 1; i++)
                {
                    SteamUserStats.GetStat("stat_" + i, out steamStatKeys[i - 1]);
                }
                SteamUserStats.GetStat("wins", out wins);
                SteamUserStats.GetStat("wins_p", out wins_p);
                SteamUserStats.GetStat("wins_ai", out wins_ai);
                SteamUserStats.GetStat("losses", out losses);
                SteamUserStats.GetStat("losses_p", out losses_p);
                SteamUserStats.GetStat("losses_ai", out losses_ai);
            }
            else
            {
                Debug.Log("RequestStats - failed, " + pCallback.m_eResult);
            }
        }
    }
Beispiel #15
0
        public bool IsAchievementUnlocked(AchievementData ach)
        {
            bool flag;

            if (ach.AchHandle != null)
            {
                return(SteamUserStats.GetAchievement(ach.AchHandle, out flag) && flag);
            }
            return(SteamUserStats.GetAchievement(ach.Key, out flag) && flag);
        }
Beispiel #16
0
        public override bool IsAchievementCompleted(string name)
        {
            bool flag;

            if (SteamUserStats.GetAchievement(name, ref flag))
            {
                return(flag);
            }
            return(false);
        }
Beispiel #17
0
        public static AchievementInfo Query(string achId)
        {
            var achName   = SteamUserStats.GetAchievementDisplayAttribute(achId, "name");
            var achDesc   = SteamUserStats.GetAchievementDisplayAttribute(achId, "desc");
            var hiddenStr = SteamUserStats.GetAchievementDisplayAttribute(achId, "hidden");
            var hidden    = BoolFromIntStr(hiddenStr);

            SteamUserStats.GetAchievement(achId, out var achieved);

            return(new AchievementInfo(achId, achName, achDesc, achieved, hidden));
        }
 public void UnlockSteamAchievement(string name)
 {
     if (SteamManager.Initialized)
     {
         SteamUserStats.GetAchievement(name, out Check_It); //Checks to see whether the achievement has been unlocked or not
         if (!Check_It)
         {
             SteamUserStats.SetAchievement(name); //Sets teh achievement
             SteamUserStats.StoreStats();         //Notifies the Stema server that it has been updated. Otherwise the achievement wont be updated until the player exits the game.
         }
     }
 }
Beispiel #19
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        #region Add anchorpoint to the list if Akkoro enters range
        if (collision.gameObject.layer == anchorLayer)
        {
            if (!anchorPositions.Contains(collision.gameObject.transform))
            {
                anchorPositions.Add(collision.gameObject.transform);
            }
            collision.gameObject.GetComponent <SpriteRenderer>().sprite = anchorSprites[1];
        }
        #endregion

        #region Collect alien
        if (collision.gameObject.CompareTag("Alien"))
        {
            AlienObjects thisAlien = collision.GetComponent <AlienCollectable>().alien;
            SaveController.alienCollectables[thisAlien.name] = true;
            print("Collected the alien: " + thisAlien.name);


            bool temp = true;

            if (SaveController.alienCollectables.Count == 1)
            {
                SteamUserStats.GetAchievement("First Critter", out temp);
                if (!temp)
                {
                    SteamUserStats.SetAchievement("First Critter");
                    SteamUserStats.StoreStats();
                }
            }


            temp = true;

            if (SaveController.alienCollectables.Count == 8)
            {
                SteamUserStats.GetAchievement("All Critters", out temp);
                if (!temp)
                {
                    SteamUserStats.SetAchievement("All Critters");
                    SteamUserStats.StoreStats();
                }
            }



            Destroy(collision.gameObject);
        }
        #endregion
    }
 public override bool IsAchivementCompleted(string achivementId)
 {
     if (IsSignedIn && !string.IsNullOrEmpty(achivementId))
     {
         bool result = false;
         SteamUserStats.GetAchievement(achivementId, out result);
         return(result);
     }
     else
     {
         return(false);
     }
 }
Beispiel #21
0
        public override void UnlockAchievement(string achievementID)
        {
            if (SteamManager.Initialized)
            {
                bool AchievementUnlocked;
                SteamUserStats.GetAchievement(achievementID, out AchievementUnlocked);

                if (!AchievementUnlocked)
                {
                    SteamUserStats.SetAchievement(achievementID);
                    SteamUserStats.StoreStats();
                }
            }
        }
    public static void GetSteamAchievement(string achievementName)
    {
        if (fa.dontConnectSteam)
        {
            return;
        }

        if (SteamManager.Initialized)
        {
            bool resultBool = false;
            SteamUserStats.GetAchievement(achievementName, out resultBool);
            SteamUserStats.SetAchievement(achievementName);
        }
    }
 public void zero_score()
 {
     if (gameplayParametrs != null && !gameplayParametrs.ThisDemoVersion)
     {
         bool resultYN = false;
         bool unloskYN = false;
         resultYN = SteamUserStats.GetAchievement(name_zero_score, out unloskYN);
         if (resultYN && !unloskYN)
         {
             SteamUserStats.SetAchievement(name_zero_score);
             to_server_ok = false;
         }
     }
 }
 public void destroy_fighter()
 {
     if (gameplayParametrs != null && !gameplayParametrs.ThisDemoVersion)
     {
         bool resultYN = false;
         bool unloskYN = false;
         resultYN = SteamUserStats.GetAchievement(name_destroy_fighter, out unloskYN);
         if (resultYN && !unloskYN)
         {
             SteamUserStats.SetAchievement(name_destroy_fighter);
             to_server_ok = false;
         }
     }
 }
 public void lvl_5_complite()
 {
     if (gameplayParametrs != null && !gameplayParametrs.ThisDemoVersion)
     {
         bool resultYN = false;
         bool unloskYN = false;
         resultYN = SteamUserStats.GetAchievement(name_Complete_lvl_5, out unloskYN);
         if (resultYN && !unloskYN)
         {
             SteamUserStats.SetAchievement(name_Complete_lvl_5);
             to_server_ok = false;
         }
     }
 }
Beispiel #26
0
    private void OnUserStatsReceived(UserStatsReceived_t pCallback)
    {
        if (!((ulong)gameID == pCallback.m_nGameID))
        {
            return;
        }

        if (EResult.k_EResultOK == pCallback.m_eResult)
        {
            Debug.Log("Received stats and achievements from Steam");

            statsValid = true;

            // load achievements
            foreach (KeyValuePair <AchievementID, Achievement> entry in achievements)
            {
                bool ret = SteamUserStats.GetAchievement(entry.Key.ToString(), out entry.Value.achieved);
                if (ret)
                {
                    entry.Value.name = SteamUserStats.GetAchievementDisplayAttribute(entry.Key.ToString(), "name");
                    entry.Value.desc = SteamUserStats.GetAchievementDisplayAttribute(entry.Key.ToString(), "desc");

                    if (entry.Value.achieved)
                    {
                        achievementCounter++;
                    }
                }
                else
                {
                    Debug.LogWarning("SteamUserStats.GetAchievement failed for Achievement " + entry.Key + "\nIs it registered in the Steam Partner site?");
                }
            }

            // load stats
            SteamUserStats.GetStat("GamesPlayed", out totalGamesPlayed);
            SteamUserStats.GetStat("TotalGameStarts", out totalGameStarts);
            SteamUserStats.GetStat("AssesKilled", out assesKilled);
            SteamUserStats.GetStat("EnemiesKilled", out enemiesKilled);
            SteamUserStats.GetStat("EnemiesCut", out enemiesCut);
            SteamUserStats.GetStat("BulletsShot", out bulletsShot);
            SteamUserStats.GetStat("CharactersPlayed", out charactersPlayed);

            storeStats = true;
        }
        else
        {
            Debug.Log("RequestStats - failed, " + pCallback.m_eResult);
        }
    }
Beispiel #27
0
    private void ResetAchievement(AchievementInfo info)
    {
        bool ret = SteamUserStats.GetAchievement(info.m_apiName, out info.m_bAchieved);

        if (ret && info.m_bAchieved)
        {
            //StatsUserPrefs.SaveIntValue();
            SteamUserStats.ClearAchievement(info.m_apiName);
            SteamUserStats.RequestCurrentStats();
        }
        else
        {
            Debug.LogWarning("SteamUserStats.GetAchievement failed Rest for Achievement " + info.m_apiName + "\nIs it registered in the Steam Partner site?");
        }
    }
 public void doggyStyle()
 {
     if (gameplayParametrs != null && !gameplayParametrs.ThisDemoVersion)
     {
         bool resultYN = false;
         bool unloskYN = false;
         resultYN = SteamUserStats.GetAchievement(name_doggyStyle, out unloskYN);
         if (resultYN && !unloskYN)
         {
             SteamUserStats.SetAchievement(name_doggyStyle);
             Debug.Log("Doggy Style");
             to_server_ok = false;
         }
     }
 }
 public void sec60LVL1()
 {
     if (gameplayParametrs != null && !gameplayParametrs.ThisDemoVersion)
     {
         bool resultYN = false;
         bool unloskYN = false;
         resultYN = SteamUserStats.GetAchievement(name_60secLVL1, out unloskYN);
         if (resultYN && !unloskYN)
         {
             SteamUserStats.SetAchievement(name_60secLVL1);
             Debug.Log("LVL1 IN 60 SEC");
             to_server_ok = false;
         }
     }
 }
    //-----------------------------------------------------------------------------
    // Purpose: We have stats data from Steam. It is authoritative, so update
    //			our data with those results now.
    //-----------------------------------------------------------------------------
    private void OnUserStatsReceived(UserStatsReceived_t pCallback)
    {
        if (!SteamManager.Initialized)
        {
            return;
        }

        // we may get callbacks for other games' stats arriving, ignore them
        if ((ulong)m_GameID == pCallback.m_nGameID)
        {
            if (EResult.k_EResultOK == pCallback.m_eResult)
            {
                Debug.Log("Received stats and achievements from Steam\n");

                m_bStatsValid = true;

                // load achievements
                foreach (Achievement_t ach in m_Achievements)
                {
                    bool ret = SteamUserStats.GetAchievement(ach.m_eAchievementID.ToString(), out ach.m_bAchieved);
                    if (ret)
                    {
                        ach.m_strName        = SteamUserStats.GetAchievementDisplayAttribute(ach.m_eAchievementID.ToString(), "name");
                        ach.m_strDescription = SteamUserStats.GetAchievementDisplayAttribute(ach.m_eAchievementID.ToString(), "desc");
                    }
                    else
                    {
                        Debug.LogWarning("SteamUserStats.GetAchievement failed for Achievement " + ach.m_eAchievementID + "\nIs it registered in the Steam Partner site?");
                    }
                }

                // load stats

                /*
                 *              SteamUserStats.GetStat("NumGames", out m_nTotalGamesPlayed);
                 *              SteamUserStats.GetStat("NumWins", out m_nTotalNumWins);
                 *              SteamUserStats.GetStat("NumLosses", out m_nTotalNumLosses);
                 *              SteamUserStats.GetStat("FeetTraveled", out m_flTotalFeetTraveled);
                 *              SteamUserStats.GetStat("MaxFeetTraveled", out m_flMaxFeetTraveled);
                 *              SteamUserStats.GetStat("AverageSpeed", out m_flAverageSpeed);
                 */
            }
            else
            {
                Debug.Log("RequestStats - failed, " + pCallback.m_eResult);
            }
        }
    }