Esempio n. 1
0
        /// <summary>
        /// 熔解兵器
        /// </summary>
        /// <param name="primaryKeyId">Primary key identifier.</param>
        public void BreakWeapon(int primaryKeyId)
        {
            int resultId = 0;

            db = OpenDb();
            //查询资源
            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);
            }
            if (resources != null)
            {
                sqReader = db.ExecuteQuery("select Id, WeaponId from WeaponsTable where Id = " + primaryKeyId);
                if (sqReader.Read())
                {
                    WeaponData   weapon = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", sqReader.GetString(sqReader.GetOrdinal("WeaponId")));
                    ResourceData findResource;
                    ResourceData resource;
                    float        addNum;
                    for (int i = 0; i < weapon.Needs.Count; i++)
                    {
                        resource     = weapon.Needs[i];
                        findResource = resources.Find(item => item.Type == resource.Type);
                        if (findResource != null)
                        {
                            addNum = Mathf.Floor((float)(resource.Num * 0.5f));
                            //累加资源
                            findResource.Num += addNum;
                        }
                    }
                    //删除兵器
                    db.ExecuteQuery("delete from WeaponsTable where Id = " + primaryKeyId);
                    //更新资源
                    db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "' where Id = " + id);
                    resultId = primaryKeyId;
                }
            }
            db.CloseSqlConnection();
            if (primaryKeyId > 0)
            {
                Messenger.Broadcast <int>(NotifyTypes.BreakWeaponEcho, primaryKeyId);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// 前往城镇
        /// </summary>
        /// <param name="fromIndex">From index.</param>
        /// <param name="toIndex">To index.</param>
        public void GoToCity(int fromIndex, int toIndex)
        {
            SceneData toScene = null;

            ModifyResources();
            db = OpenDb();
            string           indexToId = JsonManager.GetInstance().GetMapping <string>("SceneIndexToIds", toIndex.ToString());
            SqliteDataReader sqReader  = db.ExecuteQuery("select CityId from EnterCityTable where CityId == '" + indexToId + "' and BelongToRoleId = '" + currentRoleId + "'");

            if (sqReader.HasRows)
            {
                FloydResult result = floyd.GetResult(fromIndex, toIndex);
                //查询银子是否足够支付路费
                sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'");
                List <ResourceData> resources = null;
                if (sqReader.Read())
                {
                    string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData"));
                    resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr);
                    resources    = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr);
                    //查询目前的银子余额
                    ResourceData resource = resources.Find(re => re.Type == ResourceType.Silver);
                    if (resource != null)
                    {
                        if (resource.Num >= result.Distance)
                        {
                            resource.Num -= result.Distance;
                            //扣钱
                            db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "' where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id")));
                            toScene = JsonManager.GetInstance().GetMapping <SceneData>("Scenes", GetCityIdByIndex(toIndex));
                            Debug.LogWarning(GetCityIdByIndex(toIndex) + "," + toScene.Id + "," + toScene.Name);
                        }
                        else
                        {
                            AlertCtrl.Show("银子不够支付路费!");
                        }
                    }
                }
            }
            else
            {
                AlertCtrl.Show("并没有开启前方传送点!");
            }
            db.CloseSqlConnection();
            if (toScene != null)
            {
                Messenger.Broadcast <SceneData>(NotifyTypes.GoToCityEcho, toScene);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 获取准备出发界面数据
        /// </summary>
        public void GetReadyToTravelPanelData()
        {
            ModifyResources();
            List <RoleData> roles = new List <RoleData>();
            ItemData        food  = null;

            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select * from RolesTable where State != " + ((int)RoleStateType.NotRecruited) + " and BelongToRoleId = '" + currentRoleId + "' order by State");
            RoleData         role;

            while (sqReader.Read())
            {
                role = JsonManager.GetInstance().DeserializeObject <RoleData>(sqReader.GetString(sqReader.GetOrdinal("RoleData")));
                role.MakeJsonToModel();
                role.PrimaryKeyId = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                role.State        = (RoleStateType)sqReader.GetInt32(sqReader.GetOrdinal("State"));
                role.Injury       = (InjuryType)sqReader.GetInt32(sqReader.GetOrdinal("InjuryType"));
                roles.Add(role);
            }
            sqReader = db.ExecuteQuery("select Data, AreaFoodNum from UserDatasTable where BelongToRoleId = '" + currentRoleId + "'");
            if (sqReader.Read())
            {
                UserData user = JsonManager.GetInstance().DeserializeObject <UserData>(sqReader.GetString(sqReader.GetOrdinal("Data")));
                user.AreaFood.Num = sqReader.GetInt32(sqReader.GetOrdinal("AreaFoodNum"));
                if (user.AreaFood.Num < user.AreaFood.MaxNum)
                {
                    sqReader = db.ExecuteQuery("select * from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'");
                    if (sqReader.Read())
                    {
                        //更新
                        List <ResourceData> resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(sqReader.GetString(sqReader.GetOrdinal("ResourcesData")));
                        ResourceData        resource  = resources.Find(item => item.Type == ResourceType.Food);
                        double cutNum = (double)(user.AreaFood.MaxNum - user.AreaFood.Num);
                        cutNum = resource.Num >= cutNum ? cutNum : resource.Num;
                        if (cutNum > 0)
                        {
                            resource.Num      -= cutNum;
                            user.AreaFood.Num += (int)cutNum;
                        }
                    }
                }
                food = user.AreaFood;
            }
            db.CloseSqlConnection();
            if (roles.Count > 0 && food != null)
            {
                Messenger.Broadcast <List <RoleData>, ItemData>(NotifyTypes.GetReadyToTravelPanelDataEcho, roles, food);
            }
        }
Esempio n. 4
0
        /// <summary>
        /// 将索引映射成实体类
        /// </summary>
        public void MakeJsonToModel()
        {
            Books.Clear();
            BookData book;

            for (int i = 0; i < ResourceBookDataIds.Count; i++)
            {
                book = JsonManager.GetInstance().GetMapping <BookData>("Books", ResourceBookDataIds[i]);
                book.MakeJsonToModel();
                Books.Add(book);
            }
            if (ResourceWeaponDataId != "")
            {
                Weapon = JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", ResourceWeaponDataId);
            }
            else
            {
                Weapon = null;
            }
            //处理伤势对全属性的影响
            switch (Injury)
            {
            case InjuryType.None:
            default:
                injuryRate = 1;
                break;

            case InjuryType.White:
                injuryRate = 0.9f;
                break;

            case InjuryType.Yellow:
                injuryRate = 0.8f;
                break;

            case InjuryType.Purple:
                injuryRate = 0.6f;
                break;

            case InjuryType.Red:
                injuryRate = 0.2f;
                break;

            case InjuryType.Moribund:
                injuryRate = 0.1f;
                break;
            }
            InitAttribute();
        }
Esempio n. 5
0
        /// <summary>
        /// 治疗侠客
        /// </summary>
        /// <param name="id">Identifier.</param>
        public void CureRole(int id)
        {
            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select RoleData, InjuryType from RolesTable where Id = " + id);
            int      injury;
            bool     success = false;
            RoleData role    = null;

            if (sqReader.Read())
            {
                injury = sqReader.GetInt32(sqReader.GetOrdinal("InjuryType"));
                string roleDataStr = sqReader.GetString(sqReader.GetOrdinal("RoleData"));
                roleDataStr = roleDataStr.IndexOf("{") == 0 ? roleDataStr : DESStatics.StringDecder(roleDataStr);
                role        = JsonManager.GetInstance().DeserializeObject <RoleData>(roleDataStr);
                if (injury > 0)
                {
                    sqReader = db.ExecuteQuery("select Id, Num from BagTable where Type = " + ((int)ItemType.Vulnerary) + " and Lv >= " + injury + " and BelongToRoleId = '" + currentRoleId + "' order by Lv");
                    int primaryKeyId = 0;
                    int num          = 0;
                    if (sqReader.Read())
                    {
                        primaryKeyId = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                        num          = sqReader.GetInt32(sqReader.GetOrdinal("Num"));
                        if (num > 1)
                        {
                            db.ExecuteQuery("update BagTable set Num = " + (num - 1) + " where Id = " + primaryKeyId);
                        }
                        else
                        {
                            db.ExecuteQuery("delete from BagTable where Id = " + primaryKeyId);
                        }
                        db.ExecuteQuery("update RolesTable set InjuryType = " + ((int)InjuryType.None) + " where Id = " + id);
                        success = true;
                    }
                    else
                    {
                        AlertCtrl.Show(string.Format("行囊中并未发现有能够治愈{0}的伤药(需要{1}级伤药)", Statics.GetInjuryName((InjuryType)injury), injury), null);
                    }
                }
            }
            db.CloseSqlConnection();

            if (success && role != null)
            {
                Statics.CreatePopMsg(Vector3.zero, string.Format("<color=\"#FFFF00\">{0}</color>的伤势已经痊愈!", role.Name), Color.white, 30);
                GetHospitalPanelData();
                CallRoleInfoPanelData(false);                 //刷新队伍数据
            }
        }
Esempio n. 6
0
        /// <summary>
        /// 获取秘籍的修为和已领悟的诀要集合
        /// </summary>
        /// <returns>The book exp and secrets.</returns>
        public ExpAndSecretData GetBookExpAndSecrets(string bookId)
        {
            ExpAndSecretData data = new ExpAndSecretData();

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

            if (sqReader.Read())
            {
                data.Exp     = JsonManager.GetInstance().DeserializeObject <ExpData>(DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("ExpData"))));
                data.Secrets = JsonManager.GetInstance().DeserializeObject <List <SecretData> >(DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("SecretsData"))));
            }
            db.CloseSqlConnection();
            return(data);
        }
