public void UpdateBestText()
    {
        if (LoadedLevel == null)
        {
            return;
        }
        bool ranked = PlayerPrefsExt.GetBool(PreferenceKeys.RankedMode());

        if (Math.Abs(ZPlayerPrefs.GetFloat(
                         PreferenceKeys.BestScore(LoadedLevel, CytoidApplication.CurrentChartType, ranked),
                         defaultValue: -1) - (-1)) < 0.000001)
        {
            bestText.text = "NO HIGH SCORE YET";
        }
        else
        {
            bestText.text =
                (ranked ? "R score" : "Score") + " " + Mathf.CeilToInt(ZPlayerPrefs.GetFloat(
                                                                           PreferenceKeys.BestScore(LoadedLevel, CytoidApplication.CurrentChartType, ranked),
                                                                           0)).ToString("D6")
                + "   " + (ranked ? "R acc." : "Acc.") + " " +
                ZPlayerPrefs.GetFloat(
                    PreferenceKeys.BestAccuracy(LoadedLevel, CytoidApplication.CurrentChartType, ranked),
                    0).ToString("0.##") + "%";
        }
    }
Beispiel #2
0
 public void setButton()
 {
     nickname = inputText.text;
     score    = ZPlayerPrefs.GetFloat("highscore");
     postTest = ZPlayerPrefs.GetInt("posttest");
     for (int i = 0; i < nickname.Length; i++)
     {
         if (nickname[i] != ' ')
         {
             isNotEmpty = true;
             break;
         }
     }
     if (postTest == 0)
     {
         if (!isNotEmpty)
         {
             enternickname.SetActive(true);
             StartCoroutine(turnoff());
         }
         else
         {
             SetHighscore(nickname, score);
             postPostedText.SetActive(false);
             ZPlayerPrefs.SetInt("posttest", 1);
         }
     }
     else if (postTest == 1)
     {
         postPostedText.SetActive(true);
         StartCoroutine(turnoff());
     }
 }
    public void OnLevelLoaded()
    {
        switchDifficultyView.OnLevelLoaded();
        CytoidApplication.CurrentLevel = LoadedLevel;

        UpdateBestText();

        var useLocalOptions =
            ZPlayerPrefs.GetBool(PreferenceKeys.WillOverrideOptions(CytoidApplication.CurrentLevel), false);

        overrideOptionsToggle.isOn = useLocalOptions;

        if (useLocalOptions)
        {
            localIsInversedToggle.isOn =
                ZPlayerPrefs.GetBool(PreferenceKeys.WillInverse(CytoidApplication.CurrentLevel), false);
            localUserOffsetInput.text =
                ZPlayerPrefs.GetFloat(PreferenceKeys.NoteDelay(CytoidApplication.CurrentLevel),
                                      PlayerPrefs.GetFloat("user_offset")).ToString();
        }
        else
        {
            localIsInversedToggle.isOn = isInversedToggle.isOn;
            localUserOffsetInput.text  = userOffsetInput.text;
        }

        // confirmText.text = "Are you sure you want to delete\n" + LoadedLevel.id + "?";

        deleteButton.SetActive(!LoadedLevel.is_internal);

        PlayerPrefs.SetString("last_level", LoadedLevel.id);
    }
    private void Awake()
    {
        Cursor.visible = true;
        ZPlayerPrefs.Initialize("welcome", "toTheJungle");
        float highscore = ZPlayerPrefs.GetFloat("Highscore");

        higScoreText.text = highscore.ToString();
    }
Beispiel #5
0
 public void Diffsc0re()
 {
     if (changedifimage.currentdiff != defaultdiff)
     {
         ZPlayerPrefs.Initialize("what'sYourName", "salt12issalt");
         sc0re.text = ZPlayerPrefs.GetFloat(GameObject.FindGameObjectWithTag("YEABOI").name + changedifimage.ENHE).ToString("F2") + "%";
         if (ZPlayerPrefs.GetFloat(GameObject.FindGameObjectWithTag("YEABOI").name + changedifimage.ENHE + "AC") == 1f)
         {
             AC.SetActive(true);
             FC.SetActive(false);
         }
         else if (ZPlayerPrefs.GetFloat(GameObject.FindGameObjectWithTag("YEABOI").name + changedifimage.ENHE + "FC") == 1f)
         {
             FC.SetActive(true);
             AC.SetActive(false);
         }
         else
         {
             AC.SetActive(false);
             FC.SetActive(false);
         }
         if (sc0re.text == null)
         {
             sc0re.text = "No Score Yet!";
         }
     }
     else
     {
         ZPlayerPrefs.Initialize("what'sYourName", "salt12issalt");
         sc0re.text = ZPlayerPrefs.GetFloat(GameObject.FindGameObjectWithTag("YEABOI").name).ToString("F2") + "%";
         if (ZPlayerPrefs.GetFloat(GameObject.FindGameObjectWithTag("YEABOI").name + "AC") == 1f)
         {
             AC.SetActive(true);
             FC.SetActive(false);
         }
         else if (ZPlayerPrefs.GetFloat(GameObject.FindGameObjectWithTag("YEABOI").name + "FC") == 1f)
         {
             FC.SetActive(true);
             AC.SetActive(false);
         }
         else
         {
             AC.SetActive(false);
             FC.SetActive(false);
         }
         if (sc0re.text == null)
         {
             sc0re.text = "No Score Yet!";
         }
     }
 }
    public void GetPlayerPrefs()
    {
        // Get Value to check
        Debug.Log("Get Value string1: " + ZPlayerPrefs.GetString("string1") + ", Encrypt: " + ZPlayerPrefs.GetRowString("string1"));
        Debug.Log("Get Value string2: " + ZPlayerPrefs.GetString("string2") + ", Encrypt: " + ZPlayerPrefs.GetRowString("string2"));
        Debug.Log("Get Value string3: " + ZPlayerPrefs.GetString("string3") + ", Encrypt: " + ZPlayerPrefs.GetRowString("string3"));

        Debug.Log("Get Value Float1: " + ZPlayerPrefs.GetFloat("Float1") + ", Encrypt: " + ZPlayerPrefs.GetRowString("Float1"));
        Debug.Log("Get Value Float2: " + ZPlayerPrefs.GetFloat("Float2") + ", Encrypt: " + ZPlayerPrefs.GetRowString("Float2"));
        Debug.Log("Get Value Float3: " + ZPlayerPrefs.GetFloat("Float3") + ", Encrypt: " + ZPlayerPrefs.GetRowString("Float3"));

        Debug.Log("Get Value Int1: " + ZPlayerPrefs.GetInt("Int1") + ", Encrypt: " + ZPlayerPrefs.GetRowString("Int1"));
        Debug.Log("Get Value Int2: " + ZPlayerPrefs.GetInt("Int2") + ", Encrypt: " + ZPlayerPrefs.GetRowString("Int2"));
        Debug.Log("Get Value Int3: " + ZPlayerPrefs.GetInt("Int3") + ", Encrypt: " + ZPlayerPrefs.GetRowString("Int3"));
    }
