Exemple #1
0
    public themeRecord[] getThemes(int limit)
    {
        string query = "SELECT * FROM themes ORDER BY id";

        if (limit > 0)
        {
            query += " LIMIT " + limit;
        }

        try {
            dbcmd             = dbcon.CreateCommand();
            dbcmd.CommandText = query;
            reader            = dbcmd.ExecuteReader();
        } catch (Exception e) {
            Debug.Log(e);
            errMsg = e.ToString();
            return(null);
        }

        System.Collections.Generic.List <themeRecord> themes = new System.Collections.Generic.List <themeRecord>();
        while (reader.Read())
        {
            int         id      = reader.GetInt32(0);
            string      name    = reader.GetString(1);
            string      imgPath = reader.GetString(2);
            float       score   = reader.GetFloat(3);
            themeRecord _theme  = new themeRecord(id, name, score, imgPath);
            themes.Add(_theme);
        }

        return(themes.ToArray());
    }
Exemple #2
0
    public bool updateTheme(themeRecord theme)
    {
        string query = "UPDATE themes SET score ='" + theme.score + "' WHERE id = '" + theme.id + "'";

        try {
            dbcmd             = dbcon.CreateCommand();
            dbcmd.CommandText = query;
            reader            = dbcmd.ExecuteReader();
        } catch (Exception e) {
            Debug.Log(e);
            errMsg = e.ToString();
            return(false);
        }

        return(true);
    }
Exemple #3
0
 //update given theme's score
 public bool updateTheme(themeRecord theme)
 {
     return(updateTheme(theme.id, theme.score));
 }
Exemple #4
0
    // Use this for initialization
    void Start()
    {
        // 設定UI位置
        float h = Screen.height;
        float w = Screen.width;

        rRank          = new Rect(0, 0, h * 0.3f, h * 0.3f);
        rRank.center   = new Vector2(w * 0.5f, h * 0.5f);
        rNextChapter   = new Rect(rRank);
        rNextChapter.x = w - h * 0.3f;
        rTryAgain      = new Rect(rRank);
        rTryAgain.x    = 0;
        rChapter       = new Rect(w - 100.0f, h - 50.0f, 100.0f, 50.0f);
        rTitle         = new Rect(0.0f, h - 50.0f, 100.0f, 50.0f);
        rTheme         = new Rect(w * 0.5f - 50, h - 50.0f, 100.0f, 50.0f);

        // 初始化章節資訊
        currentTheme   = DataManager.modelComponent.getTheme(Global.Instance.seletedTheme);
        nextTheme      = DataManager.modelComponent.getTheme(Global.Instance.seletedTheme + 1);
        currentChapter = currentTheme.chapters[Global.Instance.seletedChapter];
        if (Global.Instance.seletedChapter + 1 < currentTheme.chapters.Length)
        {
            nextChapter = currentTheme.chapters[Global.Instance.seletedChapter + 1];
        }
        else
        {
            nextChapter = null;
        }

        // 計算此次遊戲結果
        if (Global.Instance.battleResult > (float)Rank.A)
        {
            rank = "A";
        }
        else if (Global.Instance.battleResult > (float)Rank.B)
        {
            rank = "B";
        }
        else if (Global.Instance.battleResult > (float)Rank.C)
        {
            rank = "C";
        }
        return;

        scoreIncrease = Global.Instance.battleResult - currentChapter.score;

        // 若分數沒有增加則不更新結果
        if (scoreIncrease < 0.0f)
        {
            return;
        }

        // 更新結果
        currentChapter.score = Global.Instance.battleResult;
        currentTheme.score  += scoreIncrease;

        // 若有下一關且分數大於門檻值則解鎖下一關
        if (nextChapter != null && currentChapter.score >= chapterThreshold)
        {
            nextChapter.status = chapterRecord.ChapterStatus.unlocked;
        }

        if (nextTheme != null && currentTheme.score >= themeThreshold)
        {
            nextTheme.status = themeRecord.ThemeStatus.unlocked;
        }

        // 將結果寫入資料庫
        DataManager.UpdateChapter(nextChapter);
        DataManager.UpdateTheme(nextTheme);
    }
 //*
 public static void UpdateTheme(themeRecord theme)
 {
 }    //*/