Esempio n. 7
0
        /// <summary>
        /// 刷新任务
        /// </summary>
        public void RefreshTaskToNpc()
        {
            TaskData taskData;

            for (int i = 0; i < taskList.Count; i++)
            {
                taskData = taskList[i];
                if (!npcContainersMapping.ContainsKey(taskData.BelongToNpcId))
                {
                    createNpcContainer(JsonManager.GetInstance().GetMapping <NpcData>("Npcs", taskData.BelongToNpcId));
                }
                npcContainersMapping[taskData.BelongToNpcId].UpdateTaskData(taskData.Id, taskData.State);
                npcContainersMapping[taskData.BelongToNpcId].RefreshTaskView();
            }
        }
Esempio n. 8
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);
     }
 }
Esempio n. 9
0
        /// <summary>
        /// 查询道具诗句
        /// </summary>
        /// <returns>The property.</returns>
        /// <param name="type">Type.</param>
        public PropData GetProp(PropType type)
        {
            PropData propData = null;

            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select Id, Data from GiftsTable where Type = " + (int)type + " and BelongToRoleId = '" + currentRoleId + "'");
            string           dataStr;

            if (sqReader.Read())
            {
                dataStr  = DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("Data")));
                propData = JsonManager.GetInstance().DeserializeObject <PropData>(dataStr);
            }
            db.CloseSqlConnection();
            return(propData);
        }
