示例#1
0
 private void Update()
 {
     MissionFinishChecker();//每次检查任务是否完成
     try
     {
         MissionSql.CloseConnection();
     }
     catch (Exception)
     {
     }
     if (Missions_SetToOne.Count != 0)
     {
         foreach (int MissionID in Missions_SetToOne)
         {
             if (MissionID != 0)
             {
                 SetMissionDone(MissionID);
             }
         }
         Missions_SetToOne.Clear();
         Debug.Log("MissionSetToOne Has " + Missions_SetToOne.Count);
     }
     if (CurrentListCount != MissionProcessingList.Count)//当正在进行的任务列表中的数量发生改变的时候更新UI
     {
         //Debug.Log("Test");
         CurrentListCount = MissionProcessingList.Count;
         UpdateUIMissionDescription();
     }
 }
 private void OnApplicationQuit()
 {
     if (sql != null)
     {
         //关闭数据库连接
         sql.CloseConnection();
     }
 }
示例#3
0
    public static int AddItemToList(string NPCName, int MissionID)
    {
        MissionSql = new SQLiteHelper("data source=Missions.db");
        if (MissionProcessingList.Count >= 3)
        {
            //从这个地方开始拦截,尚需修改
            Debug.Log("任务已满!");
            MissionSql.CloseConnection();
            return(2);
        }
        else
        {
            //搜索相关任务,如果有就返回1
            string           NPCName_string   = "\'" + NPCName + "\'";
            string           MissionID_string = "\"" + MissionID + "\"";
            SqliteDataReader reader           = MissionSql.ReadTable("MissionInfo", new string[] { "MissionID", "NPCName", "MissionType", "TargetName", "ProcessingCount", "TargetCount" }, new string[] { "NPCName", "State", "TriggerDay" }, new string[] { "=", "=", "<=" }, new string[] { NPCName_string, "0", "\"" + BasicInformation.Day + "\"" });//此处记得加上时间判断,用于筛选出改NPC可行的任务
            if (reader.Read())
            {
                MissionProcessingList.Add(new Tuple <String, int>(reader.GetString(reader.GetOrdinal("NPCName")), reader.GetInt32(reader.GetOrdinal("MissionID"))));
                SetItemState(reader.GetInt32(reader.GetOrdinal("MissionID")));//改为2
                Debug.Log("MissionID = " + reader.GetInt32(reader.GetOrdinal("MissionID")));
                Debug.Log("任务已添加");
                //在这里更新这个表
                ArrayList MissionDetailInfo = MissionInfoArrayListChooser();//任务完成之后记得clear则会个MissionDetailInfo
                MissionDetailInfo.Add(reader.GetInt32(reader.GetOrdinal("MissionID")));
                MissionDetailInfo.Add(reader.GetInt32(reader.GetOrdinal("MissionType")));
                MissionDetailInfo.Add(reader.GetString(reader.GetOrdinal("TargetName")));
                MissionDetailInfo.Add(reader.GetInt32(reader.GetOrdinal("ProcessingCount")));
                MissionDetailInfo.Add(reader.GetInt32(reader.GetOrdinal("TargetCount")));
                Debug.Log("任务类型为:" + (int)MissionDetailInfo[1]);
                //Debug.Log((int)MissionDetailInfo[1] == 3);
                if ((int)MissionDetailInfo[1] == 3)//如果任务为聊天任务直接就进入结算状态
                {
                    Debug.Log("聊天任务");
                    MissionSql.UpdateValues("MissionInfo", new string[] { "State" }, new string[] { "3" }, "MissionID", "=", "\"" + reader.GetInt32(reader.GetOrdinal("MissionID")) + "\"");
                }
                MissionSql.CloseConnection();
                return(1);
            }
            else//没有这个NPC,或者这个NPC在这个日期没有任务
            {
                Debug.Log("没有这个NPC,或者这个NPC在这个日期没有任务");

                MissionSql.CloseConnection();
                return(0);
            }
            //如果没有就返回0
        }
    }
