public static void UnlockThisLevel(FreshLevels.Type type, bool noSave)
    {
        if (type == FreshLevels.Type.None)
        {
            //Debug.Log("Error: Level type was None. Level not unlocked!");
            return;
        }

        //special cases (when you go to these text intros, also unlock the next level, in case the player quits during the story)
        if (type == FreshLevels.Type.PreSlimeDaddyStory)
        {
            type = FreshLevels.Type.SlimeDaddy_BatterUp;
        }
        if (type == FreshLevels.Type.PostSatanStory)
        {
            type = FreshLevels.Type.MusicLvl1;
        }

        string strictLabel = FreshLevels.GetStrictLabelForType(type);

        if (strictLabel == null)
        {
            //Debug.Log("Error: Level name was NULL. Level not unlocked!");
            return;
        }
        PlayerPrefs.SetInt("nu_" + strictLabel, 1);
        if (!noSave)
        {
            PlayerPrefs.Save();
        }

        //Debug.Log("Unlocked level. " + type + ", " + strictLabel);
    }
Example #2
0
    public static void SendPBToSteam(FreshLevels.Type type, float speedruntime)
    {
        //Fail out, if:
        if (fa.dontConnectSteam)
        {
            return;
        }
        if (!SteamManager.Initialized)
        {
            return;
        }
        if (speedruntime < 2)
        {
            return;
        }                                        //less than 2 seconds is always impossible
        if (speedruntime < FreshLevels.GetImpossibleTimeForLevel(type))
        {
            return;
        }                                                                                  //time was impossible
        if (FreshLevels.NotALeaderboardLevel(type))
        {
            return;
        }                                                            //There are / should be no leaderboards for this level

        AddToQueue(type, speedruntime);
    }
Example #3
0
    public static void StartPlaybackOfGhosts()
    {
        if (!fa.useGhosts)
        {
            return;
        }
        if (!FreshLevels.IsGameplayLevel(SceneManager.GetActiveScene().name))
        {
            playingBack = false;
            return;
        }

        playingBack     = true;
        loadedGhosts    = new List <List <GhostFrame> >();
        createdPuppets  = new List <Puppet>();
        loadedGhostData = false;
        createdGhosts   = false;

        if (DBFuncs.self != null)
        {
            //DBFuncs.self.DownloadGhost("thegamedesigner");
            DBFuncs.self.DownloadBestGhost();
        }


        //bool useYourLastAttempt = true;//Placeholder for the types of ghosts that should be loaded

        //if (useYourLastAttempt)
        //{
        //	List<GhostFrame> ghost = Fresh_Loading.LoadLocalGhostAttempt();
        //	if (ghost != null && ghost.Count > 0) { loadedGhosts.Add(ghost); }
        //}
    }
    public static bool LoadLevelUnlocked(FreshLevels.Type fType)
    {
        FreshLevels.Type type = fType;
        if (type == FreshLevels.Type.IntroStory)
        {
            return(true);
        }                                                                  //Always unlocked

        int result = 0;

        /*
         * if (PlayerPrefs.HasKey("LevelUnlocked_" + type))
         * {
         *      result = PlayerPrefs.GetInt("LevelUnlocked_" + type, 0);
         * }*/

        if (fType != FreshLevels.Type.None)
        {
            string s = FreshLevels.GetStrictLabelForType(fType);
            if (PlayerPrefs.HasKey("nu_" + s))
            {
                result = PlayerPrefs.GetInt("nu_" + type, 0);
            }
        }


        return(result == 1);
    }
Example #5
0
 public static void GetALvl(string lvlName)
 {
     //Get the enum from the string
     FreshLevels.Type lvlType = FreshLevels.Type.None;
     lvlType = FreshLevels.GetTypeNameForStr(lvlName);
     if (lvlType != FreshLevels.Type.None)
     {
         RemoteData.GetUsageStats(lvlName, (data) =>
         {
             if (data != "error")
             {
                 //Debug.Log("Writing unparsed for " + lvlName);
                 for (int i = 0; i < unparsedBool.Length; i++)
                 {
                     if (!unparsedBool[i])
                     {
                         unparsedBool[i] = true;
                         unparsedStr[i]  = data;
                         unparsedInt[i]  = (int)lvlType;
                         break;
                     }
                 }
             }
         });
     }
 }
Example #6
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");
            }
        }
    }
