Exemplo n.º 1
0
        /// <summary>
        /// 将背包里的辎重箱放入工坊资源中
        /// </summary>
        public void BringResourcesToWorkshop()
        {
            db = OpenDb();
            //查询背包
            SqliteDataReader sqReader = db.ExecuteQuery("select * from BagTable where BelongToRoleId = '" + currentRoleId + "' and Type >= " + (int)ItemType.Wheat + " and Type <= " + (int)ItemType.DarksteelIngot);

            if (sqReader.HasRows)
            {
                List <ResourceType> types = new List <ResourceType>();
                List <int>          nums  = new List <int>();
                ResourceType        type;
                while (sqReader.Read())
                {
                    type = Statics.ChangeItemTypeToResourctType((ItemType)sqReader.GetInt32(sqReader.GetOrdinal("Type")));
                    types.Add(type);
                    nums.Add(sqReader.GetInt32(sqReader.GetOrdinal("Num")) * sqReader.GetInt32(sqReader.GetOrdinal("Lv")));
                }
                if (types.Count > 0)
                {
                    //查询出资源
                    sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'");
                    if (sqReader.Read())
                    {
                        int    resourceId   = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                        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        findResource;
                        int    num;
                        string msg = "";
                        for (int i = 0; i < types.Count; i++)
                        {
                            findResource = resources.Find(re => re.Type == types[i]);
                            if (findResource != null)
                            {
                                num = nums[i];
                                findResource.Num += num;
                                msg += string.Format("\n{0}+{1}", Statics.GetResourceName(types[i]), num);
                            }
                            else
                            {
                                msg += string.Format("\n<color=\"#FF0000\">工坊产力不够无力储存{0}只好丢弃</color>", Statics.GetResourceName(types[i]));
                            }
                        }
                        //清空背包里的辎重箱
                        db.ExecuteQuery("delete from BagTable where BelongToRoleId = '" + currentRoleId + "' and Type >= " + (int)ItemType.Wheat + " and Type <= " + (int)ItemType.DarksteelIngot);
                        //更新资源数据
                        db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + DESStatics.StringEncoder(JsonManager.GetInstance().SerializeObject(resources)) + "' where Id = " + resourceId);
                        if (msg != "")
                        {
                            msg = "这次游历江湖带回了" + msg;
                            Statics.CreatePopMsg(Vector3.zero, msg, Color.green, 30);
                        }
                    }
                }
            }
            db.CloseSqlConnection();
        }
Exemplo n.º 2
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();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 刷新工坊分配资源后的界面
        /// </summary>
        public void RefreshResultResourcesView()
        {
            workerNumText.text = string.Format("家丁: {0}/{1}", workerNum, maxWorkerNum);
            string desc = "";

            if (resultResources.Count > 0)
            {
                for (int i = 0; i < resultResources.Count; i++)
                {
                    desc += (Statics.GetResourceName(resultResources[i].Type) + (resultResources[i].Num > 0 ? "+" + resultResources[i].Num.ToString() : resultResources[i].Num.ToString())) + " ";
                }
            }
            else
            {
                desc = "没有任何生产材料产出";
            }
            resultDescText.text = desc;
        }
        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)));
        }
Exemplo n.º 5
0
        public void RefreshView()
        {
            Icon.sprite    = Statics.GetResourceSprite(resourceData.Type);
            Name.text      = Statics.GetResourceName(resourceData.Type);
            Num.text       = resourceData.Num.ToString();
            WorkerNum.text = resourceData.WorkersNum.ToString();
            ResourceRelationshipData relationship = WorkshopModel.Relationships.Find(item => item.Type == resourceData.Type);

            if (relationship != null)
            {
                Output.text = string.Format("{0}+{1}", Statics.GetResourceName(relationship.Type), relationship.YieldNum);
                string       costStr = relationship.Needs.Count > 0 ? "" : "无";
                ResourceData need;
                for (int i = 0; i < relationship.Needs.Count; i++)
                {
                    need     = relationship.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") + "_" + "ResourceTypeStrOfWorkShopNewFlagIsHide_" + resourceData.Type.ToString())));
        }
Exemplo n.º 6
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;
        }
Exemplo n.º 7
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);
                }
            }
        }
