Ejemplo n.º 1
0
    public static void ChangeFriendLevels()
    {
        if (friendLevels == "")
        {
            return;
        }

        int dayChange = PlayerPrefs.GetInt("facebook_daychange_level", -1);

        if (DateTime.Now.DayOfYear == dayChange)
        {
            return;
        }

        PlayerPrefs.SetInt("facebook_daychange_level", DateTime.Now.DayOfYear);

        List <int> friendLevelList = CUtils.BuildListFromString <int>(friendLevels);

        for (int i = 0; i < friendLevelList.Count; i++)
        {
            int delta = UnityEngine.Random.Range(0, 3);
            friendLevelList[i] += delta;
            if (friendLevelList[i] >= CommonConst.TOTAL_LEVELS)
            {
                friendLevelList[i] = CommonConst.TOTAL_LEVELS;
            }
        }
        friendLevels = CUtils.BuildStringFromCollection(friendLevelList);
    }
Ejemplo n.º 2
0
    public static int GetMyScore(int level)
    {
        List <int> scores = CUtils.BuildListFromString <int>(myScores);

        if (level <= scores.Count)
        {
            return(scores[level - 1]);
        }
        return(0);
    }
Ejemplo n.º 3
0
    public static string GetFriendAvatarUrl(int index)
    {
        List <string> avatarUrls = CUtils.BuildListFromString <string>(friendAvatarUrls);

        if (index < avatarUrls.Count)
        {
            return(avatarUrls[index]);
        }
        return("");
    }
Ejemplo n.º 4
0
    public static int GetFriendScore(int index, int level)
    {
        string     strScores = GetFriendScores(index);
        List <int> scores    = CUtils.BuildListFromString <int>(strScores);

        if (level <= scores.Count)
        {
            return(scores[level - 1]);
        }
        return(0);
    }
Ejemplo n.º 5
0
    public static List <int> GetFriendIndexesPassed(int level)
    {
        List <int> indexes         = new List <int>();
        List <int> friendLevelList = CUtils.BuildListFromString <int>(friendLevels);

        for (int i = 0; i < friendLevelList.Count; i++)
        {
            if (friendLevelList[i] > level)
            {
                indexes.Add(i);
            }
        }
        return(indexes);
    }
Ejemplo n.º 6
0
    public static void SetMyScore(int level, int score)
    {
        List <int> scores = CUtils.BuildListFromString <int>(myScores);

        if (level <= scores.Count)
        {
            scores[level - 1] = score;
        }
        else if (level == scores.Count + 1)
        {
            scores.Add(score);
        }

        myScores = CUtils.BuildStringFromCollection(scores);
    }
Ejemplo n.º 7
0
    private char?GetUnlockLetter(int numPass)
    {
        string[]  progress  = Prefs.levelProgress;
        GameLevel gameLevel = Utils.Load(Prefs.unlockedWorld, Prefs.unlockedSubWorld, Prefs.unlockedLevel);
        var       answers   = CUtils.BuildListFromString <string>(gameLevel.answers);

        var index = GetUnlockLetterIndex(progress, numPass);

        if (index != null)
        {
            char letter = answers[index.Item1][index.Item2];
            letter = char.ToUpper(letter);
            return(letter);
        }
        return(null);
    }
Ejemplo n.º 8
0
    private void Start()
    {
        FacebookUtils.ChangeFriendLevels();

        string avatarUrls   = FacebookUtils.friendAvatarUrls;
        string friendLevels = FacebookUtils.friendLevels;

        if (avatarUrls == "" || friendLevels == "")
        {
            return;
        }

        List <string> avatarUrlList   = CUtils.BuildListFromString <string>(avatarUrls);
        List <int>    friendLevelList = CUtils.BuildListFromString <int>(friendLevels);

        int i = 0;

        int[] sumFriendInLevels = new int[CommonConst.TOTAL_LEVELS];
        foreach (int level in friendLevelList)
        {
            sumFriendInLevels[level - 1]++;
        }
        int[] countFriendInLevels = new int[CommonConst.TOTAL_LEVELS];
        foreach (string avatarUrl in avatarUrlList)
        {
            if (i >= friendLevelList.Count)
            {
                break;
            }
            int level = friendLevelList[i];
            if (level <= CommonConst.TOTAL_LEVELS)
            {
                //Debug.Log(avatarUrl);
                Transform levelTransform = levelsTransform.GetChild(level - 1);

                GameObject friendAvatar = (GameObject)Instantiate(friendAvatarPrefab);
                friendAvatar.transform.SetParent(transform);
                friendAvatar.transform.position   = levelTransform.position + new Vector3(0.1f * (-(sumFriendInLevels[level - 1] - 1) / 2f + countFriendInLevels[level - 1]), 0);
                friendAvatar.transform.localScale = Vector3.one;
                FriendAvatar fAvatar = friendAvatar.GetComponent <FriendAvatar>();
                fAvatar.url   = avatarUrl;
                fAvatar.index = i;
                countFriendInLevels[level - 1]++;
            }
            i++;
        }
    }
        private static void LogErrorIfMissingAnswerInCrossword()
        {
            CrosswordGenerator generator = new CrosswordGenerator();
            var levels = AnagramLevelsController.instance.Levels;

            foreach (var level in levels)
            {
                var wordList = CUtils.BuildListFromString <string>(level.answers);
                generator.SetWords(wordList);
                generator.RTL = ConfigController.Config.isRightToLeftLanguage;
                var crossedWords = CrosswordShuffler.Generate(generator);
                if (generator.allWordsFit)
                {
                    continue;
                }

                Debug.LogError("Not all words fit in level word=" + level.word);
            }
        }
