Exemplo n.º 1
0
    public void DrawHighScores()
    {
        int counter = 0;        // Counter jsou jen sudá čísla

        // sudý = skóre
        // lichý (sudý + 1) = jméno

        System.Collections.Generic.SortedList <float, string> sortedHighscoreList = new System.Collections.Generic.SortedList <float, string>();

        while (PlayerPrefs.HasKey(counter.ToString()))                  // Načtu všechny hodnoty z PlayerPrefs do SortedList<float = score, string = name>
        {
            string playerName  = PlayerPrefs.GetString((counter + 1).ToString());
            float  playerScore = PlayerPrefs.GetFloat(counter.ToString());
            while (sortedHighscoreList.ContainsKey(playerScore))
            {
                playerScore++;                                          // Pokud by již skóre existovalo, pro jednoduchost mu přičtu+1 abych nemusel řešit složitě sort
            }
            sortedHighscoreList.Add(playerScore, playerName);
            counter += 2;
        }

        leaderboardText.text = "";

        for (int i = sortedHighscoreList.Count - 1; i >= 0; i--)
        {
            string playerName  = sortedHighscoreList.Values[i];
            float  playerScore = sortedHighscoreList.Keys[i];
            leaderboardText.text += sortedHighscoreList.Count - i + ". " + playerName + ": " + playerScore + "\r\n";
        }
    }
Exemplo n.º 2
0
    public Vector2 moveTowardsPlace(Vector2 targetPos)
    {
        var sortedMoveToList = new System.Collections.Generic.SortedList <float, Vector2>();

        if ((targetPos - position).magnitude < sight)
        {
            for (int x = -1; x <= 1; x++)
            {
                for (int y = -1; y <= 1; y++)
                {
                    Vector2 tempMove = new Vector2(x, y);

                    if (!GameMap.Instance.wallDictionary.ContainsKey(position + tempMove))                      //  xxx
                    {                                                                                           //  x_x  -> vybere nejbližsí možnost z okolí
                        float distance = (targetPos - (position + tempMove)).magnitude;                         //  xxx     -> teoreticky by se dalo něco ušetřit
                        if (!sortedMoveToList.ContainsKey(distance))                                            // Pokud v listu ještě není hodnota o stejné vzdálenosti
                        {
                            if (restrictedToDiagonalMovementOnly)                                               // Neozkoušeno!
                            {
                                if ((Mathf.Abs(x) + Mathf.Abs(y)) < 2)                                          // Jen pokud je |x| nebo |y|
                                {
                                    sortedMoveToList.Add(distance, tempMove);
                                }
                            }
                            else
                            {
                                sortedMoveToList.Add(distance, tempMove);
                            }
                        }
                    }
                }
            }

            if (sortedMoveToList.Count > 0)         // Pokud je v sortedListu nějaká hodnota, pak ji vyber
            {
                return(sortedMoveToList.Values[0]);
            }
            else                                    // Pokud není, tak vrať Vector2.zero
            {
                return(Vector2.zero);
            }
        }
        else
        {
            return(Vector2.zero);
        }
    }
Exemplo n.º 3
0
 internal SortedListKeyEnumerator(SortedList <TKey, TValue> sortedList)
 {
     _sortedList = sortedList;
     _version    = sortedList.version;
 }
Exemplo n.º 4
0
            private readonly SortedList <TKey, TValue> _dict; // Do not rename (binary serialization)

            internal ValueList(SortedList <TKey, TValue> dictionary)
            {
                _dict = dictionary;
            }
Exemplo n.º 5
0
 internal KeyEnumerator(SortedList <TKey, TValue> l)
 {
     this.l = l;
     idx    = NOT_STARTED;
     ver    = l.modificationCount;
 }
Exemplo n.º 6
0
 public Enumerator(SortedList <TKey, TValue> host)
     : this(host, EnumeratorMode.ENTRY_MODE)
 {
 }