Esempio n. 10
0
        /// <summary>
        /// 根据角色id查询角色数据
        /// </summary>
        /// <returns>The role data by role identifier.</returns>
        /// <param name="roleId">Role identifier.</param>
        public RoleData GetRoleDataByRoleId(string roleId)
        {
            RoleData data = null;

            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select Id, RoleData, InjuryType from RolesTable where RoleId = '" + roleId + "' and State > 0 and BelongToRoleId = '" + currentRoleId + "'");

            if (sqReader.Read())
            {
                data = JsonManager.GetInstance().DeserializeObject <RoleData>(sqReader.GetString(sqReader.GetOrdinal("RoleData")));
                data.PrimaryKeyId = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                data.Injury       = (InjuryType)sqReader.GetInt32(sqReader.GetOrdinal("InjuryType"));
            }
            db.CloseSqlConnection();
            return(data);
        }
Esempio n. 11
0
        /// <summary>
        /// 将索引映射成实体类
        /// </summary>
        public void MakeJsonToModel()
        {
            Enemys.Clear();
            RoleData enemy;

            for (int i = 0; i < ResourceEnemyIds.Count; i++)
            {
                enemy = JsonManager.GetInstance().GetMapping <RoleData>("RoleDatas", ResourceEnemyIds[i]);
//				enemy.MakeJsonToModel();
                Enemys.Add(enemy);
            }
            for (int i = 0; i < Drops.Count; i++)
            {
                Drops[i].MakeJsonToModel();
            }
        }
