public void AddItemByIdemData(ItemData item, int num, int numtag,int shortcut) { UpdateCount+=1; if (itemManager != null) { if (item != null && num > 0) { ItemData itemdata = itemManager.CloneItemData (item); if (itemdata != null) { ItemCollector itemc = new ItemCollector (); itemc.Index = itemManager.GetIndexByID (itemdata.ItemID); itemc.Item = itemdata; itemc.NumTag = numtag; itemc.Shortcut = shortcut; for (int i=0; i<Items.Count; i++) { if (Items [i].Item != null && Items [i].Item.ItemID == itemdata.ItemID && itemdata.Stack) { Items [i].Num += num; return; } } itemc.Num += num; Items.Add (itemc); if (itemc.Index == -1) { Debug.Log (itemdata.name + " Is not registered in Item Manager! this item will not save"); } } } } }
public override void DoAction(ItemData itemData) { ///Tmp moves all to vault on backend MoveMultipleStacks stacks = new MoveMultipleStacks(); stacks.StackInfos = new List<MoveItemStackInfo>(); foreach (ItemData item in SourceContainer.containerItems) { MoveItemStackInfo info = new MoveItemStackInfo(); info.MoveAmount = item.stackSize; info.StackID = item.stackID; stacks.StackInfos.Add(info); } string convert = JsonConvert.SerializeObject(stacks); WebserviceCalls.webservice.MoveItemStacks(convert, ItemSystemGameData.UserID.ToString(), "User", ItemSystemGameData.AppID, DestinationLocation, delegate(MoveMultipleItemsResponse x) { ItemData[] containerItems = new ItemData[SourceContainer.containerItems.Count]; SourceContainer.containerItems.CopyTo(containerItems); foreach (MovedItemsInfo info in x.movedItems) { foreach (ItemData data in containerItems) { if (data.stackID == info.OriginalStackID) { data.stackID = info.NewStackID; SourceContainer.Remove(data, true); DestinationContainer.Add(data, -1, false); } } } }); }
protected override void AddItem(ItemData modified, int amount = -1, bool isSave = true) { ItemData newItem = null; if (amount == -1) { amount = modified.stackSize; modified.ownerContainer = this; if (!AddToExistingStack(modified, modified.stackSize, isSave)) { modified.CreatNew(out newItem, amount, this); containerItems.Add(newItem); AddItemEvent(newItem, isSave); } } else { modified.CreatNew(out newItem, amount, this); if (!AddToExistingStack(newItem, amount, isSave)) { containerItems.Add(newItem); AddItemEvent(newItem, isSave); } } Destroy(modified.gameObject); }
/// <summary> /// Constractor. /// </summary> /// <param name="itemData">Item data.</param> /// <param name="attack">Attack value.</param> /// <param name="defense">Defense value.</param> /// <param name="equipJob">Can equip job bit flag.</param> protected EquipBase(ref ItemData itemData, int attack, int defense, char equipJob) : base(ref itemData) { this.attack = attack; // 攻撃力 this.defense = defense; // 防御力 this.equipJob = equipJob; // 装備できるジョブ }
public void ShowItem(ItemData item) { ItemData itemInCurrentSlot; CrewInspector.Instance.CurrentInspectedCharacter.GetItemInSlot(CrewInspector.Instance.CurrentInspectedSlot, out itemInCurrentSlot); showingEquippedItem = itemInCurrentSlot == item; gameObject.SetActive(true); itemName.text = item.itemName; itemDescription.text = item.itemDescription; itemImage.sprite = item.LoadItemIcon(); string itemProps = item.GetItemStatModifiersList(); if (string.IsNullOrEmpty(itemProps)) itemProperties.text = "No properties"; else itemProperties.text = itemProps; if (showingEquippedItem) { equipUnequipButton.GetComponentInChildren<Text>().text = "Unequip"; EnableEquipButton(true); } else { equipUnequipButton.GetComponentInChildren<Text>().text = "Equip"; EnableEquipButton(CrewInventory.Instance.GetFreeItemAmount(item.itemName) > 0); } }
protected virtual void OnItemClick(ItemData item, EventArgs e) { EventHandler handler = ItemClick; if (handler != null) { handler(item, e); } }
public static ItemSelectButton Create(ItemData data) { GameObject button = Instantiate(Resources.Load("GUI/CrewInspector/ItemSelectButton")) as GameObject; ItemSelectButton buttonScript = button.GetComponent<ItemSelectButton>(); buttonScript.Init(data); return buttonScript; }
protected override void AddItem(ItemData modified, int amount = -1, bool isSave = true) { if (slots.Count == 0) return; // No active slots to check. Dictionary<int, SlottedContainerSlotData> ShortList = GetAllAvalibleSlots(modified); if (ShortList.Count == 0 || ShortList == null) { return; // did not find any matching slots. } if (slotSelector == null) throw new Exception("Slot selector must be set before adding items to slots."); SlottedContainerSlotData selectedSlot = slotSelector.PickBestSlot(ShortList); if (selectedSlot == null) { return; // slected slot did not exist. } AddToSlot(modified, int.Parse(selectedSlot.slotNameID), amount, isSave); return; }
public void Init(int itemID, int num) { itemData = DataManager.Instance.GetItemDataSet().GetItemData(itemID); nameText.text = itemData.name; descriptionText.text = itemData.shortDesc; numText.text = "*" + num.ToString(); if(itemData.type == ItemType.Weapon) { WeaponData weaponData = itemData as WeaponData; descriptionText.text = System.String.Format("攻击:{0}~{1} 命中:{2} 速度:{3}\n暴击:{4} 打断:{5}", weaponData.basicATKMin, weaponData.basicATKMax, weaponData.basicACC, weaponData.basicSPD, weaponData.basicCRT, weaponData.interrupt); } else if(itemData.type == ItemType.Magic) { MagicData magicData = itemData as MagicData; descriptionText.text = System.String.Format("攻击:{0}~{1} 命中:{2} 速度:{3}\n暴击:{4} 打断:{5}", magicData.basicATKMin, magicData.basicATKMax, magicData.basicACC, magicData.basicSPD, magicData.basicCRT, magicData.interrupt); } GetComponent<Button>().onClick.AddListener(delegate() { OnClick(name); }); }
protected void ModifiedItemEvent(ItemData item, bool isSave) { if (ModifiedItem != null) { ModifiedItem(item, isSave); } }
public void AddToSlot(ItemData modified, int slotID, int amount = -1, bool isSave = true) { SlottedContainerSlotData selectedSlot = slots[slotID]; ItemData NewSlotData = null; int TargetStackSize = amount; if (amount == -1) TargetStackSize = modified.stackSize; if (TargetStackSize > selectedSlot.slotMaxCountLimit) { TargetStackSize = selectedSlot.slotMaxCountLimit; } modified.CreatNew(out NewSlotData, TargetStackSize, this); selectedSlot.slotData = NewSlotData; ModdifyStatsByFactor(NewSlotData, 1); containerItems.Add(NewSlotData); Destroy(modified.gameObject); AddItemEvent(NewSlotData, isSave); selectedSlot.OnItemChangedWrapper(); }
protected void AddItemEvent(ItemData item, bool isSave) { if (AddedItem != null) { AddedItem(item, isSave); } }
protected void RemoveItemEvent(ItemData item, int amount, bool isMoving) { if (RemovedItem != null) { RemovedItem(item, amount, isMoving); } }
void equipment_removedItem(ItemData item, int amount, bool isMovedToAnotherContainer) { if (item.assetURL == currentItem.assetURL && amount == item.stackSize) { Destroy(ActiveModel); } }
// Use this for initialization void Start () { AddIDS (); database = GameObject.FindGameObjectWithTag ("Database"); displays = GameObject.FindGameObjectWithTag ("Background"); itemData = database.GetComponent<ItemData> (); }
void Update() { if (itemData == null) itemData = GetComponent<ItemData>(); itemAmountLabel.text = itemData.stackSize.ToString(); }
protected override void AddItem(ItemData modified, int amount = -1, bool isSave = true) { modified.ownerContainer.Remove(modified, false, modified.stackSize); WebserviceCalls.webservice.DeductStackAmount(modified.stackID, modified.stackSize, ReturnedString); Destroy(modified.gameObject); }
public override bool isItemSelected(ItemData item, IEnumerable behaviourPairs, bool IsInverted = false) { foreach (string behaviourString in behaviourPairs) { ItemFilterSystem.BehaviourPair pair = JsonConvert.DeserializeObject<ItemFilterSystem.BehaviourPair>(behaviourString); if (item.classID == pair.classID) { foreach (BehaviourDefinition itemBehaviour in item.behaviours) { if (itemBehaviour.ID == pair.behaviourID) { if (!IsInverted) return true; else { return false; } } } } } if (!IsInverted) return false; else { return true; } }
public void GetItem(ItemData item) { Player.Instance().hpComponent.AddHp(item.addHp); Player.Instance().AddAttack(item.addAttack); Player.Instance().AddDefence(item.addDefence); Player.Instance().AddGold(item.addGold); Message.RaiseOneMessage<Player>("PlayerShow", this, this); string str = "你获得了" + item.name; if (item.addHp > 0) { str += ",生命值增加了" + item.addHp; } if (item.addAttack > 0) { str += ",攻击力增加了" + item.addAttack; } if (item.addDefence > 0) { str += ",防御力增加了" + item.addDefence; } if (item.addGold > 0) { str += ",金币增加了" + item.addGold; } str += "。"; Game.Instance().ShowMessage(str, Game.Instance().gamePosition); }
public void CreatePanelByData(ItemData data,int num) { GameObject o = CreatePanel(data,num); o.GetComponent<Button>().onClick.AddListener(() => { selectType = data.type; bottomText.text = data.explanation; //ホーム画面なら if(homeManager){ homeManager.ChangeItem(data); } if(mainManager){ switch(data.type){ case ItemType.GreatLifeOrb: mainManager.NotifyUseAll(); break; default: mainManager.NotifyUseOne(); break; } } ResetColor(); ColorBlock cblock = o.GetComponent<Button>().colors; cblock.normalColor = Color.white; cblock.highlightedColor = Color.white; o.GetComponent<Button>().colors = cblock; }); }
public static void insertItems() { ItemData item; item = new ItemData (); item.id = 1; item.name = "Queso de cabra"; item.description = "Hecho en el mejor caserío muggle"; item.price = 40; item.health = 20; item.type = Item.ItemType.Consumable; item.subType = Item.ItemSubType.Health; item.create (); item = new ItemData (); item.id = 2; item.name = "Colgante de Dermor"; item.description = "No se me ocurre nada bueno"; item.price = 2500; item.type = Item.ItemType.Armor; item.subType = Item.ItemSubType.Necklace; item.create (); item = new ItemData (); item.id = 3; item.name = "Varita de principiante"; item.description = "La varita reglamentaria del centro"; item.price = 40; item.type = Item.ItemType.Weapon; item.subType = Item.ItemSubType.Wand; item.create (); }
public ChestModifySlotEventArgs(TSPlayer player, int chestIndex, int slotIndex, ItemData newItem) : base(player) { this.ChestIndex = chestIndex; this.SlotIndex = slotIndex; this.NewItem = newItem; }
public static void registerItem(String id, Texture invTexture, GameObject model) { if (items.ContainsKey(id)) throw new Exception("Cannot have two items with the same id (" + id + ")"); items[id] = new ItemData(invTexture, model); }
private ItemData CreateItemDataFromGameObject(GameObject gameObject) { ValidateGameObject (gameObject); ItemData itemData = new ItemData (); itemData.transformData.position = gameObject.transform.position; itemData.transformData.rotation = gameObject.transform.eulerAngles; itemData.transformData.scale = gameObject.transform.localScale; itemData.name = gameObject.name; foreach (IPersistable persistable in gameObject.GetComponents<IPersistable>()) { SerializableDictionary<string, object> componentConfiguration = new SerializableDictionary<string, object> (); foreach (FieldInfo field in persistable.GetType().GetFields()) { componentConfiguration.Add (field.Name, field.GetValue (persistable)); } string componentName = persistable.GetType ().FullName; itemData.componentData.configurations.Add (componentName, componentConfiguration); } foreach (Transform child in gameObject.transform) { if (child.GetComponents<IPersistable> ().Length > 0) { itemData.children.Add (CreateItemDataFromGameObject (child.gameObject)); } } return itemData; }
public override bool Compare(ItemData item) { if (item.RefItem.type != ItemData.Type.Weapon) return base.Compare(item); ItemWeaponData weapon = (ItemWeaponData)item; return WeaponName.CompareTo(weapon.WeaponName) == 0; }
public void ResetItem(Pair pos,ItemData itemData, int ord = (int)ITEM_ORDER.ITEM_ORDER_BACK, bool revert = false) { if (itemData != null) { item = itemData; Reset(pos, ord, revert, item.spritePath, item.color); } }
void SetToSlot(int slot, ItemData itemData) { if (slot == -1) return; itemData.transform.parent = slots[slot].transform; itemData.transform.localPosition = new Vector3(0, 0, -1); itemData.transform.localScale = Vector3.one; }
public override bool Compare(ItemData item) { if (item.RefItem.type != ItemData.Type.Skill) return false; ItemSkillData itemData = item as ItemSkillData; return RefItem.weaponId == itemData.RefItem.weaponId; }
public bool GetItemInSlot(int slotId, out ItemData itemData) { itemData = null; if (inventory.ContainsKey(slotId)) { itemData = inventory[slotId]; return true; } return false; }
public void EquipItemInSlot(ItemData item, int slotId) { if (inventory.ContainsKey(slotId)) UnequipItemInSlot(item, slotId); inventory.Add(slotId, item); statModifiers.AddStats(item.GetStatModifiers()); //CrewInventory.Instance.OnEquippedItem(item.itemName, this); }
public void Activate(ItemData item) { this.item = item; ConstructDataString(); toolTip.SetActive(true); }
void OnClickDown(ButtonScript obj, object args, int param1, int param2) { StoreUI.Instance.itemInfoTips.gameObject.SetActive(true); StoreUI.Instance.itemInfoTips.Item = ItemData.GetData(param1); }
private bool Check(Map map, Mobile m, List <Item> items, int x, int y, int startTop, int startZ, bool canSwim, bool cantWalk, out int newZ) { newZ = 0; StaticTile[] tiles = map.Tiles.GetStaticTiles(x, y, true); LandTile landTile = map.Tiles.GetLandTile(x, y); bool landBlocks = (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Impassable) != 0; bool considerLand = !landTile.Ignored; if (landBlocks && canSwim && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Wet) != 0) //Impassable, Can Swim, and Is water. Don't block it. { landBlocks = false; } else if (cantWalk && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Wet) == 0) //Can't walk and it's not water { landBlocks = true; } int landZ = 0, landCenter = 0, landTop = 0; map.GetAverageZ(x, y, ref landZ, ref landCenter, ref landTop); bool moveIsOk = false; int stepTop = startTop + StepHeight; int checkTop = startZ + PersonHeight; bool ignoreDoors = (m_AlwaysIgnoreDoors || !m.Alive || m.Body.BodyID == 0x3DB || m.IsDeadBondedPet); #region Tiles for (int i = 0; i < tiles.Length; ++i) { StaticTile tile = tiles[i]; ItemData itemData = TileData.ItemTable[tile.ID & 0x3FFF]; TileFlag flags = itemData.Flags; if ((flags & ImpassableSurface) == TileFlag.Surface || (canSwim && (flags & TileFlag.Wet) != 0)) // Surface && !Impassable { if (cantWalk && (flags & TileFlag.Wet) == 0) { continue; } int itemZ = tile.Z; int itemTop = itemZ; int ourZ = itemZ + itemData.CalcHeight; int ourTop = ourZ + PersonHeight; int testTop = checkTop; if (moveIsOk) { int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); if (cmp > 0 || (cmp == 0 && ourZ > newZ)) { continue; } } if (ourZ + PersonHeight > testTop) { testTop = ourZ + PersonHeight; } if (!itemData.Bridge) { itemTop += itemData.Height; } if (stepTop >= itemTop) { int landCheck = itemZ; if (itemData.Height >= StepHeight) { landCheck += StepHeight; } else { landCheck += itemData.Height; } if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ) { continue; } if (IsOk(ignoreDoors, ourZ, testTop, tiles, items)) { newZ = ourZ; moveIsOk = true; } } } } #endregion #region Items for (int i = 0; i < items.Count; ++i) { Item item = items[i]; ItemData itemData = item.ItemData; TileFlag flags = itemData.Flags; if (!item.Movable && ((flags & ImpassableSurface) == TileFlag.Surface || (m.CanSwim && (flags & TileFlag.Wet) != 0))) // Surface && !Impassable && !Movable { if (cantWalk && (flags & TileFlag.Wet) == 0) { continue; } int itemZ = item.Z; int itemTop = itemZ; int ourZ = itemZ + itemData.CalcHeight; int ourTop = ourZ + PersonHeight; int testTop = checkTop; if (moveIsOk) { int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); if (cmp > 0 || (cmp == 0 && ourZ > newZ)) { continue; } } if (ourZ + PersonHeight > testTop) { testTop = ourZ + PersonHeight; } if (!itemData.Bridge) { itemTop += itemData.Height; } if (stepTop >= itemTop) { int landCheck = itemZ; if (itemData.Height >= StepHeight) { landCheck += StepHeight; } else { landCheck += itemData.Height; } if (considerLand && landCheck < landCenter && landCenter > ourZ && testTop > landZ) { continue; } if (IsOk(ignoreDoors, ourZ, testTop, tiles, items)) { newZ = ourZ; moveIsOk = true; } } } } #endregion if (considerLand && !landBlocks && stepTop >= landZ) { int ourZ = landCenter; int ourTop = ourZ + PersonHeight; int testTop = checkTop; if (ourZ + PersonHeight > testTop) { testTop = ourZ + PersonHeight; } bool shouldCheck = true; if (moveIsOk) { int cmp = Math.Abs(ourZ - m.Z) - Math.Abs(newZ - m.Z); if (cmp > 0 || (cmp == 0 && ourZ > newZ)) { shouldCheck = false; } } if (shouldCheck && IsOk(ignoreDoors, ourZ, testTop, tiles, items)) { newZ = ourZ; moveIsOk = true; } } return(moveIsOk); }
public static void setPlayerPosition(Character chr, float goX, float goY, short map) { MartialClient c = chr.getAccount().mClient; Logger.WriteLog(Logger.LogTypes.Debug, goX + " | " + goY + " | " + map); Area lastArea = chr.getArea(); Area newArea = WMap.Instance.getGrid(map).getAreaByRound(goX, goY); if (newArea == null) { StaticPackets.sendSystemMessageToClient(chr.getAccount().mClient, 1, "The position " + goX + "|" + goY + "|" + map + " can't be reached."); Waypoint closestTown = TownCoordsCache.Instance.getClosestWaypointForMap(map, new Waypoint(goX, goY)); if (closestTown == null) { Area vvArea = WMap.Instance.getGrid(1).getAreaByRound(-1660, 2344); if (vvArea == null) { Logger.WriteLog(Logger.LogTypes.Error, "Pure setPlayerPosition error {0}|{1}|{2}", goX, goY, map); StaticPackets.sendSystemMessageToClient(chr.getAccount().mClient, 1, "We're sorry, but an hard error has occured. Please report it to an admin."); c.Close(); return; } else { goX = -1660; goY = 2344; map = 1; newArea = vvArea; } } else { goX = closestTown.getX(); goY = closestTown.getY(); newArea = WMap.Instance.getGrid(map).getAreaByRound(goX, goY); } } if (lastArea != null) { WMap.Instance.getGrid(chr.getMap()).sendTo3x3AreaLeave(chr, lastArea); lastArea.removeCharacter(chr); } if (newArea != null) { chr.setArea(newArea); } else { chr.getAccount().mClient.Close(); return; } newArea.addCharacter(chr); chr.setMap(map); chr.setPosition(new float[] { goX, goY }); OutPacket op = new OutPacket(5840); op.WriteInt(5824); op.WriteShort(4); // 4 - 5 op.WriteShort(1); // 6 - 7 op.WriteInt(1); // 8 - 11 op.WriteInt(chr.getuID()); // 12 - 15 op.WriteShort(1); // 16 - 19 op.WriteShort(1); // 16 - 19 op.WriteInt(chr.getMap()); // 20 - 23 op.WriteInt(DateTime.Now.Year - 2000); // 24 - 27 op.WriteByte((byte)DateTime.Now.Month); // 28 op.WriteByte(DateTime.Now.Day > 30 ? (byte)0x1e : (byte)DateTime.Now.Day); // 29 op.WriteInt(DateTime.Now.Hour); // 30 - 37 for (int i = 0; i < 120; i++) { if (chr.getCargo().getSeqSaved()[i] != -1 && chr.getCargo().getCargoSaved()[chr.getCargo().getSeqSaved()[i]] != null) { op.WriteInt(); op.WriteByte((byte)(chr.getCargo().getSeqSaved()[i] / 100)); op.WriteByte((byte)(chr.getCargo().getSeqSaved()[i] % 100)); Item item = chr.getCargo().getCargoSaved()[chr.getCargo().getSeqSaved()[i]]; op.WriteInt(item.getItemID()); ItemData itemData = ItemDataCache.Instance.getItemData(item.getItemID()); if (itemData.getTimeToExpire() > 0) { } op.WriteShort(item.getQuantity()); } else { op.WriteZero(12); } } // 38 - 1477 op.Position = 1476; for (int i = 0; i < chr.getCommunity().getFriendsList().Capacity; i++) { if (chr.getCommunity().getFriendsList().ElementAtOrDefault(i) != null) { op.WritePaddedString(chr.getCommunity().getFriendsList()[i], 17); } else { op.WriteZero(17); } } // 1476 - 1934 op.WriteRepeatedByte(0x58, 40); op.Position = 1986; for (int i = 0; i < chr.getCommunity().getIgnoresList().Capacity; i++) { if (chr.getCommunity().getIgnoresList().ElementAtOrDefault(i) != null) { op.WritePaddedString(chr.getCommunity().getIgnoresList()[i], 17); } else { op.WriteZero(17); } } // 1987 - 2157 op.WriteInt(363); // questsy op.WriteLong(); op.WriteLong(138769276674441706); op.WriteLong(21692910); op.WriteShort(); op.WriteShort(1); op.Position = 2248; for (byte i = 0; i < 240; i++) { if (chr.getInventory().getSeqSaved()[i] != -1 && chr.getInventory().getInvSaved()[chr.getInventory().getSeqSaved()[i]] != null) { op.WriteShort(); op.WriteByte((byte)(chr.getInventory().getSeqSaved()[i] / 100)); op.WriteByte((byte)(chr.getInventory().getSeqSaved()[i] % 100)); Item item = chr.getInventory().getInvSaved()[chr.getInventory().getSeqSaved()[i]]; op.WriteInt(item.getItemID()); op.WriteInt(item.getQuantity()); } else { op.WriteZero(12); } } // 2252 - 5133 op.WriteLong(chr.getCoin()); op.Position = 5140; for (byte i = 0; i < 21; i++) { if (chr.getSkillBar().getSkillBar().ContainsKey(i)) { int barID = chr.getSkillBar().getSkillBar()[i]; if (barID > 200000000) { op.WriteInt(1); } else if (barID > 511) { op.WriteInt(5); barID -= 512; } else if (barID > 255) { op.WriteInt(6); barID -= 256; } else { SkillData skill = SkillDataCache.Instance.getSkill(chr.getSkills().getLearnedSkills().ElementAtOrDefault(barID)); if (skill == null) { op.WriteInt(0); } else if (skill.getTypeSpecific() == 6) { op.WriteInt(3); } else if (skill.getTypeSpecific() == 7) { op.WriteInt(4); } else { op.WriteInt(2); } } op.WriteInt(barID); } else { op.WriteZero(8); } } // 5140 - 5299 op.Position = 5320; for (int i = 0; i < 60; i++) { if (chr.getSkills().getLearnedSkills().Count > i && chr.getSkills().getLearnedSkills()[i] != 0) { op.WriteInt(chr.getSkills().getLearnedSkills()[i]); op.WriteInt(SkillDataCache.Instance.getSkill(chr.getSkills().getLearnedSkills()[i]).getSkillPoints()); } else { op.WriteLong(); } } // 5320 - 5799 op.WriteFloat(chr.getPosition()[0]); op.WriteFloat(chr.getPosition()[1]); op.WriteInt(0x0c); op.WriteInt(140338688); op.WriteInt(); op.WriteShort(); op.WriteShort(10962); //s3c0nd p4ck3t op.WriteInt(16); op.WriteInt(7929861); op.WriteInt(chr.getuID()); c.WriteRawPacket(op.ToArray()); WMap.Instance.getGrid(chr.getMap()).sendTo3x3AreaSpawn(chr, chr.getArea()); }
void SetItemData(int index, ref ItemData newData) { Data[Items[index]] = newData; }
public void SetItemData(ItemData data) { this.data = data; spriteRenderer.sprite = data.image; }
public List <ItemModel> GetItemsByIdentifier(string identifier) { ItemData data = new ItemData(); return(data.GetItemsByIdentifier(identifier)); }
public List <ItemModel> GetAllItems() { ItemData data = new ItemData(); return(data.GetAllItems()); }
protected override Item GetItem(ID itemId, Sitecore.Globalization.Language language, Version version, Database database) { var item = base.GetItem(itemId, language, version, database); if (item == null) { return(item); } if (item.Versions.GetVersionNumbers().Length > 0) { return(item); } //Try Default Language var defaultLang = Sitecore.Configuration.Settings.GetSetting("SF.LanguageStrategy.DefaultLanguage"); if (string.IsNullOrEmpty(defaultLang)) { return(item); } var fallbackLanguage = LanguageManager.GetLanguage(defaultLang); if (fallbackLanguage == null) { return(item); } Item fallback = base.GetItem(itemId, fallbackLanguage, Version.Latest, database); if (fallback != null && fallback.Versions.GetVersionNumbers().Length > 0) { var stubData = new ItemData(fallback.InnerData.Definition, fallback.Language, fallback.Version, fallback.InnerData.Fields); var stub = new LanguageStub(itemId, stubData, database) { OriginalLanguage = item.Language }; stub.RuntimeSettings.SaveAll = true; return(stub); } //Item doesn't exist in default language, Let's take any other version. var installedLanguages = LanguageManager.GetLanguages(database); //Assume this will be in same order of languages as defined in System Languages foreach (var installedLanguage in installedLanguages) { fallback = base.GetItem(itemId, installedLanguage, Version.Latest, database); if (fallback != null && fallback.Versions.GetVersionNumbers().Length > 0) { var stubData = new ItemData(fallback.InnerData.Definition, fallback.Language, fallback.Version, fallback.InnerData.Fields); var stub = new LanguageStub(itemId, stubData, database) { OriginalLanguage = item.Language }; stub.RuntimeSettings.SaveAll = true; return(stub); } } //Nothing Worked return the null item return(item); }
public Object VerifyNewItem(NewItemVerificationModel item) { ItemData data = new ItemData(); return(data.VerifyNewItem(item)); }
public override void SetItemData(ItemData itemData) { base.SetItemData(itemData); }
public bool CompareItem(ItemData itemData) { return(itemData.isRedeemer == isRedeemer); }
private static void appendAppearanceUpdate(Player p, PacketBuilder updateBlock) { PacketBuilder playerProps = new PacketBuilder().setSize(Packet.Size.Bare); Appearance app = p.getAppearance(); playerProps.addByte((byte)(app.getGender() & 0xFF)); if ((app.getGender() & 0x2) == 2) { playerProps.addByte((byte)0); playerProps.addByte((byte)0); } playerProps.addByte((byte)p.getPrayers().getPkIcon()); playerProps.addByte((byte)p.getPrayers().getHeadIcon()); if (!app.isInvisible()) { if (!app.isNpc()) { for (int i = 0; i < 4; i++) { if (p.getEquipment().getItemInSlot((ItemData.EQUIP)i) != -1) { playerProps.addUShort(32768 + p.getEquipment().getSlot((ItemData.EQUIP)i).getDefinition().getEquipId()); } else { playerProps.addByte((byte)0); } } if (p.getEquipment().getItemInSlot(ItemData.EQUIP.CHEST) != -1) { playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.CHEST).getDefinition().getEquipId()); } else { playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.AMULET)); } if (p.getEquipment().getItemInSlot(ItemData.EQUIP.SHIELD) != -1) { playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.SHIELD).getDefinition().getEquipId()); } else { playerProps.addByte((byte)0); } Item chest = p.getEquipment().getSlot(ItemData.EQUIP.CHEST); if (chest != null && chest.getDefinition() != null) { if (!ItemData.isFullBody(chest.getDefinition())) { playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.WEAPON)); } else { playerProps.addByte((byte)0); } } else { playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.WEAPON)); } if (p.getEquipment().getItemInSlot(ItemData.EQUIP.LEGS) != -1) { playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.LEGS).getDefinition().getEquipId()); } else { playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.SHIELD)); } Item hat = p.getEquipment().getSlot(ItemData.EQUIP.HAT); if (hat != null && hat.getDefinition() != null) { if (!ItemData.isFullHat(hat.getDefinition()) && !ItemData.isFullMask(hat.getDefinition())) { playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.HAT)); } else { playerProps.addByte((byte)0); } } else { playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.HAT)); } if (p.getEquipment().getItemInSlot(ItemData.EQUIP.HANDS) != -1) { playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.HANDS).getDefinition().getEquipId()); } else { playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.CHEST)); } if (p.getEquipment().getItemInSlot(ItemData.EQUIP.FEET) != -1) { playerProps.addUShort(32768 + p.getEquipment().getSlot(ItemData.EQUIP.FEET).getDefinition().getEquipId()); } else { playerProps.addUShort(0x100 + app.getLook(6)); } if (hat != null && hat.getDefinition() != null) { if (!ItemData.isFullMask(hat.getDefinition())) { playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.CAPE)); } else { playerProps.addByte((byte)0); } } else { playerProps.addUShort(0x100 + app.getLook(ItemData.EQUIP.CAPE)); } } else { playerProps.addUShort(-1); playerProps.addUShort(app.getNpcId()); playerProps.addByte((byte)255); } } else { for (int i = 0; i < 12; i++) { playerProps.addByte((byte)0); } } foreach (int colour in app.getColoursArray()) { playerProps.addByte((byte)colour); } playerProps.addUShort(p.getEquipment().getStandWalkAnimation()); playerProps.addLong(p.getLoginDetails().getLongName()); playerProps.addByte((byte)p.getSkills().getCombatLevel()); playerProps.addUShort(0); playerProps.addByte((byte)0); updateBlock.addByteA((byte)(playerProps.getLength() & 0xFF)); updateBlock.addBytes(playerProps.toPacket().getData(), 0, playerProps.getLength()); }
public static void Purchase(ItemData item) { Purchase(item.itemId); }
public ItemDataExportModel(ItemData itemData) { ItemName = itemData.ItemId.ToString().Replace("Item", ""); Count = itemData.Count; }
protected override void OnTarget(Mobile from, object targeted) { if (m_Head == null || m_Head.Deleted) { return; } if (m_Head.IsChildOf(from.Backpack)) { BaseHouse house = BaseHouse.FindHouseAt(from); if (house != null && house.IsOwner(from)) { IPoint3D p = targeted as IPoint3D; Map map = from.Map; if (p == null || map == null) { return; } Point3D p3d = new Point3D(p); ItemData id = TileData.ItemTable[0x10F5]; house = BaseHouse.FindHouseAt(p3d, map, id.Height); if (house != null && house.IsOwner(from)) { if (map.CanFit(p3d, id.Height)) { bool north = BaseAddon.IsWall(p3d.X, p3d.Y - 1, p3d.Z, map); bool west = BaseAddon.IsWall(p3d.X - 1, p3d.Y, p3d.Z, map); FlamingHead head = null; if (north && west) { head = new FlamingHead(StoneFaceTrapType.NorthWestWall); } else if (north) { head = new FlamingHead(StoneFaceTrapType.NorthWall); } else if (west) { head = new FlamingHead(StoneFaceTrapType.WestWall); } if (north || west) { house.Addons.Add(head); head.IsRewardItem = m_Head.IsRewardItem; head.MoveToWorld(p3d, map); m_Head.Delete(); } else { from.SendLocalizedMessage(1042266); // The head must be placed next to a wall. } } else { from.SendLocalizedMessage(1042266); // The head must be placed next to a wall. } } else { from.SendLocalizedMessage(1042036); // That location is not in your house. } } else { from.SendLocalizedMessage(502115); // You must be in your house to do this. } } else { from.SendLocalizedMessage(1042038); // You must have the object in your backpack to use it. } }
private void Start() { //находим дочернюю панель и делаем ее неактивной DescriptionPanel = this.gameObject.transform.Find("DescriptionPanel").gameObject; DescriptionPanel.SetActive(false); itemData = new ItemData(); //криворукое рандомное заполнение данных /*int randNumb = Random.Range(0, 4); //это временное * System.IO.StreamReader file = new System.IO.StreamReader("ItemsData.txt", System.Text.Encoding.GetEncoding(1251)); * string line; * int i = 0; * while (((line = file.ReadLine()) != null) && (i != randNumb * 4)) * { * i++; * } * bool res = int.TryParse(line, out itemData.id);//записываем id * line = file.ReadLine(); * itemData.name = line;//записываем имя * line = file.ReadLine(); * itemData.descriptionItem = line;//описание * line = file.ReadLine(); * itemData.pathIcon = line;//и путь до иконки * * file.Close();*/ int randNumb = IdItemQuest == 0 ? Random.Range(1, 19) : IdItemQuest; //это временное //Загружаем из ресурсов наш xml файл TextAsset xmlAsset = Resources.Load("ItemsData") as TextAsset; // надо получить число элементов в root'овом теге. XmlDocument xmlDoc = new XmlDocument(); if (xmlAsset) { xmlDoc.LoadXml(xmlAsset.text); } XmlNodeList dataList = xmlDoc.GetElementsByTagName("item"); foreach (XmlNode item in dataList) { XmlNodeList itemContent = item.ChildNodes; bool ThisItem = false; foreach (XmlNode itemItens in itemContent) { if (itemItens.Name == "id") { if (int.Parse(itemItens.InnerText) == randNumb) //TODO to int { itemData.id = randNumb; ThisItem = true; } } else if (itemItens.Name == "name" && ThisItem) { itemData.name = itemItens.InnerText; } else if (itemItens.Name == "descriptionItem" && ThisItem) { itemData.descriptionItem = itemItens.InnerText; } else if (itemItens.Name == "pathIcon" && ThisItem) { itemData.pathIcon = itemItens.InnerText; } else if (itemItens.Name == "categories" && ThisItem) { itemData.categories = int.Parse(itemItens.InnerText); } else if (itemItens.Name == "isstackable" && ThisItem) { itemData.isStackable = int.Parse(itemItens.InnerText) == 1? true:false; //был bool.Parse } else if (itemItens.Name == "cost" && ThisItem) { itemData.cost = int.Parse(itemItens.InnerText); } else if (itemItens.Name == "weight" && ThisItem) { itemData.weight = int.Parse(itemItens.InnerText); } else if (itemItens.Name == "RestoringHP" && ThisItem) { itemData.RestoringHP = int.Parse(itemItens.InnerText); } } } //найдем всплывающую панель как дочерний объект и поместим на нее текст описания TextPanel = DescriptionPanel.transform.GetChild(1); TextPanel.GetComponent <UnityEngine.UI.Text>().text = itemData.name + "\n\n" + itemData.descriptionItem; //Артем1101: начало дополнения //Смена картинки у предмета на сцене transform.GetChild(0).GetComponent <SpriteRenderer>().sprite = Resources.Load <Sprite>(itemData.pathIcon); //Артем1101: конец дополнения }
public void SetItem(GongfaData gongfa, RoleData role = null, bool isBag = false, System.Action clickFunc = null) { roleData = role; this.gongfa = gongfa; this.isBag = isBag; this.clickFunc = clickFunc; if (gongfa == null) { icon.enabled = false; color.sprite = UIAssets.instance.gongfaColor[0];; if (bg) { bg.sprite = UIAssets.instance.bgColor[0]; } if (t_name) { t_name.text = null; } if (t_type) { t_type.text = null; } if (t_level) { t_level.text = null; } Tools.SetActive(useing, false); return; } int item_id = gongfa.item_id; ItemData item = GameData.instance.all_item[item_id]; ItemStaticData static_data = GameData.instance.item_static_data[item.static_id]; icon.enabled = true; icon.sprite = UIAssets.instance.itemIcon[static_data.icon]; color.sprite = UIAssets.instance.gongfaColor[static_data.color]; if (bg) { bg.sprite = UIAssets.instance.bgColor[static_data.color]; } if (t_name) { t_name.text = static_data.name; } if (t_type) { t_type.text = GameConst.itemSubTypeName[static_data.sub_ype]; } if (t_level) { t_level.text = LevelConfigData.GetBigName(static_data.level); } if (roleData == null || !isBag) { can_drag = false; Tools.SetActive(useing, false); return; } bool isWear = roleData.GonfaIsEquip(gongfa); // 是否穿戴着 Tools.SetActive(useing, isWear); can_drag = roleData == RoleData.mainRole && !isWear; }
// Use this for initialization void Start() { itemData = GameObject.Find("DataManager").GetComponent <DataManager> ().Inventory.ToolBar [transform.GetSiblingIndex()]; transform.GetChild(0).GetComponent <Image> ().sprite = DataManager.item [itemData.ItemTemplate].icon; }
private void GetStartZ(Mobile m, Map map, Point3D loc, List <Item> itemList, out int zLow, out int zTop) { int xCheck = loc.X, yCheck = loc.Y; LandTile landTile = map.Tiles.GetLandTile(xCheck, yCheck); int landZ = 0, landCenter = 0, landTop = 0; bool landBlocks = (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Impassable) != 0; if (landBlocks && m.CanSwim && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Wet) != 0) { landBlocks = false; } else if (m.CantWalk && (TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Wet) == 0) { landBlocks = true; } map.GetAverageZ(xCheck, yCheck, ref landZ, ref landCenter, ref landTop); bool considerLand = !landTile.Ignored; int zCenter = zLow = zTop = 0; bool isSet = false; if (considerLand && !landBlocks && loc.Z >= landCenter) { zLow = landZ; zCenter = landCenter; if (!isSet || landTop > zTop) { zTop = landTop; } isSet = true; } StaticTile[] staticTiles = map.Tiles.GetStaticTiles(xCheck, yCheck, true); for (int i = 0; i < staticTiles.Length; ++i) { StaticTile tile = staticTiles[i]; ItemData id = TileData.ItemTable[tile.ID & 0x3FFF]; int calcTop = (tile.Z + id.CalcHeight); if ((!isSet || calcTop >= zCenter) && ((id.Flags & TileFlag.Surface) != 0 || (m.CanSwim && (id.Flags & TileFlag.Wet) != 0)) && loc.Z >= calcTop) { if (m.CantWalk && (id.Flags & TileFlag.Wet) == 0) { continue; } zLow = tile.Z; zCenter = calcTop; int top = tile.Z + id.Height; if (!isSet || top > zTop) { zTop = top; } isSet = true; } } for (int i = 0; i < itemList.Count; ++i) { Item item = itemList[i]; ItemData id = item.ItemData; int calcTop = item.Z + id.CalcHeight; if ((!isSet || calcTop >= zCenter) && ((id.Flags & TileFlag.Surface) != 0 || (m.CanSwim && (id.Flags & TileFlag.Wet) != 0)) && loc.Z >= calcTop) { if (m.CantWalk && (id.Flags & TileFlag.Wet) == 0) { continue; } zLow = item.Z; zCenter = calcTop; int top = item.Z + id.Height; if (!isSet || top > zTop) { zTop = top; } isSet = true; } } if (!isSet) { zLow = zTop = loc.Z; } else if (loc.Z > zTop) { zTop = loc.Z; } }
private string GetDesString() { string expend = string.Empty; string path = string.Empty; string use = string.Empty; string recoverCoolDown = string.Empty; string recover = string.Empty; string owner = string.Empty; string limit = string.Empty; ItemData itemData = ItemData.GetBasicResItemByType(baseType); string name = Localization.Get(itemData.name); //int oneHundredBillion = 100000000;//1亿 switch (baseType) { case BaseResType.PveAction: { expend = string.Format(Localization.Get("ui.common_des_view.expend_pveAction"), DungeonProxy.instance.DungeonInfoDictionary.First().Value.dungeonData.actionNeed); recover = GetRecoverTimeString(GlobalData.GetGlobalData().pveActionRecoverTime); if (GameProxy.instance.PveAction < GameProxy.instance.PveActionMax) { recoverCoolDown = string.Format(Localization.Get("ui.common_des_view.recover_time"), TimeUtil.FormatSecondToMinute((int)GameProxy.instance.PveActionNextRecoverTime)); } owner = string.Format(Localization.Get("ui.common_des_view.owner2"), GameProxy.instance.PveAction, name); limit = string.Format(Localization.Get("ui.common_des_view.limit"), GameProxy.instance.PveActionMax, name); } break; case BaseResType.TowerAction: { expend = string.Format(Localization.Get("ui.common_des_view.expend_TowerAction"), 1); recover = GetRecoverTimeString(GlobalData.GetGlobalData().worldTreeFruitRecoverTime); if (WorldTreeProxy.instance.WorldTreeFruit < WorldTreeProxy.instance.WorldTreeFruitUpperLimit) { int second = (int)TimeController.instance.GetDiffTimeWithServerTimeInSecond(WorldTreeProxy.instance.WorldTreeNextRecoverTime); recoverCoolDown = string.Format(Localization.Get("ui.common_des_view.recover_time"), TimeUtil.FormatSecondToMinute(second)); } owner = string.Format(Localization.Get("ui.common_des_view.owner2"), WorldTreeProxy.instance.WorldTreeFruit, name); limit = string.Format(Localization.Get("ui.common_des_view.limit"), WorldTreeProxy.instance.WorldTreeFruitUpperLimit, name); } break; case BaseResType.PvpAction: { expend = string.Format(Localization.Get("ui.common_des_view.expend_pvpAction"), 1); //recover = GetRecoverTimeString(GlobalData.GetGlobalData().challengeTimesRecoverTime); // if(GameProxy.instance.PvpAction<GameProxy.instance.PvpActionMax) // { // recoverCoolDown = string.Format(Localization.Get("ui.common_des_view.recover_time"),TimeUtil.FormatSecondToHour((int)GameProxy.instance.PvpActionNextRecoverTime/1000)); // } owner = string.Format(Localization.Get("ui.common_des_view.owner2"), GameProxy.instance.PvpAction, name); limit = string.Format(Localization.Get("ui.common_des_view.limit"), GameProxy.instance.PvpActionMax, name); } break; default: //limit = string.Format(Localization.Get("ui.common_des_view.limit"),GetNumberLimitString(oneHundredBillion),name); owner = string.Format(Localization.Get("ui.common_des_view.owner2"), GetNumberLimitString(GameProxy.instance.BaseResourceDictionary.GetValue(baseType)), name); break; } DropMessageData data = DropMessageData.GetDropMsgDataByResData((int)BaseResType.Item, itemData.id); path = data == null ? "" : Localization.Get(data.des); return(string.Format("{0}{1}{2}{3}{4}{5}{6}", expend, use, recover, recoverCoolDown, owner, limit, path)); }
public void Parse(HabboHotel.GameClients.GameClient Session, ClientPacket Packet) { if (Session == null || Session.GetHabbo() == null || !Session.GetHabbo().InRoom) { return; } Room Room = Session.GetHabbo().CurrentRoom; if (Room == null) { return; } int ItemId = Packet.PopInt(); Item Item = Room.GetRoomItemHandler().GetItem(ItemId); if (Item == null || Item.Data == null || Item.UserID != Session.GetHabbo().Id || Item.Data.InteractionType != InteractionType.GNOME_BOX) { return; } string PetName = Packet.PopString(); if (string.IsNullOrEmpty(PetName)) { Session.SendMessage(new CheckGnomeNameComposer(PetName, 1)); return; } int X = Item.GetX; int Y = Item.GetY; //Quickly delete it from the database. using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("DELETE FROM `items` WHERE `id` = @ItemId LIMIT 1"); dbClient.AddParameter("ItemId", Item.Id); dbClient.RunQuery(); } //Remove the item. Room.GetRoomItemHandler().RemoveFurniture(Session, Item.Id); //Apparently we need this for success. Session.SendMessage(new CheckGnomeNameComposer(PetName, 0)); //Create the pet here. Pet Pet = PetUtility.CreatePet(Session.GetHabbo().Id, PetName, 26, "30", "ffffff"); if (Pet == null) { Session.SendNotification("Oeps! Er is een fout opgetreden, meld dit bij één van de Habbis Hotel medewerkers."); return; } List <RandomSpeech> RndSpeechList = new List <RandomSpeech>(); List <BotResponse> BotResponse = new List <BotResponse>(); Pet.RoomId = Session.GetHabbo().CurrentRoomId; Pet.GnomeClothing = RandomClothing(); //Update the pets gnome clothing. using (IQueryAdapter dbClient = QuasarEnvironment.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("UPDATE `bots_petdata` SET `gnome_clothing` = @GnomeClothing WHERE `id` = @PetId LIMIT 1"); dbClient.AddParameter("GnomeClothing", Pet.GnomeClothing); dbClient.AddParameter("PetId", Pet.PetId); dbClient.RunQuery(); } //Make a RoomUser of the pet. RoomUser PetUser = Room.GetRoomUserManager().DeployBot(new RoomBot(Pet.PetId, Pet.RoomId, "pet", "freeroam", Pet.Name, "", Pet.Look, X, Y, 0, 0, 0, 0, 0, 0, ref RndSpeechList, "", 0, Pet.OwnerId, false, 0, false, 0), Pet); //Give the food. ItemData PetFood = null; if (QuasarEnvironment.GetGame().GetItemManager().GetItem(320, out PetFood)) { Item Food = ItemFactory.CreateSingleItemNullable(PetFood, Session.GetHabbo(), "", ""); if (Food != null) { Session.GetHabbo().GetInventoryComponent().TryAddItem(Food); Session.SendMessage(new FurniListNotificationComposer(Food.Id, 1)); } } }
public abstract void process(GameObject item, ItemData itemData);
public void setAccessoryItem(ItemData item) { GameDatabaseStatic.setThreeAccessoryItem(item); itemOnChange?.Invoke(this, EventArgs.Empty); }
private void SetMaterialSpriteName(GameObject obj, UISprite sprite, SpriteSwith swith, ItemData itemData) { if (itemData != null) { sprite.spriteName = itemData.smallDisplay; swith.ChangeSprite(itemData._ColorLevel); obj.SetActive(true); } else { obj.SetActive(false); } }
public static HousePlacementResult Check(Mobile from, int multiID, Point3D center, out ArrayList toMove) { // If this spot is considered valid, every item and mobile in this list will be moved under the house sign toMove = new ArrayList(); Map map = from.Map; if (map == null || map == Map.Internal) { return(HousePlacementResult.BadLand); // A house cannot go here } if (from.AccessLevel >= AccessLevel.GameMaster) { return(HousePlacementResult.Valid); // Staff can place anywhere } if (map == Map.Ilshenar || SpellHelper.IsFeluccaT2A(map, center)) { return(HousePlacementResult.BadRegion); // No houses in Ilshenar/T2A } if (map == Map.Malas && (multiID == 0x007C || multiID == 0x007E)) { return(HousePlacementResult.InvalidCastleKeep); } NoHousingRegion noHousingRegion = (NoHousingRegion)Region.Find(center, map).GetRegion(typeof(NoHousingRegion)); if (noHousingRegion != null) { return(HousePlacementResult.BadRegion); } // This holds data describing the internal structure of the house MultiComponentList mcl = MultiData.GetComponents(multiID); if (multiID >= 0x13EC && multiID < 0x1D00) { HouseFoundation.AddStairsTo(ref mcl); // this is a AOS house, add the stairs } // Location of the nortwest-most corner of the house Point3D start = new Point3D(center.X + mcl.Min.X, center.Y + mcl.Min.Y, center.Z); // These are storage lists. They hold items and mobiles found in the map for further processing List <Item> items = new List <Item>(); List <Mobile> mobiles = new List <Mobile>(); // These are also storage lists. They hold location values indicating the yard and border locations. List <Point2D> yard = new List <Point2D>(), borders = new List <Point2D>(); /* RULES: * * 1) All tiles which are around the -outside- of the foundation must not have anything impassable. * 2) No impassable object or land tile may come in direct contact with any part of the house. * 3) Five tiles from the front and back of the house must be completely clear of all house tiles. * 4) The foundation must rest flatly on a surface. Any bumps around the foundation are not allowed. * 5) No foundation tile may reside over terrain which is viewed as a road. */ for (int x = 0; x < mcl.Width; ++x) { for (int y = 0; y < mcl.Height; ++y) { int tileX = start.X + x; int tileY = start.Y + y; Tile[] addTiles = mcl.Tiles[x][y]; if (addTiles.Length == 0) { continue; // There are no tiles here, continue checking somewhere else } Point3D testPoint = new Point3D(tileX, tileY, center.Z); Region reg = Region.Find(testPoint, map); if (!reg.AllowHousing(from, testPoint)) // Cannot place houses in dungeons, towns, treasure map areas etc { if (reg.IsPartOf(typeof(TempNoHousingRegion))) { return(HousePlacementResult.BadRegionTemp); } if (reg.IsPartOf(typeof(TreasureRegion))) { return(HousePlacementResult.BadRegionHidden); } return(HousePlacementResult.BadRegion); } Tile landTile = map.Tiles.GetLandTile(tileX, tileY); int landID = landTile.ID & 0x3FFF; Tile[] oldTiles = map.Tiles.GetStaticTiles(tileX, tileY, true); Sector sector = map.GetSector(tileX, tileY); items.Clear(); for (int i = 0; i < sector.Items.Count; ++i) { Item item = sector.Items[i]; if (item.Visible && item.X == tileX && item.Y == tileY) { items.Add(item); } } mobiles.Clear(); for (int i = 0; i < sector.Mobiles.Count; ++i) { Mobile m = sector.Mobiles[i]; if (m.X == tileX && m.Y == tileY) { mobiles.Add(m); } } int landStartZ = 0, landAvgZ = 0, landTopZ = 0; map.GetAverageZ(tileX, tileY, ref landStartZ, ref landAvgZ, ref landTopZ); bool hasFoundation = false; for (int i = 0; i < addTiles.Length; ++i) { Tile addTile = addTiles[i]; if (addTile.ID == 0x4001) // Nodraw { continue; } TileFlag addTileFlags = TileData.ItemTable[addTile.ID & 0x3FFF].Flags; bool isFoundation = (addTile.Z == 0 && (addTileFlags & TileFlag.Wall) != 0); bool hasSurface = false; if (isFoundation) { hasFoundation = true; } int addTileZ = center.Z + addTile.Z; int addTileTop = addTileZ + addTile.Height; if ((addTileFlags & TileFlag.Surface) != 0) { addTileTop += 16; } if (addTileTop > landStartZ && landAvgZ > addTileZ) { return(HousePlacementResult.BadLand); // Broke rule #2 } if (isFoundation && ((TileData.LandTable[landTile.ID & 0x3FFF].Flags & TileFlag.Impassable) == 0) && landAvgZ == center.Z) { hasSurface = true; } for (int j = 0; j < oldTiles.Length; ++j) { Tile oldTile = oldTiles[j]; ItemData id = TileData.ItemTable[oldTile.ID & 0x3FFF]; if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0)) && addTileTop > oldTile.Z && (oldTile.Z + id.CalcHeight) > addTileZ) { return(HousePlacementResult.BadStatic); // Broke rule #2 } /*else if ( isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (oldTile.Z + id.CalcHeight) == center.Z ) * hasSurface = true;*/ } for (int j = 0; j < items.Count; ++j) { Item item = items[j]; ItemData id = item.ItemData; if (addTileTop > item.Z && (item.Z + id.CalcHeight) > addTileZ) { if (item.Movable) { toMove.Add(item); } else if ((id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0))) { return(HousePlacementResult.BadItem); // Broke rule #2 } } /*else if ( isFoundation && !hasSurface && (id.Flags & TileFlag.Surface) != 0 && (item.Z + id.CalcHeight) == center.Z ) * { * hasSurface = true; * }*/ } if (isFoundation && !hasSurface) { return(HousePlacementResult.NoSurface); // Broke rule #4 } for (int j = 0; j < mobiles.Count; ++j) { Mobile m = mobiles[j]; if (addTileTop > m.Z && (m.Z + 16) > addTileZ) { toMove.Add(m); } } } for (int i = 0; i < m_RoadIDs.Length; i += 2) { if (landID >= m_RoadIDs[i] && landID <= m_RoadIDs[i + 1]) { return(HousePlacementResult.BadLand); // Broke rule #5 } } if (hasFoundation) { for (int xOffset = -1; xOffset <= 1; ++xOffset) { for (int yOffset = -YardSize; yOffset <= YardSize; ++yOffset) { Point2D yardPoint = new Point2D(tileX + xOffset, tileY + yOffset); if (!yard.Contains(yardPoint)) { yard.Add(yardPoint); } } } for (int xOffset = -1; xOffset <= 1; ++xOffset) { for (int yOffset = -1; yOffset <= 1; ++yOffset) { if (xOffset == 0 && yOffset == 0) { continue; } // To ease this rule, we will not add to the border list if the tile here is under a base floor (z<=8) int vx = x + xOffset; int vy = y + yOffset; if (vx >= 0 && vx < mcl.Width && vy >= 0 && vy < mcl.Height) { Tile[] breakTiles = mcl.Tiles[vx][vy]; bool shouldBreak = false; for (int i = 0; !shouldBreak && i < breakTiles.Length; ++i) { Tile breakTile = breakTiles[i]; if (breakTile.Height == 0 && breakTile.Z <= 8 && TileData.ItemTable[breakTile.ID & 0x3FFF].Surface) { shouldBreak = true; } } if (shouldBreak) { continue; } } Point2D borderPoint = new Point2D(tileX + xOffset, tileY + yOffset); if (!borders.Contains(borderPoint)) { borders.Add(borderPoint); } } } } } } for (int i = 0; i < borders.Count; ++i) { Point2D borderPoint = borders[i]; Tile landTile = map.Tiles.GetLandTile(borderPoint.X, borderPoint.Y); int landID = landTile.ID & 0x3FFF; if ((TileData.LandTable[landID].Flags & TileFlag.Impassable) != 0) { return(HousePlacementResult.BadLand); } for (int j = 0; j < m_RoadIDs.Length; j += 2) { if (landID >= m_RoadIDs[j] && landID <= m_RoadIDs[j + 1]) { return(HousePlacementResult.BadLand); // Broke rule #5 } } Tile[] tiles = map.Tiles.GetStaticTiles(borderPoint.X, borderPoint.Y, true); for (int j = 0; j < tiles.Length; ++j) { Tile tile = tiles[j]; ItemData id = TileData.ItemTable[tile.ID & 0x3FFF]; if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (tile.Z + id.CalcHeight) > (center.Z + 2))) { return(HousePlacementResult.BadStatic); // Broke rule #1 } } Sector sector = map.GetSector(borderPoint.X, borderPoint.Y); List <Item> sectorItems = sector.Items; for (int j = 0; j < sectorItems.Count; ++j) { Item item = sectorItems[j]; if (item.X != borderPoint.X || item.Y != borderPoint.Y || item.Movable) { continue; } ItemData id = item.ItemData; if (id.Impassable || (id.Surface && (id.Flags & TileFlag.Background) == 0 && (item.Z + id.CalcHeight) > (center.Z + 2))) { return(HousePlacementResult.BadItem); // Broke rule #1 } } } List <Sector> _sectors = new List <Sector>(); List <BaseHouse> _houses = new List <BaseHouse>(); for (int i = 0; i < yard.Count; i++) { Sector sector = map.GetSector(yard[i]); if (!_sectors.Contains(sector)) { _sectors.Add(sector); if (sector.Multis != null) { for (int j = 0; j < sector.Multis.Count; j++) { if (sector.Multis[j] is BaseHouse) { BaseHouse _house = (BaseHouse)sector.Multis[j]; if (!_houses.Contains(_house)) { _houses.Add(_house); } } } } } } for (int i = 0; i < yard.Count; ++i) { foreach (BaseHouse b in _houses) { if (b.Contains(yard[i])) { return(HousePlacementResult.BadStatic); // Broke rule #3 } } /*Point2D yardPoint = yard[i]; * * IPooledEnumerable eable = map.GetMultiTilesAt( yardPoint.X, yardPoint.Y ); * * foreach ( Tile[] tile in eable ) * { * for ( int j = 0; j < tile.Length; ++j ) * { * if ( (TileData.ItemTable[tile[j].ID & 0x3FFF].Flags & (TileFlag.Impassable | TileFlag.Surface)) != 0 ) * { * eable.Free(); * return HousePlacementResult.BadStatic; // Broke rule #3 * } * } * } * * eable.Free();*/ } return(HousePlacementResult.Valid); }
public void Parse(GameClient Session, ClientPacket Packet) { string VoucherCode = Packet.PopString().Replace("\r", ""); Voucher Voucher = null; if (!CloudServer.GetGame().GetCatalog().GetVoucherManager().TryGetVoucher(VoucherCode, out Voucher)) { Session.SendMessage(new VoucherRedeemErrorComposer(0)); return; } if (Voucher.CurrentUses >= Voucher.MaxUses) { Session.SendNotification("Você usou esse código o máximo de vezes permitidas!"); return; } DataRow GetRow = null; using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("SELECT * FROM `user_vouchers` WHERE `user_id` = '" + Session.GetHabbo().Id + "' AND `voucher` = @Voucher LIMIT 1"); dbClient.AddParameter("Voucher", VoucherCode); GetRow = dbClient.getRow(); } if (GetRow != null) { Session.SendNotification("Ops! Você já está usando esse código!"); return; } else { using (IQueryAdapter dbClient = CloudServer.GetDatabaseManager().GetQueryReactor()) { dbClient.SetQuery("INSERT INTO `user_vouchers` (`user_id`,`voucher`) VALUES ('" + Session.GetHabbo().Id + "', @Voucher)"); dbClient.AddParameter("Voucher", VoucherCode); dbClient.RunQuery(); } } Voucher.UpdateUses(); if (Voucher.Type == VoucherType.CREDIT) { Session.GetHabbo().Credits += Voucher.Value; Session.SendMessage(new CreditBalanceComposer(Session.GetHabbo().Credits)); Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acaba de receber um premio! " + Voucher.Value + " créditos. Use com sabedoria " + Session.GetHabbo().Username + ".", "")); } else if (Voucher.Type == VoucherType.DUCKET) { Session.GetHabbo().Duckets += Voucher.Value; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Duckets, Voucher.Value)); Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acaba de receber um premio! " + Voucher.Value + " duckets. Use com sabedoria " + Session.GetHabbo().Username + ".", "")); } else if (Voucher.Type == VoucherType.DIAMOND) { Session.GetHabbo().Diamonds += Voucher.Value; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().Diamonds, Voucher.Value, 5)); Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acaba de receber um premio! " + Voucher.Value + " diamantes. Use com sabedoria " + Session.GetHabbo().Username + ".", "")); } else if (Voucher.Type == VoucherType.GOTW) { Session.GetHabbo().GOTWPoints += Voucher.Value; Session.SendMessage(new HabboActivityPointNotificationComposer(Session.GetHabbo().GOTWPoints, Voucher.Value, 103)); Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acaba de receber um premio! " + Voucher.Value + " " + ExtraSettings.PTOS_COINS + ". Use com sabedoria " + Session.GetHabbo().Username + ".", "")); } else if (Voucher.Type == VoucherType.ITEM) { ItemData Item = null; if (!CloudServer.GetGame().GetItemManager().GetItem((Voucher.Value), out Item)) { // No existe este ItemId. return; } Item GiveItem = ItemFactory.CreateSingleItemNullable(Item, Session.GetHabbo(), "", ""); if (GiveItem != null) { Session.GetHabbo().GetInventoryComponent().TryAddItem(GiveItem); Session.SendMessage(new FurniListNotificationComposer(GiveItem.Id, 1)); Session.SendMessage(new FurniListUpdateComposer()); Session.SendMessage(RoomNotificationComposer.SendBubble("voucher", "Você acabou de receber o objeto raro, corre " + Session.GetHabbo().Username + ", confira seu invetário algo novo está ai!", "")); } Session.GetHabbo().GetInventoryComponent().UpdateItems(false); } Session.SendMessage(new VoucherRedeemOkComposer()); }
/// <summary> /// 完成任务奖励 /// </summary> /// <param name="packet"></param> /// <returns></returns> private bool CompleteTaskReward(CReadPacket packet) { Debug.Log("CompleteTaskReward任务奖励——---------------------------------------------------------------"); Dictionary <string, object> data = packet.data; object[] itemList = data["rwdData"] as object[]; TaskManager.Single().itemlist.Clear(); if (itemList != null) { for (int i = 0; i < itemList.Length; i++) { Dictionary <string, object> itemDataDic = itemList[i] as Dictionary <string, object>; if (itemDataDic != null) { ItemData itemdata = new ItemData(); itemdata.Id = int.Parse(itemDataDic["id"].ToString()); itemdata.Count = int.Parse(itemDataDic["num"].ToString()); if (itemdata.Id == 0) { continue; } //if (itemdata.Id == 101 || itemdata.Id == 10101 || itemdata.Id == 1010101 || itemdata.Id == 102 || itemdata.Id == 103) //{ // itemdata.GradeTYPE = GradeType.Gray; //} //if (itemdata.Id == 101) //{ // itemdata.Name = "金币"; // itemdata.GradeTYPE = GradeType.Gray; // itemdata.IconName = "jinbi"; // itemdata.GoodsType = MailGoodsType.GoldType; // itemdata.Gold = itemdata.Count; //} //if (itemdata.Id == 10101) //{ // itemdata.Name = "钻石"; // itemdata.GradeTYPE = GradeType.Gray; // itemdata.IconName = "zuanshi"; // itemdata.GoodsType = MailGoodsType.DiamomdType; // itemdata.Diamond = itemdata.Count; //} //if (itemdata.Id == 1010101) //{ // itemdata.Name = "战队经验"; // itemdata.GradeTYPE = GradeType.Gray; // itemdata.IconName = "zhandui-exp"; // itemdata.GoodsType = MailGoodsType.ExE; // itemdata.Exe = itemdata.Count; //} //if (itemdata.Id == 102) //{ // itemdata.Name = "英雄经验"; // itemdata.GradeTYPE = GradeType.Gray; // itemdata.IconName = "exp"; // itemdata.GoodsType = MailGoodsType.HeroExp; // itemdata.HeroExp = itemdata.Count; //} //if (itemdata.Id == 103) //{ // itemdata.Name = "悬赏币"; // itemdata.GradeTYPE = GradeType.Gray; // itemdata.IconName = "xuanshangbi"; // itemdata.GoodsType = MailGoodsType.XuanshangGold; // itemdata.XuanshangGold = itemdata.Count; //} ItemNodeState itemnodestate = null; if (GameLibrary.Instance().ItemStateList.ContainsKey(itemdata.Id)) { itemnodestate = GameLibrary.Instance().ItemStateList[itemdata.Id]; itemdata.Name = itemnodestate.name; itemdata.Types = itemnodestate.types; itemdata.Describe = itemnodestate.describe; itemdata.Sprice = itemnodestate.sprice; itemdata.Piles = itemnodestate.piles; itemdata.IconName = itemnodestate.icon_name; switch (itemnodestate.grade)//(VOManager.Instance().GetCSV<ItemCSV>("Item").GetVO(itemdata.Id).grade) { case 1: itemdata.GradeTYPE = GradeType.Gray; break; case 2: itemdata.GradeTYPE = GradeType.Green; break; case 4: itemdata.GradeTYPE = GradeType.Blue; break; case 7: itemdata.GradeTYPE = GradeType.Purple; break; case 11: itemdata.GradeTYPE = GradeType.Orange; break; case 16: itemdata.GradeTYPE = GradeType.Red; break; } } if (itemdata.Types == 6) { itemdata.UiAtlas = ResourceManager.Instance().GetUIAtlas("UIHeroHead"); } else { itemdata.UiAtlas = ResourceManager.Instance().GetUIAtlas("Prop"); } TaskManager.Single().itemlist.Add(itemdata); } } } //不需要自己判断,只要服务器给我发送奖励协议,就弹出奖励面板(任务状态和任务列表 需要看服务器什么时候发给我 然后再做更新界面) if (TaskManager.Single().itemlist.Count > 0) { //任务奖励弹窗 //TaskEffectManager.instance.ShowTaskEffect(TaskEffectType.SucceedTask);//任务完成会伴随任务奖励界面,目前方案是先出现任务完成特效 0.5s后显示再显示奖励面板 UITaskEffectPanel.instance.ShowTaskEffect(TaskEffectType.SucceedTask); //Control.ShowGUI(GameLibrary.UITaskRewardPanel); //领取奖励后将该任务设置为已领取奖励,并从追踪列表中删除(这个放在读取任务列表和任务状态时候再处理) //Debug.LogError(TaskManager.Single().CurrentTaskItem); //TaskManager.Single().CurrentTaskItem.taskProgress = TaskProgress.Reward; //TaskManager.Single().ModifeTask(TaskManager.Single().CurrentTaskItem, TaskModifyType.Remove); } return(true); }
public void Init(ItemData data) { this.ItemData = data; }