示例#4
0
    public static void CancelTheMission(string NPCName, string MissionID_string)
    {
        MissionProcessingList.Remove(new Tuple <String, int>(NPCName, Convert.ToInt32(MissionID_string)));

        MissionSql.CloseConnection();
        MissionSql = new SQLiteHelper("data source=Missions.db");


        SqliteDataReader reader = MissionSql.ReadTable("MissionInfo", new string[] { "NPCName", "State", "MissionDescription" }, new string[] { "MissionID" }, new string[] { "=" }, new string[] { MissionID_string });

        reader.Read();

        if (reader.GetInt32(reader.GetOrdinal("State")) != 1)
        {
            //MissionProcessingList.Remove(reader.GetString(reader.GetOrdinal("NPCName")));
            string MissionDescription = reader.GetString(reader.GetOrdinal("MissionDescription"));
            for (int i = 0; i < 3; i++)//伪更新,实际上只是把内容设置为空了
            {
                if (MissionUIList[i].text == MissionDescription)
                {
                    MissionUIList[i].text = "";
                }
            }
            DialogController.ResetDialogsToAble(MissionID_string);
            MissionSql.UpdateValues("MissionInfo", new string[] { "State" }, new string[] { "0" }, "MissionID", "=", MissionID_string);
        }
        MissionSql.CloseConnection();
        Debug.Log("任务已清除");
    }
示例#5
0
    public static void UpdateByObjectNameAndCount(string ObjectName, int Count)//增加物品数量(大于1)
    {
        PackageInfo = new SQLiteHelper("data source = Package.db");
        string           ObjectName_string = "\'" + ObjectName + "\'";
        SqliteDataReader reader;

        reader = PackageInfo.ReadTable("PackageInfo", new string[] { "ObjectCount", "ObjectLimitCount" }, new string[] { "ObjectName" }, new string[] { "=" }, new string[] { ObjectName_string });
        reader.Read();
        int ObjectCount = reader.GetInt32(reader.GetOrdinal("ObjectCount"));

        int ObjectLimitCount = reader.GetInt32(reader.GetOrdinal("ObjectLimitCount"));

        int ActualAdd;

        if (ObjectCount + Count > ObjectLimitCount)
        {
            ActualAdd = ObjectLimitCount;
        }
        else
        {
            ActualAdd = ObjectCount + Count;
        }
        string ActualAdd_String = "\"" + ActualAdd + "\"";

        PackageInfo.UpdateValues("PackageInfo", new string[] { "ObjectCount" }, new string[] { ActualAdd_String }, "ObjectName", "=", ObjectName_string);
        PackageInfo.CloseConnection();
    }
示例#6
0
    public static int FindFinishMission(string NPCFinish)//判断当前NPC有没有结算的任务
    {
        MissionSql = new SQLiteHelper("data source=Missions.db");
        string           Mission_string;
        string           NPCName_string;//传入的是用于判断有无结算的NPC,所以是NPCFinish
        SqliteDataReader reader;

        foreach (Tuple <String, int> kvp in MissionProcessingList)
        {
            Mission_string = "\"" + kvp.Item2 + "\"";
            NPCName_string = "\'" + NPCFinish + "\'";
            Debug.Log(NPCFinish + " and " + kvp.Item2);
            reader = MissionSql.ReadTable("MissionInfo", new string[] { "State" }, new string[] { "MissionID", "NPCFinish", "State" }, new string[] { "=", "=", "=" }, new string[] { Mission_string, NPCName_string, "3" });
            try
            {
                reader.Read();
                if (reader.GetInt32(reader.GetOrdinal("State")) == 3)
                {
                    MissionProcessingList.Remove(kvp);
                    return(kvp.Item2);//返回任务ID
                }
            }
            catch (Exception)
            {
                //Debug.Log("Nope");
            }
        }
        MissionSql.CloseConnection();
        return(0);
    }
