Esempio n. 1
0
        public void RefreshView()
        {
            Icon.sprite = Statics.GetIconSprite(bookData.IconId);
            Name.text   = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(bookData.Quality), bookData.Name);
            Image iconImage;

            for (int i = 0; i < SkillIcons.Length; i++)
            {
                iconImage = SkillIcons[i];
                if (bookData.Skills.Count > i)
                {
                    iconImage.gameObject.SetActive(true);
                    iconImage.sprite = Statics.GetIconSprite(bookData.Skills[i].IconId);
                }
                else
                {
                    iconImage.gameObject.SetActive(false);
                }
            }
            DescText.gameObject.SetActive(bookData.Skills.Count == 0);
            if (bookData.BeUsingByRoleId != "")
            {
                UseBtn.gameObject.SetActive(false);
                UnuseBtn.gameObject.SetActive(true);
                bg.sprite = Statics.GetSprite("Border12");
            }
            else
            {
                UseBtn.gameObject.SetActive(true);
                UnuseBtn.gameObject.SetActive(false);
                bg.sprite = Statics.GetSprite("Border11");
            }
        }
 public void RefreshView()
 {
     Icon.sprite = Statics.GetIconSprite(bookData.IconId);
     Name.text   = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(bookData.Quality), bookData.Name);
     Flag.gameObject.SetActive(bookData.State == BookStateType.Read);
     MakeButtonEnable(MakeBtn, bookData.State == BookStateType.Unread);
     //判断是否为新增秘籍,控制新增标记显示隐藏
     NewFlag.gameObject.SetActive(string.IsNullOrEmpty(PlayerPrefs.GetString(PlayerPrefs.GetString("CurrentRoleId") + "_" + "BookIdOfCurrentForbiddenAreaNewFlagIsHide_" + bookData.Id)));
 }
Esempio n. 3
0
        public void RefreshView() {
            IconImage.sprite = Statics.GetIconSprite(secretData.IconId);
            FlashImage.gameObject.SetActive(((int)secretData.Quality) >= ((int)QualityType.FlashGold));
            NameText.text = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(secretData.Quality), secretData.Name);

            DescText.text = secretData.GetDesc();
            StudyBtn.gameObject.SetActive(string.IsNullOrEmpty(secretData.BelongToBookId));
            ForgetBtn.gameObject.SetActive(!string.IsNullOrEmpty(secretData.BelongToBookId));
        }
Esempio n. 4
0
 public void RefreshView()
 {
     Icon.sprite = Statics.GetIconSprite(roleData.IconId);
     if (roleData.State == RoleStateType.InTeam)
     {
         bg.sprite = Statics.GetSprite("Border12");
     }
     else
     {
         bg.sprite = Statics.GetSprite("Border11");
     }
     Desc.text = string.Format("称谓:{0}\n门派:{1}\n地位:{2}\n状态:{3}", roleData.Name, Statics.GetOccupationName(roleData.Occupation), roleData.IsHost ? "当家" : "门客", Statics.GetInjuryName(roleData.Injury));
     if (roleData.Weapon != null)
     {
         WeaponNameText.text = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(roleData.Weapon.Quality), roleData.Weapon.Name);
         WeaponWidth.rectTransform.sizeDelta = new Vector2(100f * (roleData.Weapon.Width / 100f) * 0.5f, WeaponWidth.rectTransform.sizeDelta.y);
         WeaponIcon.gameObject.SetActive(true);
         WeaponIcon.sprite = Statics.GetIconSprite(roleData.Weapon.IconId);
         WeaponFlashImage.gameObject.SetActive(((int)roleData.Weapon.Quality) >= ((int)QualityType.FlashGold));
     }
     else
     {
         WeaponNameText.text = "赤手空拳";
         WeaponIcon.gameObject.SetActive(false);
         WeaponFlashImage.gameObject.SetActive(false);
     }
     for (int i = 0; i < 3; i++)
     {
         if (roleData.Books.Count > i)
         {
             BookIcons[i].gameObject.SetActive(true);
             BookIcons[i].sprite = Statics.GetIconSprite(roleData.Books[i].IconId);
             BookFlashImages[i].gameObject.SetActive(((int)roleData.Books[i].Quality) >= ((int)QualityType.FlashGold));
         }
         else
         {
             BookIcons[i].gameObject.SetActive(false);
             BookFlashImages[i].gameObject.SetActive(false);
         }
     }
     if (roleData.IsHost)
     {
         SelectBtn.gameObject.SetActive(false);
         CancelBtn.gameObject.SetActive(false);
     }
     else
     {
         SelectBtn.gameObject.SetActive(roleData.State == RoleStateType.OutTeam);
         CancelBtn.gameObject.SetActive(roleData.State == RoleStateType.InTeam);
         if (roleData.Injury == InjuryType.Moribund)
         {
             MakeButtonEnable(SelectBtn, false);
             MakeButtonEnable(CancelBtn, false);
         }
     }
 }
Esempio n. 5
0
 public override void RefreshView()
 {
     if (bookData != null)
     {
         BookNameText.text = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(bookData.Quality), bookData.Name);
         BookIconImage.transform.parent.gameObject.SetActive(true);
         BookIconImage.sprite = Statics.GetIconSprite(bookData.IconId);
     }
     else
     {
         BookNameText.text = "无";
         BookIconImage.transform.parent.gameObject.SetActive(false);
     }
 }