Beispiel #7
0
    private void Start()
    {
        Cursor.visible            = false;
        spawnTime                 = 1.6f;
        currentTime               = spawnTime;
        totEnemiesLevelAarray     = new int[] { 30, 40, 50, 60, 70 };
        enemySpawnTimeLevelAarray = new float[] { 5, 5, 4, 4, 3 };
        powerBar.value            = 0;
        powerAdder                = 10;
        fireBallIsSpawned         = false;
        canLoseLife               = true;
        ZPlayerPrefs.Initialize("welcome", "toTheJungle");

        currentHighscore = ZPlayerPrefs.GetFloat("Highscore");
    }
    public void endGame()
    {
        adRequest.SetActive(false);
        gameOverUI.SetActive(true);
        spawnerOff.SetActive(false);
        pauseButton.SetActive(false);
        swordHitButton.SetActive(false);
        ship.SetActive(false);
        shipCd.SetActive(false);
        gameIsOver = true;

        if (ZPlayerPrefs.GetFloat("highscore") < score)
        {
            ZPlayerPrefs.SetFloat("highscore", score);
            ZPlayerPrefs.SetInt("posttest", 0);
        }
    }
Beispiel #9
0
 void OnLevelWasLoaded(int level)
 {
     if (level == 1)
     {
         //SNGNAM = GameObject.FindGameObjectWithTag ("LVLTXT").GetComponent<Text>().text;
         ZPlayerPrefs.Initialize("what'sYourName", "salt12issalt");
         if (ZPlayerPrefs.HasKey("Speed"))
         {
             currentSpeed = ZPlayerPrefs.GetFloat("Speed", currentSpeed);
             ZPlayerPrefs.Save();
         }
         else
         {
             ZPlayerPrefs.SetFloat("Speed", 4);
             currentSpeed = 4f;
             ZPlayerPrefs.Save();
         }
     }
 }
Beispiel #10
0
        private void Update()
        {
            if (WillInvalidate)
            {
                if (LevelSelectionController.Instance.LoadedLevel == null)
                {
                    return;
                }

                WillInvalidate = false;

                var ranked    = PlayerPrefsExt.GetBool("ranked") && OnlinePlayer.Authenticated;
                var bestScore = ZPlayerPrefs.GetFloat(
                    PreferenceKeys.BestScore(LevelSelectionController.Instance.LoadedLevel.id,
                                             CytoidApplication.CurrentChartType, ranked),
                    -1
                    );

                if (Math.Abs(bestScore + 1) < 0.000001)
                {
                    Text.text = "No best score yet.";
                }
                else
                {
                    var bestAccuracy = ZPlayerPrefs.GetFloat(
                        PreferenceKeys.BestAccuracy(LevelSelectionController.Instance.LoadedLevel.id,
                                                    CytoidApplication.CurrentChartType, ranked)
                        );

                    var grade = ScoreGrades.From(bestScore);

                    Text.text = string.Format(
                        "<b><color=#{0}>{1} </color></b> {2:D6} / {3:0.00}%",
                        ColorUtility.ToHtmlStringRGB(grade.Color()),
                        grade.ToString(),
                        Mathf.FloorToInt(bestScore),
                        Math.Floor(bestAccuracy * 100) / 100
                        );
                }

                StartCoroutine(RebuildLayout());
            }
        }
    public T Get <T>(string key)
    {
        //  PlayerPrefs.DeleteAll();
        object value = null;

        if (typeof(T) == typeof(int))
        {
            value = ZPlayerPrefs.GetInt(key);
        }
        else if (typeof(T) == typeof(long))
        {
            value = Convert.ToInt64(ZPlayerPrefs.GetString(key));
        }
        else if (typeof(T) == typeof(string))
        {
            value = ZPlayerPrefs.GetString(key);
        }
        else if (typeof(T) == typeof(float))
        {
            value = ZPlayerPrefs.GetFloat(key);
        }
        else if (typeof(T) == typeof(bool))
        {
            value = ZPlayerPrefs.GetFloat(key);
            value = Convert.ToBoolean(value);
        }
        else if (typeof(T) == typeof(DateTime))
        {
            var intValue = Convert.ToInt64(ZPlayerPrefs.GetString(key));
            value = DateTime.FromBinary(intValue);
        }
        else if (typeof(T).IsGenericType && (typeof(T).GetGenericTypeDefinition() == typeof(List <>)))
        {
            string t = ZPlayerPrefs.GetString(key, string.Empty);
            return(JsonHelper.FromJson <T>(t));
        }
        else
        {
            string t = ZPlayerPrefs.GetString(key, string.Empty);
            return(JsonUtility.FromJson <T>(t));
        }
        return((T)Convert.ChangeType(value, typeof(T)));
    }
Beispiel #12
0
    private IEnumerator OnAndroidPlayerLoaded()
    {
        if (Math.Abs(startAt) > 0.00001)
        {
            ANAMusic.seekTo(anaId, (int)(startAt * 1000));
        }
        yield return(new WaitForSeconds(1));

        ANAMusic.play(anaId);

        var userOffset = PlayerPrefs.GetFloat("user_offset", 0.12f);

        // Override options?
        if (ZPlayerPrefs.GetBool(PreferenceKeys.WillOverrideOptions(CytoidApplication.CurrentLevel)))
        {
            userOffset = ZPlayerPrefs.GetFloat(PreferenceKeys.NoteDelay(CytoidApplication.CurrentLevel));
        }


        StartTime = Time.time + Chart.offset + userOffset;
    }
    public void OnLevelLoaded()
    {
        EventKit.Broadcast("level loaded");
        CytoidApplication.CurrentLevel = LoadedLevel;

        UpdateBestText();

        chartRelativeOffsetInput.text =
            ZPlayerPrefs.GetFloat(PreferenceKeys.ChartRelativeOffset(CytoidApplication.CurrentLevel.id), 0f).ToString();

        deleteButton.SetActive(!LoadedLevel.IsInternal);

        PlayerPrefs.SetString("last_level", LoadedLevel.id);

        if (PlayerPrefsExt.GetBool("ranked"))
        {
            EventKit.Broadcast("reload rankings");
        }

        StartCoroutine(OnlineMeta.FetchMeta(LoadedLevel.id));
    }
Beispiel #14
0
 public void getsc0re()
 {
     if (GameObject.FindWithTag("LVLTXT").GetComponent <Text> ().text.Contains("Easy"))
     {
         defaultdiff = 1;
     }
     else if (GameObject.FindWithTag("LVLTXT").GetComponent <Text> ().text.Contains("Normal"))
     {
         defaultdiff = 2;
     }
     else if (GameObject.FindWithTag("LVLTXT").GetComponent <Text> ().text.Contains("Hard"))
     {
         defaultdiff = 3;
     }
     if (GameObject.FindWithTag("LVLTXT").GetComponent <Text> ().text.Contains("Extra"))
     {
         defaultdiff = 4;
     }
     ZPlayerPrefs.Initialize("what'sYourName", "salt12issalt");
     sc0re.text = ZPlayerPrefs.GetFloat(GameObject.FindGameObjectWithTag("YEABOI").name).ToString("F2") + "%";
     if (ZPlayerPrefs.GetFloat(GameObject.FindGameObjectWithTag("YEABOI").name + "AC") == 1f)
     {
         AC.SetActive(true);
         FC.SetActive(false);
     }
     else if (ZPlayerPrefs.GetFloat(GameObject.FindGameObjectWithTag("YEABOI").name + "FC") == 1f)
     {
         FC.SetActive(true);
         AC.SetActive(false);
     }
     else
     {
         AC.SetActive(false);
         FC.SetActive(false);
     }
     if (sc0re.text == null)
     {
         sc0re.text = "No Score Yet!";
     }
 }
    public void OnLevelLoaded()
    {
        switchDifficultyView.OnLevelLoaded();
        CytoidApplication.CurrentLevel = LoadedLevel;

        UpdateBestText();

        var useLocalOptions = ZPlayerPrefs.GetBool(PreferenceKeys.WillOverrideOptions(CytoidApplication.CurrentLevel), false);

        overrideOptionsToggle.isOn = useLocalOptions;

        localIsInversedToggle.isOn = isInversedToggle.isOn;
        localUserOffsetInput.text  = userOffsetInput.text;

        if (useLocalOptions)
        {
            localIsInversedToggle.isOn =
                ZPlayerPrefs.GetBool(PreferenceKeys.WillInverse(CytoidApplication.CurrentLevel), false);
            localUserOffsetInput.text =
                ZPlayerPrefs.GetFloat(PreferenceKeys.NoteDelay(CytoidApplication.CurrentLevel),
                                      PlayerPrefs.GetFloat("user_offset")).ToString();
        }
    }