示例#7
0
    public static int TakeResource(String ResourceName, int TakeNumber, bool MustTake)//MustTake表示一定要取,True代表不够也要取走,False代表不够就不取走
    {
        int              ActuallyTake        = 0;
        string           ResourceName_String = "\'" + ResourceName + "\'";
        SqliteDataReader reader;

        PackageInfo = new SQLiteHelper("data source=Package.db");
        reader      = PackageInfo.ReadTable("PackageInfo", new string[] { "ObjectCount" }, new string[] { "ObjectName" }, new string[] { "=" }, new string[] { ResourceName_String });
        reader.Read();
        int AlreadyHave = reader.GetInt32(reader.GetOrdinal("ObjectCount"));

        if (AlreadyHave >= TakeNumber)
        {
            ActuallyTake = TakeNumber;//如果现有数量大于要取数量,就按需求拿走
            int RemainNumber = AlreadyHave - ActuallyTake;
            PackageInfo.UpdateValues("PackageInfo", new string[] { "ObjectCount" }, new string[] { "\"" + RemainNumber + "\"" }, "ObjectName", "=", ResourceName_String);
        }
        else if (AlreadyHave < TakeNumber && MustTake)
        {
            ActuallyTake = AlreadyHave;//如果现有数量小于要取数量,就要多少取多少
            PackageInfo.UpdateValues("PackageInfo", new string[] { "ObjectCount" }, new string[] { "\"" + 0 + "\"" }, "ObjectName", "=", ResourceName_String);
        }
        else
        {
            ActuallyTake = -1;
        }

        PackageInfo.CloseConnection();
        return(ActuallyTake);
    }
示例#8
0
    public static void SetMissionDone(int MissionID)//将任务设为1,即已经完成永远不可读
    {
        string MissionID_string = "\"" + MissionID + "\"";

        MissionSql = new SQLiteHelper("data source=Missions.db");
        //Debug.Log(MissionID_string);

        SqliteDataReader reader = MissionSql.ReadTable("MissionInfo", new string[] { "NPCName", "MissionDescription" }, new string[] { "MissionID" }, new string[] { "=" }, new string[] { MissionID_string });

        reader.Read();


        MissionProcessingList.Remove(new Tuple <String, int>(reader.GetString(reader.GetOrdinal("NPCName")), MissionID));
        string MissionDescription = reader.GetString(reader.GetOrdinal("MissionDescription"));

        for (int i = 0; i < 3; i++)//伪更新,实际上只是把内容设置为空了
        {
            if (MissionUIList[i].text == MissionDescription)
            {
                MissionUIList[i].text = "";
            }
        }
        MissionDetailClear(MissionID);
        MissionSql.UpdateValues("MissionInfo", new string[] { "State" }, new string[] { "1" }, "MissionID", "=", MissionID_string);
        MissionSql.CloseConnection();
    }//会发生死锁
示例#9
0
    /// <summary>
    /// 更新数据
    /// </summary>
    /// <param name="dbName"></param>
    /// <param name="mainTable"></param>
    /// <param name="dataNames"></param>
    /// <param name="dataValue"></param>
    /// <param name="key"></param>
    /// <param name="operation"></param>
    /// <param name="value"></param>
    public static void UpdateTableData(string dbName, string mainTable, string[] dataNames, string[] dataValue, string key, string operation, string value)
    {
        if (key == null || operation == null || value == null)
        {
            key       = "id";
            operation = "!=";
            value     = "0";
        }
        SQLiteHelper sql = GetSQLiteHelper(dbName);

        try
        {
            sql.UpdateValues(mainTable, dataNames, dataValue, key, operation, value);
        }
        catch (Exception e)
        {
            LogUtil.Log("更新数据:" + e.Message);
        }
        finally
        {
            if (sql != null)
            {
                sql.CloseConnection();
            }
        }
    }
 public static void ResetDialogsToAble(string MissionID_string)
 {
     DialogSql = new SQLiteHelper("data source=Dialogs.db");
     Debug.Log(MissionID_string);
     DialogSql.ExecuteQuery("UPDATE NPCDialog SET IsTriggle = 0 WHERE ConversationID = " + MissionID_string + " AND IsTriggle = 1");
     DialogSql.ExecuteQuery("UPDATE PlayerDialog SET IsTriggle = 0 WHERE ConversationID = " + MissionID_string + " AND IsTriggle = 1");
     DialogSql.CloseConnection();
 }