Esempio n. 6
0
 public override void RefreshView()
 {
     icon.sprite   = Statics.GetIconSprite(weaponData.IconId);
     nameText.text = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(weaponData.Quality), weaponData.Name);
     weaponWidthScript.UpdateData(weaponData);
     weaponWidthScript.RefreshView();
     infoText.text = info;
     if (weaponData.BelongToRoleId == "")
     {
         occupationText.text = string.Format("门派限制:{0}", weaponData.Occupation != OccupationType.None ? Statics.GetOccupationName(weaponData.Occupation) : "无限制");
     }
     else
     {
         occupationText.text = string.Format("仅限 {0} 使用", JsonManager.GetInstance().GetMapping <RoleData>("RoleDatas", weaponData.BelongToRoleId).Name);
     }
 }
        public void RefreshView()
        {
            if (weaponData == null)
            {
                return;
            }
            Icon.sprite = Statics.GetIconSprite(weaponData.IconId);
            Name.text   = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(weaponData.Quality), weaponData.Name);
            string       costStr = "";
            ResourceData need;

            for (int i = 0; i < weaponData.Needs.Count; i++)
            {
                need     = weaponData.Needs[i];
                costStr += string.Format("{0}-{1}\n", Statics.GetResourceName(need.Type), need.Num);
            }
            Cost.text = costStr;
            //判断是否为新增兵器,控制新增标记显示隐藏
            NewFlag.gameObject.SetActive(string.IsNullOrEmpty(PlayerPrefs.GetString(PlayerPrefs.GetString("CurrentRoleId") + "_" + "WeaponIdOfWorkShopNewFlagIsHide_" + weaponData.Id)));
        }
Esempio n. 8
0
        public override void RefreshView()
        {
            icon.sprite = Statics.GetIconSprite(weaponData.IconId);
            flashImage.gameObject.SetActive(((int)weaponData.Quality) >= ((int)QualityType.FlashGold));
            nameText.text = string.Format("<color=\"{0}\">{1}</color> {2}", Statics.GetQualityColorString(weaponData.Quality), weaponData.Name, weaponLVData.LV > 0 ? ("+" + weaponLVData.LV) : "");
//			weaponWidthScript.UpdateData(weaponData);
//			weaponWidthScript.RefreshView();
            infoText.text = info;
            if (weaponData.BelongToRoleId == "")
            {
                occupationText.text = string.Format("门派限制:{0}", weaponData.Occupation != OccupationType.None ? Statics.GetOccupationName(weaponData.Occupation) : "无限制");
            }
            else
            {
                occupationText.text = string.Format("仅限 {0} 使用", JsonManager.GetInstance().GetMapping <RoleData>("RoleDatas", weaponData.BelongToRoleId).Name);
            }
            lvFullNoticeText.gameObject.SetActive(weaponData.Quality >= QualityType.FlashGold && weaponLVData.LV >= weaponLVData.MaxLV);
            lvUpgradeBtn.gameObject.SetActive(weaponData.Quality >= QualityType.FlashGold && weaponLVData.LV < weaponLVData.MaxLV);
            StartCoroutine(refreshHeight());
        }
Esempio n. 9
0
        public override void RefreshView()
        {
            iconImage.sprite = Statics.GetIconSprite(bookData.IconId);
            nameText.text    = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(bookData.Quality), bookData.Name);
            descText.text    = string.Format("{0}{1}描述:\n{2}", bookData.LimitWeaponType != WeaponType.None ? string.Format("兵器限制:{0}\n", Statics.GetEnmuDesc <WeaponType>(bookData.LimitWeaponType)) : "", info != "" ? string.Format("附加属性:\n<color=\"#00FF00\">{0}</color>", info) : "", bookData.Desc);

            if (prefabObj == null)
            {
                prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/SkillItemContainer");
            }
            if (bookData.Skills.Count > 0)
            {
                emptyImage.gameObject.SetActive(false);
                SkillData          skill;
                GameObject         itemPrefab;
                SkillItemContainer container;
                for (int i = 0; i < bookData.Skills.Count; i++)
                {
                    skill = bookData.Skills[i];
                    if (containers.Count <= i)
                    {
                        itemPrefab = Statics.GetPrefabClone(prefabObj);
                        MakeToParent(gridTrans.transform, itemPrefab.transform);
                        container = itemPrefab.GetComponent <SkillItemContainer>();
                        containers.Add(container);
                    }
                    else
                    {
                        container = containers[i];
                    }
                    container.UpdateData(skill, i != bookData.Skills.Count - 1);
                    container.RefreshView();
                }
            }
            else
            {
                emptyImage.gameObject.SetActive(true);
            }
        }
Esempio n. 10
0
        public void RefreshView()
        {
            if (weaponData == null)
            {
                return;
            }
            BreakBtn.gameObject.SetActive(weaponData.BeUsingByRoleId == "");
            Icon.sprite = Statics.GetIconSprite(weaponData.IconId);
            Name.text   = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(weaponData.Quality), weaponData.Name);
            string       gotStr = "";
            ResourceData need;

            for (int i = 0; i < weaponData.Needs.Count; i++)
            {
                need = weaponData.Needs[i];
                if (need.Num > 0)
                {
                    gotStr += string.Format("{0}+{1}\n", Statics.GetResourceName(need.Type), need.Num);
                }
            }
            gotStr   = gotStr == "" ? "无" : gotStr;
            Got.text = gotStr;
        }
        void onClick(GameObject e)
        {
            if (weaponData == null)
            {
                return;
            }
            switch (e.name)
            {
            case "CreateBtn":
                ConfirmCtrl.Show(string.Format("开始打造<color=\"{0}\">{1}</color>?", Statics.GetQualityColorString(weaponData.Quality), weaponData.Name), () => {
                    Messenger.Broadcast <string>(NotifyTypes.CreateNewWeaponOfWorkshop, weaponData.Id);
                }, null, "打造", "放弃");
                break;

            case "ViewBtn":
                Messenger.Broadcast <WeaponData>(NotifyTypes.ShowWeaponDetailPanel, weaponData);
                break;

            default:
                break;
            }
            viewedNewFlag();
        }
Esempio n. 12
0
 void onClick(GameObject e) {
     switch (e.name)
     {
         case "StudyBtn":
             SendMessageUpwards("study", secretData);
             break;
         case "ForgetBtn":
             SendMessageUpwards("forget", secretData);
             break;
         case "MixBtn":
             ConfirmCtrl.Show(string.Format("融合<color=\"{0}\">{1}</color>需要消耗2张同类同品质的诀要,是否继续?", Statics.GetQualityColorString(secretData.Quality), secretData.Name), () => {
                 SendMessageUpwards("mix", secretData);
             });
             break;
         default:
             break;
     }
 }