Exemplo n.º 8
0
        /// <summary>
        /// 出售背包中的物品
        /// </summary>
        /// <param name="ids">Identifiers.</param>
        public void SellItems(JArray ids)
        {
            List <ItemData> items = new List <ItemData>();

            db = OpenDb();
            SqliteDataReader sqReader = db.ExecuteQuery("select Id, ItemId, Num from BagTable where BelongToRoleId = '" + currentRoleId + "'");
            ItemData         item;

            //查询出背包中所有的可出售物品
            while (sqReader.Read())
            {
                item = JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", sqReader.GetString(sqReader.GetOrdinal("ItemId")));
                if (item.SellPrice >= 0)
                {
                    item.PrimaryKeyId = sqReader.GetInt32(sqReader.GetOrdinal("Id"));
                    item.Num          = sqReader.GetInt32(sqReader.GetOrdinal("Num"));
                    items.Add(item);
                }
            }
            //检查前端传递过来的选中的物品id是否合法
            int      id;
            ItemData findItem;
            double   addSilverNum = 0;
            double   silverNum    = 0;
            string   queryStr     = "";

            for (int i = 0; i < ids.Count; i++)
            {
                id       = (int)ids[i];
                findItem = items.Find(find => find.PrimaryKeyId == id);
                if (findItem != null)
                {
                    addSilverNum += findItem.SellPrice * findItem.Num;
                    queryStr     += (i > 0 ? "or " : "" + ("Id = " + id));
                }
            }
            //删除选中的物品
            if (queryStr != "")
            {
                db.ExecuteQuery("delete from BagTable where " + queryStr);
            }
            //添加银子到资源
            sqReader = db.ExecuteQuery("select Id, ResourcesData from WorkshopResourceTable where BelongToRoleId = '" + currentRoleId + "'");
            List <ResourceData> resources = null;

            if (sqReader.Read())
            {
                resources = JsonManager.GetInstance().DeserializeObject <List <ResourceData> >(sqReader.GetString(sqReader.GetOrdinal("ResourcesData")));
                //查询目前的银子余额
                ResourceData resource = resources.Find(re => re.Type == ResourceType.Silver);
                if (resource != null)
                {
                    resource.Num += addSilverNum;
                    silverNum     = resource.Num;
                    //加钱
                    db.ExecuteQuery("update WorkshopResourceTable set ResourcesData = '" + JsonManager.GetInstance().SerializeObject(resources) + "' where Id = " + sqReader.GetInt32(sqReader.GetOrdinal("Id")));
                }
            }
            db.CloseSqlConnection();
            Messenger.Broadcast <double>(NotifyTypes.SellItemsEcho, silverNum);
            Statics.CreatePopMsg(Vector3.zero, string.Format("{0} {1}", Statics.GetResourceName(ResourceType.Silver), "+" + addSilverNum.ToString()), Color.green, 30);
        }
Exemplo n.º 9
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);
                }
            }
        }