示例#11
0
    void Start()
    {
        //创建名为sqlite4unity的数据库
        sql = new SQLiteHelper("data source=sqlite4unity.db");

        //创建名为table1的数据表
        //sql.CreateTable("table1", new string[] { "ID", "Name", "Age", "Email" }, new string[] { "INTEGER", "TEXT", "INTEGER", "TEXT" });

        //插入两条数据
        sql.InsertValues("table1", new string[] { "'1'", "'张三'", "'22'", "'*****@*****.**'" });
        sql.InsertValues("table1", new string[] { "'2'", "'李四'", "'25'", "'*****@*****.**'" });

        //更新数据,将Name="张三"的记录中的Name改为"Zhang3"
        sql.UpdateValues("table1", new string[] { "Name" }, new string[] { "'wang5'" }, "Name", "=", "'王五'");

        //插入3条数据
        sql.InsertValues("table1", new string[] { "3", "'王五'", "25", "'*****@*****.**'" });
        sql.InsertValues("table1", new string[] { "4", "'王五'", "26", "'*****@*****.**'" });
        sql.InsertValues("table1", new string[] { "5", "'王五'", "27", "'*****@*****.**'" });

        //删除Name="王五"且Age=26的记录,DeleteValuesOR方法类似
        sql.DeleteValuesAND("table1", new string[] { "Name", "Age" }, new string[] { "=", "=" }, new string[] { "'王五'", "'26'" });

        //读取整张表
        SqliteDataReader reader = sql.ReadFullTable("table1");

        while (reader.Read())
        {
            //读取ID
            Debug.Log(reader.GetInt32(reader.GetOrdinal("ID")));
            //读取Name
            Debug.Log(reader.GetString(reader.GetOrdinal("Name")));
            //读取Age
            Debug.Log(reader.GetInt32(reader.GetOrdinal("Age")));
            //读取Email
            Debug.Log(reader.GetString(reader.GetOrdinal("Email")));
        }

        //读取数据表中Age>=25的所有记录的ID和Name
        reader = sql.ReadTable("table1", new string[] { "ID", "Name" }, new string[] { "Age" }, new string[] { ">=" }, new string[] { "'25'" });
        while (reader.Read())
        {
            //读取ID
            Debug.Log(reader.GetInt32(reader.GetOrdinal("ID")));
            //读取Name
            Debug.Log(reader.GetString(reader.GetOrdinal("Name")));
        }

        //自定义SQL,删除数据表中所有Name="王五"的记录
        sql.ExecuteQuery("DELETE FROM table1 WHERE NAME='王五'");

        sql.InsertValues("table1", new string[] { "3", "'王五'", "25", "'*****@*****.**'" });
        sql.InsertValues("table1", new string[] { "4", "'王五'", "26", "'*****@*****.**'" });
        sql.InsertValues("table1", new string[] { "5", "'王五'", "27", "'*****@*****.**'" });

        //关闭数据库连接
        sql.CloseConnection();
    }
示例#12
0
 private void Start()
 {
     MissionUIList.Add(MissionDiscribe_1);
     MissionUIList.Add(MissionDiscribe_2);
     MissionUIList.Add(MissionDiscribe_3);
     MissionSql = new SQLiteHelper("data source=Missions.db");
     Missions_SetToOne.Clear();
     InitList();
     MissionSql.CloseConnection();
 }
示例#13
0
    public static void ReadSqlite()
    {
        var dbHelper = new SQLiteHelper(SqlitePath, false);

        ReadTable <PlayerData>(dbHelper);
        // ReadTable<Test2Data>(dbHelper);
        // ReadTable<PassengerData>(dbHelper);


        dbHelper.CloseConnection();
    }
示例#14
0
    public static void UIUpdateObject(string ObjectName)//对单个物品数量进行数据库同步,用于没必要更新全部值的时候
    {
        string Name_string = "\"" + ObjectName + "\"";

        PackageInfo = new SQLiteHelper("data source = Package.db");
        SqliteDataReader reader;

        reader = PackageInfo.ReadTable("PackageInfo", new string[] { "ObjectCount" }, new string[] { "ObjectName" }, new string[] { "=" }, new string[] { Name_string });
        reader.Read();
        UISpriteList[ObjectName].transform.Find("Amount").gameObject.GetComponent <UILabel>().text = reader.GetInt32(reader.GetOrdinal("ObjectCount")).ToString();
        PackageInfo.CloseConnection();
    }
