Example #1
0
 void Awake()
 {
     players = new PlayerScore[playerCount];
     for (int i = 0; i < playerCount; ++i)
     {
         players[i] = new PlayerScore();
     }
 }
    void Start()
    {
        // iPhoneKeyboard.autorotateToPortrait = false;
        //         iPhoneKeyboard.autorotateToPortraitUpsideDown  = false;
        //         iPhoneKeyboard.autorotateToLandscapeRight  = false;
        //         iPhoneKeyboard.autorotateToLandscapeLeft = true;

        players = new PlayerScore[maxPlayer];
        int index = 0;
        string key = "";
        while(index < maxPlayer) {
            key = "player" + index;
            if(PlayerPrefs.HasKey(key)) {
                players[index] = new PlayerScore(PlayerPrefs.GetString(key));
            } else {
                players[index] = new PlayerScore();
            }
            players[index].id = index;
            players[index].rect = new Rect(120, 70 + index * 24, 300, 24);
            players[index].textStyle = textStyle;
            index++;
        }
        if(PlayerPrefs.HasKey("player")) {
            PlayerScore newPlayer = new PlayerScore(PlayerPrefs.GetString("player"));
            newPlayerPosition = maxPlayer;
            for(index = maxPlayer - 1; index >= 0 ; index--) {
                if(players[index].getWeight() < newPlayer.getWeight()) {
                    if((index + 1) < maxPlayer) {
                        players[index + 1].Copy(players[index]);
                    }
                    players[index].Copy(newPlayer);
                    newPlayerPosition = index;
                }
            }
            if(newPlayerPosition < maxPlayer)
                keyboard = iPhoneKeyboard.Open(players[newPlayerPosition].name, iPhoneKeyboardType.Default);
            MainMenu.CleanPlayerPrefs();
        }

        GameMaster.SetGame(false);
    }