示例#1
0
    // Use this for initialization
    private void Start()
    {
        // Initialise variables
        GameOptions.LoadOptions();
        challengeGenerator = GetComponent <ChallengeGenerator>();
        challengeGenerator.GenerateChallenges();
        audioManager = GetComponent <AudioManager>();
        menu         = FindObjectOfType <Menu>();

        dictData = new DictData(dict);
        dictData.Setup();
        letterList = new DictData(challengesFile);
        letterList.CleanLetterCombos();
        letters = new char[3];
        scores  = new Scores();
        answers = new List <string>();
        word    = new Word();
        input.onEndEdit.AddListener(CheckInput);
        gameState      = GameState.Pregame;
        IncreasePoints = new IntEvent();
        IncreaseTime   = new IntEvent();

        bannedWords = bannedWordsAsset.ToString().Split('\n').ToList();
        for (int i = 0; i < bannedWords.Count(); ++i)
        {
            bannedWords[i] = bannedWords[i].TrimEnd('\r');
        }

        // Check if this is the first time the game has been played
        bool playedBefore = false;

        for (int mode = 1; mode < 3; ++mode)
        {
            // For each game mode
            for (int diff = 1; diff < 4; ++diff)
            {
                // For each difficulty
                if (scores.GetBestScore((GameMode)mode, (Difficulty)diff) > 0)
                {
                    // If high score > 0 then played before
                    playedBefore = true;
                    break;
                }
            }

            if (playedBefore)
            {
                break;
            }
        }

        // Finished initialising variables

        // If not played before then start with the tutorial
        if (!playedBefore)
        {
            FindObjectOfType <LogoOpening>().SetNotPlayedBefore();
            GameInfo.SetGameMode(GameMode.Welcome);
        }

#if UNITY_IOS || UNITY_ANDROID
        // Initialise ads on mobile
        Ads.AdFinished.AddListener(AdCompleted);
        Ads.AdSkipped.AddListener(AdCompleted);
        Ads.AdFailed.AddListener(GoToMenu);
#endif
    }