Esempio n. 1
0
    private void DealCondition(int level, GameObject canvas)
    {
        Level levelConfig = LevelConfig.GetLevel(level);

        if (levelConfig == null)
        {
            levelConfig            = new Level();
            levelConfig.conditions = new Condition[0];
        }
        var conditions = canvas.transform.Find("UIConditions"); // all level item ui
        int itemNum    = conditions.childCount;                 // level item num

        for (int i = 0; i < itemNum; i++)
        {
            var conditionItem = conditions.GetChild(i).gameObject;
            var text          = conditionItem.transform.Find("Text");
            var recordText    = conditionItem.transform.Find("RecordText");          // 需要显示当前进度
            var finish1       = conditionItem.transform.Find("Finish1").gameObject;  // 完成打钩
            var finish2       = conditionItem.transform.Find("Finish2").gameObject;
            if (recordText != null)
            {
                recordText.gameObject.SetActive(false);
            }
            string resource = "UI/condition_";
            if (i >= levelConfig.conditions.Length)             // empty condition
            {
                resource += "off";
                text.GetComponent <Text>().text = "";
                finish1.SetActive(false);                 // 不打钩
                finish2.SetActive(false);
            }
            else
            {
                int achievementId = levelConfig.conditions[i].id;
                if (GetComponent <AchievementController>().GetAchievement(achievementId))
                {
                    resource += "on";
                    finish1.SetActive(true);                     // 打钩
                    finish2.SetActive(true);
                }
                else
                {
                    resource += "off";
                    finish1.SetActive(false);                    // 不打钩
                    finish2.SetActive(false);
                    if (recordText != null)                      // 显示进度数字
                    {
                        int record = GetComponent <AchievementController>().GetAchievementNum(achievementId);
                        recordText.GetComponent <Text>().text = record.ToString();
                        recordText.gameObject.SetActive(true);
                    }
                }
                Achievement achievementConfig = LevelConfig.GetAchievement(achievementId);
                text.GetComponent <Text>().text = achievementConfig.GetNumText(levelConfig.conditions[i].num);
            }
            var sprite = Resources.Load(resource, typeof(Sprite)) as Sprite;             // replace sprite color
            conditionItem.GetComponent <Image>().sprite = sprite;
        }
    }
Esempio n. 2
0
    private void DealLevelItem(GameObject levelItem, int level, bool needMask)
    {
        Level levelConfig = LevelConfig.GetLevel(level);
        var   mask        = levelItem.transform.Find("Mask").gameObject; // unreachable mask
        var   text        = levelItem.transform.Find("Text").gameObject; // name text

        if (levelConfig == null)                                         // not exist level
        {
            mask.SetActive(true);
            text.GetComponent <Text>().text = "";
            return;
        }
        mask.SetActive(needMask);
        text.GetComponent <Text>().text = levelConfig.name;                                       // name
        var sprite = Resources.Load("UI/level_" + levelConfig.quality, typeof(Sprite)) as Sprite; // replace sprite color

        levelItem.GetComponent <Image>().sprite = sprite;
    }
Esempio n. 3
0
 public void OnGameStartButtonPressed()
 {
     m_stateMachine.ChangeState(new GameState());
     PuzzleManager.Instance.InitializeNewPuzzle(InitialRowCount, LevelConfig.GetLevel(CurrentLevel));
 }