示例#15
0
    /// <summary>
    /// 读取表数据
    /// </summary>
    /// <typeparam name="T"></typeparam>
    /// <param name="dbName"></param>
    /// <param name="mainTable"></param>
    /// <param name="leftTableName"></param>
    /// <param name="mainKey"></param>
    /// <param name="leftKey"></param>
    /// <param name="mainColNames"></param>
    /// <param name="mainOperations"></param>
    /// <param name="mainColValues"></param>
    /// <returns></returns>
    public static List <T> LoadTableData <T>(string dbName, string mainTable, string[] leftTableName, string mainKey, string[] leftKey, string[] mainColNames, string[] mainOperations, string[] mainColValues)
    {
        SQLiteHelper     sql      = GetSQLiteHelper(dbName);
        SqliteDataReader reader   = null;
        List <T>         listData = new List <T>();

        try
        {
            T             tempData     = Activator.CreateInstance <T>();
            List <String> dataNameList = ReflexUtil.getAllName(tempData);
            reader = sql.ReadTable(mainTable, leftTableName, mainKey, leftKey, mainColNames, mainOperations, mainColValues);
            while (reader.Read())
            {
                T itemData = Activator.CreateInstance <T>();

                int dataNameSize = dataNameList.Count;
                for (int i = 0; i < dataNameSize; i++)
                {
                    string dataName = dataNameList[i];
                    int    ordinal  = reader.GetOrdinal(dataName);
                    if (ordinal == -1)
                    {
                        continue;
                    }

                    string name  = reader.GetName(ordinal);
                    object value = reader.GetValue(ordinal);
                    if (value != null && !value.ToString().Equals(""))
                    {
                        ReflexUtil.setValueByName(itemData, dataName, value);
                    }
                }
                listData.Add(itemData);
            }
            return(listData);
        }
        catch (Exception e)
        {
            LogUtil.log("查询表失败-" + e.Message);
            return(null);
        }
        finally
        {
            if (sql != null)
            {
                sql.CloseConnection();
            }
            if (reader != null)
            {
                reader.Close();
            }
        }
    }
示例#16
0
    public static int CheckMissionState(int MissionID)
    {
        int    State;
        string MissionID_string = "\"" + MissionID + "\"";

        MissionSql = new SQLiteHelper("data source=Missions.db");
        SqliteDataReader reader = MissionSql.ReadTable("MissionInfo", new string[] { "State" }, new string[] { "MissionID" }, new string[] { "=" }, new string[] { MissionID_string });

        reader.Read();
        State = reader.GetInt32(reader.GetOrdinal("State"));
        MissionSql.CloseConnection();
        return(State);
    }
示例#17
0
 public static void UIUpdate()//更新所有物品数量
 {
     foreach (KeyValuePair <string, UISprite> Item in UISpriteList)
     {
         string Name = Item.Key;
         //Debug.Log(Name);
         string Name_string = "\"" + Name + "\"";
         PackageInfo = new SQLiteHelper("data source = Package.db");
         SqliteDataReader reader;
         reader = PackageInfo.ReadTable("PackageInfo", new string[] { "ObjectCount" }, new string[] { "ObjectName" }, new string[] { "=" }, new string[] { Name_string });
         reader.Read();
         Item.Value.transform.Find("Amount").gameObject.GetComponent <UILabel>().text = reader.GetInt32(reader.GetOrdinal("ObjectCount")).ToString();
         PackageInfo.CloseConnection();
     }
 }
 public void AcceptButton()
 {
     //Debug.Log("Accept the mission");
     GameObject.Find("DialogBox").GetComponent <TweenPosition>().PlayReverse();
     GameObject.Find("DialogBox").transform.Find("AcceptButton").gameObject.SetActive(false);
     GameObject.Find("DialogBox").transform.Find("CancelButton").gameObject.SetActive(false);
     DialogSql = new SQLiteHelper("data source=Dialogs.db");
     DialogSql.ExecuteQuery("UPDATE PlayerDialog SET IsTriggle = 1 WHERE ConversationID = " + NPCDialogList[0] + " AND IsTriggle = 0"); //这两句要单独拿出来,只有触发了Accept行为才会修改
     DialogSql.ExecuteQuery("UPDATE NPCDialog SET IsTriggle = 1 WHERE ConversationID = " + NPCDialogList[0] + " AND IsTriggle = 0");    //Accept行为需要包括两个修改
     DialogSql.CloseConnection();
     IsFinish        = true;
     FirstTimeToRead = true;
     CallReset();
     Player.GetComponent <BasicMove>().SetControllable(true);
 }