Esempio n. 13
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:
                    Eat(id, num);
                    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();
                    }
                    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();
                    }
                    else
                    {
                        AlertCtrl.Show(string.Format("你已经习得<color=\"{0}\">{1}</color>, 无需再研读", Statics.GetQualityColorString(book.Quality), book.Name));
                    }
                    break;

                default:
                    AlertCtrl.Show("该物品不可使用!");
                    break;
                }
            }
        }
Esempio n. 14
0
        public void RefreshView()
        {
            Icon.sprite = Statics.GetIconSprite(weaponData.IconId);
            FlashImage.gameObject.SetActive(((int)weaponData.Quality) >= ((int)QualityType.FlashGold));
            Name.text = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(weaponData.Quality), weaponData.Name);
//			WeaponWidth.rectTransform.sizeDelta = new Vector2(100f * (weaponData.Width / 100f), WeaponWidth.rectTransform.sizeDelta.y);
//			PowerIndexDesc0.text = string.Format("+100%伤害概率: {0}%", (int)(weaponData.Rates[1] * 100));
//			PowerIndexDesc1.text = string.Format("+50%伤害概率: {0}%", (int)(weaponData.Rates[2] * 100));
//			PowerIndexDesc2.text = string.Format("+25%伤害概率: {0}%", (int)(weaponData.Rates[3] * 100));
            if (weaponData.BeUsingByRoleId != "")
            {
                Btn.gameObject.SetActive(false);
                bg.sprite = Statics.GetSprite("Border12");
//				PowerIndexFlag0.gameObject.SetActive(false);
//				PowerIndexFlag1.gameObject.SetActive(false);
//				PowerIndexFlag2.gameObject.SetActive(false);
                State.text = "已装备";
                TakeOffBtn.gameObject.SetActive(true);
            }
            else
            {
                TakeOffBtn.gameObject.SetActive(false);
                if (weaponData.Occupation == OccupationType.None || weaponData.Occupation == hostRoleData.Occupation)
                {
                    Btn.gameObject.SetActive(true);
                    State.text = "已装备";
                }
                else
                {
                    Btn.gameObject.SetActive(false);
                    State.text = string.Format("<color=\"#FF0000\">限{0}</color>", Statics.GetOccupationName(weaponData.Occupation));
                }
//				if (hostWeaponData != null) {
//					if (weaponData.Rates[1] != hostWeaponData.Rates[1]) {
//						PowerIndexFlag0.gameObject.SetActive(true);
//						PowerIndexFlag0.sprite = Statics.GetSprite(weaponData.Rates[1] > hostWeaponData.Rates[1] ? "StateUp" : "StateDown");
//					}
//					else {
//						PowerIndexFlag0.gameObject.SetActive(false);
//					}
//
//					if (weaponData.Rates[2] != hostWeaponData.Rates[2]) {
//						PowerIndexFlag1.gameObject.SetActive(true);
//						PowerIndexFlag1.sprite = Statics.GetSprite(weaponData.Rates[2] > hostWeaponData.Rates[2] ? "StateUp" : "StateDown");
//					}
//					else {
//						PowerIndexFlag1.gameObject.SetActive(false);
//					}
//					if (weaponData.Rates[3] != hostWeaponData.Rates[3]) {
//						PowerIndexFlag2.gameObject.SetActive(true);
//						PowerIndexFlag2.sprite = Statics.GetSprite(weaponData.Rates[3] > hostWeaponData.Rates[3] ? "StateUp" : "StateDown");
//					}
//					else {
//						PowerIndexFlag2.gameObject.SetActive(false);
//					}
//				}
//				else {
//					PowerIndexFlag0.gameObject.SetActive(false);
//					PowerIndexFlag1.gameObject.SetActive(false);
//					PowerIndexFlag2.gameObject.SetActive(false);
//				}
            }

            OccupationText.text = weaponData.Occupation != OccupationType.None ? string.Format("门派:{0}", Statics.GetOccupationName(weaponData.Occupation)) : "";
            string info = "";

            if (weaponData.FixedDamagePlus != 0)
            {
                info += info == "" ? "" : "\n";
                info += string.Format("固定伤害:{0}", (weaponData.FixedDamagePlus > 0 ? "+" : "") + weaponData.FixedDamagePlus.ToString());
            }
            if (weaponData.DamageRatePlus != 0)
            {
                info += info == "" ? "" : "\n";
                info += string.Format("最终伤害:{0}%", (weaponData.DamageRatePlus > 0 ? "+" : "") + (weaponData.DamageRatePlus * 100).ToString());
            }
            if (weaponData.PhysicsAttackPlus != 0)
            {
                info += info == "" ? "" : "\n";
                info += string.Format("外功:{0}", (weaponData.PhysicsAttackPlus > 0 ? "+" : "") + weaponData.PhysicsAttackPlus.ToString());
            }
            DescText.text = info;
        }