Beispiel #16
0
 public void UpdateBestText()
 {
     if (LoadedLevel == null)
     {
         return;
     }
     if (Math.Abs(ZPlayerPrefs.GetFloat(
                      PreferenceKeys.BestScore(LoadedLevel, CytoidApplication.CurrentChartType),
                      defaultValue: -1) - (-1)) < 0.000001)
     {
         bestText.text = "NO HIGH SCORE YET";
     }
     else
     {
         bestText.text =
             "Score " + Mathf.CeilToInt(ZPlayerPrefs.GetFloat(
                                            PreferenceKeys.BestScore(LoadedLevel, CytoidApplication.CurrentChartType),
                                            0)).ToString("D6")
             + "   Acc. " +
             ZPlayerPrefs.GetFloat(
                 PreferenceKeys.BestAccuracy(LoadedLevel, CytoidApplication.CurrentChartType),
                 0).ToString("0.##") + "%";
     }
 }
    private void Start()
    {
        IsUploading = false;

        BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene);

        // HIGHLIGHT
        Resources.UnloadUnusedAssets();
        // HIGHLIGHT

        StartCoroutine(AutoUpload());

        var score    = CytoidApplication.LastPlayResult.Score;
        var tp       = CytoidApplication.LastPlayResult.Tp;
        var maxCombo = CytoidApplication.LastPlayResult.MaxCombo;

        titleText.text = CytoidApplication.CurrentLevel.title;

        var intScore = Mathf.CeilToInt((float)score);

        scoreText.text = intScore.ToString("D6");
        if (intScore == 1000000)
        {
            scoreText.color = Convert.HexToColor("#FDE74C");
        }

        var result = CytoidApplication.LastPlayResult;

        var text = "";

        if (Math.Abs(tp - 100) < 0.000001)
        {
            text += "Full accuracy";
        }
        else
        {
            text += tp.ToString("0.##") + "% accuracy";
        }
        text += " / ";
        if (maxCombo == result.TotalCount)
        {
            text += "Full combo";
        }
        else
        {
            text += maxCombo + " max combo";
        }

        tpComboText.text = text;


        var info = string.Format("<b>Perfect </b> {0}      <b>Great </b> {1}      <b>Good </b> {2}      <b>Bad </b> {3}      <b>Miss </b> {4}", result.PerfectCount, result.GreatCount, result.GoodCount, result.BadCount, result.MissCount);

        infoText.text = info;

        DisplayDifficultyView.Instance.SetDifficulty(CytoidApplication.CurrentChartType, CytoidApplication.CurrentLevel.GetDifficulty(CytoidApplication.CurrentChartType));

        var ranked = result.Ranked;

        // Save stats
        var oldScore = ZPlayerPrefs.GetFloat(PreferenceKeys.BestScore(CytoidApplication.CurrentLevel,
                                                                      CytoidApplication.CurrentChartType, ranked));
        var oldTp = ZPlayerPrefs.GetFloat(PreferenceKeys.BestAccuracy(CytoidApplication.CurrentLevel,
                                                                      CytoidApplication.CurrentChartType, ranked));

        if (score > oldScore)
        {
            ZPlayerPrefs.SetFloat(PreferenceKeys.BestScore(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType, ranked), (float)score);
        }
        if (tp > oldTp)
        {
            ZPlayerPrefs.SetFloat(PreferenceKeys.BestAccuracy(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType, ranked), (float)tp);
        }

        var playCount =
            ZPlayerPrefs.GetInt(PreferenceKeys.PlayCount(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType), defaultValue: 0);

        ZPlayerPrefs.SetInt(PreferenceKeys.PlayCount(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType), playCount + 1);

        if (ranked)
        {
            var rankedPlayData = CytoidApplication.CurrentRankedPlayData;

            rankedPlayData.score     = (long)score;
            rankedPlayData.accuracy  = (int)(tp * 1000000);
            rankedPlayData.max_combo = maxCombo;
            rankedPlayData.perfect   = result.PerfectCount;
            rankedPlayData.great     = result.GreatCount;
            rankedPlayData.good      = result.GoodCount;
            rankedPlayData.bad       = result.BadCount;
            rankedPlayData.miss      = result.MissCount;

            rankedPlayData.checksum = Checksum.From(rankedPlayData);
        }
        else
        {
            levelInfoIndicator.transform.SetLocalX(rankedIndicator.transform.localPosition.x);
            rankedIndicator.SetActive(false);
        }
    }
    protected override void Awake()
    {
        base.Awake();

        CytoidApplication.SetAutoRotation(true);
        CytoidApplication.ResetResolution();

        var ringColorDef    = "#FFFFFF";
        var ringColorAltDef = "#FFFFFF";
        var fillColorDef    = "#6699CC";
        var fillColorAltDef = "#FF3C38";

        SetDefaultPref("main offset", Application.platform == RuntimePlatform.Android ? 0f : 0.1f);
        SetDefaultPref("headset offset", -0.05f);
        SetDefaultPref("show_scanner", true);
        SetDefaultPref("inverse", false);
        SetDefaultPref("ring_color", ringColorDef);
        SetDefaultPref("ring_color_alt", ringColorAltDef);
        SetDefaultPref("fill_color", fillColorDef);
        SetDefaultPref("fill_color_alt", fillColorAltDef);
        SetDefaultPref("hit_sound", "None");

        var list = HitSounds.ToList();

        list.Insert(0, new HitSound {
            Name = "None"
        });
        HitSounds = list.ToArray();
        UpdateHitSound(HitSounds[1], save: false);

        var userHitSound = PlayerPrefs.GetString("hit_sound");

        for (var index = 0; index < HitSounds.Length; index++)
        {
            if (HitSounds[index].Name == userHitSound)
            {
                UpdateHitSound(HitSounds[index]);
                HitSoundIndex = index;
            }
        }

        mainOffsetInput.text          = PlayerPrefs.GetFloat("main offset").ToString();
        headsetOffsetInput.text       = PlayerPrefs.GetFloat("headset offset").ToString();
        earlyLateIndicatorToggle.isOn = PlayerPrefsExt.GetBool("early_late_indicator");
        largerHitboxesToggle.isOn     = PlayerPrefsExt.GetBool("larger_hitboxes");

        mainOffsetInput.onEndEdit.AddListener(text =>
        {
            float offset;
            if (!float.TryParse(text, out offset))
            {
                mainOffsetInput.text = PlayerPrefs.GetFloat("main offset").ToString();
            }
            else
            {
                PlayerPrefs.SetFloat("main offset", offset);
            }
        });
        chartRelativeOffsetInput.onEndEdit.AddListener(text =>
        {
            float offset;
            if (!float.TryParse(text, out offset))
            {
                chartRelativeOffsetInput.text = ZPlayerPrefs.GetFloat(PreferenceKeys.ChartRelativeOffset(CytoidApplication.CurrentLevel.id)).ToString();
            }
            else
            {
                ZPlayerPrefs.SetFloat(PreferenceKeys.ChartRelativeOffset(CytoidApplication.CurrentLevel.id), offset);
            }
        });
        headsetOffsetInput.onEndEdit.AddListener(text =>
        {
            float offset;
            if (!float.TryParse(text, out offset))
            {
                headsetOffsetInput.text = PlayerPrefs.GetFloat("headset offset").ToString();
            }
            else
            {
                PlayerPrefs.SetFloat("headset offset", offset);
            }
        });

        usernameInput.text = PlayerPrefs.GetString(PreferenceKeys.LastUsername());
        passwordInput.text = PlayerPrefs.GetString(PreferenceKeys.LastPassword());

        if (!PlayerPrefs.HasKey("ranked"))
        {
            PlayerPrefsExt.SetBool("ranked", false);
        }

        rankStatusText.text = OnlinePlayer.Authenticated && PlayerPrefsExt.GetBool("ranked") ? "On" : "Off";

        // Initialize background
        blackout.SetActive(false);

        var backgrounds = GameObject.FindGameObjectsWithTag("Background");

        if (backgrounds.Length > 1) // Already have persisted background? (i.e. returning from Game/GameResult scene)
        {
            var localBackground = backgrounds.ToList().Find(it => it.scene == gameObject.scene);
            // Destroy local background
            Destroy(localBackground);
            // Setup the persisted background
            BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene);
        }
        else // Setup the local background
        {
            BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene);
        }

        if (OnlinePlayer.Authenticated && OnlinePlayer.AvatarTexture != null)
        {
            LoadedAvatar = true;
        }

        if (Application.platform == RuntimePlatform.Android)
        {
            headsetOffsetInput.gameObject.SetActive(false);
            LayoutRebuilder.ForceRebuildLayoutImmediate(headsetOffsetInput.transform.parent.GetComponent <RectTransform>());
        }

        EventKit.Subscribe <string>("meta reloaded", OnLevelMetaReloaded);
    }
