Ejemplo n.º 1
0
 void forget(SecretData data)
 {
     if (bookData != null)
     {
         DbManager.Instance.ForgetSecret(bookData, data);
     }
 }
Ejemplo n.º 2
0
 void mix(SecretData data)
 {
     if (DbManager.Instance.MixSecrets(data))
     {
         Messenger.Broadcast <BookData, List <SecretData> >(NotifyTypes.GetSecretListPanelData, null, null);
     }
 }
Ejemplo n.º 3
0
 void study(SecretData data)
 {
     if (bookData != null)
     {
         DbManager.Instance.StudySecret(bookData, data);
     }
 }
Ejemplo n.º 4
0
        /// <summary>
        /// 遗忘秘籍诀要
        /// </summary>
        /// <param name="book">Book.</param>
        /// <param name="secret">Secret.</param>
        public void ForgetSecret(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())
            {
                secrets = JsonManager.GetInstance().DeserializeObject <List <SecretData> >(DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("SecretsData"))));
                int findIndex = secrets.FindIndex(item => item.PrimaryKeyId == secret.PrimaryKeyId);
                if (findIndex >= 0)
                {
                    secrets.RemoveAt(findIndex);
                }
                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 = '' where Id = '" + secret.PrimaryKeyId + "'");
            }
            db.CloseSqlConnection();
            if (secrets != null)
            {
                Messenger.Broadcast <BookData, List <SecretData> >(NotifyTypes.DealSecretEcho, book, secrets);
                SoundManager.GetInstance().PushSound("ui0008");
            }
        }
Ejemplo n.º 5
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");
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// 融合诀要
        /// </summary>
        /// <param name="secret">Secret.</param>
        public bool MixSecrets(SecretData secret)
        {
            bool result = false;

            if (secret.Quality >= QualityType.FlashRed)
            {
                AlertCtrl.Show(string.Format("<color=\"{0}\">{1}</color>已经是顶级诀要无法继续融合", Statics.GetQualityColorString(secret.Quality), secret.Name));
                return(result);
            }
            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select count(*) as num from BookSecretsTable where T = " + ((short)secret.Type) + " and Q = " + ((short)secret.Quality) + " and BelongToRoleId = '" + currentRoleId + "'");

            if (sqReader.Read())
            {
                if (sqReader.GetInt32(sqReader.GetOrdinal("num")) >= 2)
                {
                    sqReader = db.ExecuteQuery("select Id from BookSecretsTable where T = " + ((short)secret.Type) + " and Q = " + ((short)secret.Quality) + " and BelongToRoleId = '" + currentRoleId + "' and Id != " + secret.PrimaryKeyId + " order by Id limit 0, 1");
                    //删除素材诀要
                    while (sqReader.Read())
                    {
                        db.ExecuteQuery("delete from BookSecretsTable where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id")));
                    }
                    //升级选中的诀要
                    sqReader = db.ExecuteQuery("select SecretData, Q from BookSecretsTable where Id = " + secret.PrimaryKeyId);
                    if (sqReader.Read())
                    {
                        SecretData secretData = JsonManager.GetInstance().DeserializeObject <SecretData>(DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("SecretData"))));
                        short      endQuality = (short)(((int)secretData.Quality) + 1);
                        secretData.Quality = (QualityType)(endQuality);
                        db.ExecuteQuery("update BookSecretsTable set SecretData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObjectDealVector(secretData)) + "', Q = " + ((short)secretData.Quality) + " where Id = " + secret.PrimaryKeyId);
                        Statics.CreatePopMsg(Vector3.zero, string.Format("融合<color=\"{0}\">{1}</color>后使你武功精进!", Statics.GetQualityColorString(secretData.Quality), secretData.Name), Color.white, 30);
                        SoundManager.GetInstance().PushSound("ui0010");
                        result = true;
                    }
                    else
                    {
                        AlertCtrl.Show("需要融合的诀要不存在");
                    }
                }
                else
                {
                    AlertCtrl.Show(string.Format("至少需要2张相同品质的<color=\"{0}\">{1}</color>才能融合成更高级的诀要", Statics.GetQualityColorString(secret.Quality), secret.Name));
                }
            }
            db.CloseSqlConnection();
            return(result);
        }
