Esempio n. 1
0
    public chapterRecord[] getChapters(int themeId)
    {
        string query = "SELECT * FROM enemies WHERE themeId = '" + themeId + "' ORDER BY number";

        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 <chapterRecord> chapters = new System.Collections.Generic.List <chapterRecord>();
        while (reader.Read())
        {
            int           id       = reader.GetInt32(0);
            string        name     = reader.GetString(2);
            string        imgPath  = reader.GetString(3);
            float         score    = reader.GetFloat(4);
            chapterRecord _chapter = new chapterRecord(id, themeId, name, score, imgPath);
            chapters.Add(_chapter);
        }

        return(chapters.ToArray());
    }
Esempio n. 2
0
    public bool updateChapter(chapterRecord chapter)
    {
        string query = "UPDATE enemies SET score ='" + chapter.score + "' ";

        query += "WHERE number = '" + chapter.id + "' AND themeId = '" + chapter.themeId + "'";

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

        return(true);
    }
Esempio n. 3
0
 //update given chapter's score
 public bool updateChapter(chapterRecord chapter)
 {
     return(updateChapter(chapter.id, chapter.themeId, chapter.score));
 }
Esempio n. 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);
    }
Esempio n. 5
0
    }    //*/

    public static void UpdateChapter(chapterRecord chapter)
    {
    }