Esempio n. 12
0
        /// <summary>
        /// 添加一个新的侠客进酒馆
        /// </summary>
        /// <param name="roleId">Role identifier.</param>
        public void PushNewRoleToWinShop(string roleId)
        {
            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select RoleData from RolesTable where RoleId = '" + roleId + "' and BelongToRoleId = '" + currentRoleId + "'");

            if (!sqReader.HasRows)
            {
                RoleData role = JsonManager.GetInstance().GetMapping <RoleData>("RoleDatas", roleId);
                db.ExecuteQuery("insert into RolesTable (RoleId, RoleData, State, SeatNo, HometownCityId, BelongToRoleId, InjuryType, Ticks, DateTime) values('" + roleId + "', '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObjectDealVector(role)) + "', 0, 888, '" + role.HometownCityId + "', '" + currentRoleId + "', " + ((int)InjuryType.None) + ", " + DateTime.Now.Ticks + ", '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "');");
                if (CitySceneModel.RoleIdOfWinShopNewFlagList.FindIndex(item => item == roleId) < 0)
                {
                    CitySceneModel.RoleIdOfWinShopNewFlagList.Add(roleId);
                }
            }
            db.CloseSqlConnection();
        }
Esempio n. 13
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. 14
0
        /// <summary>
        /// 查询可以领悟的所有诀要
        /// </summary>
        /// <returns>The effective secrets.</returns>
        public List <SecretData> GetEffectiveSecrets()
        {
            List <SecretData> secrets = new List <SecretData>();

            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select * from BookSecretsTable where BelongToRoleId = '" + currentRoleId + "' and BelongToBookId = ''");
            SecretData       secret;

            while (sqReader.Read())
            {
                secret = JsonManager.GetInstance().DeserializeObject <SecretData>(DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("SecretData"))));
                secret.PrimaryKeyId = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                secrets.Add(secret);
            }
            db.CloseSqlConnection();
            return(secrets);
        }
Esempio n. 15
0
 /// <summary>
 /// 初始化任务相关数据
 /// </summary>
 void initTasks()
 {
     validTaskListData();
     if (childrenTasksMapping == null)
     {
         childrenTasksMapping = new Dictionary <string, List <string> >();
         JObject  obj = JsonManager.GetInstance().GetJson("Tasks");
         TaskData taskData;
         //处理新的任务
         TaskData task;
         foreach (var item in obj)
         {
             if (item.Key != "0")
             {
                 taskData = JsonManager.GetInstance().DeserializeObject <TaskData>(item.Value.ToString());
                 //初始化后置任务
                 if (!childrenTasksMapping.ContainsKey(taskData.Id))
                 {
                     childrenTasksMapping[taskData.Id] = new List <string>();
                 }
                 if (!childrenTasksMapping.ContainsKey(taskData.FrontTaskDataId))
                 {
                     childrenTasksMapping[taskData.FrontTaskDataId] = new List <string>();
                 }
                 //处理后置任务
                 if (taskData.BackTaskDataId != "0" &&
                     !string.IsNullOrEmpty(taskData.BackTaskDataId) &&
                     childrenTasksMapping[taskData.Id].FindIndex(id => id == taskData.BackTaskDataId) < 0)
                 {
                     childrenTasksMapping[taskData.Id].Add(taskData.BackTaskDataId);
                 }
                 //处理前置任务
                 if (childrenTasksMapping[taskData.FrontTaskDataId].FindIndex(id => id == taskData.Id) < 0)
                 {
                     childrenTasksMapping[taskData.FrontTaskDataId].Add(taskData.Id);
                 }
                 //查找当前任务的前置任务有没有完成,如果完成该任务需要添加为新任务
                 task = taskListData.Find(t => t.Id == taskData.FrontTaskDataId && t.State == TaskStateType.Completed);
                 if (task != null)
                 {
                     AddNewTaskExceptType(taskData.Id, TaskType.IsBindedWithEvent);
                 }
             }
         }
     }
 }
Esempio n. 16
0
        /// <summary>
        /// 查询城镇开启情况列表
        /// </summary>
        public void GetCitySceneMenuData(string cityId)
        {
            List <string> openedCityIds = new List <string>();

            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select CityId from EnterCityTable where BelongToRoleId = '" + currentRoleId + "'");

            while (sqReader.Read())
            {
                openedCityIds.Add(sqReader.GetString(sqReader.GetOrdinal("CityId")));
            }
            db.CloseSqlConnection();
            SceneData scene = JsonManager.GetInstance().GetMapping <SceneData>("Scenes", cityId);

            scene.MakeJsonToModel();
            CityScenePanelCtrl.Show(scene, openedCityIds);
        }
