Example #1
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())
            {
                //获取角色数据
                RoleData role = JsonManager.GetInstance().DeserializeObject <RoleData>(sqReader.GetString(sqReader.GetOrdinal("RoleData")));
                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 = '" + 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);
                            }
                        }
                        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);          //刷新队伍数据
        }
 public void UpdateData(RoleData role)
 {
     roleData = role;
     roleData.MakeJsonToModel();
     weapon = roleData.Weapon;
 }
Example #3
0
        /// <summary>
        /// 直接用工坊资源结交侠客
        /// </summary>
        /// <param name="id">Identifier.</param>
        public void InviteRoleWithResources(int id)
        {
            bool     invited = false;
            RoleData role    = null;

            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select Id, RoleId, State from RolesTable where Id = " + id);

            if (sqReader.Read())
            {
                role = JsonManager.GetInstance().GetMapping <RoleData>("RoleDatas", sqReader.GetString(sqReader.GetOrdinal("RoleId")));
                RoleStateType state = (RoleStateType)sqReader.GetInt32(sqReader.GetOrdinal("State"));
                if (state == RoleStateType.NotRecruited)
                {
                    //兵器匣里并没有需要的兵器
                    WeaponData          weapon = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", role.ResourceWeaponDataId);
                    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;
                        }
                    }
                    sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'");
                    List <ResourceData> resources = null;
                    int resourceId = 0;
                    if (sqReader.Read())
                    {
                        resourceId = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                        resources  = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(sqReader.GetString(sqReader.GetOrdinal("ResourcesData")));
                    }
                    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();
                            db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + JsonManager.GetInstance().SerializeObject(resources) + "' where Id = " + resourceId);
                            //结交侠客
                            db.ExecuteQuery("update RolesTable set State = " + ((int)RoleStateType.OutTeam) + ", SeatNo = 888 where Id = " + id);
                            invited = true;
                            db.CloseSqlConnection();
                        }
                        else
                        {
                            AlertCtrl.Show(msg, null);
                        }
                    }
                }
                else
                {
                    AlertCtrl.Show("你们已经结识!", null);
                }
            }
            db.CloseSqlConnection();
            if (invited && role != null)
            {
                Statics.CreatePopMsg(Vector3.zero, string.Format("你与<color=\"#FFFF00\">{0}</color>撮土为香,结成八拜之交!", role.Name), Color.white, 30);
                GetRolesOfWinShopPanelData(role.HometownCityId);
            }
        }
