Esempio n. 1
0
    public static void UpdateItem(Item item)
    {
        if (fa.dontConnectSteam)
        {
            return;
        }
        if (!SteamManager.Initialized)
        {
            return;
        }
        //whats the next step for this item?


        //no reference? Ask steam for one, and return out
        if (!item.hasRef && !item.waitingForRef)
        {
            item.waitingForRef = true;
            RawFuncs.Print("1. Requesting: " + item.leaderboard);

            SteamAPICall_t hSteamAPICall = SteamUserStats.FindLeaderboard(item.leaderboard);
            m_findResult.Set(hSteamAPICall, OnFindLeaderboardResult);

            return;
        }

        //does it have a reference?
        if (item.hasRef && !item.waitingForUpload)
        {
            item.waitingForUpload = true;
            RawFuncs.Print("3. uploading score(" + item.score + ") to steam leaderboard(" + item.leaderboard + ")");
            SteamAPICall_t hSteamAPICall = SteamUserStats.UploadLeaderboardScore(item.steamRef, s_leaderboardMethod, item.score, null, 0);
            m_uploadResult.Set(hSteamAPICall, OnLeaderboardUploadResult);
        }
    }
Esempio n. 2
0
    public static void Init()
    {
        RawFuncs.Print("Steam init! TestVer: 003");

        SteamStatsAndAchievements.WhatsMySteamName();
        leaderboardLabels = new string[totalNumOfLeaderboards];
        leaderboardTypes  = new FreshLevels.Type[totalNumOfLeaderboards];
        queue             = new List <Item>();

        for (int i = 0; i < totalNumOfLeaderboards; i++)
        {
            leaderboardTypes[i] = FreshLevels.IndexForLevelLeaderboard(i);
            bool syncThis = true;
            if (PlayerPrefs.HasKey("Syncd_" + leaderboardTypes[i]))
            {
                int result = 0;
                result = PlayerPrefs.GetInt("Syncd_" + leaderboardTypes[i], 0);
                if (result == 1)
                {
                    syncThis = false;
                }
            }

            if (syncThis)
            {
                float pb = PlayerPrefs.GetFloat("LevelTime_" + leaderboardTypes[i], -1);
                AddToQueue(FreshLevels.IndexForLevelLeaderboard(i), pb);

                RawFuncs.Print("" + leaderboardTypes[i] + ": " + pb + ", added to queue");
            }
        }
    }
Esempio n. 3
0
    static private void OnLeaderboardUploadResult(LeaderboardScoreUploaded_t pCallback, bool failure)
    {
        RawFuncs.Print("4. STEAM LEADERBOARDS: failure - " + failure + " Completed - " + pCallback.m_bSuccess + " NewScore: " + pCallback.m_nGlobalRankNew + " Score " + pCallback.m_nScore + " HasChanged - " + pCallback.m_bScoreChanged);

        for (int i = 0; i < queue.Count; i++)
        {
            if (queue[i].open)
            {
                if (queue[i].waitingForUpload)
                {
                    if (!failure)
                    {
                        queue[i].finished = true;
                        queue[i].open     = false;
                        RawFuncs.Print("5. Success!");
                        PlayerPrefs.SetInt("Syncd_" + queue[i].type, 1);
                        PlayerPrefs.Save();
                    }
                    else
                    {
                        queue[i].finished         = false;
                        queue[i].waitingForUpload = false;                        //try again
                        RawFuncs.Print("5b. Trying again...");
                    }
                }
                return;
            }
        }
    }
Esempio n. 4
0
    static private void OnFindLeaderboardResult(LeaderboardFindResult_t pCallback, bool failure)
    {
        RawFuncs.Print("2. " + Time.time + " STEAM LEADERBOARDS: Found - " + pCallback.m_bLeaderboardFound + " leaderboardID - " + pCallback.m_hSteamLeaderboard.m_SteamLeaderboard);
        for (int i = 0; i < queue.Count; i++)
        {
            if (queue[i].open)
            {
                if (queue[i].waitingForRef && !queue[i].hasRef)
                {
                    queue[i].hasRef   = true;
                    queue[i].steamRef = pCallback.m_hSteamLeaderboard;
                }
                else
                {
                    //the open one isn't waiting/already has a ref, which means it's probably the wrong one?
                    //shoulnd't ever get here, but probably the packet got lost, then showed up later?

                    //just ignore this result

                    //(possibly kill this one, and add to it's timespent, as it might be better to move on?)
                }

                return;
            }
        }
        return;



        //RawFuncs.Print("" + Time.time + " STEAM LEADERBOARDS: Found - " + pCallback.m_bLeaderboardFound + " leaderboardID - " + pCallback.m_hSteamLeaderboard.m_SteamLeaderboard);
        //leaderboardSteamRefs[requestIndex] = pCallback.m_hSteamLeaderboard;
        //leaderboardFound[requestIndex] = true;
        //requestIndex++;
        //waiting = false;
    }