Beispiel #19
0
        protected virtual IEnumerator Start()
        {
            // Load level
            if (CytoidApplication.CurrentLevel != null)
            {
                Level = CytoidApplication.CurrentLevel;
            }
            else
            {
                Level = JsonConvert.DeserializeObject <Level>(
                    File.ReadAllText(Application.persistentDataPath + "/player/level.json"));
                Level.BasePath = Application.persistentDataPath + "/player/";
                CytoidApplication.CurrentChartType = Level.charts[0].type;

                var www = new WWW("file://" + Level.BasePath + Level.background.path);
                yield return(www);

                yield return(null); // Wait an extra frame

                www.LoadImageIntoTexture(CytoidApplication.BackgroundTexture);

                var backgroundSprite =
                    Sprite.Create(CytoidApplication.BackgroundTexture,
                                  new Rect(0, 0, CytoidApplication.BackgroundTexture.width,
                                           CytoidApplication.BackgroundTexture.height),
                                  new Vector2(0, 0));
                var background = GameObject.FindGameObjectWithTag("Background");
                if (background != null)
                {
                    background.GetComponent <Image>().sprite = backgroundSprite;

                    // Fill the screen by adapting to the aspect ratio
                    background.GetComponent <AspectRatioFitter>().aspectRatio =
                        (float)CytoidApplication.BackgroundTexture.width / CytoidApplication.BackgroundTexture.height;
                    yield return(null); // Wait an extra frame
                }

                www.Dispose();
                Resources.UnloadUnusedAssets();

                CytoidApplication.CurrentLevel = Level;
            }

            // System settings
            CytoidApplication.SetAutoRotation(false);
            if (Application.platform == RuntimePlatform.Android && !Level.IsInternal)
            {
                print("Using Android Native Audio");
                GameOptions.Instance.UseAndroidNativeAudio = true;
            }

            // Load chart
            print("Loading chart");

            if (CytoidApplication.CurrentChartType == null)
            {
                CytoidApplication.CurrentChartType = Level.charts[0].type;
            }

            var chartSection = Level.charts.Find(it => it.type == CytoidApplication.CurrentChartType);

            string chartText;

            if (Application.platform == RuntimePlatform.Android && Level.IsInternal)
            {
                var chartWww = new WWW(Level.BasePath + chartSection.path);
                yield return(chartWww);

                chartText = Encoding.UTF8.GetString(chartWww.bytes);
            }
            else
            {
                chartText = File.ReadAllText(Level.BasePath + chartSection.path, Encoding.UTF8);
            }

            Chart = new Chart(
                chartText,
                0.8f + (5 - (int)PlayerPrefs.GetFloat("horizontal margin", 3) - 1) * 0.025f,
                (5.5f + (5 - (int)PlayerPrefs.GetFloat("vertical margin", 3)) * 0.5f) / 9.0f
                );

            // Load audio
            print("Loading audio");

            var audioPath = Level.BasePath + Level.GetMusicPath(CytoidApplication.CurrentChartType);

            if (GameOptions.Instance.UseAndroidNativeAudio)
            {
                NativeAudioId = ANAMusic.load(audioPath, true);
                Length        = ANAMusic.getDuration(NativeAudioId);
            }
            else
            {
                var www = new WWW(
                    (Level.IsInternal && Application.platform == RuntimePlatform.Android ? "" : "file://") +
                    audioPath);
                yield return(www);

                AudioSource.clip = www.GetAudioClip();
                Length           = AudioSource.clip.length;

                www.Dispose();
            }

            // Game options
            var options = GameOptions.Instance;

            options.HitboxMultiplier       = PlayerPrefsExt.GetBool("larger_hitboxes") ? 1.5555f : 1.3333f;
            options.ShowEarlyLateIndicator = PlayerPrefsExt.GetBool("early_late_indicator");
            options.ChartOffset            = PlayerPrefs.GetFloat("main offset", 0);
            options.ChartOffset           += ZPlayerPrefs.GetFloat(PreferenceKeys.ChartRelativeOffset(Level.id), 0);

            if (Application.platform != RuntimePlatform.Android && Headset.Detect())
            {
                options.ChartOffset += ZPlayerPrefs.GetFloat("headset offset");
            }

            if (CytoidApplication.CurrentHitSound.Name != "None")
            {
#if (UNITY_IOS || UNITY_ANDROID) && !UNITY_EDITOR
                options.HitSound = NativeAudio.Load("Hits/" + CytoidApplication.CurrentHitSound.Name + ".wav");
#endif
            }

            Play.Init(Chart);

            print("Chart checksum: " + Chart.Checksum);
            // Rank data
            if (Play.IsRanked)
            {
                RankedPlayData                            = new RankedPlayData();
                RankedPlayData.user                       = OnlinePlayer.Name;
                RankedPlayData.password                   = OnlinePlayer.Password;
                RankedPlayData.start                      = TimeExt.Millis();
                RankedPlayData.id                         = Level.id;
                RankedPlayData.type                       = CytoidApplication.CurrentChartType;
                RankedPlayData.mods                       = string.Join(",", Array.ConvertAll(Play.Mods.ToArray(), mod => mod.ToString()));
                RankedPlayData.version                    = Level.version;
                RankedPlayData.chart_checksum             = Chart.Checksum;
                RankedPlayData.device.width               = Screen.width;
                RankedPlayData.device.height              = Screen.height;
                RankedPlayData.device.dpi                 = (int)Screen.dpi;
                RankedPlayData.device.model               = SystemInfo.deviceModel;
                CytoidApplication.CurrentRankedPlayData   = RankedPlayData;
                CytoidApplication.CurrentUnrankedPlayData = null;
            }
            else
            {
                UnrankedPlayData                          = new UnrankedPlayData();
                UnrankedPlayData.user                     = OnlinePlayer.Authenticated ? OnlinePlayer.Name : "local";
                UnrankedPlayData.password                 = OnlinePlayer.Authenticated ? OnlinePlayer.Password : "";
                UnrankedPlayData.id                       = Level.id;
                UnrankedPlayData.type                     = CytoidApplication.CurrentChartType;
                UnrankedPlayData.version                  = Level.version;
                UnrankedPlayData.chart_checksum           = Chart.Checksum;
                CytoidApplication.CurrentRankedPlayData   = null;
                CytoidApplication.CurrentUnrankedPlayData = UnrankedPlayData;
            }

            // Touch handlers
            if (!Mod.Auto.IsEnabled())
            {
                LeanTouch.OnFingerDown += OnFingerDown;
                LeanTouch.OnFingerSet  += OnFingerSet;
                LeanTouch.OnFingerUp   += OnFingerUp;
            }

            yield return(new WaitForSeconds(0.2f));

            View.OnStart();

            IsLoaded = true;

            EventKit.Broadcast("game loaded");

            // Wait for Storyboard
            while (!StoryboardController.Instance.Loaded)
            {
                yield return(null);
            }

            yield return(new WaitForSeconds(0.3f));

            StartGame();
        }