Esempio n. 15
0
        /// <summary>
        /// 替换兵器(不允许侠客不拿兵器)
        /// </summary>
        /// <param name="id">Identifier.</param>
        /// <param name="beUsingByRoleId">Be using by role identifier.</param>
        public void ReplaceWeapon(int id, string beUsingByRoleId)
        {
            db = OpenDb();
            //查询角色信息
            SqliteDataReader sqReader = db.ExecuteQuery("select RoleId, RoleData from RolesTable where RoleId = '" + beUsingByRoleId + "' and BelongToRoleId = '" + currentRoleId + "'");

            if (sqReader.Read())
            {
                //获取角色数据
                string roleDataStr = sqReader.GetString(sqReader.GetOrdinal("RoleData"));
                roleDataStr = roleDataStr.IndexOf("{") == 0 ? roleDataStr : DESStatics.StringDecder(roleDataStr);
                RoleData role = JsonManager.GetInstance().DeserializeObject <RoleData>(roleDataStr);
                sqReader = db.ExecuteQuery("select * from WeaponsTable where BeUsingByRoleId = '" + beUsingByRoleId + "' and BelongToRoleId ='" + currentRoleId + "'");
                while (sqReader.Read())
                {
                    //将兵器先卸下
                    int dataId = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                    db.ExecuteQuery("update WeaponsTable set BeUsingByRoleId = '' where Id = " + dataId);
                }
                sqReader = db.ExecuteQuery("select Id, WeaponId from WeaponsTable where Id = " + id);
                if (sqReader.Read())
                {
                    string     weaponId = sqReader.GetString(sqReader.GetOrdinal("WeaponId"));
                    WeaponData weapon   = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", weaponId);
                    if (weapon.BelongToRoleId == "")
                    {
                        if (weapon.Occupation == OccupationType.None || weapon.Occupation == HostData.Occupation)
                        {
                            //装备新兵器
                            db.ExecuteQuery("update WeaponsTable set BeUsingByRoleId = '" + beUsingByRoleId + "' where Id = " + id);
                            //更新角色的武器信息
                            role.ResourceWeaponDataId = weaponId;
                            //查询下新武器替换上后秘籍需不需要卸下
                            sqReader = db.ExecuteQuery("select Id, BookId from BooksTable where BeUsingByRoleId = '" + currentRoleId + "' and BelongToRoleId = '" + currentRoleId + "'");
                            BookData book;
                            string   unuseBookMsg = "";
                            while (sqReader.Read())
                            {
                                book = JsonManager.GetInstance().GetMapping <BookData>("Books", sqReader.GetString(sqReader.GetOrdinal("BookId")));
                                if (book.LimitWeaponType != WeaponType.None && (book.LimitWeaponType != weapon.Type))
                                {
                                    db.ExecuteQuery("update BooksTable set SeatNo = 888, BeUsingByRoleId = '' where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id")));
                                    int index = role.ResourceBookDataIds.FindIndex(item => item == book.Id);
                                    if (index >= 0)
                                    {
                                        //更新角色的秘籍信息
                                        role.ResourceBookDataIds.RemoveAt(index);
                                    }
                                    unuseBookMsg += " " + book.Name;
                                }
                            }
                            //更新主角关联数据
                            db.ExecuteQuery("update RolesTable set RoleData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObjectDealVector(role)) + "' where RoleId = '" + beUsingByRoleId + "'");
                            if (unuseBookMsg != "")
                            {
                                Statics.CreatePopMsg(Vector3.zero, string.Format("拿上<color=\"{0}\">{1}</color>后不可能再习练{2}", Statics.GetQualityColorString(weapon.Quality), weapon.Name, unuseBookMsg), Color.white, 30);
                            }
                            SoundManager.GetInstance().PushSound("ui0011");
                        }
                        else
                        {
                            AlertCtrl.Show(string.Format("<color=\"{0}\">{1}</color>只有 {2} 才能使用!", Statics.GetQualityColorString(weapon.Quality), weapon.Name, Statics.GetOccupationDesc(weapon.Occupation)));
                        }
                    }
                    else
                    {
                        AlertCtrl.Show(string.Format("<color=\"{0}\">{1}</color>只有 {2} 才能使用!", Statics.GetQualityColorString(weapon.Quality), weapon.Name, JsonManager.GetInstance().GetMapping <RoleData>("RoleDatas", weapon.BelongToRoleId).Name));
                    }
                }
            }
            db.CloseSqlConnection();
            GetWeaponsListPanelData();             //刷新兵器匣列表
            CallRoleInfoPanelData(false);          //刷新队伍数据
        }
Esempio n. 16
0
        public void RefreshView()
        {
            Icon.sprite = Statics.GetIconSprite(weaponData.IconId);
            Name.text   = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(weaponData.Quality), weaponData.Name);
            WeaponWidth.rectTransform.sizeDelta = new Vector2(100f * (weaponData.Width / 100f), WeaponWidth.rectTransform.sizeDelta.y);
            PowerIndexDesc0.text = string.Format("+100%伤害概率: {0}%", (int)(weaponData.Rates[1] * 100));
            PowerIndexDesc1.text = string.Format("+50%伤害概率: {0}%", (int)(weaponData.Rates[2] * 100));
            PowerIndexDesc2.text = string.Format("+25%伤害概率: {0}%", (int)(weaponData.Rates[3] * 100));
            if (weaponData.BeUsingByRoleId != "")
            {
                Btn.gameObject.SetActive(false);
                bg.sprite = Statics.GetSprite("Border12");
                PowerIndexFlag0.gameObject.SetActive(false);
                PowerIndexFlag1.gameObject.SetActive(false);
                PowerIndexFlag2.gameObject.SetActive(false);
                State.text = "已装备";
                TakeOffBtn.gameObject.SetActive(true);
            }
            else
            {
                TakeOffBtn.gameObject.SetActive(false);
                if (weaponData.Occupation == OccupationType.None || weaponData.Occupation == hostRoleData.Occupation)
                {
                    Btn.gameObject.SetActive(true);
                    State.text = "已装备";
                }
                else
                {
                    Btn.gameObject.SetActive(false);
                    State.text = string.Format("<color=\"#FF0000\">限{0}</color>", Statics.GetOccupationName(weaponData.Occupation));
                }
                if (hostWeaponData != null)
                {
                    if (weaponData.Rates[1] != hostWeaponData.Rates[1])
                    {
                        PowerIndexFlag0.gameObject.SetActive(true);
                        PowerIndexFlag0.sprite = Statics.GetSprite(weaponData.Rates[1] > hostWeaponData.Rates[1] ? "StateUp" : "StateDown");
                    }
                    else
                    {
                        PowerIndexFlag0.gameObject.SetActive(false);
                    }

                    if (weaponData.Rates[2] != hostWeaponData.Rates[2])
                    {
                        PowerIndexFlag1.gameObject.SetActive(true);
                        PowerIndexFlag1.sprite = Statics.GetSprite(weaponData.Rates[2] > hostWeaponData.Rates[2] ? "StateUp" : "StateDown");
                    }
                    else
                    {
                        PowerIndexFlag1.gameObject.SetActive(false);
                    }
                    if (weaponData.Rates[3] != hostWeaponData.Rates[3])
                    {
                        PowerIndexFlag2.gameObject.SetActive(true);
                        PowerIndexFlag2.sprite = Statics.GetSprite(weaponData.Rates[3] > hostWeaponData.Rates[3] ? "StateUp" : "StateDown");
                    }
                    else
                    {
                        PowerIndexFlag2.gameObject.SetActive(false);
                    }
                }
                else
                {
                    PowerIndexFlag0.gameObject.SetActive(false);
                    PowerIndexFlag1.gameObject.SetActive(false);
                    PowerIndexFlag2.gameObject.SetActive(false);
                }
            }
        }