示例#19
0
    }//会发生死锁

    public static void UpdateUIMissionDescription()
    {
        MissionSql = new SQLiteHelper("data source=Missions.db");
        SqliteDataReader reader;
        int Counter = 0;

        foreach (Tuple <string, int> kvp in MissionProcessingList)
        {
            string MissionID_string = "\"" + kvp.Item2 + "\"";
            reader = MissionSql.ReadTable("MissionInfo", new string[] { "MissionDescription" }, new string[] { "MissionID" }, new string[] { "=" }, new string[] { MissionID_string });
            reader.Read();
            MissionUIList[Counter].text = reader.GetString(reader.GetOrdinal("MissionDescription"));
            //Debug.Log(MissionUIList[Counter]);
            Counter++;
        }
        MissionSql.CloseConnection();
    }
        public static void CreateDataBaseBySql()
        {
            string tempSqlPath = EditorUtility.OpenFilePanel("Load sql of Directory", Application.dataPath, "sql");

            try
            {
                string       tempSql    = File.ReadAllText(tempSqlPath);
                SQLiteHelper tempHelper = new SQLiteHelper(DbPath);
                Debug.Log(tempSql);
                tempHelper.ExecuteQuery(tempSql);
                tempHelper.CloseConnection();
            }
            catch (System.Exception e)
            {
                Debug.LogError(e.Message);
            }
        }
示例#21
0
    public static Tuple <string, int> GetRewardInfo(int Mission)
    {
        MissionSql.CloseConnection();
        String Mission_string = "\"" + Mission + "\"";

        MissionSql = new SQLiteHelper("data source=Missions.db");
        SqliteDataReader reader;

        reader = MissionSql.ReadTable("MissionInfo", new string[] { "MissionReward", "MissionRewardNumber" }, new string[] { "MissionID" }, new string[] { "=" }, new string[] { Mission_string });

        reader.Read();
        string MissionReward                  = reader.GetString(reader.GetOrdinal("MissionReward"));
        int    MissionRewardNumber            = reader.GetInt32(reader.GetOrdinal("MissionRewardNumber"));
        Tuple <string, int> MissionRewardInfo = new Tuple <string, int>(MissionReward, MissionRewardNumber);

        MissionSql.CloseConnection();
        return(MissionRewardInfo);
    }
示例#22
0
    public static void ObjectUpdate(string ObjectName)//增加物品数量(等于1)
    {
        PackageInfo = new SQLiteHelper("data source=Package.db");
        SqliteDataReader reader;
        string           ObjectName_string = "\'" + ObjectName + "\'";

        reader = PackageInfo.ReadTable("PackageInfo", new string[] { "ObjectCount", "ObjectLimitCount" }, new string[] { "ObjectName" }, new string[] { "=" }, new string[] { ObjectName_string });
        reader.Read();
        int    ObjectCount            = reader.GetInt32(reader.GetOrdinal("ObjectCount"));
        string ObjectCount_Add_String = "\"" + (ObjectCount + 1) + "\"";
        int    ObjectLimitCount       = reader.GetInt32(reader.GetOrdinal("ObjectLimitCount"));

        if (ObjectCount < ObjectLimitCount)
        {
            PackageInfo.UpdateValues("PackageInfo", new string[] { "ObjectCount" }, new string[] { ObjectCount_Add_String }, "ObjectName", "=", ObjectName_string);
        }
        PackageInfo.CloseConnection();
    }