Esempio n. 5
0
    void LoadLevelStats()
    {
        int index = -1;

        index = FreshLevels.GetIndexForType(currentNode.levelType);
        Debug.Log("Loading for: " + currentNode.levelType + ", Time: " + FreshLevels.levels[index].lowestTime);
        if (index != -1)
        {
            if (FreshLevels.levels[index].lowestDeaths == -1)
            {
                skull.sprite = whiteSkull;
                //saved deaths not found (or level type not found), so probably hasn't beaten this level yet.
                deathText.text = "--";
            }
            else
            {
                if (FreshLevels.levels[index].lowestDeaths == 0)
                {
                    skull.sprite = goldSkull;
                }
                else
                {
                    skull.sprite = whiteSkull;
                }
                deathText.text = "" + FreshLevels.levels[index].lowestDeaths;
            }
            if (FreshLevels.levels[index].lowestTime == -1)
            {
                clock.sprite = whiteClock;
                //saved deaths not found (or level type not found), so probably hasn't beaten this level yet.
                timeText.text = "--- / " + FreshLevels.GetGoldTimeForLevel(FreshLevels.levels[index].type);
            }
            else
            {
                if (FreshLevels.levels[index].lowestTime < FreshLevels.GetGoldTimeForLevel(FreshLevels.levels[index].type))
                {
                    clock.sprite = goldClock;
                }
                else
                {
                    clock.sprite = whiteClock;
                }
                //Debug.Log("Getting spdrun time, " + FreshLevels.levels[index] + ": " + FreshLevels.levels[index].lowestTime);
                timeText.text = RawFuncs.GetSpeedRunTimeStr(FreshLevels.levels[index].lowestTime) + " / " + +FreshLevels.GetGoldTimeForLevel(FreshLevels.levels[index].type);
            }
        }
        else
        {
            //level type not found, possible error.
            deathText.text = "xx";
            timeText.text  = "xx:xx:xxx";
        }
    }
    public static void WhatsMySteamName()
    {
        if (fa.dontConnectSteam)
        {
            return;
        }
        if (SteamManager.Initialized)
        {
            //Debug.Log("Name: " + SteamFriends.GetPersonaName());

            RawFuncs.Print("Name: " + SteamFriends.GetPersonaName());
        }
    }
Esempio n. 7
0
    void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            RawFuncs.WipePrint();
        }

        /*
         *
         * //Platforming
         * if (ReInput.players.GetPlayer(0).GetButtonDown("Jump")) { RawFuncs.Print("Jump"); }
         * if (ReInput.players.GetPlayer(0).GetButtonDown("Ability1")) { RawFuncs.Print("Stomp/Airsword"); }
         * if (ReInput.players.GetPlayer(0).GetButtonDown("Move Down")) { RawFuncs.Print("Drop off wall"); }
         * if (ReInput.players.GetPlayer(0).GetButtonDown("Restart")) { RawFuncs.Print("Restart level"); }
         * if (ReInput.players.GetPlayer(0).GetButtonDown("Respawn")) { RawFuncs.Print("Respawn from checkpoint"); }
         * if (ReInput.players.GetPlayer(0).GetButtonDown("Move Left")) { RawFuncs.Print("Move Left"); }
         * if (ReInput.players.GetPlayer(0).GetButtonDown("Move Right")) { RawFuncs.Print("Move Right"); }
         *
         * //Menus
         * if (ReInput.players.GetPlayer(0).GetButtonDown("Menu Up")) { RawFuncs.Print("Menu Up"); }
         * if (ReInput.players.GetPlayer(0).GetButtonDown("Menu Down")) { RawFuncs.Print("Menu Down"); }
         * if (ReInput.players.GetPlayer(0).GetButtonDown("Menu Right")) { RawFuncs.Print("Menu Right"); }
         * if (ReInput.players.GetPlayer(0).GetButtonDown("Menu Left")) { RawFuncs.Print("Menu Left"); }
         * if (ReInput.players.GetPlayer(0).GetButtonDown("Menu Select")) { RawFuncs.Print("Menu Select"); }
         * if (ReInput.players.GetPlayer(0).GetButtonDown("Menu Escape")) { RawFuncs.Print("Menu Escape"); }
         *
         * //FPS buttons
         * if (ReInput.players.GetPlayer(0).GetButtonDown("FPS Fire")) { RawFuncs.Print("FPS Fire"); }
         * if (ReInput.players.GetPlayer(0).GetButtonDown("FPS Cycle")) { RawFuncs.Print("FPS Cycle"); }
         *
         * //FPS axes
         * float axis = 0;
         * axis = ReInput.players.GetPlayer(0).GetAxis("FPS Forward");
         * if (axis < -deadzone) { RawFuncs.Print("FPS Backwards"); }
         * if (axis > deadzone) { RawFuncs.Print("FPS Forwards"); }
         *
         * axis = ReInput.players.GetPlayer(0).GetAxis("FPS Strafe");
         * if (axis < -deadzone) { RawFuncs.Print("FPS Strafe Left"); }
         * if (axis > deadzone) { RawFuncs.Print("FPS Strafe Right"); }
         *
         * axis = ReInput.players.GetPlayer(0).GetAxis("FPS Look Horizontal");
         * if (axis < -deadzone) { RawFuncs.Print("FPS Look Left"); }
         * if (axis > deadzone) { RawFuncs.Print("FPS Look Right"); }
         *
         * axis = ReInput.players.GetPlayer(0).GetAxis("FPS Look Vertical");
         * if (axis < -deadzone) { RawFuncs.Print("FPS Look Down"); }
         * if (axis > deadzone) { RawFuncs.Print("FPS Look Up"); }
         */
    }