Esempio n. 17
0
        /// <summary>
        /// 请求资源累加数据
        /// </summary>
        /// <param name="data">Data.</param>
        public void ModifyResourcesEcho(JArray data)
        {
            modifyTimeout = (int)data[0] + 1;
            List <ResourceData> receiveResources  = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(data[1].ToString());
            List <ResourceData> _receiveResources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(data[2].ToString());

            Timer.RemoveTimer("WorkshopModifyResourceTimer");
            timerText.text = string.Format("下次刷新: {0}", Statics.GetTime(modifyTimeout));
            Timer.AddTimer("WorkshopModifyResourceTimer", modifyTimeout, (timer) => {
                timerText.text = string.Format("下次刷新: {0}", Statics.GetTime(timer.Second));
            }, (timer) => {
                timerText.text = string.Format("下次刷新: {0}", Statics.GetTime(timer.Second));
                Messenger.Broadcast(NotifyTypes.ModifyResources);
            });
            ResourceData receive;
            WorkshopResourceContainer findContainer;
            string msg = "";

            for (int i = 0; i < receiveResources.Count; i++)
            {
                receive = receiveResources[i];
                if (receive.Num != 0)
                {
                    msg += string.Format("<color=\"{2}\">{0} {1}</color>\n", Statics.GetResourceName(receive.Type), (receive.Num > 0 ? ("+" + receive.Num.ToString()) : receive.Num.ToString()), receive.Num > 0 ? "#00FF00" : "#FF0000");
                    if (toggleGroup0.gameObject.activeSelf)
                    {
                        findContainer = resourceContainers.Find(item => item.Type == receive.Type);
                        //更新资源的工作家丁数
                        if (findContainer != null)
                        {
                            findContainer.UpdateNum(receive.Num);
                        }
                    }
                }
            }
            if (msg != "")
            {
                Statics.CreatePopMsg(Vector3.zero, msg, Color.white, 30);
            }
            //刷新产出总量
            if (_receiveResources.Count > 0)
            {
                resultResources = _receiveResources;
                RefreshResultResourcesView();
            }
        }
Esempio n. 18
0
        /// <summary>
        /// 修改队伍的位子编号
        /// </summary>
        /// <param name="ids">Identifiers.</param>
        public void ChangeRolesSeatNo(JArray ids)
        {
            db = OpenDb();
            //将原来的角色先全部下阵
            db.ExecuteQuery("update RolesTable set State = " + ((int)RoleStateType.OutTeam) + " where State = " + ((int)RoleStateType.InTeam) + " and BelongToRoleId = '" + currentRoleId + "'");
            string id;

            for (int i = 0; i < ids.Count; i++)
            {
                id = ids[i].ToString();
                db.ExecuteQuery("update RolesTable set State = " + ((int)RoleStateType.InTeam) + ", SeatNo = " + i + " where Id = " + id);
            }
            //处理干粮
            SqliteDataReader sqReader = db.ExecuteQuery("select Data, AreaFoodNum from UserDatasTable where BelongToRoleId = '" + currentRoleId + "'");

            if (sqReader.Read())
            {
                UserData user = JsonManager.GetInstance().DeserializeObject <UserData>(sqReader.GetString(sqReader.GetOrdinal("Data")));
                user.AreaFood.Num = sqReader.GetInt32(sqReader.GetOrdinal("AreaFoodNum"));
                if (user.AreaFood.Num < user.AreaFood.MaxNum)
                {
                    sqReader = db.ExecuteQuery("select * from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'");
                    if (sqReader.Read())
                    {
                        //更新
                        string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData"));
                        resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr);
                        List <ResourceData> resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr);
                        ResourceData        resource  = resources.Find(item => item.Type == ResourceType.Food);
                        double cutNum = (double)(user.AreaFood.MaxNum - user.AreaFood.Num);
                        cutNum = resource.Num >= cutNum ? cutNum : resource.Num;
                        if (cutNum > 0)
                        {
                            resource.Num      -= cutNum;
                            user.AreaFood.Num += (int)cutNum;
                            //扣除工坊中的干粮
                            db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "' where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id")));
                            //增加随身携带的干粮
                            db.ExecuteQuery("update UserDatasTable set AreaFoodNum = " + user.AreaFood.Num + " where BelongToRoleId = '" + currentRoleId + "'");
                        }
                    }
                }
            }
            db.CloseSqlConnection();
        }
