示例#1
0
        /// <summary>
        /// 领悟秘籍诀要
        /// </summary>
        /// <param name="secret">Secret.</param>
        public void StudySecret(BookData book, SecretData secret)
        {
            List <SecretData> secrets = null;

            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select Id, ExpData, SecretsData from BookExpsTable where BookId = " + book.Id + " and BelongToRoleId = '" + currentRoleId + "'");

            if (sqReader.Read())
            {
                ExpData exp = JsonManager.GetInstance().DeserializeObject <ExpData>(DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("ExpData"))));
                secrets = JsonManager.GetInstance().DeserializeObject <List <SecretData> >(DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("SecretsData"))));
                int bookLv = Statics.GetBookLV(exp.Cur);
                if (secrets.Count >= bookLv)
                {
                    AlertCtrl.Show(string.Format("<color=\"{0}\">{1}</color>目前只能领悟最多{2}张诀要", Statics.GetQualityColorString(book.Quality), book.Name, bookLv));
                    db.CloseSqlConnection();
                    return;
                }
                else
                {
                    if (secrets.FindIndex(item => item.Type == secret.Type) < 0)
                    {
                        secrets.Add(secret);
                        db.ExecuteQuery("update BookExpsTable set SecretsData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(secrets)) + "' where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id")));
                        db.ExecuteQuery("update BookSecretsTable set BelongToBookId = '" + book.Id + "' where Id = '" + secret.PrimaryKeyId + "'");
                    }
                    else
                    {
                        AlertCtrl.Show("该类型诀要不能重复领悟!");
                        db.CloseSqlConnection();
                        return;
                    }
                }
            }
            else
            {
                secrets = new List <SecretData>()
                {
                    secret
                };
                //处理空数据初始化
                db.ExecuteQuery("insert into BookExpsTable (BookId, ExpData, SecretsData, BelongToRoleId) values('" + book.Id + "', '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(new ExpData(0, Statics.GetBookMaxExp(book.Quality)))) + "', '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(secrets)) + "', '" + currentRoleId + "')");
                db.ExecuteQuery("update BookSecretsTable set BelongToBookId = '" + book.Id + "' where Id = '" + secret.PrimaryKeyId + "'");
            }
            db.CloseSqlConnection();
            if (secrets != null)
            {
                Messenger.Broadcast <BookData, List <SecretData> >(NotifyTypes.DealSecretEcho, book, secrets);
                Statics.CreatePopMsg(Vector3.zero, string.Format("领悟<color=\"{0}\">{1}</color>后<color=\"{2}\">{3}</color>更为精进!!", Statics.GetQualityColorString(secret.Quality), secret.Name, Statics.GetQualityColorString(book.Quality), book.Name), Color.white, 30);
                SoundManager.GetInstance().PushSound("ui0010");
            }
        }
示例#2
0
 public ExpAndSecretData()
 {
     Exp     = new ExpData(0, 0);
     Secrets = new List <SecretData>();
 }