Esempio n. 8
0
    public static void UpdateQueue()
    {
        if (fa.dontConnectSteam)
        {
            return;
        }
        if (!SteamManager.Initialized)
        {
            return;
        }

        //loop through, find the open one, update that.
        for (int i = 0; i < queue.Count; i++)
        {
            if (queue[i].open && !queue[i].finished)
            {
                queue[i].timespent += queueDelay;
                if (queue[i].timespent > queueGiveup)
                {
                    //giving up
                    RawFuncs.Print("Giving up on " + queue[i].leaderboard);
                    queue[i].open = false;
                }
                else
                {
                    UpdateItem(queue[i]);
                }
                return;
            }
        }

        //if it didn't find one, open one
        for (int i = 0; i < queue.Count; i++)
        {
            if (!queue[i].finished && queue[i].timespent < queueGiveup)            //if I haven't already spent enough time attempting this one
            {
                RawFuncs.Print("Opening new item for " + queue[i].leaderboard);
                queue[i].open = true;
                return;
            }
        }
    }
Esempio n. 9
0
    private void Awake()
    {
        // Only one instance of SteamManager at a time!
        if (s_instance != null)
        {
            Destroy(gameObject);
            return;
        }
        s_instance = this;

        if (s_EverInialized)
        {
            // This is almost always an error.
            // The most common case where this happens is the SteamManager getting desstroyed via Application.Quit() and having some code in some OnDestroy which gets called afterwards, creating a new SteamManager.
            throw new System.Exception("Tried to Initialize the SteamAPI twice in one session!");
        }

        // We want our SteamManager Instance to persist across scenes.
        DontDestroyOnLoad(gameObject);

        if (!Packsize.Test())
        {
            Debug.LogError("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform.", this);
            RawFuncs.Print("[Steamworks.NET] Packsize Test returned false, the wrong version of Steamworks.NET is being run in this platform.");
        }

        if (!DllCheck.Test())
        {
            Debug.LogError("[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version.", this);
            RawFuncs.Print("[Steamworks.NET] DllCheck Test returned false, One or more of the Steamworks binaries seems to be the wrong version.");
        }

        try {
            // If Steam is not running or the game wasn't started through Steam, SteamAPI_RestartAppIfNecessary starts the
            // Steam client and also launches this game again if the User owns it. This can act as a rudimentary form of DRM.

            // Once you get a Steam AppID assigned by Valve, you need to replace AppId_t.Invalid with it and
            // remove steam_appid.txt from the game depot. eg: "(AppId_t)480" or "new AppId_t(480)".
            // See the Valve documentation for more information: https://partner.steamgames.com/documentation/drm#FAQ
            if (SteamAPI.RestartAppIfNecessary(AppId_t.Invalid))
            {
                Application.Quit();
                return;
            }
        }
        catch (System.DllNotFoundException e) {         // We catch this exception here, as it will be the first occurence of it.
            Debug.LogError("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib. It's likely not in the correct location. Refer to the README for more details.\n" + e, this);
            RawFuncs.Print("[Steamworks.NET] Could not load [lib]steam_api.dll/so/dylib. It's likely not in the correct location. Refer to the README for more details.\n" + e);
            Application.Quit();
            return;
        }

        // Initialize the SteamAPI, if Init() returns false this can happen for many reasons.
        // Some examples include:
        // Steam Client is not running.
        // Launching from outside of steam without a steam_appid.txt file in place.
        // Running under a different OS User or Access level (for example running "as administrator")
        // Valve's documentation for this is located here:
        // https://partner.steamgames.com/documentation/getting_started
        // https://partner.steamgames.com/documentation/example // Under: Common Build Problems
        // https://partner.steamgames.com/documentation/bootstrap_stats // At the very bottom

        // If you're running into Init issues try running DbgView prior to launching to get the internal output from Steam.
        // http://technet.microsoft.com/en-us/sysinternals/bb896647.aspx
        m_bInitialized = SteamAPI.Init();
        if (!m_bInitialized)
        {
            Debug.Log("[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.", this);
            RawFuncs.Print("[Steamworks.NET] SteamAPI_Init() failed. Refer to Valve's documentation or the comment above this line for more information.");
            return;
        }

        s_EverInialized = true;
    }