Beispiel #20
0
    private void Start()
    {
        CytoidApplication.ResetResolution();

        IsUploading          = false;
        SuccessfullyUploaded = false;

        BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene);

        // HIGHLIGHT
        Resources.UnloadUnusedAssets();
        // HIGHLIGHT

        if (OnlinePlayer.Authenticated)
        {
            StartCoroutine(AutoUpload());
        }
        else
        {
            uploadButton.gameObject.SetActive(false);
        }

        var play = CytoidApplication.CurrentPlay;

        var score    = play.Score;
        var tp       = play.Tp;
        var maxCombo = play.MaxCombo;

        titleText.text = CytoidApplication.CurrentLevel.title;

        var intScore = Mathf.FloorToInt((float)score);

        scoreText.text = intScore.ToString("D6");
        if (intScore == 1000000)
        {
            scoreText.color = Convert.HexToColor("#ffc107");
        }
        else if (intScore > 999000)
        {
            scoreText.color = Convert.HexToColor("#007bff");
        }

        var text = "";

        if (Math.Abs(tp - 100) < 0.000001)
        {
            text += "Full accuracy";
        }
        else
        {
            text += (Math.Floor(tp * 100) / 100).ToString("0.00") + "% accuracy";
        }
        text += " / ";
        if (maxCombo == play.NoteCleared)
        {
            text += "Full combo";
        }
        else
        {
            text += maxCombo + " max combo";
        }

        tpComboText.text = text;

        var info = string.Format(
            "<b>Perfect</b> {0}      <b>Great</b> {1}      <b>Good</b> {2}      <b>Bad</b> {3}      <b>Miss</b> {4}",
            play.NoteRankings.Values.Count(grading => grading == NoteGrade.Perfect),
            play.NoteRankings.Values.Count(grading => grading == NoteGrade.Great),
            play.NoteRankings.Values.Count(grading => grading == NoteGrade.Good),
            play.NoteRankings.Values.Count(grading => grading == NoteGrade.Bad),
            play.NoteRankings.Values.Count(grading => grading == NoteGrade.Miss)
            );

        if (PlayerPrefsExt.GetBool("early_late_indicator"))
        {
            info += string.Format("\n<alpha=#38>( <b>Early</b> {0}      <b>Late</b> {1}      <b>Average Timing Error</b> {2}{3:0.000}s      <b>Standard Timing Error</b> {4:0.000}s )",
                                  play.Early, play.Late, play.AvgTimeOff > 0 ? "+" : "", play.AvgTimeOff, play.StandardTimeOff);
        }
        infoText.text = info;

        DisplayDifficultyView.Instance.SetDifficulty(CytoidApplication.CurrentLevel, CytoidApplication.CurrentLevel.charts.Find(it => it.type == CytoidApplication.CurrentChartType));

        var ranked = CytoidApplication.CurrentRankedPlayData != null;

        // Save stats
        var oldScore = ZPlayerPrefs.GetFloat(PreferenceKeys.BestScore(CytoidApplication.CurrentLevel.id,
                                                                      CytoidApplication.CurrentChartType, ranked));
        var oldAccuracy = ZPlayerPrefs.GetFloat(PreferenceKeys.BestAccuracy(CytoidApplication.CurrentLevel.id,
                                                                            CytoidApplication.CurrentChartType, ranked));

        var newBest = false;

        if (score > oldScore)
        {
            newBest = true;

            ZPlayerPrefs.SetFloat(
                PreferenceKeys.BestScore(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType, ranked),
                (float)score);

            var clearType = string.Empty;
            if (play.Mods.Contains(Mod.AP))
            {
                clearType = "AP";
            }
            if (play.Mods.Contains(Mod.FC))
            {
                clearType = "FC";
            }
            if (play.Mods.Contains(Mod.Hard))
            {
                clearType = "Hard";
            }
            if (play.Mods.Contains(Mod.ExHard))
            {
                clearType = "ExHard";
            }
            ZPlayerPrefs.SetString(
                PreferenceKeys.BestClearType(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType,
                                             ranked),
                clearType
                );
        }

        if (tp > oldAccuracy)
        {
            newBest = true;

            ZPlayerPrefs.SetFloat(
                PreferenceKeys.BestAccuracy(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType, ranked),
                (float)tp);
        }

        if (newBest)
        {
            EventKit.Broadcast("new best");
        }

        var playCount =
            ZPlayerPrefs.GetInt(
                PreferenceKeys.PlayCount(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType),
                defaultValue: 0);

        ZPlayerPrefs.SetInt(
            PreferenceKeys.PlayCount(CytoidApplication.CurrentLevel.id, CytoidApplication.CurrentChartType),
            playCount + 1);
    }