Example #7
0
    public static void AddToQueue(FreshLevels.Type type, float speedruntime)
    {
        //Fail out, if:
        if (fa.dontConnectSteam)
        {
            return;
        }
        if (!SteamManager.Initialized)
        {
            return;
        }
        if (speedruntime < 2)
        {
            return;
        }                                        //less than 2 seconds is always impossible
        if (speedruntime < FreshLevels.GetImpossibleTimeForLevel(type))
        {
            return;
        }                                                                                  //time was impossible
        if (FreshLevels.DoNotSyncLevel(type))
        {
            return;
        }                                                      //don't sync this level if it's got a secret exit or other reason to not keep old scores

        Item a = new Item();

        a.leaderboard = FreshLevels.GetStrictLabelForType(type);
        a.score       = Mathf.FloorToInt(speedruntime * 1000);
        a.type        = type;
        queue.Add(a);
    }
    public static void BackwardsCompat_LvlNumCheck()
    {
        if (BackwardsCompat_Index == 999)
        {
            return;
        }

        int r = PlayerPrefs.GetInt("doneBackCompat1", 0);

        if (r == 1)
        {
            BackwardsCompat_Index = 999; return;
        }
        int lvlnum = PlayerPrefs.GetInt("lvlNum", 0);
        int index  = BackwardsCompat_Index;

        FreshLevels.Type t = (FreshLevels.Type)index;
        if (t == FreshLevels.Type.End)
        {
            BackwardsCompat_Index = 999;

            PlayerPrefs.SetInt("doneBackCompat1", 1);
            return;
        }

        if (lvlnum >= FreshLevels.GetLvlNumForType(t))
        {
            UnlockThisLevel(t, true);
        }
        if (BackwardsCompat_Index == 50)
        {
            PlayerPrefs.Save();
        }                                                               //Only save every so often. Don't need to save every frame.
        if (BackwardsCompat_Index == 100)
        {
            PlayerPrefs.Save();
        }
        if (BackwardsCompat_Index == 150)
        {
            PlayerPrefs.Save();
        }
        if (BackwardsCompat_Index == 200)
        {
            PlayerPrefs.Save();
        }
        if (BackwardsCompat_Index == 250)
        {
            PlayerPrefs.Save();
        }
        if (BackwardsCompat_Index == 300)
        {
            PlayerPrefs.Save();
        }
        if (BackwardsCompat_Index == 500)
        {
            PlayerPrefs.Save();
        }
        BackwardsCompat_Index++;
    }
    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";
        }
    }
Example #10
0
 public static void Qc_GetLeaderboardNameSlot(FreshLevels.Type type, int slot)
 {
     if (fa.dontConnect3rdParty)
     {
         return;
     }
     //Debug.Log("Trying to get qc leaderboard time slot " + slot);
     FrRemoteData.Qc_GetLeaderboardSlotName(slot, "" + type, (data) =>
     {
         fa.leaderboardNames[FreshLevels.LevelForIndexLeaderboard(type), slot] = data;
     });
 }
Example #11
0
    public static void CleanStartRecording()
    {
        if (FreshLevels.IsGameplayLevel(SceneManager.GetActiveScene().name))
        {
            recording = true;
            frames    = new List <GhostFrame>();

            if (DBFuncs.self != null)
            {
                DBFuncs.self.UploadGhostAttempt("", true, false);
            }
        }
        else
        {
            recording = false;
            frames    = new List <GhostFrame>();
        }
    }