Ejemplo n.º 10
0
    private void Test_2()
    {
        for (int world = 0; world < 6; world++)
        {
            for (int sub = 0; sub < 5; sub++)
            {
                int num = dotMob.Utils.GetNumLevels(world, sub);
                for (int level = 0; level < num; level++)
                {
                    var gameLevel = Resources.Load <GameLevel>("World_" + world + "/SubWorld_" + sub + "/Level_" + level);

                    var answers = CUtils.BuildListFromString <string>(gameLevel.answers);
                    if (gameLevel.word.Contains("a") && gameLevel.word.Contains("m") && answers[0].Length == 2)
                    {
                        print(world + "|" + sub + "|" + level);
                    }
                }
            }
        }
    }
Ejemplo n.º 11
0
    public void Load(GameLevel gameLevel)
    {
        this.gameLevel = gameLevel;

        var wordList = CUtils.BuildListFromString <string> (this.gameLevel.answers);

        validWords = CUtils.BuildListFromString <string> (this.gameLevel.validWords);
        numWords   = wordList.Count;

        numCol = numWords <= 4 ? 1 :
                 numWords <= 10 ? 2 : 3;

        numRow = (int)Mathf.Ceil(numWords / (float)numCol);

        int maxCellInWidth = 0;

        for (int i = numRow; i <= numWords; i += numRow)
        {
            maxCellInWidth += wordList[i - 1].Length;
        }

        if (numWords % numCol != 0)
        {
            maxCellInWidth += wordList[numWords - 1].Length;
        }

        if (numCol > 1)
        {
            float coef = (maxCellInWidth + (maxCellInWidth - numCol) * Const.CELL_GAP_COEF + (numCol - 1) * Const.COL_GAP_COEF);
            cellSize = rt.rect.width / coef;
            float maxSize = rt.rect.height / (numRow + (numRow + 1) * Const.CELL_GAP_COEF);
            if (maxSize < cellSize)
            {
                cellSize       = maxSize;
                startFirstColX = (rt.rect.width - cellSize * coef) / 2f;
            }
        }
        else
        {
            cellSize = rt.rect.height / (numRow + (numRow - 1) * Const.CELL_GAP_COEF + 0.8f);
            float maxSize = rt.rect.width / (maxCellInWidth + (maxCellInWidth - 1) * Const.CELL_GAP_COEF);

            if (maxSize < cellSize)
            {
                hasLongLine = true;
                cellSize    = maxSize;
            }
        }

        string[] levelProgress = GetLevelProgress();

        int lineIndex = 0;

        //int levelProgressIndex = 0;
        foreach (var word in wordList)
        {
            LineWord line = Instantiate(MonoUtils.instance.lineWord);
            line.answer   = word.ToUpper();
            line.cellSize = cellSize;
            line.SetLineWidth();
            line.Build();

            if (levelProgress.Length > 0)
            {
                line.SetProgress(levelProgress[lineIndex]);
                //levelProgressIndex++;
            }

            line.transform.SetParent(transform);
            line.transform.localScale    = Vector3.one;
            line.transform.localPosition = Vector3.zero;

            lines.Add(line);
            lineIndex++;
        }

        CheckGameComplete();
        SetLinesPosition();
    }
Ejemplo n.º 12
0
    public static List <int> GetPanWordIndexes(int world, int subWorld, int level)
    {
        string data = PlayerPrefs.GetString("pan_word_indexes_v2_" + world + "_" + subWorld + "_" + level);

        return(CUtils.BuildListFromString <int>(data));
    }