示例#23
0
 private static void MissionFinishChecker() //将任务状态设置为待结算
 {
     if (MissionDetailInfo_1.Count != 0)    //当MissionDetailInfo有东西的时候进判断
     {
         if ((int)MissionDetailInfo_1[3] == (int)MissionDetailInfo_1[4])
         {
             //更新State为3,待结算
             MissionSql = new SQLiteHelper("data source=Missions.db");
             string MissionID_string = "\'" + (int)MissionDetailInfo_1[0] + "\'";
             MissionSql.UpdateValues("MissionInfo", new string[] { "State" }, new string[] { "3" }, "MissionID", "=", MissionID_string);
             Debug.Log("任务" + MissionDetailInfo_1[0] + "已完成");
             MissionDetailInfo_1.Clear();
             MissionSql.CloseConnection();
         }
     }
     if (MissionDetailInfo_2.Count != 0)
     {
         if ((int)MissionDetailInfo_2[3] == (int)MissionDetailInfo_2[4])
         {
             //同上
             MissionSql = new SQLiteHelper("data source=Missions.db");
             string MissionID_string = "\'" + (int)MissionDetailInfo_2[0] + "\'";
             MissionSql.UpdateValues("MissionInfo", new string[] { "State" }, new string[] { "3" }, "MissionID", "=", MissionID_string);
             Debug.Log("任务" + MissionDetailInfo_2[0] + "已完成");
             MissionDetailInfo_2.Clear();
             MissionSql.CloseConnection();
         }
     }
     if (MissionDetailInfo_3.Count != 0)
     {
         if ((int)MissionDetailInfo_3[3] == (int)MissionDetailInfo_3[4])
         {
             //同上
             MissionSql = new SQLiteHelper("data source=Missions.db");
             string MissionID_string = "\'" + (int)MissionDetailInfo_3[0] + "\'";
             MissionSql.UpdateValues("MissionInfo", new string[] { "State" }, new string[] { "3" }, "MissionID", "=", MissionID_string);
             Debug.Log("任务" + MissionDetailInfo_3[0] + "已完成");
             MissionDetailInfo_3.Clear();
             MissionSql.CloseConnection();
         }
     }
 }
    public void ReFreshData()//刷新对话
    {
        DialogSql = new SQLiteHelper("data source=Dialogs.db");


        PlayerDialogList = GetFinishedPlayerContent(NPCName);        //先看有没有结算对话
        NPCDialogList    = GetFinishedNPCContent(NPCName);
        if (NPCDialogList.Count <= 1 && PlayerDialogList.Count <= 1) //再看有没有任务对话
        {
            PlayerDialogList = GetPlayerContent(NPCName);            //两者直接引用传出的数据,所以第0项持续更新
            NPCDialogList    = GetNPCContent(NPCName);
            Debug.Log("查找任务对话");
            if (NPCDialogList.Count <= 1 && PlayerDialogList.Count <= 1)//最后看有没有任务执行中对话
            {
                PlayerDialogList = GetProcessingPlayerContent(NPCName);
                NPCDialogList    = GetProcessingNPCContent(NPCName);
                Debug.Log("查找执行任务中对话");
            }
        }
        DialogSql.CloseConnection();
    }
示例#25
0
    /// <summary>
    /// 创建表
    /// </summary>
    /// <param name="tableName"></param>
    /// <param name="dataTypeList"></param>
    public static void CreateTable(string dbName, string tableName, Dictionary <string, string> dataTypeList)
    {
        SQLiteHelper sql = GetSQLiteHelper(dbName);

        if (tableName == null)
        {
            LogUtil.Log("创建表失败,没有表名");
            return;
        }
        if (dataTypeList == null || dataTypeList.Count == 0)
        {
            LogUtil.Log("创建表失败,没有数据");
            return;
        }
        string[] keyNameList   = new string[dataTypeList.Count];
        string[] valueNameList = new string[dataTypeList.Count];
        int      position      = 0;

        foreach (var item in dataTypeList)
        {
            keyNameList[position]   = item.Key;
            valueNameList[position] = item.Value;
            position++;
        }
        try
        {
            sql.CreateTable(tableName, keyNameList, valueNameList);
        }
        catch (Exception e)
        {
            LogUtil.Log("创建表失败-" + e.Message);
        }
        finally
        {
            if (sql != null)
            {
                sql.CloseConnection();
            }
        }
    }
示例#26
0
    /// <summary>
    /// 插入数据
    /// </summary>
    /// <param name="dbName"></param>
    /// <param name="tableName"></param>
    /// <param name="keys"></param>
    /// <param name="values"></param>
    public static bool InsertValues(string dbName, string tableName, string[] keys, string[] values)
    {
        SQLiteHelper sql = GetSQLiteHelper(dbName);

        try
        {
            sql.InsertValues(tableName, keys, values);
            return(true);
        }
        catch (Exception e)
        {
            LogUtil.Log("插入数据失败:" + e.Message);
            return(false);
        }
        finally
        {
            if (sql != null)
            {
                sql.CloseConnection();
            }
        }
    }
示例#27
0
    public static bool DeleteTableDataAndLeft(string dbName, string tableName, string[] colNames, string[] operations, string[] colValues)
    {
        SQLiteHelper sql = GetSQLiteHelper(dbName);

        try
        {
            sql.DeleteValuesANDAndLeft(tableName, colNames, operations, colValues);
            return(true);
        }
        catch (Exception e)
        {
            LogUtil.Log("更新数据失败:" + e.Message);
            return(false);
        }
        finally
        {
            if (sql != null)
            {
                sql.CloseConnection();
            }
        }
    }
