static int UpdateInto(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 6);
         SqliteDbHelper obj  = (SqliteDbHelper)ToLua.CheckObject(L, 1, typeof(SqliteDbHelper));
         string         arg0 = ToLua.CheckString(L, 2);
         string[]       arg1 = ToLua.CheckStringArray(L, 3);
         string[]       arg2 = ToLua.CheckStringArray(L, 4);
         string         arg3 = ToLua.CheckString(L, 5);
         string         arg4 = ToLua.CheckString(L, 6);
         Mono.Data.Sqlite.SqliteDataReader o = obj.UpdateInto(arg0, arg1, arg2, arg3, arg4);
         ToLua.PushObject(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Exemple #2
0
    void OnGUI()
    {
        if (Time.timeScale == 0)
        {
            if (GUI.Button(new Rect(Screen.width * 0.5f - 50, Screen.height * 0.4f, 100, 30), "继续游戏"))
            {
                Time.timeScale = 1;
            }
            //退出游戏
            if (GUI.Button(new Rect(Screen.width * 0.5f - 50, Screen.height * 0.6f, 100, 30), "退出游戏"))
            {
                Application.Quit();
            }
        }

        int life = 0;

        if (m_player != null)
        {
            life = (int)m_player.m_life;
        }
        else
        {
            //放大字体
            GUI.skin.label.fontSize = 50;

            //提示游戏失败
            GUI.skin.label.alignment = TextAnchor.LowerCenter;
            GUI.Label(new Rect(0, Screen.height * 0.2f, Screen.width, 60), "游戏失败");


            GUI.skin.label.fontSize = 20;
            //显示按钮
            if (GUI.Button(new Rect(Screen.width * 0.5f - 50, Screen.height * 0.5f + 150, 100, 30), "再试一次"))
            {
                Application.LoadLevel(Application.loadedLevelName);
            }


            //获取最小成绩
            int min = IntScore[0];
            for (int i = 0; i < IntScore.Length; i++)
            {
                if (IntScore[i] < min)
                {
                    min = IntScore[i];
                }
            }
            //如果进入前五 提示
            if (m_score >= min)
            {
                //放大字体
                GUI.skin.label.fontSize = 50;
                //提示游戏失败
                GUI.skin.label.alignment = TextAnchor.LowerCenter;
                GUI.Label(new Rect(0, Screen.height * 0.5f - 50, Screen.width, 60), "您破了纪录");
                GUI.skin.label.fontSize = 30;

                //将高分代替低分
                db.UpdateInto("five", m_score, min);
                db.CloseSqlConnection();
                Debug.Log("close table ok");

                //在数组中重新排位
                for (int i = 0; i < IntScore.Length; i++)
                {
                    if (IntScore[i] == min)
                    {
                        IntScore[i] = m_score;
                        break;
                    }
                }
            }
            if (GUI.Button(new Rect(Screen.width * 0.5f - 50, Screen.height * 0.5f + 50, 100, 30), "查看记录"))
            {
                buttonDown = true;
                //endConnection();
                Debug.Log(score.Count);
            }
        }
        if (buttonDown == true)
        {
            for (int i = 0; i < IntScore.Length; i++)
            {
                GUI.skin.label.fontSize  = 30;
                GUI.skin.label.alignment = TextAnchor.LowerCenter;
                GUI.Label(new Rect(Screen.width * 0.5f + 150, Screen.height * 0.5f + 50, 100, (i + 1) * 40), IntScore[i].ToString());
            }

            //db.CloseSqlConnection();
        }
        GUI.skin.label.fontSize = 15;
        //显示生命值
        GUI.Label(new Rect(5, 5, 100, 30), "装甲  " + life);
        //show the highScore
        GUI.skin.label.alignment = TextAnchor.LowerCenter;
        GUI.Label(new Rect(0, 5, Screen.width, 30), "记录" + m_hiscore);
        //shou the score you get
        GUI.Label(new Rect(0, 25, Screen.width, 30), "得分" + m_score);
    }
Exemple #3
0
    void OnGUI()
    {
        if (GUILayout.Button("create table"))
        {
            db.CreateTable("mytable", new string[] { "id", "name", "email" }, new string[] { "int", "varchar(20)", "varchar(50)" });
            Debug.Log("create table ok");
        }

        if (GUILayout.Button("insert data"))
        {
            db.InsertInto("mytable",
                          new string[] { "" + (++id), "'随风去旅行" + id + "'", "'zhangj_live" + id + "@163.com'" });

            Debug.Log("insert table ok");
        }
        if (GUILayout.Button("insert data specific"))
        {
            db.InsertIntoSpecific("mytable",
                                  new string[] { "name", "id" }, new string[] { "'随风去旅行6'", "99" });

            Debug.Log("insert data specific ok");
        }
        if (GUILayout.Button("Delete data"))
        {
            db.Delete("mytable",
                      new string[] { "name" }, new string[] { "'随风去旅行6'" });

            Debug.Log("Delete data ok");
        }
        if (GUILayout.Button("Read Full Table"))
        {
            IDataReader sqReader = db.ReadFullTable("mytable");
            while (sqReader.Read())
            {
                string id = "id=" + sqReader.GetInt32(sqReader.GetOrdinal("id"));
                name = "name=" + sqReader.GetString(sqReader.GetOrdinal("name"));
                emls = "email=" + sqReader.GetString(sqReader.GetOrdinal("email"));
                Debug.LogError(id + "/" + name + "/" + emls);
            }

            Debug.Log("Read Full Table ok");
        }

        if (GUILayout.Button("search database"))
        {
            IDataReader sqReader = db.SelectWhere("mytable", new string[] { "name", "email" }, new string[] { "id" }, new string[] { "=" }, new string[] { "2" });
            while (sqReader.Read())
            {
                name = "name=" + sqReader.GetString(sqReader.GetOrdinal("name"));
                emls = "email=" + sqReader.GetString(sqReader.GetOrdinal("email"));
            }
        }

        if (GUILayout.Button("Update data"))
        {
            db.UpdateInto("mytable",
                          new string[] { "name", "email" }, new string[] { "'吴小雄'", "'吴小雄21a'" },
                          "id", "5");

            Debug.Log("Update data ok");
        }

        if (name != "")
        {
            GUI.Label(new Rect(100, 100, 100, 100), name);
            GUI.Label(new Rect(100, 200, 100, 100), emls);
            //  GUILayout.Label(emls);
        }
        if (GUILayout.Button("close database"))
        {
            db.CloseSqlConnection();
            Debug.Log("close table ok");
        }
    }