Ejemplo n.º 7
0
        void OnItemUpdated(LoopListViewItem item)
        {
            if (secretsData.Count <= 0)
            {
                return;
            }
            SecretItemContainer itemScript    = item.GetComponent <SecretItemContainer>();
            SecretData          currentSecret = secretsData[item.ItemIndex];

            itemScript.UpdateData(currentSecret);
            itemScript.RefreshView();
            itemScript.StateText.gameObject.SetActive(false);
            if (hasSecretsData == null)
            {
                itemScript.StudyBtn.gameObject.SetActive(false);
                itemScript.ForgetBtn.gameObject.SetActive(false);
                if (currentSecret.Quality < QualityType.FlashRed)
                {
                    itemScript.MixBtn.gameObject.SetActive(true);
                    //闪红以下品质4张及4张以上相同类型相同品质的诀要就可以融合
                    List <SecretData> sameSecrets = secretsData.FindAll(sec => sec.Type == currentSecret.Type && sec.Quality == currentSecret.Quality);
                    itemScript.MixBtn.gameObject.SetActive(sameSecrets != null && sameSecrets.Count >= 2);
                }
                else
                {
                    itemScript.MixBtn.gameObject.SetActive(false);
                    itemScript.StateText.gameObject.SetActive(true);
                }
            }
            else
            {
                if (hasSecretsData.FindIndex(sec => sec.PrimaryKeyId == currentSecret.PrimaryKeyId) >= 0)
                {
                    itemScript.ForgetBtn.gameObject.SetActive(true);
                }
                else
                {
                    itemScript.StudyBtn.gameObject.SetActive(true);
                }
                itemScript.MixBtn.gameObject.SetActive(false);
            }
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 使用物品
        /// </summary>
        /// <param name="Id">Identifier.</param>
        public void UseItem(int id)
        {
            db = OpenDb();
            string           itemId   = "";
            ItemType         type     = ItemType.None;
            int              num      = 0;
            SqliteDataReader sqReader = db.ExecuteQuery("select ItemId, Type, Num from BagTable where Id = " + id);

            if (sqReader.Read())
            {
                itemId = sqReader.GetString(sqReader.GetOrdinal("ItemId"));
                type   = (ItemType)sqReader.GetInt32(sqReader.GetOrdinal("Type"));
                num    = sqReader.GetInt32(sqReader.GetOrdinal("Num"));
            }
            db.CloseSqlConnection();
            if (type != ItemType.None && num > 0)
            {
                ItemData item;
                switch (type)
                {
                case ItemType.Food:
                    if (UserModel.CurrentUserData.PositionStatu == UserPositionStatusType.InArea)
                    {
                        Eat(id, num);
                        SoundManager.GetInstance().PushSound("ui0004");
                    }
                    else
                    {
                        AlertCtrl.Show("野外闯荡江湖时才能吃干粮");
                    }
                    break;

                case ItemType.Weapon:
                    item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", itemId);
                    if (AddNewWeapon(item.StringValue, ""))
                    {
                        WeaponData weapon = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", item.StringValue);
                        Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"{0}\">{1}</color>+1", Statics.GetQualityColorString(weapon.Quality), weapon.Name), Color.white, 30);

                        //删除兵器盒
                        db = OpenDb();
                        db.ExecuteQuery("delete from BagTable where Id = " + id);
                        db.CloseSqlConnection();
                        //重新加载背包数据
                        GetBagPanelData();
                        SoundManager.GetInstance().PushSound("ui0004");
                    }
                    else
                    {
                        AlertCtrl.Show("兵器匣已满,请先整理兵器匣");
                    }
                    break;

                case ItemType.Book:
                    item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", itemId);
                    BookData book = JsonManager.GetInstance().GetMapping <BookData>("Books", item.StringValue);
                    if (AddNewBook(item.StringValue, ""))
                    {
                        Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"{0}\">{1}</color>+1", Statics.GetQualityColorString(book.Quality), book.Name), Color.white, 30);

                        //删除秘籍盒
                        db = OpenDb();
                        db.ExecuteQuery("delete from BagTable where Id = " + id);
                        db.CloseSqlConnection();
                        //重新加载背包数据
                        GetBagPanelData();
                        SoundManager.GetInstance().PushSound("ui0004");
                    }
                    else
                    {
                        AlertCtrl.Show(string.Format("你已经习得<color=\"{0}\">{1}</color>, 无需再研读", Statics.GetQualityColorString(book.Quality), book.Name));
                    }
                    break;

                case ItemType.RandomSecre:     //打开随机诀要锦囊
                    item     = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", itemId);
                    db       = OpenDb();
                    sqReader = db.ExecuteQuery("select count(*) as num from BookSecretsTable where BelongToRoleId = '" + currentRoleId + "'");
                    bool isSecretsFull = false;
                    if (sqReader.Read())
                    {
                        isSecretsFull = sqReader.GetInt32(sqReader.GetOrdinal("num")) >= MaxSecretNumOfBag;
                    }
                    if (!isSecretsFull)
                    {
                        //添加新的诀要
                        SecretData secret = Statics.CreateNewSecret(Statics.GetRandomSecretType(item.StringValue), QualityType.White);
                        db.ExecuteQuery("insert into BookSecretsTable (SecretData, T, Q, BelongToBookId, BelongToRoleId) values('" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObjectDealVector(secret)) + "', " + ((short)secret.Type) + ", " + ((short)secret.Quality) + ", '', '" + currentRoleId + "')");
                        PlayerPrefs.SetString("AddedNewBookFlag", "true");
                        PlayerPrefs.SetString("AddedNewSecretFlag", "true");
                        Messenger.Broadcast(NotifyTypes.MakeRoleInfoPanelRedPointRefresh);
                        Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"{0}\">{1}</color>+1", Statics.GetQualityColorString(secret.Quality), secret.Name), Color.white, 30);
                        db.ExecuteQuery("delete from BagTable where Id = " + id);
                        db.CloseSqlConnection();
                        //重新加载背包数据
                        GetBagPanelData();
                        SoundManager.GetInstance().PushSound("ui0004");
                    }
                    else
                    {
                        AlertCtrl.Show(string.Format("诀要背包上限为{0},请先清理背包", MaxSecretNumOfBag));
                    }
                    break;

                default:
                    AlertCtrl.Show("该物品不可使用!");
                    break;
                }
            }
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 添加掉落物到背包
        /// </summary>
        /// <returns>The item to bag.</returns>
        /// <param name="drops">Drops.</param>
        public List <DropData> PushItemToBag(List <DropData> drops, bool withoutNumLimit = false, float makeAFortuneRate = 0)
        {
            int             bagNumLeft  = GetItemNumLeftInBag();
            List <DropData> resultDrops = new List <DropData>();

            db = OpenDb();
            SqliteDataReader sqReader;
            DropData         drop;
            int  num;
            int  maxNum;
            int  addNum;
            bool isSecretsFull;

            for (int i = 0; i < drops.Count; i++)
            {
                drop = drops[i];
                if (drop.Item == null)
                {
                    drop.MakeJsonToModel();
                }
                if (drop.Item.Type == ItemType.Task)
                {
                    //判断是否为任务物品,任务物品在使用过后就不再掉落
                    sqReader = db.ExecuteQuery("select * from UsedItemRecordsTable where ItemId = '" + drop.Item.Id + "' and BelongToRoleId = '" + currentRoleId + "'");
                    if (sqReader.HasRows)
                    {
                        continue;
                    }
                }
                //背包位子如果不足则除了任务物品之外,其他的物品都不能添加进背包
                //诀要也不受背包满限制
                if (!withoutNumLimit && bagNumLeft <= 0)
                {
                    if (drop.Item.Type != ItemType.Task && drop.Item.Type != ItemType.Book && drop.Item.Type < ItemType.SecretIncreaseMaxHP)
                    {
                        Statics.CreatePopMsg(Vector3.zero, string.Format("背包满了,{0}不能拾取", drop.Item.Name), Color.red, 30);
                        continue;
                    }
                }
                //判断是否掉落
                if (!drop.IsTrigger(makeAFortuneRate))
                {
                    continue;
                }
                if (drop.Item.Type < ItemType.SecretIncreaseMaxHP)
                {
                    //查询背包里是否有物品以及物品的数量是否达到上限
                    sqReader = db.ExecuteQuery("select * from BagTable where ItemId = '" + drop.Item.Id + "' and Num < MaxNum and BelongToRoleId = '" + currentRoleId + "'");
                    if (!sqReader.HasRows)
                    {
                        //添加新的物品
                        db.ExecuteQuery("insert into BagTable (ItemId, Type, Num, MaxNum, Lv, BelongToRoleId) values('" + drop.Item.Id + "', " + ((int)drop.Item.Type) + ", " + drop.Item.Num + ", " + drop.Item.MaxNum + ", " + drop.Item.Lv + ", '" + currentRoleId + "')");
                    }
                    else
                    {
                        int itemNum = drop.Item.Num;
                        //修改物品的数量
                        while (sqReader.Read())
                        {
                            num      = sqReader.GetInt32(sqReader.GetOrdinal("Num"));
                            maxNum   = sqReader.GetInt32(sqReader.GetOrdinal("MaxNum"));
                            addNum   = (maxNum - num) <= itemNum ? (maxNum - num) : itemNum;
                            itemNum -= addNum;
                            db.ExecuteQuery("update BagTable set Num = " + (num + addNum) +
                                            " where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id")));
                            //如果掉落物的数量还有则下个循环继续处理添加物品
                            if (itemNum > 0)
                            {
                                i--;
                            }
                        }
                    }
                    resultDrops.Add(drop);
                    //任务物品不算入背包占位数
                    if (!withoutNumLimit && drop.Item.Type != ItemType.Task)
                    {
                        bagNumLeft--;
                    }
                }
                else
                {
                    //处理诀要
                    sqReader      = db.ExecuteQuery("select count(*) as num from BookSecretsTable where BelongToRoleId = '" + currentRoleId + "'");
                    isSecretsFull = false;
                    if (sqReader.Read())
                    {
                        isSecretsFull = sqReader.GetInt32(sqReader.GetOrdinal("num")) >= MaxSecretNumOfBag;
                    }
                    if (!isSecretsFull)
                    {
                        //添加新的诀要
                        SecretData secret = Statics.CreateNewSecret(Statics.ChangeItemTypeToSecretType(drop.Item.Type), QualityType.White);
                        db.ExecuteQuery("insert into BookSecretsTable (SecretData, T, Q, BelongToBookId, BelongToRoleId) values('" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObjectDealVector(secret)) + "', " + ((short)secret.Type) + ", " + ((short)secret.Quality) + ", '', '" + currentRoleId + "')");
                        resultDrops.Add(drop);
                        PlayerPrefs.SetString("AddedNewBookFlag", "true");
                        PlayerPrefs.SetString("AddedNewSecretFlag", "true");
                    }
                    else
                    {
                        Statics.CreatePopMsg(Vector3.zero, string.Format("诀要背包上限为{0},请先清理背包", MaxSecretNumOfBag), Color.red, 30);
                    }
                }
            }
            db.CloseSqlConnection();
            if (resultDrops.Count > 0)
            {
                PlayerPrefs.SetString("AddedNewItemFlag", "true");
            }
            return(resultDrops);
        }
Ejemplo n.º 10
0
 public void UpdateData(SecretData data) {
     secretData = data;
 }