示例#28
0
    public void UserAdd()
    {
        string userId   = userIdText.text;
        string userInfo = userInfoText.text;
        string groupId  = groupIdText.text;

        if (userInfo == "" || groupId == "")
        {
            userDebugText.text = "请完整填写信息!";
            return;
        }
        string path = Application.dataPath + "/ScreenShoots/" + groupId + "/" + userInfo + ".jpg";

        if (File.Exists(path))
        {
            byte[]  image  = File.ReadAllBytes(path);
            JObject result = client.UserAdd(userId, userInfo, groupId, image);
            flag = 1;
            ErrorInfo(result);
        }
        else
        {
            userDebugText.text = "照片库里没有这张照片,请确认或重新截图!";
        }

        if (!File.Exists(Application.streamingAssetsPath + "/" + groupId))
        {
            sql = new SQLiteHelper("data source=" + Application.streamingAssetsPath + "/" + groupId);
            sql.CreateTable("table1", new string[] { "ID", "Info", "GroupID", "Success" }, new string[] { "TEXT", "TEXT", "TEXT", "BOOLEAN" });
            sql.InsertValues("table1", new string[] { "'" + userId + "'", "'" + userInfo + "'", "'" + groupId + "'", "'" + false + "'" });
            sql.CloseConnection();
        }
        else
        {
            sql = new SQLiteHelper("data source=" + Application.streamingAssetsPath + "/" + groupId);
            sql.InsertValues("table1", new string[] { "'" + userId + "'", "'" + userInfo + "'", "'" + groupId + "'", "'" + false + "'" });
            sql.CloseConnection();
        }
    }
示例#29
0
 public static void CloseTheDataBase()//所有涉及到数据库的操作全部完成之后都需要调用一次,不然会导致数据库锁死
 {
     sql.CloseConnection();
 }
示例#30
0
    public static bool GunShoot(int WeaponType)
    {
        PackageInfo = new SQLiteHelper("data source=Package.db");
        int  BulletNumber;
        bool OKToShoot = false;

        switch (WeaponType)//0 Knife,1 Pistol,2 Grenade
        {
        case 0:
        {
            OKToShoot = true;
            Debug.Log("Knife");
            break;
        }

        case 1:
        {
            string           BulletType = "PistolBullet";
            SqliteDataReader reader;
            reader = PackageInfo.ReadTable("PackageInfo", new string[] { "ObjectCount" }, new string[] { "ObjectName" }, new string[] { "=" }, new string[] { "\"" + BulletType + "\"" });
            reader.Read();
            BulletNumber = reader.GetInt32(reader.GetOrdinal("ObjectCount"));
            if (BulletNumber <= 0)
            {
                OKToShoot = false;
            }
            else
            {
                PackageInfo.UpdateValues("PackageInfo", new string[] { "ObjectCount" }, new string[] { "\"" + (BulletNumber - 1) + "\"" }, "ObjectName", "=", "\"" + BulletType + "\"");
                OKToShoot = true;
            }
            Debug.Log(BulletType + OKToShoot);
            break;
        }

        case 2:
        {
            string           BulletType = "GrenadeBullet";
            SqliteDataReader reader;
            reader = PackageInfo.ReadTable("PackageInfo", new string[] { "ObjectCount" }, new string[] { "ObjectName" }, new string[] { "=" }, new string[] { "\"" + BulletType + "\"" });
            reader.Read();
            BulletNumber = reader.GetInt32(reader.GetOrdinal("ObjectCount"));
            if (BulletNumber <= 0)
            {
                OKToShoot = false;
            }
            else
            {
                PackageInfo.UpdateValues("PackageInfo", new string[] { "ObjectCount" }, new string[] { "\"" + (BulletNumber - 1) + "\"" }, "ObjectName", "=", "\"" + BulletType + "\"");
                OKToShoot = true;
            }
            //Debug.Log(BulletType + OKToShoot);
            break;
        }

        default:
        {
            OKToShoot = false;
            Debug.Log("Default");
            break;
        }
        }
        PackageInfo.CloseConnection();
        return(OKToShoot);
    }