Esempio n. 17
0
        void onClick(GameObject e)
        {
            if (!e.GetComponent <Button>().enabled)
            {
                return;
            }
            switch (e.name)
            {
            case "MakeBtn":
                if (roleData.State == RoleStateType.NotRecruited)
                {
//					ConfirmCtrl.Show(string.Format("是否将<color=\"{0}\">{1}</color>赠给{2}与其结交?", Statics.GetQualityColorString(weapon.Quality), weapon.Name, roleData.Name), () => {
//						Messenger.Broadcast<int>(NotifyTypes.InviteRole, roleData.PrimaryKeyId);
//					});
                    string needMsg = "";
                    for (int i = 0, len = weapon.Needs.Count; i < len; i++)
                    {
                        needMsg += string.Format("{0}个{1}", weapon.Needs[i].Num, Statics.GetEnmuDesc <ResourceType>(weapon.Needs[i].Type)) + (i < len - 1 ? "," : "");
                    }
                    if (needMsg != "")
                    {
                        ConfirmCtrl.Show(string.Format("要将<color=\"{0}\">{1}</color>赠送给{2}\n需要{3}\n是否立即锻造兵器?", Statics.GetQualityColorString(weapon.Quality), weapon.Name, roleData.Name, needMsg), () => {
                            Messenger.Broadcast <int>(NotifyTypes.InviteRole, roleData.PrimaryKeyId);
                        });
                    }
                    else
                    {
                        AlertCtrl.Show("兵器没有原材料无法打造", null);
                    }
                }
                else
                {
                    AlertCtrl.Show(string.Format("{0}已经和你结交", roleData.Name), null);
                }
                break;

            case "Btn":
                Messenger.Broadcast <RoleData>(NotifyTypes.ShowRoleDetailPanel, roleData);
                break;

            default:
                break;
            }
            viewedNewFlag();
        }
Esempio n. 18
0
        /// <summary>
        /// 研读秘籍
        /// </summary>
        /// <param name="id">Identifier.</param>
        public void ReadBook(int id)
        {
            bool     read = false;
            BookData book = null;

            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select BookId from BooksTable where Id = " + id);

            if (sqReader.Read())
            {
                book = JsonManager.GetInstance().GetMapping <BookData>("Books", sqReader.GetString(sqReader.GetOrdinal("BookId")));
                if (book.Occupation == OccupationType.None || book.Occupation == HostData.Occupation)
                {
                    bool     enough = true;
                    string   msg    = "";
                    CostData cost;
                    ItemData item;
                    //计算需要的物品是否足够
                    for (int i = 0; i < book.Needs.Count; i++)
                    {
                        cost     = book.Needs[i];
                        item     = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", cost.Id);
                        sqReader = db.ExecuteQuery("select Num from BagTable where ItemId = '" + cost.Id + "' and BelongToRoleId = '" + currentRoleId + "'");
                        if (sqReader.Read())
                        {
                            if (sqReader.GetInt32(sqReader.GetOrdinal("Num")) < cost.Num)
                            {
                                enough = false;
                                msg    = string.Format("行囊里的{0}不够", item.Name);
                                break;
                            }
                        }
                        else
                        {
                            enough = false;
                            msg    = string.Format("行囊里并不曾见过有{0}", item.Name);
                            break;
                        }
                    }

                    if (enough)
                    {
                        int num;
                        //扣除物品
                        for (int i = 0; i < book.Needs.Count; i++)
                        {
                            cost     = book.Needs[i];
                            sqReader = db.ExecuteQuery("select Id, Num from BagTable where ItemId = '" + cost.Id + "' and BelongToRoleId = '" + currentRoleId + "'");
                            if (sqReader.Read())
                            {
                                num = sqReader.GetInt32(sqReader.GetOrdinal("Num")) - cost.Num;
                                num = num < 0 ? 0 : num;
                                if (num > 0)
                                {
                                    db.ExecuteQuery("update BagTable set Num = " + num + " where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id")));
                                }
                                else
                                {
                                    db.ExecuteQuery("delete from BagTable where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id")));
                                }
                            }
                        }
                        //研读秘籍
                        db.ExecuteQuery("update BooksTable set State = " + ((int)BookStateType.Read) + ", SeatNo = 888 where Id = " + id);
                        read = true;
                    }
                    else
                    {
                        AlertCtrl.Show(msg, null);
                    }
                }
                else
                {
                    AlertCtrl.Show(string.Format("非{0}弟子不得研习<color=\"{1}\">{2}</color>!", Statics.GetOccupationName(book.Occupation), Statics.GetQualityColorString(book.Quality), book.Name));
                }
            }
            db.CloseSqlConnection();
            if (read && book != null)
            {
                Statics.CreatePopMsg(Vector3.zero, string.Format("研读<color=\"{0}\">{1}</color>后使你武功精进!", Statics.GetQualityColorString(book.Quality), book.Name), Color.white, 30);
                GetBooksOfForbiddenAreaPanelData(book.BelongToCityId);
            }
        }