Example #12
0
    public static void Qc_ReportLevelTime(FreshLevels.Type type, float levelTime, string ghostData)
    {
        if (fa.dontConnect3rdParty)
        {
            return;
        }
        if (fa.cheater)
        {
            return;
        }
        if (FreshLevels.NotALeaderboardLevel(type))
        {
            return;
        }                                                            //There are / should be no leaderboards for this level

        Debug.Log("Reported QC level time");
        FrRemoteData.Qc_ReportLevelTime("" + type, levelTime, ghostData, (data) =>
        {
            AddResult(data, Type.Generic);
        });
    }
    void Update()
    {
        if (playerObj == null)
        {
            playerObj = GameObject.FindGameObjectWithTag("Player");
        }
        else
        {
            //Debug.Log("HERE1 " + playerObj.transform.position + ", " + transform.position + ", " + portalDist + ", Triggered/Fading: " + triggered + ", " + xa.fadingOut);
            if (Vector3.Distance(playerObj.transform.position, transform.position) < portalDist)
            {
                if (!triggered)
                {
                    triggered           = true;
                    xa.allowPlayerInput = false;
                    xa.hasCheckpointed  = false;
                    Time.timeScale      = 1;
                    FreshLevels.Type levelType = FreshLevels.GetTypeOfCurrentLevel();


                    if (!isSecretExit)
                    {
                        Fresh_Saving.SaveLevelDeaths(levelType, za.deaths);
                        Fresh_Saving.SaveLevelTime(levelType, fa.speedrunTime);

                        FrFuncs.Qc_ReportLevelTime(levelType, fa.speedrunTime, "noGhostData");
                        SteamLeaderboards.SendPBToSteam(levelType, fa.speedrunTime);
                    }



                    //Update unlocked levels (lvlNum)
                    NodeController.WonLevel(levelType);

                    xa.re.cleanLoadLevel(Restart.RestartFrom.RESTART_FROM_MENU, FreshLevels.GetStrNameForType(gotoLvl));
                }
            }
        }
    }
    public static void UnlockThisLevel(string level)
    {
        if (level == "StartMenu")
        {
            return;
        }
        if (level == "ESJ2Title")
        {
            return;
        }
        if (level == "MegaMetaWorld")
        {
            return;
        }

        FreshLevels.Type t = FreshLevels.GetTypeNameForStr(level);
        if (t == FreshLevels.Type.None)
        {
            Debug.Log("Error: string " + level + " returned type .None in GetTypeNameForStr. Level not unlocked!"); return;
        }
        UnlockThisLevel(t);
    }
