public void LoadPlayer(PlayerMobile pm) { Backpack pack = (Backpack)pm.Backpack; //pm.SendMessage(String.Format("SettingBackpack")); TeleportAllPets(pm, (Point3D)PlayerLocations[pm.Serial], (Map)PlayerMaps[pm.Serial]); pm.Location = (Point3D)PlayerLocations[pm.Serial]; PlayerLocations.Remove(pm.Serial); //pm.SendMessage(String.Format("SettingLocation")); pm.Map = (Map)PlayerMaps[pm.Serial]; PlayerMaps.Remove(pm.Serial); //pm.SendMessage(String.Format("SettingMap")); ArrayList items = (ArrayList)PlayerItems[pm.Serial]; PlayerItems.Remove(pm.Serial); //pm.SendMessage(String.Format("Setting Arraylist of Items")); for (int i = 0; i < items.Count; ++i) { //pm.SendMessage(String.Format("LoadPlayer() {0} / {1}.", i , items.Count)); Item item = (Item)items[i]; if (item.Layer == Layer.Invalid) { //pm.SendMessage(String.Format("Layer Invalid!")); item.Location = (Point3D)ItemLocations[item.Serial]; ItemLocations.Remove(item.Serial); pack.AddItem(item); } else { Item test = (Item)pm.FindItemOnLayer(item.Layer); if (test == null || test == item) { ItemLocations.Remove(item.Serial); pm.EquipItem(item); test = (Item)pm.FindItemOnLayer(item.Layer); if (test == null) { pack.AddItem(item); } } else { item.Location = (Point3D)ItemLocations[item.Serial]; ItemLocations.Remove(item.Serial); if (item != pm.Backpack && item != pm.BankBox) { pack.AddItem(item); } } } } }
public void CannotAddItemWhenFull() { Backpack b = new Backpack(); Sword s = new Sword(); b.AddItem(s); b.AddItem(s); b.AddItem(s); var actual = b.AddItem(s); Assert.AreEqual(AddItemStatus.NoEmptySlots, actual); }
public static void ContainerCauseException() { // Create a backpack which can hold 4 things, add 5 Backpack myPack = new Backpack(); myPack.AddItem(new HealingPotion()); myPack.AddItem(new HealingPotion()); myPack.AddItem(new HealingPotion()); myPack.AddItem(new HealingPotion()); // This line should fail, we cannot add 5 things // backpacks can only hold 4 items. myPack.AddItem(new HealingPotion()); }
public void CannotAddItemToFullBackpack() { Backpack b = new Backpack(); Sword steelSword = new Sword(); b.AddItem(steelSword); b.AddItem(steelSword); b.AddItem(steelSword); b.AddItem(steelSword); AddItemStatus actual = b.AddItem(steelSword); Assert.AreEqual(AddItemStatus.BagIsFull, actual); }
public void CannotAddItemToFullBackpack() { Backpack b = new Backpack(); GreatAxe axe = new GreatAxe(); b.AddItem(axe); b.AddItem(axe); b.AddItem(axe); b.AddItem(axe); bool actual = b.AddItem(axe); Assert.AreEqual(false, actual); }
public void CannotAddItemToFullBackpack() { Backpack b = new Backpack(); GreatAxe axe = new GreatAxe(); b.AddItem(axe); b.AddItem(axe); b.AddItem(axe); b.AddItem(axe); AddItemStatus actual = b.AddItem(axe); Assert.AreEqual(AddItemStatus.BagIsFull, actual); }
private void Start() { backpack = GameObject.FindWithTag("Backpack").GetComponent <Backpack>(); ma = new InteractiveItem("Daily/道具/玛", "玛"); backpack.AddItem(ma); yang = new InteractiveItem("Daily/道具/洋", "洋"); backpack.AddItem(yang); la = new InteractiveItem("Daily/道具/拉", "拉"); backpack.AddItem(la); ha = new InteractiveItem("Daily/道具/哈", "哈"); backpack.AddItem(ha); wa = new InteractiveItem("Daily/道具/哇", "哇"); backpack.AddItem(wa); }
public void CannotAddItemToFullBackpack() { Backpack p = new Backpack(); GreatAxe g = new GreatAxe(); p.AddItem(g); p.AddItem(g); p.AddItem(g); p.AddItem(g); AddItemStatus actual = p.AddItem(g); Assert.AreEqual(AddItemStatus.ContainerFull, actual); }
public void CannotAddItemToFullBackpack() { Backpack b = new Backpack(); TurtleArmor armor = new TurtleArmor(); b.AddItem(armor); b.AddItem(armor); b.AddItem(armor); b.AddItem(armor); AddItemStatus actual = b.AddItem(armor); Assert.AreEqual(AddItemStatus.BagIsFull, actual); }
public static void ContainerFun() { try { Backpack myPack = new Backpack(); myPack.AddItem(new HealingPotion()); myPack.AddItem(new HealingPotion()); myPack.AddItem(new HealingPotion()); myPack.AddItem(new HealingPotion()); myPack.AddItem(new HealingPotion()); } catch { Console.WriteLine("Something bad happned"); } }
private void OnControllerColliderHit(ControllerColliderHit hit) { if (hit.gameObject.CompareTag("Obstacle")) { var obstacle = hit.gameObject.GetComponent <Obstacle>(); if (obstacle) { healthSystem.DecreaseHealth(obstacle.health); } } if (hit.gameObject.CompareTag("Item")) { if (backpack.AddItem(hit.gameObject)) { Destroy(hit.gameObject); } } /*if(hit.gameObject.CompareTag("Food")) * { * var food = hit.gameObject.GetComponent<Food>(); * if(food) * { * Destroy(hit.gameObject); * healthSystem.IncreaseHealth(food.health); * hungerSystem.DecreaseHungerLevel(food.hunger); * } * }*/ }
private void OnCollisionUpdate() { bool pickedUp = false; //If near an item on the ground pick it up first if (canTouch) { if (Input.GetKeyDown(KeyCode.E)) { if (itemColliderID.gameObject.GetComponent <Item> ().type == ItemType.BOTTLE) { GameObject scroll = Instantiate(Resources.Load <GameObject> (itemColliderID.gameObject.GetComponent <Item> ().message), canvas.transform); scroll.transform.localPosition = new Vector3(0, 0); string note = itemColliderID.gameObject.GetComponent <Item> ().message; itemColliderID.gameObject.GetComponent <Item> ().itemName = note; } pickedUp = backpack.AddItem(itemColliderID.gameObject.GetComponent <Item> ()); if (pickedUp) { Destroy(itemColliderID.gameObject); itemColliderID = null; atUse = false; canTouch = false; } else { notification.InventoryFlag = true; } } } }
void OnControllerColliderHit(ControllerColliderHit hit) { /*if (hit.gameObject.CompareTag("Food")) * { * var food = hit.gameObject.GetComponent<Food>(); * Destroy(hit.gameObject); * healthSystem.IncreaseHealth(food.health); * hungerSystem.DecreaseHungerLevel(food.hunger); * * }*/ if (hit.gameObject.CompareTag("Item")) { if (Input.GetKeyDown(KeyCode.E)) { if (backpack.AddItem(hit.gameObject)) { Destroy(hit.gameObject); } } } else if (hit.gameObject.CompareTag("Obstacle")) { var food = hit.gameObject.GetComponent <Obstacle>(); healthSystem.DecreaseHealth(food.health); } }
public void OnClick(string name) { InteractiveItem item = new InteractiveItem("Daily/道具/" + name, name); backpack.AddItem(item); ThroneData.throneItemList.Remove(name); UpdateItems(); }
private void OnTriggerStay2D(Collider2D collision) { if (MyInput.isButtonDown) { UIManager.Dialogue(text); backpack.AddItem(jue); slot.SetActive(true); } }
private void OnTriggerStay2D(Collider2D collision) { if (MyInput.isButtonDown) { backpack.AddItem(wa); next.SetActive(true); Destroy(gameObject); } }
public void CanAddItemToBackpack() { Backpack b = new Backpack(); HealthPotion p = new HealthPotion(); AddItemStatus actual = b.AddItem(p); Assert.AreEqual(AddItemStatus.Ok, actual); }
public void CanAddItem() { Backpack b = new Backpack(); Sword s = new Sword(); var actual = b.AddItem(s); Assert.AreEqual(AddItemStatus.Ok, actual); }
public void CanAddItemToBackpack() { Backpack b = new Backpack(); HealthPotion p = new HealthPotion(); bool actual = b.AddItem(p); Assert.AreEqual(true, actual); }
public void PutItemInBackpackSuccessfully() { //Arrange Backpack bag = new Backpack(); Boomerang rang = new Boomerang(); WoodenSword sword = new WoodenSword(); BattleAxe axe = new BattleAxe(); //Act bag.AddItem(rang); bag.AddItem(sword); bag.AddItem(axe); //Assert Assert.AreEqual(3, bag.ItemCount); bag.DisplayContents(); }
/////////////////////////////////////////////////////////////////// // CrearItem: // Adds an item to the creature, and place it on a give position p /////////////////////////////////////////////////////////////////// public void CrearItem(Item t, Point3D p) { Backpack.AddItem(t); t.Location = p; if (t is BaseOrgano) { BaseOrgano vis = t as BaseOrgano; vis.CrearVisceras(); } }
public void CanRemoveItemToBackpack() { Backpack b = new Backpack(); HealthPotion p = new HealthPotion(); b.AddItem(p); Item actual = b.RemoveItem(); Assert.AreEqual(p, actual); }
public void CanRemoveItemFromBackpack() { Backpack b = new Backpack(); HealthPotion p = new HealthPotion(); b.AddItem(p); Item actual = b.RemoveItem(); //do these two variables reference the same object? Assert.AreEqual(p, actual); }
private void OnTriggerStay2D(Collider2D collision) { if (MyInput.isButtonDown && !backpack.ContainsItem("拉")) { UIManager.Dialogue(text); backpack.AddItem(la); obj.SetActive(true); DailyPlayer.camera.GetComponent <Camera>().orthographicSize = 14f; DailyPlayer.camera.GetComponent <SmartCamera>().enabled = false; } }
private void OnTriggerStay2D(Collider2D collision) { if (MyInput.isButtonDown) { UIManager.Dialogue(text); DailyPlayer.buddhist.SetActive(true); if (!backpack.ContainsItem("阿")) { backpack.AddItem(a); } } }
// Update is called once per frame void Update() { if (isSpell || isBackpack) { timer -= Time.deltaTime; if (timer <= 0) { Vector3 targetPos = spellTreeIcon.transform.localPosition; if (isBackpack) { targetPos = backpackIcon.transform.localPosition; } spellIcon.transform.localPosition = Vector3.MoveTowards(spellIcon.transform.localPosition, targetPos, iconSpeed * Time.deltaTime); if (Vector3.Distance(spellIcon.transform.localPosition, targetPos) < 1) { if (isSpell) { isSpell = false; spellTreeIcon.GetComponent <ShakingIcon>().ShakeMe(); } else { isBackpack = false; backpackIcon.GetComponent <ShakingIcon>().ShakeMe(); backpack.AddItem(itemBuffer, true); itemBuffer = ""; } ResetFlyingSpell(); } if (isSpell) { spellIcon.transform.localScale = new Vector3(4, 4, 1); } else { spellIcon.transform.localScale = new Vector3(2, 2, 1); } } } }
public void CheckRecipe(ItemType type1, ItemType type2, string product) { Slot tmp1 = Slot1.GetComponent <Slot>(); Slot tmp2 = Slot2.GetComponent <Slot>(); if (!tmp1.isEmpty && !tmp2.isEmpty) { if ((tmp1.CurrentItem.type == type1 && tmp2.CurrentItem.type == type2) || (tmp1.CurrentItem.type == type2 && tmp2.CurrentItem.type == type1)) { Item result = Resources.Load <GameObject>(product).GetComponent <Item>(); if (BackPack.EmptySlots() >= 1) { BackPack.AddItem(result); if (!tmp1.CurrentItem.keepItem) { tmp1.DestroyItem(); } else { CheckDurability(tmp1); } if (!tmp2.CurrentItem.keepItem) { tmp2.DestroyItem(); } else { CheckDurability(tmp2); } } else { notification.InventoryFlag = true; } } } }
public ViewItemGump(AuctionEntry tobid, AuctionContainer c, Mobile ToDisplay) : base(50, 50) { bid = tobid; cont = c; if (ToDisplay != null) { bag = new Backpack(); item = new VirtualItem(bid.Item); //bag.Layer = Layer.Invalid; bag.AddItem(item); bag.MoveToWorld(ToDisplay.Location, ToDisplay.Map); bag.Z -= 10; Timer.DelayCall(TimeSpan.FromSeconds(15), delegate { bag.Delete(); }); bag.Movable = false; //ToDisplay.AddItem( bag ); bag.DisplayTo(ToDisplay); } AddNewPage(); AddEntryHtml(500, tobid.Owner.Name); AddNewLine(); AddEntryHtml(500, tobid.Name); AddNewLine(); AddEntryHtml(500, tobid.Description); AddNewLine(); int minprice = 0; if (bid.Bids.Count == 0) { minprice = bid.StartPrice; } else { minprice = bid.Bids[bid.Bids.Count - 1].Value + 1; } AddEntryButton(20, ArrowRightID1, ArrowRightID2, 1, ArrowRightWidth, ArrowRightHeight); AddEntryHtml(479, "VIEW ITEM"); AddNewLine(); AddEntryButton(20, ArrowRightID1, ArrowRightID2, 2, ArrowRightWidth, ArrowRightHeight); AddEntryHtml(59, "BID"); AddEntryText(119, 0, (minprice).ToString()); AddEntryHeader(299); for (int i = 1; i <= 10; i++) { if (bid.Bids.Count - i < bid.Bids.Count && bid.Bids.Count - i >= 0) { AddNewLine(); AddEntryLabel(100, bid.Bids[bid.Bids.Count - i].From.Name); AddEntryLabel(099, bid.Bids[bid.Bids.Count - i].Value.ToString()); AddEntryHeader(299); } } FinishPage(); }
public override void GiveRewards() { base.GiveRewards(); Backpack pack = new Backpack(); PowerScroll ps = new PowerScroll(SkillName.Imbuing, 110.0); pack.Hue = Utility.RandomDyedHue(); ps.LootType = LootType.Regular; pack.AddItem(ps); Owner.AddToBackpack(pack); Owner.SendLocalizedMessage(1074360, "backpack"); // You receive a reward: backpack }
/// <summary> /// Moves all of the given Mobile's items to their bank. /// </summary> public virtual void PackToBank(Mobile m) { if (m == null || !m.Player) { return; } BankBox bank = m.FindBankNoCreate(); Backpack pack = new Backpack(); pack.Hue = 1157; List <Item> items = new List <Item>(); for (int i = 0; i < m.Items.Count; i++) { if (m.Items[i] is BankBox || (m.Backpack != null && m.Items[i].Serial == m.Backpack.Serial)) { continue; } items.Add(m.Items[i]); } if (m.Backpack != null) { for (int i = 0; i < m.Backpack.Items.Count; i++) { items.Add(m.Backpack.Items[i]); } } items.ForEach( delegate(Item i) { pack.AddItem(i); }); items.Clear(); if (bank == null) { pack.MoveToWorld(m.Location, m.Map); } else { bank.AddItem(pack); } }