Esempio n. 19
0
        /// <summary>
        /// 装备秘籍
        /// </summary>
        /// <param name="id">Identifier.</param>
        public void UseBook(int id)
        {
            //查询主角当前的兵器类型
            WeaponType hostWeaponType = GetHostWeaponType();

            db = OpenDb();
            //查询角色信息
            SqliteDataReader sqReader = db.ExecuteQuery("select RoleId, RoleData from RolesTable where RoleId = '" + currentRoleId + "' and BelongToRoleId = '" + currentRoleId + "'");
            int addIndex = -1;

            if (sqReader.Read())
            {
                string roleId = sqReader.GetString(sqReader.GetOrdinal("RoleId"));
                //获取角色数据
                RoleData role = JsonManager.GetInstance().DeserializeObject <RoleData>(sqReader.GetString(sqReader.GetOrdinal("RoleData")));
                sqReader = db.ExecuteQuery("select BookId, SeatNo from BooksTable where SeatNo >= 0 and State = " + ((int)BookStateType.Read) + " and BelongToRoleId = '" + currentRoleId + "'");
                List <string> resourceBookDataIds = new List <string>();
                List <int>    seatNos             = new List <int>()
                {
                    -1, -1, -1
                };
                int seatNo;
                while (sqReader.Read())
                {
                    seatNo = sqReader.GetInt32(sqReader.GetOrdinal("SeatNo"));
                    if (seatNos.Count > seatNo)
                    {
                        seatNos[seatNo] = seatNo;
                        resourceBookDataIds.Add(sqReader.GetString(sqReader.GetOrdinal("BookId")));
                    }
                }
                addIndex = seatNos.FindIndex(item => item == -1);
                if (addIndex >= 0)
                {
                    sqReader = db.ExecuteQuery("select BookId from BooksTable where Id = " + id);
                    if (sqReader.Read())
                    {
                        string   bookId   = sqReader.GetString(sqReader.GetOrdinal("BookId"));
                        BookData bookData = JsonManager.GetInstance().GetMapping <BookData>("Books", bookId);
                        if (bookData.LimitWeaponType == WeaponType.None || hostWeaponType == WeaponType.None || bookData.LimitWeaponType == hostWeaponType)
                        {
                            resourceBookDataIds.Add(bookId);
                            db.ExecuteQuery("update BooksTable set SeatNo = " + addIndex + ", BeUsingByRoleId = '" + currentRoleId + "' where Id = " + id);
                            //更新角色的秘籍信息
                            role.ResourceBookDataIds = resourceBookDataIds;
                            db.ExecuteQuery("update RolesTable set RoleData = '" + JsonManager.GetInstance().SerializeObjectDealVector(role) + "' where RoleId = '" + roleId + "'");
                        }
                        else
                        {
                            AlertCtrl.Show(string.Format("装备上[{0}]才能习练<color=\"{1}\">{2}</color>\n{3}", Statics.GetEnmuDesc <WeaponType>(bookData.LimitWeaponType), Statics.GetQualityColorString(bookData.Quality), bookData.Name, hostWeaponType != WeaponType.None ? ("你现在拿的是[" + Statics.GetEnmuDesc <WeaponType>(hostWeaponType) + "]") : "你现在手里没有任何兵器"), null);
                        }
                    }
                }
            }
            db.CloseSqlConnection();
            if (addIndex >= 0)
            {
                GetBooksListPanelData();
                CallRoleInfoPanelData(false);                 //刷新队伍数据
            }
            else
            {
                AlertCtrl.Show("最多只能同时习练3本秘籍!", null);
            }
        }
Esempio n. 20
0
        public void RefreshView()
        {
            Icon.sprite = Statics.GetIconSprite(bookData.IconId);
            FlashImage.gameObject.SetActive(((int)bookData.Quality) >= ((int)QualityType.FlashGold));
            Name.text = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(bookData.Quality), bookData.Name);
            TitleText.gameObject.SetActive(bookData.IsLostKnowledge);
//			Image iconImage;
//			for (int i = 0; i < SkillIcons.Length; i++) {
//				iconImage = SkillIcons[i];
//				if (bookData.Skills.Count > i) {
//					iconImage.gameObject.SetActive(true);
//					iconImage.sprite = Statics.GetIconSprite(bookData.Skills[i].IconId);
//				}
//				else {
//					iconImage.gameObject.SetActive(false);
//				}
//			}
//			DescText.gameObject.SetActive(bookData.Skills.Count == 0);
            string attrsStr = "";

            if (bookData.MagicAttackPlus > 0)
            {
                attrsStr += string.Format("内功+{0} ", bookData.MagicAttackPlus);
            }
            if (bookData.MagicDefensePlus > 0)
            {
                attrsStr += string.Format("内防+{0} ", bookData.MagicDefensePlus);
            }
            if (bookData.PhysicsDefensePlus > 0)
            {
                attrsStr += string.Format("外防+{0} ", bookData.PhysicsDefensePlus);
            }
            if (bookData.DodgePlus > 0)
            {
                attrsStr += string.Format("轻功+{0} ", bookData.DodgePlus);
            }
            if (bookData.HurtCutRatePlus > 0)
            {
                attrsStr += string.Format("伤害减免{0}% ", (int)(bookData.HurtCutRatePlus * 100 + 0.5f));
            }
            if (bookData.MaxHPPlus > 0)
            {
                attrsStr += string.Format("气血+{0} ", bookData.MaxHPPlus);
            }
            if (bookData.CanNotMoveResistance > 0)
            {
                attrsStr += string.Format("抗定身+{0} ", bookData.CanNotMoveResistance);
            }
            if (bookData.ChaosResistance > 0)
            {
                attrsStr += string.Format("抗混乱+{0} ", bookData.ChaosResistance);
            }
            if (bookData.DisarmResistance > 0)
            {
                attrsStr += string.Format("抗缴械+{0} ", bookData.DisarmResistance);
            }
            if (bookData.DrugResistance > 0)
            {
                attrsStr += string.Format("抗毒+{0} ", bookData.DrugResistance);
            }
            if (bookData.SlowResistance > 0)
            {
                attrsStr += string.Format("抗迟缓+{0} ", bookData.SlowResistance);
            }
            if (bookData.VertigoResistance > 0)
            {
                attrsStr += string.Format("抗眩晕+{0} ", bookData.VertigoResistance);
            }
            DescText.text = string.Format("{0}", bookData.GetCurrentSkill() != null ? bookData.GetCurrentSkill().Desc.Replace(" ", "") : "<color=\"#00FFFF\">内功心法</color>\n(可以与秘籍同时装备)");
            if (bookData.BeUsingByRoleId != "")
            {
                UseBtn.gameObject.SetActive(false);
                UnuseBtn.gameObject.SetActive(true);
                bg.sprite = Statics.GetSprite("Border12");
            }
            else
            {
                UseBtn.gameObject.SetActive(true);
                UnuseBtn.gameObject.SetActive(false);
                bg.sprite = Statics.GetSprite("Border11");
            }
        }