Beispiel #21
0
    // Use this for initialization
    void Awake()
    {
        #if !UNITY_EDITOR
        // On IOS...
        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            imagetype=".jpg";
        }
        #endif
        #if UNITY_EDITOR
        imagetype = ".jpg";
        #endif
        ZPlayerPrefs.Initialize ("what'sYourName", "salt12issalt");
        DirectoryInfo directoryInfoo = new DirectoryInfo (Application.persistentDataPath);
        print ("Streaming Assets Path: " + Application.persistentDataPath);
        DirectoryInfo[] allFiless = directoryInfoo.GetDirectories ("*");
        foreach (DirectoryInfo directory in allFiless) {
            var toPath = directory + "/" + Path.GetFileName ("DEMOID.txt");
            print (toPath);
            if (File.Exists (toPath)) {
                print ("YEAAAAAHHHDHSDHASHDSAHDAHDSAHD");
            }
            DirectoryInfo directoryInfo = new DirectoryInfo (directory + "/");
            print ("Streaming Assets Path: " + directoryInfo);
            FileInfo[] allFiles = directoryInfo.GetFiles ("*.*");
            foreach (FileInfo file in allFiles) {
                if (file.Name.Contains ("bg")) {
                    StartCoroutine ("LoadPlayerUI", file);

                }
            }

        }
        prefabs = GameObject.FindGameObjectsWithTag ("YEABOI");
        foreach (GameObject goo in prefabs) {
            Chartnm = goo.name;
            GameObject.FindGameObjectWithTag ("NSN").GetComponent<Text> ().text = Chartnm;
        }
        if (GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().AllCharming == true) {
            ALL.SetActive (true);
        } else if (GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().FullCombo == true) {
            FULL.SetActive (true);
        }
        GameObject.FindGameObjectWithTag ("RDTEXT").GetComponent<Text> ().text = GM.DIFNAM;
        MAXCOMBO.text = GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().exChartcombo.ToString ();
        MAXCHARMING.text = GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().exChartcombo.ToString ();
        charmcount.text = GM.highestcharmingcount.ToString ();
        highcombo.text = GM.highestcombo.ToString ();
        FinalSc0re.text = GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().sc0re.ToString ("F2") + "%";
        if (changedifimage.currentdiff == 0 || UpdateScrollSnap.defaultdiff == changedifimage.currentdiff) {
            if (ZPlayerPrefs.GetFloat (GameObject.FindGameObjectWithTag ("YEABOI").name) < GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().sc0re) {
                ZPlayerPrefs.SetFloat (GameObject.FindGameObjectWithTag ("YEABOI").name, GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().sc0re);
                Debug.Log ("Get Value" + GameObject.FindGameObjectWithTag ("YEABOI").name + ZPlayerPrefs.GetFloat (GameObject.FindGameObjectWithTag ("YEABOI").name) + ", Encrypt: " + ZPlayerPrefs.GetRowString (GameObject.FindGameObjectWithTag ("YEABOI").name));
            }
            if (GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().AllCharming == true) {
                ZPlayerPrefs.SetFloat (GameObject.FindGameObjectWithTag ("YEABOI").name + "AC", 1f);
            } else if (GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().FullCombo == true) {
                ZPlayerPrefs.SetFloat (GameObject.FindGameObjectWithTag ("YEABOI").name + "FC", 1f);
            }
            ZPlayerPrefs.Save ();
        } else {
            if (ZPlayerPrefs.GetFloat (GameObject.FindGameObjectWithTag ("YEABOI").name+ changedifimage.ENHE) < GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().sc0re) {
                ZPlayerPrefs.SetFloat (GameObject.FindGameObjectWithTag ("YEABOI").name+ changedifimage.ENHE, GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().sc0re);
                Debug.Log ("Get Value" + GameObject.FindGameObjectWithTag ("YEABOI").name+ changedifimage.ENHE + ZPlayerPrefs.GetFloat (GameObject.FindGameObjectWithTag ("YEABOI").name+ changedifimage.ENHE) + ", Encrypt: " + ZPlayerPrefs.GetRowString (GameObject.FindGameObjectWithTag ("YEABOI").name+ changedifimage.ENHE));
            }
            if (GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().AllCharming == true) {
                ZPlayerPrefs.SetFloat (GameObject.FindGameObjectWithTag ("YEABOI").name+ changedifimage.ENHE + "AC", 1f);
            } else if (GameObject.FindGameObjectWithTag ("Scoreobject").GetComponent<GM> ().FullCombo == true) {
                ZPlayerPrefs.SetFloat (GameObject.FindGameObjectWithTag ("YEABOI").name+ changedifimage.ENHE + "FC", 1f);
            }
            ZPlayerPrefs.Save ();
        }
    }
