Exemple #1
0
    // 检查一个等级是否通过
    public bool CheckLevel()
    {
        if (GetComponent <LevelController> ().NextLevelConfig == null)        // 已经到了最高级
        {
            return(false);
        }
        var  conditions = GetComponent <LevelController> ().NextLevelConfig.conditions;       // check this level condition
        bool allPassed  = true;

        foreach (var condition in conditions)
        {
            if (!this.GetAchievement(condition.id))
            {
                allPassed = false;
                break;
            }
        }
        if (allPassed)         // all passed, level up
        {
            GetComponent <LevelController> ().LevelUp();
            this.ResetAchievement();
            // 播放升级动画
            AniInfo aniInfo  = new AniInfo(AniLevelUp);
            Level   curLevel = GetComponent <LevelController> ().CurLevelConfig;
            this.PlayAni(aniInfo.AddParam("level", curLevel.name).AddParam("quality", curLevel.quality.ToString()));
            this.NewHighestScore(GetComponent <ScoreController>().CurScore);            // 再判断一次最高分
        }
        return(allPassed);
    }
Exemple #2
0
    // check and save achievement,返回是否升级
    private void CheckNum(int id, int num, int oldNum, bool checkLevel)
    {
        int needNum = this.GetAchievementNeedNum(id);

        if (needNum == -1)
        {
            return;
        }
        if (num >= needNum)         // passed
        {
            SetAchievement(id, true);
            // 播放通过条件动画
            AniInfo aniInfo = new AniInfo(AniConditionPass);
            string  txt     = LevelConfig.GetAchievement(id).GetNumText(this.GetAchievementNeedNum(id, true));
            this.PlayAni(aniInfo.AddParam("condition", txt));

            if (checkLevel)
            {
                this.CheckLevel();                 // 检查等级
            }
        }
        else if (id != 3003)
        {
            // 播放进度动画
            string  txt     = LevelConfig.GetAchievement(id).GetNumText(this.GetAchievementNeedNum(id, true));
            AniInfo aniInfo = new AniInfo(AniConditionProgress);
            this.PlayAni(aniInfo.AddParam("condition", txt).AddParam("oldNum", oldNum.ToString()).AddParam("newNum", num.ToString()));
        }
    }