Esempio n. 21
0
        void onClick(GameObject e)
        {
            if (weaponData == null)
            {
                return;
            }
            switch (e.name)
            {
            case "BreakBtn":
                ConfirmCtrl.Show(string.Format("确定将<color=\"{0}\">{1}</color>熔解?\n<color=\"#FF0000\">熔解后此兵器将永久消失</color>!", Statics.GetQualityColorString(weaponData.Quality), weaponData.Name), () => {
                    Messenger.Broadcast <int>(NotifyTypes.BreakWeapon, weaponData.PrimaryKeyId);
                }, null, "熔解", "放弃");
                break;

            case "ViewBtn":
                Messenger.Broadcast <WeaponData>(NotifyTypes.ShowWeaponDetailPanel, weaponData);
                break;

            default:
                break;
            }
        }
        void onClick(GameObject e)
        {
            if (!e.GetComponent <Button>().enabled)
            {
                return;
            }
            switch (e.name)
            {
            case "MakeBtn":
                if (bookData.Occupation == OccupationType.None || bookData.Occupation == hostRoleData.Occupation)
                {
                    if (bookData.State == BookStateType.Unread)
                    {
                        ConfirmCtrl.Show(string.Format("是否将{0}拼合成<color=\"{1}\">{2}</color>进行研读?", costStr, Statics.GetQualityColorString(bookData.Quality), bookData.Name), () => {
                            Messenger.Broadcast <int>(NotifyTypes.ReadBook, bookData.PrimaryKeyId);
                        });
                    }
                    else
                    {
                        AlertCtrl.Show(string.Format("<color=\"{0}\">{1}</color>已经研读过", Statics.GetQualityColorString(bookData.Quality), bookData.Name), null);
                    }
                }
                else
                {
                    AlertCtrl.Show(string.Format("非{0}弟子不得研习<color=\"{1}\">{2}</color>!", Statics.GetOccupationName(bookData.Occupation), Statics.GetQualityColorString(bookData.Quality), bookData.Name));
                }
                break;

            case "Btn":
                Messenger.Broadcast <BookData>(NotifyTypes.ShowBookDetailPanel, bookData);
                break;

            default:
                break;
            }
            viewedNewFlag();
        }
Esempio n. 23
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");
            }
        }
Esempio n. 24
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);
        }
Esempio n. 25
0
        /// <summary>
        /// 兵器强化
        /// </summary>
        /// <param name="weapon">Weapon.</param>
        public void WeaponLVUpgrade(WeaponData weapon)
        {
            db = OpenDb();
            List <ResourceData> needs = new List <ResourceData>();
            ResourceData        need;
            ResourceData        find;
            double needRate = DbManager.Instance.GetWeaponNeedRate(weapon.LV + 1);

            for (int i = 0; i < weapon.Needs.Count; i++)
            {
                need = weapon.Needs[i];
                find = needs.Find(item => item.Type == need.Type);
                if (find == null)
                {
                    needs.Add(new ResourceData(need.Type, need.Num * needRate));
                }
                else
                {
                    find.Num += (need.Num * needRate);
                }
            }
            SqliteDataReader    sqReader  = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'");
            List <ResourceData> resources = null;
            int id = 0;

            if (sqReader.Read())
            {
                id = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData"));
                resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr);
                resources    = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr);
            }
            db.CloseSqlConnection();

            if (resources != null)
            {
                bool   canAdd = true;
                string msg    = "";
                for (int i = 0; i < needs.Count; i++)
                {
                    need = needs[i];
                    find = resources.Find(item => item.Type == need.Type);
                    if (find != null && find.Num >= need.Num)
                    {
                        find.Num -= need.Num;
                    }
                    else
                    {
                        canAdd = false;
                        msg    = string.Format("{0}不足!", Statics.GetResourceName(need.Type));
                        break;
                    }
                }
                if (canAdd)
                {
                    db       = OpenDb();
                    sqReader = db.ExecuteQuery("select Id, Data from WeaponLVsTable where WeaponId = '" + weapon.Id + "' and BelongToRoleId = '" + currentRoleId + "'");
                    WeaponLVData lvData;
                    if (sqReader.Read())
                    {
                        //获取角色数据
                        lvData = JsonManager.GetInstance().DeserializeObject <WeaponLVData>(DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("Data"))));
                        if (weapon.LV >= lvData.MaxLV)
                        {
                            AlertCtrl.Show("兵器强化度已满");
                            db.CloseSqlConnection();
                            return;
                        }
                        lvData.LV = weapon.LV + 1;
                        db.ExecuteQuery("update WeaponLVsTable set Data = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(lvData)) + "' where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id")));
                    }
                    else
                    {
                        lvData = new WeaponLVData(weapon.LV + 1);
                        db.ExecuteQuery("insert into WeaponLVsTable (WeaponId, Data, BelongToRoleId) values('" + weapon.Id + "', '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(lvData)) + "', '" + currentRoleId + "')");
                    }

                    db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "' where Id = " + id);
                    db.CloseSqlConnection();
                    Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"{0}\">{1}</color>+1", Statics.GetQualityColorString(weapon.Quality), weapon.Name), Color.white, 30);
                    SoundManager.GetInstance().PushSound("ui0007");
                    Messenger.Broadcast <WeaponLVData>(NotifyTypes.WeaponLVUpgradeEcho, lvData);
                }
                else
                {
                    AlertCtrl.Show(msg, null);
                }
            }
        }
