public override void Tick(RealmTime time) { base.Tick(time); foreach (var i in vaultChests) { if (i.Key.Item1.UpdateCount > i.Value) { int count = 0; try { foreach (var plr in Players.Values) { count++; if (count > 1) { plr.Client.Disconnect(); } i.Key.Item2._Items = Utils.GetCommaSepString( i.Key.Item1.Inventory.Take(8).Select(_ => _ == null ? 65535 : _.ObjectType).ToArray()); i.Key.Item2._Datas = ItemDataList.GetJson( i.Key.Item1.Inventory.Data.Take(8).ToArray()); plr.Client.AddDatabaseOpperation(db => db.SaveChest(client.Account, i.Key.Item2)); vaultChests[i.Key] = i.Key.Item1.UpdateCount; } } catch { } } } }
static void CreateMedicamentConfigDataList(List <ItemMedicamentConfigData> list) { string fileName = typeof(ItemMedicamentConfigData).Name + "DataBase"; string path = System.IO.Path.Combine(ASSET_ITEM_DATA_FOLDER, fileName + ".asset"); if (File.Exists(path)) { ItemDataList database = (ItemDataList)AssetDatabase.LoadAssetAtPath(path, typeof(ItemDataList)); if (null == database) { return; } database._itemMedicamentConfigs = new ItemMedicamentConfigData[list.Count]; for (int i = 0; i < list.Count; i++) { database._itemMedicamentConfigs[i] = list[i]; } EditorUtility.SetDirty(database); } else { ItemDataList database = ScriptableObject.CreateInstance <ItemDataList>(); database._itemMedicamentConfigs = new ItemMedicamentConfigData[list.Count]; for (int i = 0; i < list.Count; i++) { database._itemMedicamentConfigs[i] = list[i]; } AssetDatabase.CreateAsset(database, path); } }
public CatalogDeal(int Id, int PageId, string Items, string DisplayName, int Credits, int Pixels, ItemDataManager ItemDataManager) { this.Id = Id; this.PageId = PageId; this.DisplayName = DisplayName; this.ItemDataList = new List <CatalogItem>(); string[] SplitItems = Items.Split(';'); foreach (string Split in SplitItems) { string[] Item = Split.Split('*'); int ItemId = 0; int Amount = 0; if (!int.TryParse(Item[0], out ItemId) || !int.TryParse(Item[1], out Amount)) { continue; } ItemData Data = null; if (!ItemDataManager.GetItem(ItemId, out Data)) { continue; } ItemDataList.Add(new CatalogItem(0, ItemId, Data, string.Empty, PageId, CostCredits, CostPixels, 0, Amount, 0, 0, false, "", "", 0, 0, 0)); } this.CostCredits = Credits; this.CostPixels = Pixels; }
void Start() { slots = go_SlotsParent.GetComponentsInChildren <IventorySlot>(); if (Application.platform == RuntimePlatform.Android) { jsonString = File.ReadAllText(Application.persistentDataPath + "/Resources/Json/itemdata.json"); } else { jsonString = File.ReadAllText(Application.dataPath + "/Resources/Json/itemdata.json"); } itemDataList = JsonUtility.FromJson <ItemDataList>(jsonString); if (itemDataList == null) { itemDataList = new ItemDataList(); itemDatas = new List <ItemData>(); } else { itemDatas = new List <ItemData>(itemDataList.itemDatas); foreach (ItemData itemData in itemDataList.itemDatas) { Itemgem _item = Resources.Load <GameObject>("Prefabs/Gems/" + itemData.itemname).GetComponent <Itemgem>(); slots[itemData.itemorder].AddItem(_item, itemData.itemcount); } } }
void Start() { ItemConversion.converter = new GameObjectItemDataConverter(); ItemDataList droppedItems = new ItemDataList(); for (int i = 0; i < 3; i++) { SocialPlay.Data.ItemData newItem = new SocialPlay.Data.ItemData(); newItem.Amount = 0; newItem.AssetBundleName = "h"; newItem.BaseItemEnergy = 0; newItem.BaseItemID = 0; newItem.Behaviours = "k"; newItem.Description = ""; newItem.Detail = ""; newItem.Energy = 0; newItem.Image = ""; newItem.ItemID = 0; newItem.Location = 0; newItem.Name = ""; newItem.Quality = 0; newItem.SellPrice = 0; newItem.StackLocationID = Guid.Empty; newItem.Tags = ""; newItem.Type = 0; droppedItems.Add(newItem); } List <ItemData> items = ItemConversion.converter.ConvertItems(droppedItems); itemGetter.OnReceivedGeneratedItems(items); }
static public List <ItemData> LoadItemDataXML(string fileName, string filePath = @"C:\Temp\") { string fileWithPath = fileName; if (!fileWithPath.Contains(@":") && !fileWithPath.Contains(@"\")) { if (filePath.EndsWith(@"\")) { fileWithPath = filePath + fileWithPath; } else { fileWithPath = filePath + @"\" + fileWithPath; } } ItemDataList list = new ItemDataList(); // Create an instance of System.Xml.Serialization.XmlSerializer XmlSerializer serializer = new XmlSerializer(list.GetType()); // Create an instance of System.IO.TextReader // to load the serialized data from disk using (TextReader textReader = new StreamReader(fileWithPath)) { // Assign the deserialized object to the new employeeList object list = (ItemDataList)serializer.Deserialize(textReader); } return(list.Items); }
void Start () { ItemConversion.converter = new GameObjectItemDataConverter(); ItemDataList droppedItems = new ItemDataList(); for (int i = 0; i < 3; i++) { SocialPlay.Data.ItemData newItem = new SocialPlay.Data.ItemData(); newItem.Amount = 0; newItem.AssetBundleName = "h"; newItem.BaseItemEnergy = 0; newItem.BaseItemID = 0; newItem.Behaviours = "k"; newItem.Description = ""; newItem.Detail = ""; newItem.Energy = 0; newItem.Image = ""; newItem.ItemID = 0; newItem.Location = 0; newItem.Name = ""; newItem.Quality = 0; newItem.SellPrice = 0; newItem.StackLocationID = Guid.Empty; newItem.Tags = ""; newItem.Type = 0; droppedItems.Add(newItem); } List<ItemData> items = ItemConversion.converter.ConvertItems(droppedItems); itemGetter.OnReceivedGeneratedItems(items); }
//Creates a brand new ItemDataList asset file in the project directory private ItemDataList CreateNewList(string AssetName, string PathKey) { ItemDataList NewList = ScriptableObject.CreateInstance <ItemDataList>(); AssetDatabase.CreateAsset(NewList, AssetName); AssetDatabase.SaveAssets(); NewList.ItemList = new List <ItemData>(); string RelativePath = AssetDatabase.GetAssetPath(NewList); EditorPrefs.SetString(PathKey, RelativePath); return(NewList); }
/// <summary> /// ItemDataListの中身を再生成する /// /// ブロックのデータも入れないといけない為、生成用のメソッドを作成 /// 何かいい方法はない? /// </summary> public static void refresh() { ItemDataList.AddRange(ItemBaseList); foreach (var block in BlockData.BlockBaseList) { if (block.canInventory) { ItemDataList.Add(new ItemBaseData() { name = block.name, description = block.description }); } } }
public override List <ItemData> convertToItemDataFromString(string itemData) { string data = ""; ItemDataList itemDetails = null; if (itemData == "\"[]\"") { List <ItemData> convertedItems = new List <ItemData>(); return(convertedItems); } data = JToken.Parse(itemData).ToString(); itemDetails = Newtonsoft.Json.JsonConvert.DeserializeObject <ItemDataList>(data); return(ConvertItems(itemDetails)); }
public void SavePickup(int _newIndex) { string jsonFromFile = File.ReadAllText(filename); ItemDataList list = ItemDataList.CreateFromJSON(jsonFromFile); int newIndex = _newIndex; list.items[newIndex].itemPicked = 1; jsonData = JsonUtility.ToJson(list); if (File.Exists(filename)) { File.Delete(filename); } File.WriteAllText(filename, jsonData); ItemCompile(); }
static public void SaveAsXML(List <ItemData> data, string fileName, string filePath = @"C:\Temp\") { ItemDataList list = new ItemDataList(); list.Items = data; // Create an instance of System.Xml.Serialization.XmlSerializer XmlSerializer serializer = new XmlSerializer(list.GetType()); // Create an instance of System.IO.TextWriter // to save the serialized object to disk using (TextWriter textWriter = new StreamWriter($@"{filePath}{fileName}")) { // Serialize the employeeList object serializer.Serialize(textWriter, list); } }
static public List <ItemData> LoadXML(string fileName) { ItemDataList list = new ItemDataList(); // Create an instance of System.Xml.Serialization.XmlSerializer XmlSerializer serializer = new XmlSerializer(list.GetType()); // Create an instance of System.IO.TextReader // to load the serialized data from disk using (TextReader textReader = new StreamReader($@"C:\Temp\{fileName}")) { // Assign the deserialized object to the new employeeList object list = (ItemDataList)serializer.Deserialize(textReader); } return(list.Items); }
private void Start() { // TODO: Construct a cache to load all itemData and then use that to get the itemData for this item string dataString = FileHandler.ReadString("ItemConfig"); Debug.Log(dataString); ItemDataList itemDataList = JsonUtility.FromJson <ItemDataList>(dataString); foreach (ItemData item in itemDataList.itemList) { if (item.name.Equals(name)) { Debug.Log("Item Start setting itemData " + name); itemData = item; } } }
public List <ItemData> ConvertToItemDataList(string itemDataString) { string data = ""; ItemDataList itemDataList = null; if (itemDataString == "\"[]\"") { List <ItemData> convertedItems = new List <ItemData>(); } data = JToken.Parse(itemDataString).ToString(); itemDataList = Newtonsoft.Json.JsonConvert.DeserializeObject <ItemDataList>(data); List <ItemData> items = ItemConversion.converter.ConvertItems(itemDataList); return(items); }
void OnEnable() { //Try to load in any already existing item lists if (EditorPrefs.HasKey("ConsumableItemListPath")) { string ObjectPath = EditorPrefs.GetString("ConsumableItemListPath"); ConsumableItemList = AssetDatabase.LoadAssetAtPath(ObjectPath, typeof(ItemDataList)) as ItemDataList; } if (EditorPrefs.HasKey("EquipmentItemListPath")) { string ObjectPath = EditorPrefs.GetString("EquipmentItemListPath"); EquipmentItemList = AssetDatabase.LoadAssetAtPath(ObjectPath, typeof(ItemDataList)) as ItemDataList; } if (EditorPrefs.HasKey("AbilityItemListPath")) { string ObjectPath = EditorPrefs.GetString("AbilityItemListPath"); AbilityItemList = AssetDatabase.LoadAssetAtPath(ObjectPath, typeof(ItemDataList)) as ItemDataList; } }
public void ItemCompile() { string jsonFromFile = File.ReadAllText(filename); ItemDataList list = ItemDataList.CreateFromJSON(jsonFromFile); countDammit = list.items.Count(); if (File.Exists(filename)) { for (int i = 0; i < countDammit; i++) { if (list.items[i].index == this.GetComponent <Pickup>().itemIndex) { if (list.items[i].itemPicked == 1) { Destroy(this.gameObject); } } } } }
public override List <ItemData> ConvertItems(ItemDataList generatedItems, int GenerationID) { List <ItemData> convertedItems = new List <ItemData>(); for (int i = 0, imax = generatedItems.Count; i < imax; i++) { SocialPlay.Data.ItemData item = generatedItems[i]; //GameObject go = new GameObject(); ItemData itemData = new ItemData(); //go.AddComponent<ItemData>(); //go.name = item.Name; itemData.baseEnergy = item.BaseItemEnergy; //TODO fix behaviour conversion //itemData.behaviours = item.Behaviours; itemData.description = item.Description; itemData.itemName = item.Name; itemData.imageName = item.Image; itemData.classID = item.Type; itemData.quality = item.Quality; itemData.salePrice = item.SellPrice; itemData.ItemID = item.ItemID; itemData.CollectionID = int.Parse(item.BaseItemID.ToString()); itemData.stackSize = item.Amount; itemData.totalEnergy = item.Energy; itemData.stackID = item.StackLocationID; itemData.stats = ConvertItemDetail(item); itemData.assetURL = item.AssetBundleName; itemData.tags = ConvertTags(item); itemData.persistantLocation = item.Location; itemData.GenerationID = GenerationID; itemData.IsGenerated = true; convertedItems.Add(itemData); } Resources.UnloadUnusedAssets(); ItemComponentInitalizer.InitializeItemWithComponents(convertedItems, AddComponetTo.prefab); return(convertedItems); }
public override void Tick(RealmTime time) { base.Tick(time); foreach (var i in vaultChests) { if (i.Key.Item1.UpdateCount > i.Value) { i.Key.Item2._Items = Utils.GetCommaSepString( i.Key.Item1.Inventory.Take(8).Select(_ => _?.ObjectType ?? 65535).ToArray()); i.Key.Item2._Datas = ItemDataList.GetJson( i.Key.Item1.Inventory.Data.Take(8).ToArray()); Manager.Data.AddDatabaseOperation(db => { db.SaveChest(client.Account, i.Key.Item2); }); vaultChests[i.Key] = i.Key.Item1.UpdateCount; } } }
public override List<ItemData> ConvertItems(ItemDataList generatedItems) { List<ItemData> convertedItems = new List<ItemData>(); foreach (SocialPlay.Data.ItemData item in generatedItems) { GameObject go = new GameObject(); ItemData itemData = go.AddComponent<ItemData>(); go.name = item.Name; itemData.baseEnergy = item.BaseItemEnergy; //TODO fix behaviour conversion //itemData.behaviours = item.Behaviours; itemData.description = item.Description; itemData.itemName = item.Name; itemData.imageName = item.Image; itemData.classID = item.Type; itemData.quality = item.Quality; itemData.salePrice = item.SellPrice; itemData.varianceID = item.ItemID; itemData.itemID = int.Parse(item.BaseItemID.ToString()); itemData.stackSize = item.Amount; itemData.totalEnergy = item.Energy; itemData.stackID = item.StackLocationID; itemData.stats = ConvertItemDetail(item); itemData.assetURL = item.AssetBundleName; itemData.tags = ConvertTags(item); itemData.persistantLocation = item.Location; convertedItems.Add(itemData); Resources.UnloadUnusedAssets(); } ItemComponentInitalizer.InitializeItemWithComponents(convertedItems, AddComponetTo.prefab); return convertedItems; }
static public List <ItemData> LoadXML(string fileName) { string fileWithPath = FilePathCheck(fileName); SRInfoHelper.Log("Loading " + fileWithPath); ItemDataList list = new ItemDataList(); // Create an instance of System.Xml.Serialization.XmlSerializer XmlSerializer serializer = new XmlSerializer(list.GetType()); // Create an instance of System.IO.TextReader // to load the serialized data from disk if (File.Exists(fileWithPath)) { using (TextReader textReader = new StreamReader(fileWithPath)) { // Assign the deserialized object to the new employeeList object list = (ItemDataList)serializer.Deserialize(textReader); } } return(list.Items); }
void LoadItemData() { string dataString = FileHandler.ReadString("ItemConfig"); Debug.Log(dataString); loadedItemData = JsonUtility.FromJson <ItemDataList>(dataString); itemDatas = new ItemData[loadedItemData.itemList.Count]; int index = 0; foreach (var itemData in loadedItemData.itemList) { // Take only heal and power (double damage) for now if (itemData.name == "HP Sphere" || itemData.name == "Power Sphere") { itemDatas[index] = itemData; index++; } } loadedItemData.itemList.Clear(); }
public void ResetItems() { string jsonFromFile = File.ReadAllText(filename); ItemDataList list = ItemDataList.CreateFromJSON(jsonFromFile); if (File.Exists(filename)) { countDammit = list.items.Count(); Debug.Log("Deleting Entires"); for (int i = 0; i < countDammit; i++) { list.items[i].itemPicked = 0; Debug.Log("Deleted" + i + "Entires"); } } jsonData = JsonUtility.ToJson(list); if (File.Exists(filename)) { File.Delete(filename); } File.WriteAllText(filename, jsonData); ItemCompile(); }
public SRC(ILoggerFactory loggerFactory) { Log = loggerFactory.CreateLogger("SRCCore"); Help = new Help(this); Event = new Event(this); Expression = new Expression(this); Map = new Map(this); Commands = new Commands.Command(this); Sound = new Sound(this); Effect = new Effect(this); COM = new COM(this); InterMission = new InterMission(this); FileHandleManager = new FileHandleManager(); PDList = new PilotDataList(this); NPDList = new NonPilotDataList(this); UDList = new UnitDataList(this); IDList = new ItemDataList(this); MDList = new MessageDataList(this); EDList = new MessageDataList(this); ADList = new MessageDataList(this); EADList = new MessageDataList(this); DDList = new DialogDataList(this); SPDList = new SpecialPowerDataList(this); ALDList = new AliasDataList(this); TDList = new TerrainDataList(this); BCList = new BattleConfigDataList(this); PList = new Pilots.Pilots(this); UList = new Units.Units(this); IList = new Items.Items(this); // XXX 別な実装をするならコンストラクタでは設定しない SystemConfig = new LocalFileConfig(); }
private void OnEnable() { _database = new RPGDatabaseManager(); _database.Load(); if (_database.TotalEntries == 0) { DatabaseFolderHandler.ValidateAllFolders(); DatabaseFactory.CreateDatabase(); _database.Load(); } _actorDataList = _database.FetchEntry <ActorDataList>(); _classDataList = _database.FetchEntry <ActorClassDataList>(); _skillDataList = _database.FetchEntry <SkillDataList>(); _itemDataList = _database.FetchEntry <ItemDataList>(); _weaponDataList = _database.FetchEntry <WeaponDataList>(); _weaponTypeDataList = _database.FetchEntry <WeaponTypeDataList>(); _attributeSpectDataList = _database.FetchEntry <AttributeSpecDataList>(); _actorListSection = new ListSection <ActorData>(_actorDataList, "Actors"); _classListSection = new ListSection <ActorClassData>(_classDataList, "Classes"); _skillListSection = new ListSection <SkillData>(_skillDataList, "Skills"); _itemListSection = new ListSection <ItemData>(_itemDataList, "Items"); _weaponListSection = new ListSection <WeaponData>(_weaponDataList, "Weapons"); _weaponTypeListSection = new ListSection <WeaponTypeData>(_weaponTypeDataList, "Weapon Types"); var flags = ReorderableListFlags.ShowIndices | ReorderableListFlags.HideAddButton | ReorderableListFlags.DisableReordering | ReorderableListFlags.HideRemoveButtons; _attributeSpecListSection = new ListSection <AttributeSpecData>(_attributeSpectDataList, "Attribute Specs", flags); _infoSection = new InfoSection(); _effectsSection = new EffectsSection(); _coreTabSelected = (CoreTabId)DatabaseEditorPrefs.CoreTab; _mainTabSelected = (MainTabId)DatabaseEditorPrefs.MainTab; _configTabSelected = (ConfigTabId)DatabaseEditorPrefs.ConfigTab; }
private static void ReadJson() { string[] files = new string[] { "weapon", //item type name "Assets/GlobalManagers/Data/ItemData/WeaponItemDataList.asset", //output file name "armor", "Assets/GlobalManagers/Data/ItemData/ArmorItemDataList.asset", "ornament", "Assets/GlobalManagers/Data/ItemData/OrnamentItemDataList.asset", "vanity", "Assets/GlobalManagers/Data/ItemData/VanityItemDataList.asset", "material", "Assets/GlobalManagers/Data/ItemData/MaterialItemDataList.asset", "tribute", "Assets/GlobalManagers/Data/ItemData/TributeItemDataList.asset", "other", "Assets/GlobalManagers/Data/ItemData/OtherItemDataList.asset", }; ItemDataList[] lists = new ItemDataList[files.Length / 2]; Dictionary <string, ItemDataList> dict = new Dictionary <string, ItemDataList>(); for (int i = 0; i < files.Length / 2; i++) { string itemTypeName = files[i * 2]; string outputFileName = files[i * 2 + 1]; ItemDataList itemDataList = null; UnityEngine.Object oldFile = AssetDatabase.LoadAssetAtPath(outputFileName, typeof(ItemDataList)); if (oldFile == null) { itemDataList = ScriptableObject.CreateInstance(typeof(ItemDataList)) as ItemDataList; } else { itemDataList = oldFile as ItemDataList; } itemDataList._dataList.Clear(); dict.Add(itemTypeName, itemDataList); } string jsonStr = File.ReadAllText(fileName); JsonHashtable ht = FCJson.jsonDecode(jsonStr) as JsonHashtable; foreach (System.Object obj in ht.ValueList) { Hashtable ht2 = obj as Hashtable; ItemData itemdata = new ItemData(); itemdata.id = ht2["itemId"] as string; itemdata.type = (ItemType)(int)ht2["type"]; itemdata.subType = (ItemSubType)(int)ht2["subType"]; itemdata.enableLevel = (int)ht2["enableLevel"]; itemdata.roleID = (int)ht2["class"]; itemdata.level = (int)ht2["level"]; itemdata.nameIds = (string)ht2["name"]; itemdata.descriptionIds = (string)ht2["description"]; itemdata.rareLevel = (int)ht2["rareLevel"]; itemdata.iconPath = (string)ht2["icon"]; itemdata.instance = (string)ht2["instance"]; itemdata.sellCount = (float)ht2["sellCount"]; itemdata.stack = (int)ht2["stack"]; itemdata.attrId0 = (AIHitParams)(int)ht2["attributeId0"]; itemdata.attrValue0 = (float)ht2["value0"]; itemdata.attrId1 = (AIHitParams)(int)ht2["attributeId1"]; itemdata.attrValue1 = (float)ht2["value1"]; itemdata.attrId2 = (AIHitParams)(int)ht2["attributeId2"]; itemdata.attrValue2 = (float)ht2["value2"]; string typeName = itemdata.type.ToString(); if (dict.ContainsKey(typeName)) { dict[typeName]._dataList.Add(itemdata); } else //all other types are put into file "other" { dict["other"]._dataList.Add(itemdata); Debug.LogWarning(string.Format("ItemType {0} not found in dictionary, item {1} put into file \"other\".", typeName, itemdata.id)); } } for (int i = 0; i < files.Length / 2; i++) { string itemTypeName = files[i * 2]; string outputFileName = files[i * 2 + 1]; if (!File.Exists(outputFileName)) //new file { AssetDatabase.CreateAsset(dict[itemTypeName], outputFileName); } else { EditorUtility.SetDirty(dict[itemTypeName]); } Debug.Log(string.Format("{0} records imported to {1}", dict[itemTypeName]._dataList.Count, outputFileName)); } }
protected override void HandleRequest() { NameValueCollection query; using (var rdr = new StreamReader(ListenerContext.Request.InputStream)) query = HttpUtility.ParseQueryString(rdr.ReadToEnd()); if (query.AllKeys.Length == 0) { string queryString = string.Empty; string currUrl = ListenerContext.Request.RawUrl; int iqs = currUrl.IndexOf('?'); if (iqs >= 0) { query = HttpUtility.ParseQueryString((iqs < currUrl.Length - 1) ? currUrl.Substring(iqs + 1) : String.Empty); } } OfferList list = new OfferList(); using (var db = new Database(Program.Settings.GetValue("conn"))) { var acc = db.Verify(GUID, PASS); MySqlCommand cmd = db.CreateQuery(); cmd.CommandText = "SELECT * FROM market WHERE status=0 ORDER BY id DESC"; if (acc != null && NameValueCollection["filter"] == "mine") { cmd.CommandText = "SELECT * FROM market WHERE accId=@accId ORDER BY id DESC"; cmd.Parameters.AddWithValue("@accId", acc.AccountId); } ushort[] offerSearch = new ushort[0]; ItemData[] offerSearchD = new ItemData[0]; if (NameValueCollection["offerItems"] != null && NameValueCollection["offerItems"] != "") { offerSearch = Utils.FromCommaSepString16(NameValueCollection["offerItems"]); offerSearchD = new ItemData[offerSearch.Length]; if (NameValueCollection["offerData"] != "") { offerSearchD = ItemDataList.CreateData(NameValueCollection["offerData"]); } } ushort[] reqSearch = new ushort[0]; ItemData[] reqSearchD = new ItemData[0]; if (NameValueCollection["requestItems"] != null && NameValueCollection["requestItems"] != "") { reqSearch = Utils.FromCommaSepString16(NameValueCollection["requestItems"]); reqSearchD = new ItemData[reqSearch.Length]; if (NameValueCollection["requestData"] != "") { reqSearchD = ItemDataList.CreateData(NameValueCollection["requestData"]); } } using (MySqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) { if (offerSearch.Length > 0) { List <ushort> offerItems = new List <ushort>(Utils.FromCommaSepString16(rdr.GetString("offerItems"))); ItemData[] offerData = ItemDataList.CreateData(rdr.GetString("offerData")); bool success = false; for (int i = 0; i < offerSearch.Length; i++) { int res = -1; if ((res = offerItems.IndexOf(offerSearch[i])) == -1) { continue; } if (offerSearchD[i] != null) { bool offerDataE = offerData[res] != null; if ((offerSearchD[i].Strange && (!offerDataE || !offerData[res].Strange)) || (!offerSearchD[i].Strange && offerDataE && offerData[res].Strange)) { continue; } if (!offerSearchD[i].Strange && offerSearchD[i].NamePrefix != "") { if (!offerDataE || (offerDataE && offerData[res].NamePrefix != offerSearchD[i].NamePrefix)) { continue; } } if (offerSearchD[i].Effect != "" && (!offerDataE || (offerData[res].Effect != offerSearchD[i].Effect))) { continue; } } else if (offerData[res] != null) { if (offerData[res].Strange || offerData[res].NamePrefix != "" || offerData[res].Effect != "") { continue; } } success = true; break; } if (!success) { continue; } } if (reqSearch.Length > 0) { List <ushort> reqItems = new List <ushort>(Utils.FromCommaSepString16(rdr.GetString("requestItems"))); ItemData[] reqData = ItemDataList.CreateData(rdr.GetString("requestData")); bool success = false; for (int i = 0; i < reqSearch.Length; i++) { int res = -1; if ((res = reqItems.IndexOf(reqSearch[i])) == -1) { continue; } if (reqSearchD[i] != null) { bool reqDataE = reqData[res] != null; if ((reqSearchD[i].Strange && (!reqDataE || !reqData[res].Strange)) || (!reqSearchD[i].Strange && reqDataE && reqData[res].Strange)) { continue; } if (!reqSearchD[i].Strange && reqSearchD[i].NamePrefix != "") { if (!reqDataE || (reqDataE && reqData[res].NamePrefix != reqSearchD[i].NamePrefix)) { continue; } } if (reqSearchD[i].Effect != "" && (!reqDataE || (reqData[res].Effect != reqSearchD[i].Effect))) { continue; } } else if (reqData[res] != null) { if (reqData[res].Strange || reqData[res].NamePrefix != "" || reqData[res].Effect != "") { continue; } } success = true; break; } if (!success) { continue; } } list.Offers.Add(new Offer { Id = rdr.GetInt32("id"), AccId = rdr.GetInt32("accId"), Mine = acc != null ? rdr.GetInt32("accId") == acc.AccountId : false, Status = rdr.GetInt32("status"), _OfferItems = rdr.GetString("offerItems"), _OfferData = rdr.GetString("offerData"), _RequestItems = rdr.GetString("requestItems"), _RequestData = rdr.GetString("requestData") }); } } } if (NameValueCollection["filter"] != "mine" && NameValueCollection["filter"] != "searched") { if (list.Offers.Count > 100) { list.Offers.RemoveRange(100, list.Offers.Count - 100); } } var ms = new MemoryStream(); var serializer = new XmlSerializer(list.GetType(), new XmlRootAttribute("Offers") { Namespace = "" }); var xws = new XmlWriterSettings(); xws.OmitXmlDeclaration = true; xws.Encoding = Encoding.UTF8; xws.Indent = true; XmlWriter xtw = XmlWriter.Create(ListenerContext.Response.OutputStream, xws); serializer.Serialize(xtw, list, list.Namespaces); }
void OnGUI() { //Show the window title at the top GUILayout.BeginHorizontal(); GUILayout.Label("Master Item List Editor", EditorStyles.boldLabel); GUILayout.EndHorizontal(); GUILayout.Space(10); //Combines all the lists together into 1 giant master item list with every single thing detailed within, exports it out into a text file storing all that data if (GUILayout.Button("Export Master List", GUILayout.ExpandWidth(false))) { //Create a brand new master list which will contain every item from every list we have List <ItemData> MasterItemList = new List <ItemData>(); //Fill the new MasterItemList so it contains all the other lists combined foreach (ItemData Item in ConsumableItemList.ItemList) { MasterItemList.Add(Item); } foreach (ItemData Item in EquipmentItemList.ItemList) { MasterItemList.Add(Item); } foreach (ItemData Item in AbilityItemList.ItemList) { MasterItemList.Add(Item); } //Loop through the entire list, assigning a new ItemNumber value to each item as we go through for (int i = 0; i < MasterItemList.Count; i++) { MasterItemList[i].ItemNumber = (i + 1); } //Create a list of strings, each string being 1 line in the text file we are going to export List <string> FileLines = new List <string>(); //Each line in the texture file details an item that exists inside the game foreach (ItemData Item in MasterItemList) { FileLines.Add(Item.Name + ":" + Item.DisplayName + ":" + Item.Type + ":" + Item.Slot + ":" + Item.ItemNumber); } //Cast the List of strings into a regular array, then write it all into a new text file string[] Lines = FileLines.ToArray(); string FileName = "C:/mmo-client/Assets/Exports/MasterItemList.txt"; System.IO.File.WriteAllLines(FileName, Lines); } //Loads in a previous master item list from a local text file ////Loads in a previous master item list from a local text file //if(GUILayout.Button("Import Master List", GUILayout.ExpandWidth(false))) //{ // //string[] FileLines = System.IO.File.ReadAllLines("C:/mmo-client/Assets/Exports/MasterItemList.txt"); // //foreach(string Line in FileLines) // //{ // // string[] LineSplit = Line.Split(':'); // //} //} //Consumable Item List Management GUILayout.Label("Consumable Items"); if (ConsumableItemList == null) { if (GUILayout.Button("Create New Consumable ItemDataList", GUILayout.ExpandWidth(false))) { ConsumableItemList = CreateNewList("Assets/Items/ConsumableItemDataList.asset", "ConsumableItemListPath"); } } else { if (GUILayout.Button("Open Consumable List", GUILayout.ExpandWidth(false))) { string AbsolutePath = EditorUtility.OpenFilePanel("Select Consumable Item List", "", ""); if (AbsolutePath.StartsWith(Application.dataPath)) { string RelativePath = AbsolutePath.Substring(Application.dataPath.Length - "Assets".Length); ConsumableItemList = AssetDatabase.LoadAssetAtPath(RelativePath, typeof(ItemDataList)) as ItemDataList; if (ConsumableItemList == null) { ConsumableItemList.ItemList = new List <ItemData>(); } if (ConsumableItemList) { EditorPrefs.SetString("ConsumableItemListPath", RelativePath); } } } ExistingConsumableItem = EditorGUILayout.ObjectField("Existing Consumable Item Insert", ExistingConsumableItem, typeof(ItemData), false) as ItemData; if (GUILayout.Button("Add", GUILayout.ExpandWidth(false))) { ConsumableItemList.ItemList.Add(ExistingConsumableItem); ExistingConsumableItem = null; } //Place buttons to move back and forth while navigating the list of consumable items GUILayout.BeginHorizontal(); if (GUILayout.Button("Prev", GUILayout.ExpandWidth(false))) { if (ConsumableDataIndex > 1) { ConsumableDataIndex--; } } GUILayout.Space(5); if (GUILayout.Button("Next", GUILayout.ExpandWidth(false))) { if (ConsumableDataIndex < ConsumableItemList.ItemList.Count) { ConsumableDataIndex++; } } GUILayout.EndHorizontal(); //Navigate through the items in the consumables list if it has any in it if (ConsumableItemList.ItemList.Count > 0) { GUILayout.BeginHorizontal(); ConsumableDataIndex = Mathf.Clamp(EditorGUILayout.IntField("Current Consumable ItemData", ConsumableDataIndex, GUILayout.ExpandWidth(false)), 1, ConsumableItemList.ItemList.Count); EditorGUILayout.LabelField("of " + ConsumableItemList.ItemList.Count.ToString() + " items", "", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); ItemData CurrentConsumableItemData = ConsumableItemList.ItemList[ConsumableDataIndex - 1]; GUILayout.BeginHorizontal(); CurrentConsumableItemData.Name = EditorGUILayout.TextField("Current Consumable Name", CurrentConsumableItemData.Name as string); CurrentConsumableItemData.DisplayName = EditorGUILayout.TextField("Current Consumable Display Name", CurrentConsumableItemData.DisplayName as string); CurrentConsumableItemData.Description = EditorGUILayout.TextField("Current Consumable Description", CurrentConsumableItemData.Description as string); CurrentConsumableItemData.Type = (ItemType)EditorGUILayout.EnumPopup("Current Consumable Item Type", CurrentConsumableItemData.Type); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); CurrentConsumableItemData.Prefab = EditorGUILayout.ObjectField("Current Consumable Pickup Prefab", CurrentConsumableItemData.Prefab, typeof(GameObject), false) as GameObject; CurrentConsumableItemData.Icon = EditorGUILayout.ObjectField("Current Consumable Icon", CurrentConsumableItemData.Icon, typeof(Sprite), false) as Sprite; CurrentConsumableItemData.ConsumableEffect = EditorGUILayout.ObjectField("Current Consumable Effects", CurrentConsumableItemData.ConsumableEffect, typeof(ConsumableData), false) as ConsumableData; GUILayout.EndHorizontal(); } //Allow the creation of brand new consumable items that get stored straight into the consumable item data list with the others GUILayout.BeginHorizontal(); NewConsumableItemName = EditorGUILayout.TextField("New Consumable Name", NewConsumableItemName as string); NewConsumableDisplayName = EditorGUILayout.TextField("New Consumable Display Name", NewConsumableDisplayName as string); NewConsumableDescription = EditorGUILayout.TextField("New Consumable Description", NewConsumableDescription as string); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); NewConsumablePickupPrefab = EditorGUILayout.ObjectField("New Consumable Pickup Prefab", NewConsumablePickupPrefab, typeof(GameObject), false) as GameObject; NewConsumableIcon = EditorGUILayout.ObjectField("New Consumable Icon", NewConsumableIcon, typeof(Sprite), false) as Sprite; NewConsumableEffects = EditorGUILayout.ObjectField("New Consumable Effects", NewConsumableEffects, typeof(ConsumableData), false) as ConsumableData; GUILayout.EndHorizontal(); if (GUILayout.Button("Create New Consumable", GUILayout.ExpandWidth(false))) { //Create the new consumable itemdata object and store all the relevant information inside it ItemData NewConsumableItem = ScriptableObject.CreateInstance <ItemData>(); NewConsumableItem.Name = NewConsumableItemName; NewConsumableItem.DisplayName = NewConsumableDisplayName; NewConsumableItem.Description = NewConsumableDescription; NewConsumableItem.Prefab = NewConsumablePickupPrefab; NewConsumableItem.Icon = NewConsumableIcon; NewConsumableItem.ConsumableEffect = NewConsumableEffects; NewConsumableItem.Type = ItemType.Consumable; //Save this as a new asset in the project directory string AssetName = "Assets/Items/Consumables/" + NewConsumableItem.Name + ".asset"; AssetDatabase.CreateAsset(NewConsumableItem, AssetName); AssetDatabase.SaveAssets(); //Place this in the list with the rest of the consumable items ConsumableItemList.ItemList.Add(NewConsumableItem); //Empty all the input fields NewConsumableItemName = ""; NewConsumableDisplayName = ""; NewConsumableDescription = ""; NewConsumablePickupPrefab = null; NewConsumableIcon = null; NewConsumableEffects = null; } } //Equipment Item List Management GUILayout.Space(15); GUILayout.Label("Equipment Items"); if (EquipmentItemList == null) { if (GUILayout.Button("Create New Equipment ItemDataList", GUILayout.ExpandWidth(false))) { EquipmentItemList = CreateNewList("Assets/Items/EquipmentItemDataList.asset", "EquipmentItemListPath"); } } else { if (GUILayout.Button("Open Equipment List", GUILayout.ExpandWidth(false))) { string AbsolutePath = EditorUtility.OpenFilePanel("Select Equipment Item List", "", ""); if (AbsolutePath.StartsWith(Application.dataPath)) { string RelativePath = AbsolutePath.Substring(Application.dataPath.Length - "Assets".Length); EquipmentItemList = AssetDatabase.LoadAssetAtPath(RelativePath, typeof(ItemDataList)) as ItemDataList; if (EquipmentItemList == null) { EquipmentItemList.ItemList = new List <ItemData>(); } if (EquipmentItemList) { EditorPrefs.SetString("EquipmentItemListPath", RelativePath); } } } ExistingEquipmentItem = EditorGUILayout.ObjectField("Existing Equipment Item Insert", ExistingEquipmentItem, typeof(ItemData), false) as ItemData; if (GUILayout.Button("Add", GUILayout.ExpandWidth(false))) { EquipmentItemList.ItemList.Add(ExistingEquipmentItem); ExistingEquipmentItem = null; } GUILayout.BeginHorizontal(); if (GUILayout.Button("Prev", GUILayout.ExpandWidth(false))) { if (EquipmentDataIndex > 1) { EquipmentDataIndex--; } } GUILayout.Space(5); if (GUILayout.Button("Next", GUILayout.ExpandWidth(false))) { if (EquipmentDataIndex < EquipmentItemList.ItemList.Count) { EquipmentDataIndex++; } } GUILayout.EndHorizontal(); //Navigate through the items in the equipments list if it has any in it if (EquipmentItemList.ItemList.Count > 0) { GUILayout.BeginHorizontal(); EquipmentDataIndex = Mathf.Clamp(EditorGUILayout.IntField("Current Equipment ItemData", EquipmentDataIndex, GUILayout.ExpandWidth(false)), 1, EquipmentItemList.ItemList.Count); EditorGUILayout.LabelField("of " + EquipmentItemList.ItemList.Count.ToString() + " items", "", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); ItemData CurrentEquipmentItemData = EquipmentItemList.ItemList[EquipmentDataIndex - 1]; GUILayout.BeginHorizontal(); CurrentEquipmentItemData.Name = EditorGUILayout.TextField("Current Equipment Name", CurrentEquipmentItemData.Name as string); CurrentEquipmentItemData.DisplayName = EditorGUILayout.TextField("Current Equipment Display Name", CurrentEquipmentItemData.DisplayName as string); CurrentEquipmentItemData.Description = EditorGUILayout.TextField("Current Equipment Description", CurrentEquipmentItemData.Description as string); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); CurrentEquipmentItemData.Type = (ItemType)EditorGUILayout.EnumPopup("Current Equipment Item Type", CurrentEquipmentItemData.Type); CurrentEquipmentItemData.Prefab = EditorGUILayout.ObjectField("Current Consumable Pickup Prefab", CurrentEquipmentItemData.Prefab, typeof(GameObject), false) as GameObject; CurrentEquipmentItemData.Icon = EditorGUILayout.ObjectField("Current Consumable Icon", CurrentEquipmentItemData.Icon, typeof(Sprite), false) as Sprite; GUILayout.EndHorizontal(); } //Allow the creation of brand new equipment items that get stored straight into the equipments item data list with the others GUILayout.BeginHorizontal(); NewEquipmentItemName = EditorGUILayout.TextField("New Equipment Name", NewEquipmentItemName as string); NewEquipmentDisplayName = EditorGUILayout.TextField("New Equipment Display Name", NewEquipmentDisplayName as string); NewEquipmentDescription = EditorGUILayout.TextField("New Equipment Description", NewEquipmentDescription as string); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); NewEquipmentType = (ItemType)EditorGUILayout.EnumPopup("New Equipment Item Type", NewEquipmentType); NewEquipmentSlot = (EquipmentSlot)EditorGUILayout.EnumPopup("New Equipment Item Slot", NewEquipmentSlot); NewEquipmentPickupPrefab = EditorGUILayout.ObjectField("New Equipment Pickup Prefab", NewEquipmentPickupPrefab, typeof(GameObject), false) as GameObject; NewEquipmentIcon = EditorGUILayout.ObjectField("New Equipment Icon", NewEquipmentIcon, typeof(Sprite), false) as Sprite; GUILayout.EndHorizontal(); if (GUILayout.Button("Create New Equipment", GUILayout.ExpandWidth(false))) { //Create the new equipment ItemData object and store all the relevant information inside it ItemData NewEquipmentItem = ScriptableObject.CreateInstance <ItemData>(); NewEquipmentItem.Name = NewEquipmentItemName; NewEquipmentItem.DisplayName = NewEquipmentDisplayName; NewEquipmentItem.Description = NewEquipmentDescription; NewEquipmentItem.Type = NewEquipmentType; NewEquipmentItem.Prefab = NewEquipmentPickupPrefab; NewEquipmentItem.Icon = NewEquipmentIcon; NewEquipmentItem.Slot = NewEquipmentSlot; //Save this as a new asset in the project string AssetName = "Assets/Items/Equipments/" + NewEquipmentItem.Name + ".asset"; AssetDatabase.CreateAsset(NewEquipmentItem, AssetName); AssetDatabase.SaveAssets(); EquipmentItemList.ItemList.Add(NewEquipmentItem); //Empty all the input fields NewEquipmentItemName = ""; NewEquipmentDisplayName = ""; NewEquipmentDescription = ""; NewEquipmentSlot = EquipmentSlot.NULL; NewEquipmentType = ItemType.NULL; NewEquipmentPickupPrefab = null; NewEquipmentIcon = null; } } //Ability Item List Management GUILayout.Space(15); GUILayout.Label("Ability Items"); if (AbilityItemList == null) { if (GUILayout.Button("Create New Ability ItemDataList", GUILayout.ExpandWidth(false))) { AbilityItemList = CreateNewList("Assets/Items/AbilityItemDataList.asset", "AbilityItemListPath"); } } else { if (GUILayout.Button("Open Ability List", GUILayout.ExpandWidth(false))) { string AbsolutePath = EditorUtility.OpenFilePanel("Select Ability Item List", "", ""); if (AbsolutePath.StartsWith(Application.dataPath)) { string RelativePath = AbsolutePath.Substring(Application.dataPath.Length - "Assets".Length); AbilityItemList = AssetDatabase.LoadAssetAtPath(RelativePath, typeof(ItemDataList)) as ItemDataList; if (AbilityItemList == null) { AbilityItemList.ItemList = new List <ItemData>(); } if (AbilityItemList) { EditorPrefs.SetString("AbilityItemListPath", RelativePath); } } } ExistingAbilityItem = EditorGUILayout.ObjectField("Existing Ability Item Insert", ExistingAbilityItem, typeof(ItemData), false) as ItemData; if (GUILayout.Button("Add", GUILayout.ExpandWidth(false))) { AbilityItemList.ItemList.Add(ExistingAbilityItem); ExistingAbilityItem = null; } GUILayout.BeginHorizontal(); if (GUILayout.Button("Prev", GUILayout.ExpandWidth(false))) { if (AbilityDataIndex > 1) { AbilityDataIndex--; } } GUILayout.Space(5); if (GUILayout.Button("Next", GUILayout.ExpandWidth(false))) { if (AbilityDataIndex < AbilityItemList.ItemList.Count) { AbilityDataIndex++; } } GUILayout.EndHorizontal(); //Navigate through the items in the abilitys list if it has any in it if (AbilityItemList.ItemList.Count > 0) { GUILayout.BeginHorizontal(); AbilityDataIndex = Mathf.Clamp(EditorGUILayout.IntField("Current Ability ItemData", AbilityDataIndex, GUILayout.ExpandWidth(false)), 1, AbilityItemList.ItemList.Count); EditorGUILayout.LabelField("of " + AbilityItemList.ItemList.Count.ToString() + " items", "", GUILayout.ExpandWidth(false)); GUILayout.EndHorizontal(); ItemData CurrentAbilityItemData = AbilityItemList.ItemList[AbilityDataIndex - 1]; GUILayout.BeginHorizontal(); CurrentAbilityItemData.Name = EditorGUILayout.TextField("Current Ability Name", CurrentAbilityItemData.Name as string); CurrentAbilityItemData.DisplayName = EditorGUILayout.TextField("Current Ability Display Name", CurrentAbilityItemData.DisplayName as string); CurrentAbilityItemData.Description = EditorGUILayout.TextField("Current Ability Description", CurrentAbilityItemData.Description as string); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); CurrentAbilityItemData.Type = (ItemType)EditorGUILayout.EnumPopup("Current Ability Item Type", CurrentAbilityItemData.Type); CurrentAbilityItemData.Prefab = EditorGUILayout.ObjectField("Current Ability Pickup Prefab", CurrentAbilityItemData.Prefab, typeof(GameObject), false) as GameObject; CurrentAbilityItemData.Icon = EditorGUILayout.ObjectField("Current Ability Icon", CurrentAbilityItemData.Icon, typeof(Sprite), false) as Sprite; GUILayout.EndHorizontal(); } //Allow the creation of brand new equipment items that get stored straight into the equipments item data list with the others GUILayout.BeginHorizontal(); NewAbilityItemName = EditorGUILayout.TextField("New Ability Name", NewAbilityItemName as string); NewAbilityDisplayName = EditorGUILayout.TextField("New Ability Display Name", NewAbilityDisplayName as string); NewAbilityDescription = EditorGUILayout.TextField("New Ability Description", NewAbilityDescription as string); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); NewAbilityPickupPrefab = EditorGUILayout.ObjectField("New Ability Pickup Prefab", NewAbilityPickupPrefab, typeof(GameObject), false) as GameObject; NewAbilityIcon = EditorGUILayout.ObjectField("New Ability Icon", NewAbilityIcon, typeof(Sprite), false) as Sprite; GUILayout.EndHorizontal(); if (GUILayout.Button("Create New Ability", GUILayout.ExpandWidth(false))) { //Create the new equipment ItemData object and store all the relevant information inside it ItemData NewAbilityItem = ScriptableObject.CreateInstance <ItemData>(); NewAbilityItem.Name = NewAbilityItemName; NewAbilityItem.DisplayName = NewAbilityDisplayName; NewAbilityItem.Description = NewAbilityDescription; NewAbilityItem.Prefab = NewAbilityPickupPrefab; NewAbilityItem.Icon = NewAbilityIcon; NewAbilityItem.Type = ItemType.AbilityGem; //Save this as a new asset in the project string AssetName = "Assets/Items/Abilities/" + NewAbilityItem.Name + ".asset"; AssetDatabase.CreateAsset(NewAbilityItem, AssetName); AssetDatabase.SaveAssets(); AbilityItemList.ItemList.Add(NewAbilityItem); //Empty all the input fields NewAbilityItemName = ""; NewAbilityDisplayName = ""; NewAbilityDescription = ""; NewAbilityPickupPrefab = null; NewAbilityIcon = null; } } }
protected override void HandleRequest() { OfferList list = new OfferList(); using (Database db = new Database()) { MySqlCommand cmd = db.CreateQuery(); Account acc = db.Verify(Query["guid"], Query["password"], Program.GameData); cmd.CommandText = "SELECT * FROM market WHERE status=0 ORDER BY id DESC"; if (acc != null && Query["filter"] == "mine") { cmd.CommandText = "SELECT * FROM market WHERE accId=@accId ORDER BY id DESC"; cmd.Parameters.AddWithValue("@accId", int.Parse(acc.AccountId)); } ushort[] offerSearch = new ushort[0]; ItemData[] offerSearchD = new ItemData[0]; if (Query["offerItems"] != null && Query["offerItems"] != "") { offerSearch = Utils.FromCommaSepString16z(Query["offerItems"]); offerSearchD = new ItemData[offerSearch.Length]; if (Query["offerData"] != "") { offerSearchD = ItemDataList.CreateData(Query["offerData"]); } } ushort[] reqSearch = new ushort[0]; ItemData[] reqSearchD = new ItemData[0]; if (Query["requestItems"] != null && Query["requestItems"] != "") { reqSearch = Utils.FromCommaSepString16z(Query["requestItems"]); reqSearchD = new ItemData[reqSearch.Length]; if (Query["requestData"] != "") { reqSearchD = ItemDataList.CreateData(Query["requestData"]); } } using (MySqlDataReader rdr = cmd.ExecuteReader()) if (rdr.HasRows) { while (rdr.Read()) { if (offerSearch.Length > 0) { List <ushort> offerItems = new List <ushort>(Utils.FromCommaSepString16z(rdr.GetString("offerItems"))); ItemData[] offerData = ItemDataList.CreateData(rdr.GetString("offerData")); bool success = false; for (int i = 0; i < offerSearch.Length; i++) { int res = -1; if ((res = offerItems.IndexOf(offerSearch[i])) == -1) { continue; } success = true; break; } if (!success) { continue; } } if (reqSearch.Length > 0) { List <ushort> reqItems = new List <ushort>(Utils.FromCommaSepString16z(rdr.GetString("requestItems"))); ItemData[] reqData = ItemDataList.CreateData(rdr.GetString("requestData")); bool success = false; for (int i = 0; i < reqSearch.Length; i++) { int res = -1; if ((res = reqItems.IndexOf(reqSearch[i])) == -1) { continue; } success = true; break; } if (!success) { continue; } } list.Offers.Add(new Offer { Id = rdr.GetInt32("id"), AccId = rdr.GetInt32("accId"), Mine = acc != null ? rdr.GetInt32("accId") == int.Parse(acc.AccountId) : false, Status = rdr.GetInt32("status"), _OfferItems = rdr.GetString("offerItems"), _OfferData = rdr.GetString("offerData"), _RequestItems = rdr.GetString("requestItems"), _RequestData = rdr.GetString("requestData") }); } } } if (Query["filter"] != "mine" && Query["filter"] != "searched") { if (list.Offers.Count > 50) { list.Offers.RemoveRange(50, list.Offers.Count - 50); } } XmlSerializer serializer = new XmlSerializer(list.GetType(), new XmlRootAttribute("Offers") { Namespace = "" }); XmlWriterSettings xws = new XmlWriterSettings(); xws.OmitXmlDeclaration = true; xws.Encoding = Encoding.UTF8; xws.Indent = true; XmlWriter xtw = XmlWriter.Create(Context.Response.OutputStream, xws); serializer.Serialize(xtw, list, list.Namespaces); }
public abstract List<ItemData> ConvertItems(ItemDataList serverDetails);
public abstract List <ItemData> ConvertItems(ItemDataList serverDetails, int GenerationID);
public abstract List <ItemData> ConvertItems(ItemDataList serverDetails);
public override void HandleRequest(HttpListenerContext context) { NameValueCollection query; using (var rdr = new StreamReader(context.Request.InputStream)) query = HttpUtility.ParseQueryString(rdr.ReadToEnd()); if (query.AllKeys.Length == 0) { string queryString = string.Empty; string currUrl = context.Request.RawUrl; int iqs = currUrl.IndexOf('?'); if (iqs >= 0) { query = HttpUtility.ParseQueryString((iqs < currUrl.Length - 1) ? currUrl.Substring(iqs + 1) : String.Empty); } } /*using (var db = new Database(Program.Settings.GetValue("conn"))) * { * Account acc = db.Verify(query["guid"], query["password"]); * int num = Convert.ToInt32(query["num"]); * int offset = Convert.ToInt32(query["offset"]); * if (num == 0) * { * num = 50; * } * byte[] status; * if (acc == null) * status = Encoding.UTF8.GetBytes("<Error>Account credentials not valid</Error>"); * else * { * try * { * status = Encoding.UTF8.GetBytes(db.HttpGetGuildMembers(num, offset, acc)); * } * catch * { * status = Encoding.UTF8.GetBytes("<Error>Guild member error</Error>"); * } * } * context.Response.OutputStream.Write(status, 0, status.Length); * }*/ OfferList list = new OfferList(); using (var db = new Database(Program.Settings.GetValue("conn"))) { var acc = db.Verify(query["guid"], query["password"]); var cmd = db.CreateQuery(); cmd.CommandText = "SELECT * FROM market WHERE status=0 ORDER BY id DESC"; if (acc != null && query["filter"] == "mine") { cmd.CommandText = "SELECT * FROM market WHERE accId=@accId ORDER BY id DESC"; cmd.Parameters.AddWithValue("@accId", acc.AccountId); } ushort[] offerSearch = new ushort[0]; ItemData[] offerSearchD = new ItemData[0]; if (query["offerItems"] != null && query["offerItems"] != "") { offerSearch = Utils.FromCommaSepString16(query["offerItems"]); offerSearchD = new ItemData[offerSearch.Length]; if (query["offerData"] != "") { offerSearchD = ItemDataList.CreateData(query["offerData"]); } } ushort[] reqSearch = new ushort[0]; ItemData[] reqSearchD = new ItemData[0]; if (query["requestItems"] != null && query["requestItems"] != "") { reqSearch = Utils.FromCommaSepString16(query["requestItems"]); reqSearchD = new ItemData[reqSearch.Length]; if (query["requestData"] != "") { reqSearchD = ItemDataList.CreateData(query["requestData"]); } } using (var rdr = cmd.ExecuteReader()) if (rdr.HasRows) { while (rdr.Read()) { if (offerSearch.Length > 0) { List <ushort> offerItems = new List <ushort>(Utils.FromCommaSepString16(rdr.GetString("offerItems"))); ItemData[] offerData = ItemDataList.CreateData(rdr.GetString("offerData")); bool success = false; for (int i = 0; i < offerSearch.Length; i++) { int res = -1; if ((res = offerItems.IndexOf(offerSearch[i])) == -1) { continue; } if (offerSearchD[i] != null) { bool offerDataE = offerData[res] != null; if ((offerSearchD[i].Strange && (!offerDataE || !offerData[res].Strange)) || (!offerSearchD[i].Strange && offerDataE && offerData[res].Strange)) { continue; } if (!offerSearchD[i].Strange && offerSearchD[i].NamePrefix != "") { if (!offerDataE || (offerDataE && offerData[res].NamePrefix != offerSearchD[i].NamePrefix)) { continue; } } if (offerSearchD[i].Effect != "" && (!offerDataE || (offerData[res].Effect != offerSearchD[i].Effect))) { continue; } } else if (offerData[res] != null) { if (offerData[res].Strange || offerData[res].NamePrefix != "" || offerData[res].Effect != "") { continue; } } success = true; break; } if (!success) { continue; } } if (reqSearch.Length > 0) { List <ushort> reqItems = new List <ushort>(Utils.FromCommaSepString16(rdr.GetString("requestItems"))); ItemData[] reqData = ItemDataList.CreateData(rdr.GetString("requestData")); bool success = false; for (int i = 0; i < reqSearch.Length; i++) { int res = -1; if ((res = reqItems.IndexOf(reqSearch[i])) == -1) { continue; } if (reqSearchD[i] != null) { bool reqDataE = reqData[res] != null; if ((reqSearchD[i].Strange && (!reqDataE || !reqData[res].Strange)) || (!reqSearchD[i].Strange && reqDataE && reqData[res].Strange)) { continue; } if (!reqSearchD[i].Strange && reqSearchD[i].NamePrefix != "") { if (!reqDataE || (reqDataE && reqData[res].NamePrefix != reqSearchD[i].NamePrefix)) { continue; } } if (reqSearchD[i].Effect != "" && (!reqDataE || (reqData[res].Effect != reqSearchD[i].Effect))) { continue; } } else if (reqData[res] != null) { if (reqData[res].Strange || reqData[res].NamePrefix != "" || reqData[res].Effect != "") { continue; } } success = true; break; } if (!success) { continue; } } list.Offers.Add(new Offer { Id = rdr.GetInt32("id"), AccId = rdr.GetInt32("accId"), Mine = acc != null ? rdr.GetInt32("accId") == acc.AccountId : false, Status = rdr.GetInt32("status"), _OfferItems = rdr.GetString("offerItems"), _OfferData = rdr.GetString("offerData"), _RequestItems = rdr.GetString("requestItems"), _RequestData = rdr.GetString("requestData") }); } } } if (query["filter"] != "mine" && query["filter"] != "searched") { if (list.Offers.Count > 50) { list.Offers.RemoveRange(50, list.Offers.Count - 50); } } var ms = new MemoryStream(); var serializer = new XmlSerializer(list.GetType(), new XmlRootAttribute("Offers") { Namespace = "" }); var xws = new XmlWriterSettings(); xws.OmitXmlDeclaration = true; xws.Encoding = Encoding.UTF8; xws.Indent = true; XmlWriter xtw = XmlWriter.Create(context.Response.OutputStream, xws); serializer.Serialize(xtw, list, list.Namespaces); }