Esempio n. 19
0
        /// <summary>
        /// 吃干粮
        /// </summary>
        /// <param name="id">Identifier.</param>
        /// <param name="num">Number.</param>
        public void Eat(int id, int num)
        {
            int eatNum = 0;

            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select Id, Data, AreaFoodNum from UserDatasTable where BelongToRoleId = '" + currentRoleId + "'");

            if (sqReader.Read())
            {
                int      userDataId = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                UserData user       = JsonManager.GetInstance().DeserializeObject <UserData>(sqReader.GetString(sqReader.GetOrdinal("Data")));
                user.AreaFood.Num = sqReader.GetInt32(sqReader.GetOrdinal("AreaFoodNum"));
                user.AreaFood.Num = user.AreaFood.Num > user.AreaFood.MaxNum ? user.AreaFood.MaxNum : user.AreaFood.Num;
                if (user.AreaFood.Num < user.AreaFood.MaxNum)
                {
                    eatNum             = user.AreaFood.MaxNum - user.AreaFood.Num;
                    eatNum             = eatNum <= num ? eatNum : num;
                    user.AreaFood.Num += eatNum;
                    num -= eatNum;
                    if (num > 0)
                    {
                        //减掉吃掉的干粮辎重
                        db.ExecuteQuery("update BagTable set Num = " + num + " where Id = " + id);
                    }
                    else
                    {
                        //删除干粮辎重
                        db.ExecuteQuery("delete from BagTable where Id = " + id);
                    }
                    //更新当前干粮
                    db.ExecuteQuery("Update UserDatasTable set Data = '" + JsonManager.GetInstance().SerializeObjectDealVector(user) + "', AreaFoodNum = " + user.AreaFood.Num + " where Id = " + userDataId);
                    AreaMainPanelCtrl.MakeUpdateFoods(user.AreaFood.Num);
                }
                else
                {
                    AlertCtrl.Show("目前体力充沛不需要进食!");
                }
            }
            db.CloseSqlConnection();
            if (eatNum > 0)
            {
                Statics.CreatePopMsg(Vector3.zero, string.Format("补充了{0}个干粮", eatNum), Color.green, 30);
                GetBagPanelData();
            }
        }
Esempio n. 20
0
        /// <summary>
        /// 请求医馆角色数据
        /// </summary>
        public void GetHospitalPanelData()
        {
            db = OpenDb();
            List <RoleData>  roles    = new List <RoleData>();
            SqliteDataReader sqReader = db.ExecuteQuery("select * from RolesTable where State != " + ((int)RoleStateType.NotRecruited) + " and BelongToRoleId = '" + currentRoleId + "'");
            RoleData         role;

            while (sqReader.Read())
            {
                role = JsonManager.GetInstance().DeserializeObject <RoleData>(sqReader.GetString(sqReader.GetOrdinal("RoleData")));
                role.PrimaryKeyId = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                role.State        = (RoleStateType)sqReader.GetInt32(sqReader.GetOrdinal("State"));
                role.Injury       = (InjuryType)sqReader.GetInt32(sqReader.GetOrdinal("InjuryType"));
                roles.Add(role);
            }
            db.CloseSqlConnection();
            Messenger.Broadcast <List <RoleData> >(NotifyTypes.GetHospitalPanelDataEcho, roles);
        }
Esempio n. 21
0
        /// <summary>
        /// 查询所有的道具
        /// </summary>
        /// <returns>The all properties.</returns>
        public List <PropData> GetAllProps()
        {
            List <PropData> props = new List <PropData>();

            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select Data from GiftsTable where BelongToRoleId = '" + currentRoleId + "'");
            string           dataStr;
            PropData         propData;

            while (sqReader.Read())
            {
                dataStr  = DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("Data")));
                propData = JsonManager.GetInstance().DeserializeObject <PropData>(dataStr);
                props.Add(propData);
            }
            db.CloseSqlConnection();
            return(props);
        }
Esempio n. 22
0
        /// <summary>
        /// 获取行囊物品数据
        /// </summary>
        public List <ItemData> GetItems(ItemType type)
        {
            List <ItemData> items = new List <ItemData>();

            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select Id, ItemId, Num from BagTable where BelongToRoleId = '" + currentRoleId + "' and Type = " + (int)type + " order by Lv desc");
            ItemData         item;

            while (sqReader.Read())
            {
                item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", sqReader.GetString(sqReader.GetOrdinal("ItemId")));
                item.PrimaryKeyId = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                item.Num          = sqReader.GetInt32(sqReader.GetOrdinal("Num"));
                items.Add(item);
            }
            db.CloseSqlConnection();
            return(items);
        }