Esempio n. 26
0
        /// <summary>
        /// 打造兵器
        /// </summary>
        /// <param name="weaponId">Weapon identifier.</param>
        public void CreateNewWeaponOfWorkshop(string weaponId)
        {
            db = OpenDb();
            WeaponData          weapon = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", weaponId);
            List <ResourceData> needs  = new List <ResourceData>();
            ResourceData        need;
            ResourceData        find;

            for (int i = 0; i < weapon.Needs.Count; i++)
            {
                need = weapon.Needs[i];
                find = needs.Find(item => item.Type == need.Type);
                if (find == null)
                {
                    needs.Add(new ResourceData(need.Type, need.Num));
                }
                else
                {
                    find.Num += need.Num;
                }
            }
            SqliteDataReader    sqReader  = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'");
            List <ResourceData> resources = null;
            int id = 0;

            if (sqReader.Read())
            {
                id = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData"));
                resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr);
                resources    = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr);
            }
            db.CloseSqlConnection();

            if (resources != null)
            {
                bool   canAdd = true;
                string msg    = "";
                for (int i = 0; i < needs.Count; i++)
                {
                    need = needs[i];
                    find = resources.Find(item => item.Type == need.Type);
                    if (find != null && find.Num >= need.Num)
                    {
                        find.Num -= need.Num;
                    }
                    else
                    {
                        canAdd = false;
                        msg    = string.Format("{0}不足!", Statics.GetResourceName(need.Type));
                        break;
                    }
                }
                if (canAdd)
                {
                    //检测添加武器
                    if (AddNewWeapon(weapon.Id))
                    {
                        db = OpenDb();
                        db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "' where Id = " + id);
                        db.CloseSqlConnection();
                        Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"{0}\">{1}</color>+1", Statics.GetQualityColorString(weapon.Quality), weapon.Name), Color.white, 30);
                        SoundManager.GetInstance().PushSound("ui0007");
                    }
                    else
                    {
                        AlertCtrl.Show("兵器匣已满!", null);
                    }
                }
                else
                {
                    AlertCtrl.Show(msg, null);
                }
            }
        }
Esempio n. 27
0
        public override void RefreshView()
        {
            iconImage.sprite = Statics.GetIconSprite(bookData.IconId);
            flashImage.gameObject.SetActive(((int)bookData.Quality) >= ((int)QualityType.FlashGold));
            nameText.text = string.Format("<color=\"{0}\">{1}</color>", Statics.GetQualityColorString(bookData.Quality), bookData.Name);
            descText.text = string.Format("{0}{1}{2}{3}\n描述:\n{4}",
                                          bookData.GetCurrentSkill() != null ? bookData.GetCurrentSkill().Desc : "心法无招式",
                                          bookData.LimitWeaponType != WeaponType.None ? string.Format("\n兵器限制:{0}", Statics.GetEnmuDesc <WeaponType>(bookData.LimitWeaponType)) : "",
                                          info != "" ? string.Format("\n附加属性:\n<color=\"#00FF00\">{0}</color>", info) : "",
                                          secretInfo != "" ? string.Format("\n诀要加成属性:\n<color=\"#00FF00\">{0}</color>", secretInfo) : "",
                                          !string.IsNullOrEmpty(bookData.Desc) ? bookData.Desc : "无");
            if (bookData.IsMindBook)
            {
                titleText.text = "心法";
            }
            else if (bookData.IsLostKnowledge)
            {
                titleText.text = "绝学";
            }
            else
            {
                titleText.text = "秘籍";
            }
            if (prefabObj == null)
            {
                prefabObj = Statics.GetPrefab("Prefabs/UI/GridItems/SkillItemContainer");
            }
            StartCoroutine(refreshHeight());
            if (!bookData.IsMindBook)
            {
                secretsDescText.text = string.Format("修为:\n{0}/{1}", expAndSecretData.Exp.Cur, expAndSecretData.Exp.Max > 0 ? Statics.GetBookStepExp(expAndSecretData.Exp.Cur) : 0);
                studyText.text       = string.Format("领悟:{0}/{1}", expAndSecretData.Secrets.Count, Statics.GetBookLV(expAndSecretData.Exp.Cur));
                MakeButtonEnable(studyBtn, true);
            }
            else
            {
                secretsDescText.text = "修为:\n不可修炼";
                studyText.text       = "不可领悟";
                MakeButtonEnable(studyBtn, false);
            }
//			if (bookData.Skills.Count > 0) {
//				emptyImage.gameObject.SetActive(false);
//				SkillData skill;
//				GameObject itemPrefab;
//				SkillItemContainer container;
//				for (int i = 0; i < bookData.Skills.Count; i++) {
//					skill = bookData.Skills[i];
//					if (containers.Count <= i) {
//						itemPrefab = Statics.GetPrefabClone(prefabObj);
//						MakeToParent(gridTrans.transform, itemPrefab.transform);
//						container = itemPrefab.GetComponent<SkillItemContainer>();
//						containers.Add(container);
//					}
//					else {
//						container = containers[i];
//					}
//					container.UpdateData(skill, i != bookData.Skills.Count - 1);
//					container.RefreshView();
//				}
//			}
//			else {
//				emptyImage.gameObject.SetActive(true);
//			}
        }
Esempio n. 28
0
        void onClick(GameObject e)
        {
            switch (e.name)
            {
            case "Block":
                Back();
                break;

            case "lvUpgradeBtn":
                if (weaponData.LV >= weaponLVData.MaxLV)
                {
                    AlertCtrl.Show(string.Format("<color=\"{0}\">{1}</color>强化度已到满级", Statics.GetQualityColorString(weaponData.Quality), weaponData.Name));
                    break;
                }
                string needMsg  = "";
                double needRate = DbManager.Instance.GetWeaponNeedRate(weaponData.LV + 1);
                for (int i = 0, len = weaponData.Needs.Count; i < len; i++)
                {
                    needMsg += string.Format("{0}个{1}", weaponData.Needs[i].Num * needRate, Statics.GetEnmuDesc <ResourceType>(weaponData.Needs[i].Type)) + (i < len - 1 ? "," : "");
                }
                ConfirmCtrl.Show(string.Format("将<color=\"{0}\">{1}</color>强化到{2}\n需要{3}\n是否立即强化兵器?", Statics.GetQualityColorString(weaponData.Quality), weaponData.Name, weaponData.LV + 1, needMsg), () => {
                    Messenger.Broadcast <WeaponData>(NotifyTypes.WeaponLVUpgrade, weaponData);
                });
                break;

            default:
                break;
            }
        }
Esempio n. 29
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;
                }
            }
        }