Example #15
0
    public void Awake()
    {
        xa.fresh_localNode = this;
        fa.isMenuLevel     = this.isMenuLevel;

        if (this.showMouse)
        {
            Setup.SetCursor(Setup.C.Visible);
        }
        else
        {
            Setup.SetCursor(Setup.C.NotVisible);
        }
        fa.escapeDoesntTriggerInGameMainMenu = this.escapeDoesntOpenInGameMainMenu;

        if (this.loadLevelInfo)
        {
            FreshLevels.InitFreshLevelInfo();
        }

        if (autoOpenStartMenu)
        {
        }
    }
    void Update()
    {
        bool changed = false;

        if (!oncePerGameStart)
        {
            Debug.Log("ONCE");
            oncePerGameStart = true;
            changed          = true;

            for (int i = 0; i < nodes.Length; i++)
            {
                if (nodes[i].levelType == FreshLevels.Type.IntroStory)
                {
                    currentNode = nodes[i];
                    break;
                }
            }
            currentLevelName.text = currentNode.levelName;
            LoadLevelStats();
        }

        if (!checkedForSavedMapPos)
        {
            checkedForSavedMapPos = true;
            if (fa.lastLevelPlayed != FreshLevels.Type.None)
            {
                for (int i = 0; i < nodes.Length; i++)
                {
                    if (nodes[i].levelType == fa.lastLevelPlayed)
                    {
                        currentNode = nodes[i];
                        changed     = true;
                    }
                }
            }
        }

        if (Controls.GetInputDown(Controls.Type.MenuUp, 0))
        {
            if (currentNode.north != null)
            {
                currentNode        = currentNode.north;         //
                fa.lastLevelPlayed = currentNode.levelType;
                changed            = true;
            }
        }
        if (Controls.GetInputDown(Controls.Type.MenuDown, 0))
        {
            if (currentNode.south != null)
            {
                currentNode        = currentNode.south;
                fa.lastLevelPlayed = currentNode.levelType;
                changed            = true;
            }
        }
        if (Controls.GetInputDown(Controls.Type.MenuLeft, 0))
        {
            if (currentNode.west != null)
            {
                currentNode        = currentNode.west;
                fa.lastLevelPlayed = currentNode.levelType;
                changed            = true;
            }
        }
        if (Controls.GetInputDown(Controls.Type.MenuRight, 0))
        {
            if (currentNode.east != null)
            {
                currentNode        = currentNode.east;
                fa.lastLevelPlayed = currentNode.levelType;
                changed            = true;
            }
        }

        if (Controls.GetInputDown(Controls.Type.MenuSelect, 0))
        {
            if (currentNode.locked)
            {
                Fresh_SoundEffects.PlaySound(Fresh_SoundEffects.Type.Fart);
                iTween.PunchRotation(currentNode.gameObject, iTween.Hash("z", 17.5f, "time", 0.3f));
            }
            else
            {
                string lvlName = FreshLevels.GetStrNameForType(currentNode.levelType);
                //Debug.Log("Tried to go to level: " + lvlName);
                if (lvlName != "")
                {
                    xa.re.cleanLoadLevel(Restart.RestartFrom.RESTART_FROM_MENU, lvlName);
                }
            }
        }

        if (changed)
        {
            for (int i = 0; i < allSkies.Length; i++)
            {
                allSkies[i].SetActive(false);
            }

            iTween.MoveTo(nodeCamera, iTween.Hash("x", currentNode.transform.position.x, "y", currentNode.transform.position.y, "easetype", iTween.EaseType.easeInOutSine, "time", 0.2f));

            if (currentNode.setCamPos)
            {
                //iTween.MoveTo(camera, iTween.Hash("x", currentNode.camPos.x, "y", currentNode.camPos.y, "easetype", iTween.EaseType.easeInOutSine, "time", 0.5f));
                //camera.transform.SetX(currentNode.camPos.x);
                //camera.transform.SetY(currentNode.camPos.y);
            }

            iTween.RotateTo(nodeCamera, iTween.Hash("z", currentNode.cameraAngle2, "easetype", iTween.EaseType.easeInOutSine, "time", 0.2f));


            for (int i = 0; i < currentNode.objsOn.Length; i++)
            {
                currentNode.objsOn[i].SetActive(true);
            }


            currentLevelName.text = currentNode.levelName;

            LoadLevelStats();
        }

        cursor.transform.SetX(currentNode.gameObject.transform.position.x);
        cursor.transform.SetY(currentNode.gameObject.transform.position.y);
    }
    void InitNodes()
    {
        //Load lvlNum (for now, fake it)
        //lvlNum = 10;//(10 is the starting number);
        lvlNums  = new int[100];              //Max 100 levels then
        lvlTypes = new FreshLevels.Type[100]; //Max 100 levels then
        int lvlNumIndex = 0;

        nodesGOs = GameObject.FindGameObjectsWithTag("metaMapNode");
        nodes    = new NodeScript[nodesGOs.Length];
        for (int i = 0; i < nodesGOs.Length; i++)
        {
            nodes[i] = nodesGOs[i].GetComponent <NodeScript>();
            lvlTypes[lvlNumIndex] = nodes[i].levelType;



            //unlock with the new system
            bool alwaysUnlocked = false;
            if (nodes[i].levelType == FreshLevels.Type.IntroStory)
            {
                alwaysUnlocked = true;
            }

            //check if you own these DLC
            if (nodes[i].levelType == FreshLevels.Type.AlpDLC_IntroStory && (xa.hasAlpDLC || fa.forceUnlockOfAlpDLC))
            {
                alwaysUnlocked = true;
            }
            if (nodes[i].levelType == FreshLevels.Type.IsThisADaggerISeeBeforeMe && xa.hasBonusDLC)
            {
                alwaysUnlocked = true;
            }

            if (alwaysUnlocked)
            {
                nodes[i].locked = false;
                if (nodes[i].lockObj != null)
                {
                    nodes[i].lockObj.SetActive(nodes[i].locked);
                }
            }
            else
            {
                string strictName = FreshLevels.GetStrictLabelForType(nodes[i].levelType);
                if (PlayerPrefs.HasKey("nu_" + strictName))
                {
                    nodes[i].locked = false;
                    if (nodes[i].lockObj != null)
                    {
                        nodes[i].lockObj.SetActive(nodes[i].locked);
                    }
                }
                else
                {
                    nodes[i].locked = true;
                    nodes[i].lockObj.SetActive(nodes[i].locked);
                }
            }


            /*
             * lvlNums[lvlNumIndex] = nodes[i].lvlNum;
             * lvlNumIndex++;
             *
             * if (nodes[i].lvlNum != -1 && lvlNum < nodes[i].lvlNum)
             * {
             *      nodes[i].locked = true;
             *      nodes[i].lockObj.SetActive(nodes[i].locked);
             * }
             * else if (!xa.hasBonusDLC && nodes[i].BonusDLC)
             * {
             *      nodes[i].locked = true;
             *      nodes[i].lockObj.SetActive(nodes[i].locked);
             * }
             * else
             * {
             *      nodes[i].locked = false;
             *      if (nodes[i].lockObj != null) { nodes[i].lockObj.SetActive(nodes[i].locked); }
             * }*/
        }
    }