Esempio n. 23
0
        int modifyResourceTimeout    = 20;      //刷新资源间隔时间(单位:秒)

        /// <summary>
        /// 检测是否有新的生产单元
        /// </summary>
        /// <param name="cityId">City identifier.</param>
        public void CheckNewWorkshopItems(string cityId)
        {
            db = OpenDb();
            List <ResourceRelationshipData> resourcesRelationshipsInCity = WorkshopModel.Relationships.FindAll(item => item.BelongToCityId == cityId);

            if (resourcesRelationshipsInCity.Count > 0)
            {
                List <ResourceData> resources;
                SqliteDataReader    sqReader = db.ExecuteQuery("select * from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'");
                if (sqReader.Read())
                {
                    //更新
                    string resourcesStr = sqReader.GetString(sqReader.GetOrdinal("ResourcesData"));
                    resourcesStr = resourcesStr.IndexOf("[") == 0 ? resourcesStr : DESStatics.StringDecder(resourcesStr);
                    resources    = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(resourcesStr);
                    for (int i = 0; i < resourcesRelationshipsInCity.Count; i++)
                    {
                        if (resources.FindIndex(item => item.Type == resourcesRelationshipsInCity[i].Type) < 0)
                        {
                            resources.Add(new ResourceData(resourcesRelationshipsInCity[i].Type, 0));
                        }
                    }
                    db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "' where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id")));
                }
                else
                {
                    //新增
                    resources = new List <ResourceData>();
                    for (int i = 0; i < resourcesRelationshipsInCity.Count; i++)
                    {
                        resources.Add(new ResourceData(resourcesRelationshipsInCity[i].Type, 0));
                    }
                    db.ExecuteQuery("insert into WorkshopResourceTable (ResourcesData, Ticks, WorkerNum, MaxWorkerNum, BelongToRoleId) values('" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "', " + DateTime.Now.Ticks + ", 0, 0, '" + currentRoleId + "')");
                }
                //记录当前所有的工坊资源类型列表
                CitySceneModel.ResourceTypeStrOfWorkShopNewFlagList = new List <string>();
                for (int i = resources.Count - 1; i >= 0; i--)
                {
                    CitySceneModel.ResourceTypeStrOfWorkShopNewFlagList.Add(resources[i].Type.ToString());
                }
            }
            db.CloseSqlConnection();
        }
Esempio n. 24
0
 public void UpdateData(string id, JArray data, bool willDuring)
 {
     taskId       = id;
     msgStr       = data[2].ToString();
     dialogStatus = (TaskDialogStatusType)((short)data[3]);
     fightId      = data[5].ToString();
     fightData    = JsonManager.GetInstance().GetMapping <FightData>("Fights", fightId);
     if (willDuring)
     {
         alphaGroup       = gameObject.AddComponent <CanvasGroup>();
         alphaGroup.alpha = 0;
         alphaGroup.DOFade(1, 0.5f).OnComplete(() => {
             if (alphaGroup != null)
             {
                 Destroy(alphaGroup);
             }
         });
     }
 }
Esempio n. 25
0
        /// <summary>
        /// 请求书筐中的秘籍数据
        /// </summary>
        public void GetBooksListPanelData()
        {
            List <BookData> books = new List <BookData>();

            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select * from BooksTable where State = " + ((int)BookStateType.Read) + " and BelongToRoleId = '" + currentRoleId + "' order by SeatNo");
            BookData         book;

            while (sqReader.Read())
            {
                book = JsonManager.GetInstance().GetMapping <BookData>("Books", sqReader.GetString(sqReader.GetOrdinal("BookId")));
                book.PrimaryKeyId    = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                book.State           = (BookStateType)sqReader.GetInt32(sqReader.GetOrdinal("State"));
                book.BeUsingByRoleId = sqReader.GetString(sqReader.GetOrdinal("BeUsingByRoleId"));
                books.Add(book);
            }
            db.CloseSqlConnection();
            Messenger.Broadcast <List <BookData> >(NotifyTypes.GetBooksListPanelDataEcho, books);
        }