Beispiel #22
0
    public static IEnumerator QueryRankings(string level, string type)
    {
        var request = UnityWebRequest.Get(
            string.Format(CytoidApplication.Host + "/rankings?level={0}&type={1}&player={2}",
                          level, type, Name)
            );

        request.downloadHandler = new DownloadHandlerBuffer();
        request.SetRequestHeader("Content-Type", "application/json");

        yield return(request.Send());

        if (request.isNetworkError)
        {
            LastRankingQueryResult = new RankingQueryResult {
                status = -1
            };
        }
        else
        {
            try
            {
                LastRankingQueryResult =
                    JsonConvert.DeserializeObject <RankingQueryResult>(request.downloadHandler.text);
                LastRankingQueryResult.status = 0;

                #if UNITY_EDITOR
                Debug.Log(JsonConvert.SerializeObject(LastRankingQueryResult));
                #endif

                // Replace local score if higher
                if (LastRankingQueryResult.player_rank != -1)
                {
                    var ranking = LastRankingQueryResult.rankings.First(it => it.player == Name);

                    if (ranking != null)
                    {
                        var oldScore = ZPlayerPrefs.GetFloat(PreferenceKeys.BestScore(level,
                                                                                      type, true));

                        if (ranking.score > oldScore)
                        {
                            ZPlayerPrefs.SetFloat(
                                PreferenceKeys.BestScore(level,
                                                         type,
                                                         true),
                                ranking.score);
                            ZPlayerPrefs.SetFloat(
                                PreferenceKeys.BestAccuracy(level,
                                                            type, true),
                                (float)ranking.accuracy / 100);

                            BestScoreText.WillInvalidate = true;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log.e(e.Message);
                LastRankingQueryResult = new RankingQueryResult {
                    status = -1
                };
                yield break;
            }
        }

        request.Dispose();
    }
 public float getPersistantGoldScore()
 {
     return(ZPlayerPrefs.GetFloat("goldscore"));
 }
 // Use this for initialization
 void Start()
 {
     localHighscore = ZPlayerPrefs.GetFloat("highscore");
 }
    public float getHighscore()
    {
        float highscore = ZPlayerPrefs.GetFloat("highscore");

        return(highscore);
    }
Beispiel #26
0
    private IEnumerator Start()
    {
        IsRanked = PlayerPrefsExt.GetBool(PreferenceKeys.RankedMode());
        if (!LocalProfile.Exists())
        {
            IsRanked = false;
        }

        if (!IsRanked)
        {
            levelInfoIndicator.transform.SetLocalX(rankedIndicator.transform.localPosition.x);
            rankedIndicator.SetActive(false);
        }

        if (PlayerPrefs.GetInt("autoplay") == 1 && !IsRanked)
        {
            autoPlay = true;
        }
        if (PlayerPrefsExt.GetBool("larger_hitboxes"))
        {
            hitboxMultiplier = 1.33f;
        }
        showEarlyLateIndicator = PlayerPrefsExt.GetBool("early_late_indicator");

        CytoidApplication.SetAutoRotation(false);

        SetAllowPause(false);

        OnScreenChainNotes          = new List <NoteView>();
        OnScreenHoldNotes           = new List <NoteView>();
        OnScreenRegularAndHoldNotes = new List <NoteView>();

#if UNITY_EDITOR
        autoPlay = true;
        if (!string.IsNullOrEmpty(editorLevelOverride))
        {
            CytoidApplication.CurrentLevel = CytoidApplication.Levels.Find(it =>
                                                                           string.Equals(it.title, editorLevelOverride, StringComparison.OrdinalIgnoreCase));
            CytoidApplication.CurrentChartType = editorChartTypeOverride;
        }
        // Still null? Fallback
        if (CytoidApplication.CurrentLevel == null)
        {
            CytoidApplication.CurrentLevel = CytoidApplication.Levels.Find(it =>
                                                                           string.Equals(it.title, editorLevelFallback, StringComparison.OrdinalIgnoreCase));
            CytoidApplication.CurrentChartType = editorChartTypeFallback;
        }
        if (Math.Abs(editorStartAtOverride - startAt) > 0.00001f)
        {
            startAt = editorStartAtOverride;
        }
#endif

        var level = CytoidApplication.CurrentLevel;

        if (!level.ChartsLoaded)
        {
            level.LoadCharts();
        }

        ThemeController.Instance.Init(level);
        DisplayDifficultyView.Instance.SetDifficulty(CytoidApplication.CurrentChartType,
                                                     level.GetDifficulty(CytoidApplication.CurrentChartType));
        titleText.text = level.title;

        isInversed = PlayerPrefsExt.GetBool("inverse");

        // Override options?
        if (ZPlayerPrefs.GetBool(PreferenceKeys.WillOverrideOptions(level)))
        {
            isInversed = ZPlayerPrefs.GetBool(PreferenceKeys.WillInverse(level));
        }

        // Chart and background are already loaded

        if (CytoidApplication.CurrentChartType == null)
        {
            CytoidApplication.CurrentChartType = level.charts[0].type;
        }
        Chart    = level.charts.Find(it => it.type == CytoidApplication.CurrentChartType).chart;
        PlayData = new PlayData(Chart, IsRanked);
        CytoidApplication.CurrentPlayData = PlayData;

        if (IsRanked)
        {
            CytoidApplication.CurrentRankedPlayData = RankedPlayData;
        }


        // Load audio clip
        if (level.is_internal || Application.platform != RuntimePlatform.Android)
        {
            var www = new WWW((level.is_internal && Application.platform == RuntimePlatform.Android ? "" : "file://") +
                              level.basePath + level.GetMusicPath(CytoidApplication.CurrentChartType));
            yield return(www);

            clip             = CytoidApplication.ReadAudioClipFromWWW(www);
            audioSource.clip = clip;
        }

        // Don't continue until faded in
        backgroundOverlayMask.willFadeIn = true;
        while (backgroundOverlayMask.IsFading)
        {
            yield return(null);
        }
        yield return(null);

        // Init notes
        NoteViews = new OrderedDictionary();
        foreach (var id in Chart.chronologicalIds)
        {
            var note = Chart.notes[id];
            // if (note.time <= startAt) continue;
            var prefab = singleNotePrefab;
            switch (note.type)
            {
            case NoteType.Hold:
                prefab = holdNotePrefab;
                break;

            case NoteType.Chain:
                prefab = chainNotePrefab;
                break;
            }
            var noteView = Instantiate(prefab, transform).GetComponent <NoteView>();
            noteView.Init(Chart, note);
            NoteViews.Add(id, noteView);
        }

        foreach (NoteView note in NoteViews.Values)
        {
            note.OnAllNotesInitialized();
        }

        // Register handlers
        LeanTouch.OnFingerDown += OnFingerDown;
        LeanTouch.OnFingerSet  += OnFingerSet;
        LeanTouch.OnFingerUp   += OnFingerUp;

        // Release unused assets
        Resources.UnloadUnusedAssets();

        // Init scanner
        Instantiate(scannerPrefab, transform);


        if (level.is_internal || Application.platform != RuntimePlatform.Android)
        {
            audioSource.time = startAt;
            var userOffset = PlayerPrefs.GetFloat("user_offset", 0.2f);

            // Override options?
            if (ZPlayerPrefs.GetBool(PreferenceKeys.WillOverrideOptions(level)))
            {
                userOffset = ZPlayerPrefs.GetFloat(PreferenceKeys.NoteDelay(level));
            }

            const float delay = 1f;
            audioSource.PlayDelayed(delay);

            StartTime = Time.time + Chart.offset + userOffset + delay;
        }
        else
        {
            anaId = ANAMusic.load(level.basePath + level.GetMusicPath(CytoidApplication.CurrentChartType), true, true,
                                  id =>
            {
                StartCoroutine(OnAndroidPlayerLoaded());
            });
        }

        // Ranked
        if (!LocalProfile.Exists())
        {
            RankedPlayData.user     = "******";
            RankedPlayData.password = "";
        }
        else
        {
            RankedPlayData.user     = LocalProfile.Instance.username;
            RankedPlayData.password = LocalProfile.Instance.password;
        }
        RankedPlayData.start          = TimeExt.Millis();
        RankedPlayData.id             = level.id;
        RankedPlayData.type           = CytoidApplication.CurrentChartType;
        RankedPlayData.mods           = "";
        RankedPlayData.version        = level.version;
        RankedPlayData.chart_checksum = Chart.checksum;
        RankedPlayData.device.width   = Screen.width;
        RankedPlayData.device.height  = Screen.height;
        RankedPlayData.device.dpi     = (int)Screen.dpi;
        RankedPlayData.device.model   = SystemInfo.deviceModel;
        // Ranked

/*#if UNITY_EDITOR
 *      StartCoroutine(EndGame());
 #endif*/
    }
Beispiel #27
0
    private void Start()
    {
        BackgroundCanvasHelper.SetupBackgroundCanvas(gameObject.scene);

        // HIGHLIGHT
        Resources.UnloadUnusedAssets();
        // HIGHLIGHT

        var score = CytoidApplication.LastPlayResult.Score;
        var tp    = CytoidApplication.LastPlayResult.Tp;

        titleText.text = CytoidApplication.CurrentLevel.title;
        scoreText.text = Mathf.CeilToInt(score).ToString("D6");
        tpText.text    = tp.ToString("0.##") + "% Accuracy";
        comboText.text = CytoidApplication.LastPlayResult.MaxCombo + " Max. Combo";

        var result = CytoidApplication.LastPlayResult;
        var info   = "";

        info += result.PerfectCount + " Perfect   ";
        info += result.ExcellentCount + " Excellent   ";
        info += result.GoodCount + " Good   ";
        info += result.BadCount + " Bad   ";
        info += result.MissCount + " Miss";

        infoText.text = info;

        DisplayDifficultyView.Instance.SetDifficulty(CytoidApplication.CurrentChartType, CytoidApplication.CurrentLevel.GetDifficulty(CytoidApplication.CurrentChartType));

        // Save stats
        var oldScore = ZPlayerPrefs.GetFloat(PreferenceKeys.BestScore(CytoidApplication.CurrentLevel,
                                                                      CytoidApplication.CurrentChartType));
        var oldTp = ZPlayerPrefs.GetFloat(PreferenceKeys.BestAccuracy(CytoidApplication.CurrentLevel,
                                                                      CytoidApplication.CurrentChartType));

        if (score > oldScore)
        {
            ZPlayerPrefs.SetFloat(PreferenceKeys.BestScore(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType), score);
        }
        if (tp > oldTp)
        {
            ZPlayerPrefs.SetFloat(PreferenceKeys.BestAccuracy(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType), tp);
        }

        var playCount =
            ZPlayerPrefs.GetInt(PreferenceKeys.PlayCount(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType), defaultValue: 0);

        ZPlayerPrefs.SetInt(PreferenceKeys.PlayCount(CytoidApplication.CurrentLevel, CytoidApplication.CurrentChartType), playCount + 1);

        if (!CytoidApplication.UseDoozyUI)
        {
            nextButton.onClick.AddListener(() =>
            {
                action = Action.Next;
                DoAction();
            });
            retryButton.onClick.AddListener(() =>
            {
                action = Action.Retry;
                DoAction();
            });
        }
    }
Beispiel #28
0
    void Awake()
    {
        Application.targetFrameRate = 120;

        if (Application.platform == RuntimePlatform.IPhonePlayer)
        {
            Time.fixedDeltaTime = 0.01f;
        }
        else if (Application.platform == RuntimePlatform.Android)
        {
            Time.fixedDeltaTime = 0.01f;
        }
        ZPlayerPrefs.Initialize("what'sYourName", "salt12issalt");
        if (ZPlayerPrefs.HasKey("Speed"))
        {
            currentSpeed = ZPlayerPrefs.GetFloat("Speed", currentSpeed);
            ZPlayerPrefs.Save();
        }
        else
        {
            ZPlayerPrefs.SetFloat("Speed", 4);
            currentSpeed = 4f;
            ZPlayerPrefs.Save();
        }
        ZPlayerPrefs.Initialize("what'sYourName", "salt12issalt");
        if (ZPlayerPrefs.HasKey("FixTime"))
        {
            if (ZPlayerPrefs.GetFloat("FixTime") < 0.02f)
            {
                Time.fixedDeltaTime = ZPlayerPrefs.GetFloat("FixTime");
                CFT = Time.fixedDeltaTime;
                ZPlayerPrefs.Save();
            }
            else
            {
                if (Application.platform == RuntimePlatform.IPhonePlayer)
                {
                    ZPlayerPrefs.SetFloat("FixTime", Time.fixedDeltaTime);
                    CFT = Time.fixedDeltaTime;
                    ZPlayerPrefs.Save();
                }
                else
                {
                    Time.fixedDeltaTime = ZPlayerPrefs.GetFloat("FixTime");
                    CFT = Time.fixedDeltaTime;
                    ZPlayerPrefs.Save();
                }
            }
        }
        else
        {
            ZPlayerPrefs.SetFloat("FixTime", Time.fixedDeltaTime);
            CFT = Time.fixedDeltaTime;
            ZPlayerPrefs.Save();
        }
        ZPlayerPrefs.Initialize("what'sYourName", "salt12issalt");
        if (ZPlayerPrefs.HasKey("Offset"))
        {
            CalibrationLoadingScript.offset = ZPlayerPrefs.GetFloat("Offset");
            ExampleLoadingScript.offset     = ZPlayerPrefs.GetFloat("Offset");
            ZPlayerPrefs.Save();
        }
        else
        {
            ZPlayerPrefs.SetFloat("Offset", 0.00f);
            CalibrationLoadingScript.offset = 0.00f;
            ExampleLoadingScript.offset     = 0.00f;
            ZPlayerPrefs.Save();
        }

        //SNGNAM = GameObject.FindGameObjectWithTag ("LVLTXT").GetComponent<Text>().text;
        //StartCoroutine (SNG ());
    }
Beispiel #29
0
 public void Start()
 {
     ZPlayerPrefs.Initialize("h@takeKak@sh114", "h@takeKak@sh1");
     highScoreText.text = "HIGHSCORE :" + ZPlayerPrefs.GetFloat("highscore");
 }
Beispiel #30
0
    private IEnumerator Start()
    {
        if (PlayerPrefs.GetInt("autoplay") == 1)
        {
            autoPlay = true;
        }

        CytoidApplication.SetAutoRotation(false);

        SetAllowPause(false);

        OnScreenChainNotes          = new List <NoteView>();
        OnScreenHoldNotes           = new List <NoteView>();
        OnScreenRegularAndHoldNotes = new List <NoteView>();

#if UNITY_EDITOR
        autoPlay = true;
        if (!string.IsNullOrEmpty(editorLevelOverride))
        {
            CytoidApplication.CurrentLevel = CytoidApplication.Levels.Find(it =>
                                                                           string.Equals(it.title, editorLevelOverride, StringComparison.OrdinalIgnoreCase));
            CytoidApplication.CurrentChartType = editorChartTypeOverride;
        }
        // Still null? Fallback
        if (CytoidApplication.CurrentLevel == null)
        {
            CytoidApplication.CurrentLevel = CytoidApplication.Levels.Find(it =>
                                                                           string.Equals(it.title, editorLevelFallback, StringComparison.OrdinalIgnoreCase));
            CytoidApplication.CurrentChartType = editorChartTypeFallback;
        }
        if (Math.Abs(editorStartAtOverride - startAt) > 0.00001f)
        {
            startAt = editorStartAtOverride;
        }
#endif

        var level = CytoidApplication.CurrentLevel;

        ThemeController.Instance.Init(level);
        DisplayDifficultyView.Instance.SetDifficulty(CytoidApplication.CurrentChartType,
                                                     level.GetDifficulty(CytoidApplication.CurrentChartType));
        titleText.text = level.title;

        isInversed = PlayerPrefsExt.GetBool("inverse");

        // Override options?
        if (ZPlayerPrefs.GetBool(PreferenceKeys.WillOverrideOptions(level)))
        {
            isInversed = ZPlayerPrefs.GetBool(PreferenceKeys.WillInverse(level));
        }

        // Chart and background are already loaded
        Chart    = level.charts.Find(it => it.type == CytoidApplication.CurrentChartType).chart;
        PlayData = new PlayData(Chart);
        CytoidApplication.CurrentPlayData = PlayData;

        // Load audio clip
        if (level.isInternal || Application.platform != RuntimePlatform.Android)
        {
            var www = new WWW((level.isInternal && Application.platform == RuntimePlatform.Android ? "" : "file://") +
                              level.basePath + level.GetMusicPath(CytoidApplication.CurrentChartType));
            yield return(www);

            clip             = CytoidApplication.ReadAudioClipFromWWW(www);
            audioSource.clip = clip;
        }

        // Don't continue until faded in
        backgroundOverlayMask.willFadeIn = true;
        while (backgroundOverlayMask.IsFading)
        {
            yield return(null);
        }
        yield return(null);

        // Init notes
        NoteViews = new OrderedDictionary();
        foreach (var id in Chart.chronologicalIds)
        {
            var note = Chart.notes[id];
            // if (note.time <= startAt) continue;
            var prefab = singleNotePrefab;
            switch (note.type)
            {
            case NoteType.Hold:
                prefab = holdNotePrefab;
                break;

            case NoteType.Chain:
                prefab = chainNotePrefab;
                break;
            }
            var noteView = Instantiate(prefab, transform).GetComponent <NoteView>();
            noteView.Init(Chart, note);
            NoteViews.Add(id, noteView);
        }

        foreach (NoteView note in NoteViews.Values)
        {
            note.OnAllNotesInitialized();
        }

        // Register handlers
        LeanTouch.OnFingerDown += OnFingerDown;
        LeanTouch.OnFingerSet  += OnFingerSet;
        LeanTouch.OnFingerUp   += OnFingerUp;

        // Release unused assets
        Resources.UnloadUnusedAssets();

        // Init scanner
        Instantiate(scannerPrefab, transform);


        if (level.isInternal || Application.platform != RuntimePlatform.Android)
        {
            audioSource.time = startAt;
            var userOffset = PlayerPrefs.GetFloat("user_offset", 0.2f);

            // Override options?
            if (ZPlayerPrefs.GetBool(PreferenceKeys.WillOverrideOptions(level)))
            {
                userOffset = ZPlayerPrefs.GetFloat(PreferenceKeys.NoteDelay(level));
            }

            const float delay = 1f;
            audioSource.PlayDelayed(delay);

            StartTime = Time.time + Chart.offset + userOffset + delay;
        }
        else
        {
            anaId = ANAMusic.load(level.basePath + level.GetMusicPath(CytoidApplication.CurrentChartType), true, true,
                                  id =>
            {
                StartCoroutine(OnAndroidPlayerLoaded());
            });
        }
    }