Beispiel #1
0
 /// <summary>
 /// 传入用户任务数据
 /// </summary>
 /// <param name="info">一条系统任务</param>
 /// <param name="data">一条用户任务</param>
 public BaseQuest(QuestInfo info, QuestDataInfo data)
 {
     m_info = info;
     m_data = data;
     m_data.QuestID = m_info.ID;
     m_list = new List<BaseCondition>();
     List<QuestConditionInfo> list = QuestMgr.GetQuestCondiction(info);
     int index = 0;
     foreach (QuestConditionInfo ci in list)
     {
         BaseCondition cd = BaseCondition.CreateCondition(this, ci, data.GetConditionValue(index++));
         if (cd != null)
             m_list.Add(cd);
     }
 }
Beispiel #2
0
 public bool UpdateDbQuestDataInfo(QuestDataInfo info)
 {
     bool flag = false;
     try
     {
         flag = this.db.RunProcedure("SP_QuestData_Add", new SqlParameter[12]
     {
       new SqlParameter("@UserID", (object) info.UserID),
       new SqlParameter("@QuestID", (object) info.QuestID),
       new SqlParameter("@CompletedDate", (object) info.CompletedDate),
       new SqlParameter("@IsComplete", (object) (int) (info.IsComplete ? 1 : 0)),
       new SqlParameter("@Condition1", (object) info.Condition1),
       new SqlParameter("@Condition2", (object) info.Condition2),
       new SqlParameter("@Condition3", (object) info.Condition3),
       new SqlParameter("@Condition4", (object) info.Condition4),
       new SqlParameter("@IsExist", (object) (int) (info.IsExist ? 1 : 0)),
       new SqlParameter("@RepeatFinish", (object) info.RepeatFinish),
       new SqlParameter("@RandDobule", (object) info.RandDobule),
       new SqlParameter("@QuestLevel", (object) info.QuestLevel)
     });
         info.IsDirty = false;
     }
     catch (Exception ex)
     {
         if (BaseBussiness.log.IsErrorEnabled)
             BaseBussiness.log.Error((object)"Init", ex);
     }
     return flag;
 }
 /// <summary>
 /// 从数据库中获取当前玩家的系统中存在的任务
 /// </summary>
 /// <param name="userID">用户信息</param>
 /// <returns></returns>
 public QuestDataInfo[] GetUserQuest(int userID)
 {
     List<QuestDataInfo> infos = new List<QuestDataInfo>();
     SqlDataReader reader = null;
     try
     {
         SqlParameter[] para = new SqlParameter[1];
         para[0] = new SqlParameter("@UserID", SqlDbType.Int, 4);
         para[0].Value = userID;
         db.GetReader(ref reader, "SP_QuestData_All", para);
         while (reader.Read())
         {
             QuestDataInfo info = new QuestDataInfo();
             info.CompletedDate = (DateTime)reader["CompletedDate"];
             info.IsComplete = (bool)reader["IsComplete"];
             info.Condition1 = (int)reader["Condition1"];
             info.Condition2 = (int)reader["Condition2"];
             info.Condition3 = (int)reader["Condition3"];
             info.Condition4 = (int)reader["Condition4"];
             info.QuestID = (int)reader["QuestID"];
             info.UserID = (int)reader["UserId"];
             info.IsExist = (bool)reader["IsExist"];
             info.RandDobule = (int)reader["RandDobule"];
             info.RepeatFinish = (int)reader["RepeatFinish"];
             infos.Add(info);
         }
     }
     catch (Exception e)
     {
         if (log.IsErrorEnabled)
             log.Error("Init", e);
     }
     finally
     {
         if (reader != null && !reader.IsClosed)
             reader.Close();
     }
     return infos.ToArray();
 }
 /// <summary>
 /// 更新或插入一条用户任务信息
 /// </summary>
 /// <param name="info">任务信息</param>
 /// <returns>返回结果</returns>
 public bool UpdateDbQuestDataInfo(QuestDataInfo info)
 {
     bool result = false;
     try
     {
         SqlParameter[] para = new SqlParameter[11];
         para[0] = new SqlParameter("@UserID", info.UserID);
         para[1] = new SqlParameter("@QuestID", info.QuestID);
         para[2] = new SqlParameter("@CompletedDate", info.CompletedDate);
         para[3] = new SqlParameter("@IsComplete", info.IsComplete);
         para[4] = new SqlParameter("@Condition1", info.Condition1);
         para[5] = new SqlParameter("@Condition2", info.Condition2);
         para[6] = new SqlParameter("@Condition3", info.Condition3);
         para[7] = new SqlParameter("@Condition4", info.Condition4);
         para[8] = new SqlParameter("@IsExist", info.IsExist);
         para[9] = new SqlParameter("@RepeatFinish", info.RepeatFinish);
         para[10] = new SqlParameter("@RandDobule", info.RandDobule);
         result = db.RunProcedure("SP_QuestData_Add", para);  /*备注需要改回SP_QuestData_Add*/
         info.IsDirty = false;  //置为拉圾数据
     }
     catch (Exception e)
     {
         if (log.IsErrorEnabled)
             log.Error("Init", e);
     }
     finally
     {
     }
     return result;
 }
Beispiel #5
0
 public static XElement CreateQuestDataInfo(QuestDataInfo info)
 {
     return new XElement("Item", new XAttribute("CompletedDate", info.CompletedDate),
         new XAttribute("IsComplete", info.IsComplete),
         new XAttribute("Condition1", info.Condition1),
         new XAttribute("Condition2", info.Condition2),
         new XAttribute("Condition3", info.Condition3),
         new XAttribute("Condition4", info.Condition4),
         new XAttribute("QuestID", info.QuestID),
         new XAttribute("UserID", info.UserID),
         new XAttribute("RepeatFinish", info.RepeatFinish));
 }