Esempio n. 26
0
        /// <summary>
        /// 根据兵器Id查询兵器强化等级
        /// </summary>
        /// <returns>The weapon L.</returns>
        /// <param name="weaponId">Weapon identifier.</param>
        public WeaponLVData GetWeaponLV(string weaponId)
        {
            WeaponLVData WeaponLVData = null;

            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select Data from WeaponLVsTable where WeaponId = '" + weaponId + "' and BelongToRoleId = '" + currentRoleId + "'");

            if (sqReader.Read())
            {
                //获取角色数据
                WeaponLVData = JsonManager.GetInstance().DeserializeObject <WeaponLVData>(DESStatics.StringDecder(sqReader.GetString(sqReader.GetOrdinal("Data"))));
            }
            else
            {
                WeaponLVData = new WeaponLVData();
            }
            db.CloseSqlConnection();
            return(WeaponLVData);
        }
Esempio n. 27
0
        public void UpdateData(object obj, bool isfighting)
        {
            disabed = false;
            JArray data = (JArray)obj;

            roleDataList = new List <RoleData>();
            JArray   itemData;
            RoleData role;

            for (int i = 0; i < data.Count; i++)
            {
                itemData = (JArray)data[i];
                role     = JsonManager.GetInstance().DeserializeObject <RoleData>(itemData[1].ToString());
                role.MakeJsonToModel();
                role.Injury = (InjuryType)((int)itemData[3]);
                role.IsDie  = false;
                roleDataList.Add(role);
            }
        }
Esempio n. 28
0
        /// <summary>
        /// 记录战斗结果
        /// </summary>
        /// <param name="win">If set to <c>true</c> window.</param>
        /// <param name="fightId">Fight identifier.</param>
        /// <param name="star">Star.</param>
        public void SendFightResult(bool win, string fightId, int star)
        {
            FightData       fight = JsonManager.GetInstance().GetMapping <FightData>("Fights", fightId);
            List <DropData> drops = new List <DropData>();

            if (win)
            {
                db = OpenDb();
                SqliteDataReader sqReader = db.ExecuteQuery("select * from FightWinedRecordsTable where FightId = '" + fightId + "' and BelongToRoleId = '" + currentRoleId + "'");
                if (sqReader.HasRows)
                {
                    if (sqReader.Read())
                    {
                        int id       = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                        int starData = sqReader.GetInt32(sqReader.GetOrdinal("Star"));
                        starData = star > starData ? star : starData;
                        int numData = sqReader.GetInt32(sqReader.GetOrdinal("Num")) + 1;
                        db.ExecuteQuery("update FightWinedRecordsTable set Star = " + starData + ", Num = " + numData + " where Id = " + id);
                    }
                }
                else
                {
                    db.ExecuteQuery("insert into FightWinedRecordsTable (FightId, Star, Num, DateTime, BelongToRoleId) values('" + fightId + "', " + star + ", 1, '" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + "', '" + currentRoleId + "');");
                }
                db.CloseSqlConnection();

                if (fight.Drops.Count > 0)
                {
                    drops = PushItemToBag(fight.Drops);
                }
                //将战斗事件从区域大地图上移除
                RemoveFightEvent(fightId);
            }
            else
            {
                //失败后需要计算队伍中侠客的伤势
                MakeRolesInjury();
            }
            Messenger.Broadcast <bool, List <DropData>, FightData>(NotifyTypes.SendFightResultEcho, win, drops, fight);
            //根据战斗胜负处理是否添加临时禁用事件
            Messenger.Broadcast <bool>(NotifyTypes.ReleaseDisableEvent, win);
        }
Esempio n. 29
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. 30
0
        /// <summary>
        /// 卸下兵器
        /// </summary>
        /// <param name="id">Identifier.</param>
        public void TakeOffWeapon(int id)
        {
            db = OpenDb();
            db.ExecuteQuery("update WeaponsTable set BeUsingByRoleId = '' where Id = " + id);
            SqliteDataReader sqReader = db.ExecuteQuery("select RoleId, RoleData from RolesTable where RoleId = '" + 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);
                role.ResourceWeaponDataId = "";
                //更新主角关联数据
                db.ExecuteQuery("update RolesTable set RoleData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObjectDealVector(role)) + "' where RoleId = '" + currentRoleId + "'");
            }
            db.CloseSqlConnection();
            GetWeaponsListPanelData();             //刷新兵器匣列表
            CallRoleInfoPanelData(false);          //刷新队伍数据
        }