Example #4
0
        /// <summary>
        /// Battles the notify init.
        /// </summary>
        public static void BattleNotifyInit()
        {
            Messenger.AddListener <string>(NotifyTypes.CreateBattle, (fightId) => {
                if (BattleFightPanelCtrl.Ctrl != null)
                {
                    Statics.CreatePopMsg(Vector3.zero, "已在战斗中", Color.white, 30);
                    return;
                }
                //获取队伍角色列表
//				RoleData currentRoleData = RoleInfoPanelCtrl.GetCurrentRoleData();
                RoleData currentRoleData = DbManager.Instance.GetHostRoleData();
                if (currentRoleData == null)
                {
                    return;
                }
                currentRoleData.MakeJsonToModel();
                if (currentRoleData.Injury == InjuryType.Moribund)
                {
                    AlertCtrl.Show("你已奄奄一息无法再战!", () => {
                        Messenger.Broadcast(NotifyTypes.BackToCity);
                    });
                    return;
                }
                //获取战斗数据
//				FightData fightData = new FightData();
//				fightData.Id = fightId;
//				fightData.Type = FightType.Normal;
//				RoleData enemy0 = new RoleData();
//				enemy0.Id = "enemy0";
//				enemy0.Name = "赏金刺客";
//				enemy0.HalfBodyId = "enemy000001";
//				BookData book0 = new BookData();
//				book0.Id = "book20001";
//				book0.Name = "地痞撒泼";
//				book0.IconId = "200000";
//				SkillData skill0 = new SkillData();
//				skill0.Type = SkillType.MagicAttack;
//				skill0.Name = "背负投";
//				BuffData buff0 = new BuffData();
//				buff0.Type = BuffType.Vertigo;
////				buff0.Value = 8888;
////				buff0.FirstEffect = true;
//				buff0.RoundNumber = 3;
//				buff0.Rate = 30;
//				buff0.FirstEffect = true;
//				skill0.DeBuffDatas.Add(buff0);
//				SkillData skill1 = new SkillData();
//				skill1.Type = SkillType.PhysicsAttack;
//				skill1.Name = "抱摔";
//				SkillData skill2 = new SkillData();
//				skill2.Type = SkillType.PhysicsAttack;
//				skill2.Name = "撕咬";
//				book0.Skills.Add(skill0);
//				book0.Skills.Add(skill1);
//				book0.Skills.Add(skill2);
//				enemy0.Books.Add(book0);
//				enemy0.AttackSpeed = 2;
//				enemy0.HP = 10000;
//				enemy0.MaxHP = 10000;
//				WeaponData weapon5 = new WeaponData();
//				weapon5.Id = "weapon5";
//				weapon5.Id = "阔刃刀";
//				weapon5.Width = 360;
//				weapon5.Rates = new float[] { 1, 0.6f, 0.2f, 0.1f };
//				enemy0.Weapon = weapon5;
//				fightData.Enemys = new List<RoleData>() {
//					enemy0
//				};
//                List<RoleData> teams = RoleInfoPanelCtrl.GetRoleDatas();
                List <RoleData> teams             = DbManager.Instance.GetRolesInTeam();
                List <List <SecretData> > secrets = new List <List <SecretData> >();
                for (int i = 0, len = teams.Count; i < len; i++)
                {
                    if (teams[i].IsHost)
                    {
                        WeaponLVData weaponLvData = DbManager.Instance.GetWeaponLV(teams[i].ResourceWeaponDataId);
                        teams[i].CurrentWeaponLV  = weaponLvData.LV;
                    }
                    teams[i].MakeJsonToModel();
                    secrets.Add(DbManager.Instance.GetSecretsBelongBooks(teams[i].ResourceBookDataIds));
                }
                FightData fightData = JsonManager.GetInstance().GetMapping <FightData>("Fights", fightId);
                fightData.MakeJsonToModel();
                Messenger.Broadcast(NotifyTypes.HideRoleInfoPanel);
                SoundManager.GetInstance().PauseBGM();
                SoundManager.GetInstance().PushSound("ui0003");
                Messenger.Broadcast <System.Action, System.Action>(NotifyTypes.PlayCameraVortex, () => {
//					BattleMainPanelCtrl.Show(currentRoleData, fightData);
                    List <ItemData> drugs = new List <ItemData>();
//                    drugs.Add(JsonManager.GetInstance().GetMapping<ItemData>("ItemDatas", "100001"));
//                    drugs.Add(JsonManager.GetInstance().GetMapping<ItemData>("ItemDatas", "100002"));
//                    drugs.Add(JsonManager.GetInstance().GetMapping<ItemData>("ItemDatas", "100003"));
                    List <ItemData> allVulnerary = DbManager.Instance.GetItems(ItemType.Drug);
                    for (int i = 0; i < 3; i++)
                    {
                        if (allVulnerary.Count > i)
                        {
                            drugs.Add(allVulnerary[i]);
                        }
                        else
                        {
                            break;
                        }
                    }
                    //处理通天塔量子强度影响的敌人成长率
                    if (UserModel.CurrentUserData.CurrentAreaSceneName == "Area31")
                    {
                        int difficulty = PlayerPrefs.GetInt("TowerDifficulty");
                        float growUp;
                        switch (difficulty)
                        {
                        case 0:
                        default:
                            growUp = 1;
                            break;

                        case 1:
                            growUp = 2;
                            break;

                        case 2:
                            growUp = 4;
                            break;
                        }
                        for (int i = 0, len = fightData.Enemys.Count; i < len; i++)
                        {
                            fightData.Enemys[i].SetGrowUp(growUp);
                        }
                    }
                    BattleFightPanelCtrl.Show(fightData, teams, secrets, fightData.Enemys, drugs, DbManager.Instance.GetProp(PropType.LimePowder));
                    PlayerPrefs.SetString("BattleIsGoingOn_FightFlag_For_" + DbManager.Instance.HostData.Id, fightId);
                }, () => {
//					Messenger.Broadcast<bool>(NotifyTypes.CallRoleInfoPanelData, true);
                });
            });

            Messenger.AddListener <List <RoleData>, string>(NotifyTypes.CreateTestBattle, (roles, fightId) => {
//                List<List<SecretData>> secrets = new List<List<SecretData>>();
//                for (int i = 0, len = roles.Count; i < len; i++) {
//                    secrets.Add(DbManager.Instance.GetSecretsBelongBooks(roles[i].ResourceBookDataIds));
//                }
                TextAsset asset = Resources.Load <TextAsset>("Data/Json/TestSecrets");
                List <List <SecretData> > secrets = PlayerPrefs.GetString("FightEditorUseSecret") == "true" ? JsonManager.GetInstance().DeserializeObject <List <List <SecretData> > >(asset.text) : new List <List <SecretData> >();
                FightData fightData = JsonManager.GetInstance().GetMapping <FightData>("Fights", fightId);
                fightData.MakeJsonToModel();
//				BattleMainPanelCtrl.Show(currentRoleData, fightData);
                List <ItemData> drugs = new List <ItemData>();
                drugs.Add(JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", "100001"));
                drugs.Add(JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", "100002"));
                drugs.Add(JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", "100003"));

                for (int i = 0, len = fightData.Enemys.Count; i < len; i++)
                {
                    fightData.Enemys[i].SetGrowUp(PlayerPrefs.GetFloat("FightEditorTestGroupUp"));
                }
                BattleFightPanelCtrl.Show(fightData, roles, secrets, fightData.Enemys, drugs, DbManager.Instance.GetProp(PropType.LimePowder));
            });

            Messenger.AddListener <bool, List <DropData>, FightData>(NotifyTypes.EndBattle, (win, drops, fightData) => {
                if (!win)
                {
                    MaiHandler.SendEvent("FightFail", DbManager.Instance.HostData.Lv.ToString(), fightData.Id);
                }
//				Messenger.Broadcast(NotifyTypes.HideRoleInfoPanel);
                Messenger.Broadcast <System.Action, System.Action>(NotifyTypes.PlayCameraVortex, () => {
                    //如果普通战斗失败则回之前到过的城镇去疗伤
                    if (fightData.Type == FightType.Normal && !win)
                    {
                        AlertCtrl.Show("江湖凶险, 稍事休息后再出发!", () => {
                            Messenger.Broadcast(NotifyTypes.BackToCity);
                            PlayerPrefs.SetString("BattleIsGoingOn_FightFlag_For_" + DbManager.Instance.HostData.Id, "");
                        });
                    }
                    else
                    {
                        PlayerPrefs.SetString("BattleIsGoingOn_FightFlag_For_" + DbManager.Instance.HostData.Id, "");
                    }
//					BattleMainPanelCtrl.Hide();
                    BattleFightPanelCtrl.Hide();
                }, () => {
                    //任务详情界面打开时不呼出角色信息板
                    if (TaskDetailInfoPanelCtrl.Ctrl == null)
                    {
                        Messenger.Broadcast <bool>(NotifyTypes.CallRoleInfoPanelData, false);
                    }
                    Messenger.Broadcast(NotifyTypes.PlayBgm);
                    if (drops.Count > 0)
                    {
                        Messenger.Broadcast <List <DropData> >(NotifyTypes.ShowDropsListPanel, drops);
                    }
                    if (fightData.Type == FightType.Task)
                    {
                        Messenger.Broadcast(NotifyTypes.ReloadTaslDetailInfoData);
                        if (win)
                        {
                            Messenger.Broadcast <string>(NotifyTypes.MakeFightWinedBtnDisable, fightData.Id);
                        }
                    }
                });
            });

            Messenger.AddListener <RoleData>(NotifyTypes.ChangeCurrentTeamRoleInBattle, (roleData) => {
                BattleMainPanelCtrl.ChangeCurrentTeamRole(roleData);
            });

            Messenger.AddListener <int>(NotifyTypes.ChangeCurrentTeamBookInBattle, (index) => {
                BattleMainPanelCtrl.ChangeCurrentTeamBook(index);
            });

            Messenger.AddListener <JArray, List <BookData> >(NotifyTypes.SendFightResult, (data, books) => {
                DbManager.Instance.SendFightResult((bool)data[0], data[1].ToString(), (int)data[2], (int)data[5], books, (float)data[6]);
                JArray usedSkillIdData = (JArray)data[3];
                JArray d;
                for (int i = 0; i < usedSkillIdData.Count; i++)
                {
                    d = (JArray)usedSkillIdData[i];
                    DbManager.Instance.UpdateUsedTheSkillRecords(d[0].ToString(), (int)d[1]);
                }
                JArray plusIndexData = (JArray)data[4];
                for (int i = 0; i < plusIndexData.Count; i++)
                {
                    d = (JArray)plusIndexData[i];
                    DbManager.Instance.UpdateWeaponPowerPlusSuccessedRecords((int)d[0], (int)d[1]);
                }
            });

            Messenger.AddListener <bool, List <DropData>, FightData>(NotifyTypes.SendFightResultEcho, (win, drops, fightData) => {
                //加载动态事件列表
                Messenger.Broadcast <string>(NotifyTypes.GetActiveEventsInArea, UserModel.CurrentUserData.CurrentAreaSceneName);
                Messenger.Broadcast <bool, List <DropData>, FightData>(NotifyTypes.EndBattle, win, drops, fightData);
            });

            Messenger.AddListener(NotifyTypes.BackToCity, () => {
                string eventId = JsonManager.GetInstance().GetMapping <string>("AreaCityPosDatas", UserModel.CurrentUserData.CurrentCitySceneId);
                string[] fen   = eventId.Split(new char[] { '_' });
                if (fen.Length >= 3)
                {
                    string areaName = fen[0];
                    int x           = int.Parse(fen[1]);
                    int y           = int.Parse(fen[2]);
                    if (UserModel.CurrentUserData != null)
                    {
                        UserModel.CurrentUserData.PositionStatu        = UserPositionStatusType.InCity;
                        UserModel.CurrentUserData.CurrentAreaSceneName = areaName;
                        UserModel.CurrentUserData.CurrentAreaX         = x;
                        UserModel.CurrentUserData.CurrentAreaY         = y;
                        Messenger.Broadcast <System.Action <UserData> >(NotifyTypes.UpdateUserData, null);
                        Messenger.Broadcast <string>(NotifyTypes.GoToScene, areaName);
                    }
                }
            });

            Messenger.AddListener(NotifyTypes.BattleFaild, () => {
                BattleMainPanelCtrl.MakeFaild();
            });

            Messenger.AddListener <string>(NotifyTypes.MakePopRole, (dieRoleId) => {
                RoleInfoPanelCtrl.MakePopRole(dieRoleId);
            });
        }
Example #5
0
 public void UpdateData(WeaponData weapon, WeaponData hostWeapon, RoleData host)
 {
     weaponData     = weapon;
     hostWeaponData = hostWeapon;
     hostRoleData   = host;
 }
Example #6
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"));
                //获取角色数据
                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 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 = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObjectDealVector(role)) + "' where RoleId = '" + roleId + "'");
                            SoundManager.GetInstance().PushSound("ui0011");
                        }
                        else
                        {
                            AlertCtrl.Show(string.Format("装备上[{0}]才能习练\n<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("最多只能同时携带三本书!", null);
            }
        }
Example #7
0
 public void UpdateData(RoleData role)
 {
     roleData = role;
 }