Exemplo n.º 10
0
        string getDialogDesc(TaskDialogData dialog)
        {
            string result = "";

            if (dialog != null)
            {
                string noticeColor = "#F57729";
                switch (dialog.Type)
                {
                case TaskDialogType.Choice:
                    return(string.Format("目标:前往<color=\"" + noticeColor + "\">{0}</color>,<color=\"" + noticeColor + "\">{1}</color>的<color=\"" + noticeColor + "\">{2}</color>有困难需要你的帮助", areaName, scene.Name, npc.Name));

                case TaskDialogType.JustTalk:
                case TaskDialogType.Notice:
                    return(string.Format("目标:前往<color=\"" + noticeColor + "\">{0}</color>的<color=\"" + noticeColor + "\">{1}</color>找<color=\"" + noticeColor + "\">{2}</color>交谈", areaName, scene.Name, npc.Name));

                default:
                    return("");

                case TaskDialogType.ConvoyNpc:
                    string[] fen = dialog.StringValue.Split(new char[] { '_' });
                    return(string.Format("目标:护送<color=\"" + noticeColor + "\">{0}</color>到达<color=\"" + noticeColor + "\">{1}</color>({2})", JsonManager.GetInstance().GetMapping <NpcData>("Npcs", fen[0]).Name, fen[1], dialog.Completed ? "<color=\"#00FF00\">已到达</color>" : "<color=\"#FF0000\">未到达</color>") + (dialog.Completed ? string.Format(" (完成!{0}在{1}等你回复)", npc.Name, scene.Name) : ""));

                case TaskDialogType.FightWined:
                    return(string.Format("目标:在战斗[<color=\"" + noticeColor + "\">{0}</color>]中获胜({1})", JsonManager.GetInstance().GetMapping <FightData>("Fights", dialog.StringValue).Name, dialog.Completed ? "<color=\"#00FF00\">已获胜</color>" : "<color=\"#FF0000\">未获胜</color>") + (dialog.Completed ? string.Format(" (<color=\"#00FF00\">完成!</color>{0}在{1}等你回复)", npc.Name, scene.Name) : ""));

                case TaskDialogType.EventFightWined:
                    return(string.Format("目标:在野外战斗[<color=\"" + noticeColor + "\">{0}</color>]中获胜({1})", JsonManager.GetInstance().GetMapping <FightData>("Fights", dialog.StringValue).Name, dialog.Completed ? "<color=\"#00FF00\">已获胜</color>" : "<color=\"#FF0000\">未获胜</color>") + (dialog.Completed ? string.Format(" (<color=\"#00FF00\">完成!</color>{0}在{1}等你回复)", npc.Name, scene.Name) : ""));

                case TaskDialogType.RecruitedThePartner:
                    RoleData role = JsonManager.GetInstance().GetMapping <RoleData>("RoleDatas", dialog.StringValue);
                    return(string.Format("结识对象:<color=\"{0}\">{1}</color>\n目标: 在<color=\"" + noticeColor + "\">{2}</color>的酒馆里与<color=\"" + noticeColor + "\">{1}</color>结识", dialog.Completed ? "#00FF00" : "#FF0000", role.Name, JsonManager.GetInstance().GetMapping <SceneData>("Scenes", role.HometownCityId).Name) + (dialog.Completed ? string.Format(" (完成!{0}在{1}等你回复)", npc.Name, scene.Name) : ""));

                case TaskDialogType.SendItem:
                    return(string.Format("需要物品:<color=\"{0}\">{1}</color>\n目标: 收集到{2}个<color=\"" + noticeColor + "\">{1}</color>", dialog.Completed ? "#00FF00" : "#FF0000", JsonManager.GetInstance().GetMapping <ItemData>("ItemDatas", dialog.StringValue).Name, dialog.IntValue) + (dialog.Completed ? string.Format(" (<color=\"#00FF00\">完成!</color>{0}在{1}等你回复)", npc.Name, scene.Name) : ""));

                case TaskDialogType.SendResource:
                    return(string.Format("需要资源:<color=\"{0}\">{1}</color>\n目标: 收集到{2}个<color=\"" + noticeColor + "\">{1}</color>", dialog.Completed ? "#00FF00" : "#FF0000", Statics.GetResourceName((ResourceType)Enum.Parse(typeof(ResourceType), dialog.StringValue)), dialog.IntValue) + (dialog.Completed ? string.Format(" (<color=\"#00FF00\">完成!</color>{0}在{1}等你回复)", npc.Name, scene.Name) : ""));

                case TaskDialogType.UsedTheBook:
                    return(string.Format("装备秘籍:<color=\"{0}\">{1}</color>\n目标: 将秘籍<color=\"" + noticeColor + "\">{1}</color>装备上", dialog.Completed ? "#00FF00" : "#FF0000", JsonManager.GetInstance().GetMapping <BookData>("Books", dialog.StringValue).Name) + (dialog.Completed ? string.Format(" (<color=\"#00FF00\">完成!</color>{0}在{1}等你回复)", npc.Name, scene.Name) : ""));

                case TaskDialogType.UsedTheSkillOneTime:
                    return(string.Format("施展招式:<color=\"{0}\">{1}</color>\n目标: 将招式<color=\"" + noticeColor + "\">{1}</color>施展一次", dialog.Completed ? "#00FF00" : "#FF0000", JsonManager.GetInstance().GetMapping <SkillData>("Skills", dialog.StringValue).Name) + (dialog.Completed ? string.Format(" (<color=\"#00FF00\">完成!</color>{0}在{1}等你回复)", npc.Name, scene.Name) : ""));

                case TaskDialogType.UsedTheWeapon:
                    return(string.Format("装备兵器:<color=\"{0}\">{1}</color>\n目标: 将兵器<color=\"" + noticeColor + "\">{1}</color>装备上", dialog.Completed ? "#00FF00" : "#FF0000", JsonManager.GetInstance().GetMapping <WeaponData>("Weapons", dialog.StringValue).Name) + (dialog.Completed ? string.Format(" (<color=\"#00FF00\">完成!</color>{0}在{1}等你回复)", npc.Name, scene.Name) : ""));

                case TaskDialogType.WeaponPowerPlusSuccessed:
                    return(string.Format("目标:招式施展时爆发<color=\"{0}\">{1}倍伤害</color>", dialog.Completed ? "#00FF00" : "#FF0000", dialog.IntValue == 1 ? "1.25" : dialog.IntValue == 2 ? "1.5" : "2") + (dialog.Completed ? string.Format(" (<color=\"#00FF00\">完成!</color>{0}在{1}等你回复)", npc.Name, scene.Name) : ""));

                case TaskDialogType.TheHour:
                    return(string.Format("目标:在<color=\"" + noticeColor + "\">{0}</color>时前往<color=\"" + noticeColor + "\">{1}</color>的<color=\"" + noticeColor + "\">{2}</color>找<color=\"" + noticeColor + "\">{3}</color>交谈({4})", Statics.GetTimeName(dialog.IntValue), areaName, scene.Name, npc.Name, dialog.Completed ? "<color=\"#00FF00\">时辰已到</color>" : "<color=\"#FF0000\">时辰未到</color>"));

                case TaskDialogType.PushRoleToWinshop:
                    return(string.Format("目标:前往<color=\"" + noticeColor + "\">{0}</color>的<color=\"" + noticeColor + "\">{1}</color>找<color=\"" + noticeColor + "\">{2}</color>交谈后可以结识新的侠客", areaName, scene.Name, npc.Name));

                case TaskDialogType.CreateTaskIsBindedWithEvent:
                    return(string.Format("目标:前往<color=\"" + noticeColor + "\">{0}</color>野外区域寻找线索", areaName));
                }
            }
            return(result);
        }
Exemplo n.º 11
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);
            }
        }