public void DropItems() { int i = 1; string input; IStuff[] myi = new IStuff[myPlayer.myInventory.Count() + 1]; // Draw Header myDrawing.ItemInteraction("Drop"); foreach (IStuff stuff in myPlayer.myInventory) { myi[i] = stuff; Console.WriteLine(i + " " + stuff); i++; } if (myi.Length > 1) { input = Console.ReadLine(); for (i = 0; i < myi.Length; i++) { if (myi[i] != null && input == Convert.ToString(i)) { myWorld.myTiles[myPlayer.y, myPlayer.x].Insert(0, myi[i]); myPlayer.myInventory.Remove(myi[i]); } } NpcChecker(); } }
/// <summary>Método que testa este projeto</summary> private void TestProject() { // Instanciar um jogador com 70 quilos Player p = new Player(70.0f); // // Adicionar vários itens à mochila do jogador: // // Pão com 2 dias, 500 gramas p.BagOfStuff.AddThing(new Food(FoodType.Bread, 2, 0.500f)); // 300 gramas de vegetais com 5 dias p.BagOfStuff.AddThing(new Food(FoodType.Vegetables, 5, 0.300f)); // Pistola com 1.5kg + 50 gramas por bala, carregada com 10 balas, com um custo de 250€ p.BagOfStuff.AddThing(new Gun(1.5f, 0.050f, 10, 250)); p.BagOfStuff.AddThing(new Gun(1.0f, 0.040f, 5, 150)); // 200 gramas de fruta fresca p.BagOfStuff.AddThing(new Food(FoodType.Fruit, 0, 0.200f)); // Quantos itens tem o jogador na mochila? Console.WriteLine($"Nº de itens na mochila: {p.BagOfStuff.StuffCount}"); // Percorrer itens na mochila e tentar "imprimir" cada um for (int i = 0; i < p.BagOfStuff.StuffCount; i++) { IStuff aThing = p.BagOfStuff.GetThing(i); Console.WriteLine(aThing); } Console.WriteLine("The bag's value is: " + " " + p.BagOfStuff.Value); Console.WriteLine("The bag's weight is: " + " " + p.BagOfStuff.Weight); }
public void MoveStuff(IStuff Stuff, int count) { for (int i = 0; i < count; i++) { Things.Add(Stuff); } }
public void DropThning(IStuff stuff, Box location, int count, IBagObject bagObject) { IStuff st = player.HaveStuffInBox(stuff, bagObject); player.RemoveStaff(st, bagObject); location.MoveStuff(stuff, 1); }
public void OverrideMethodOnDynamicMock() { DynamicMock derivedMock = new DerivedMock(); IStuff derivedInstance = (IStuff)derivedMock.MockInstance; Assert.AreEqual(17, derivedInstance.Add(5, 12)); derivedMock.Verify(); }
public void AddStuff(IStuff Stuff, int count) { for (int i = 0; i < count; i++) { IStuff st = GameStuff.DeepClone <IStuff>(Stuff); Things.Add(st); } }
public void AddStuff(IStuff Stuff, int count, Decimal price = 0) { for (int i = 0; i < count; i++) { IStuff st = GameStuff.DeepClone <IStuff>(Stuff); st.Price = (price > 0) ? price : Stuff.Price; Things.Add(st); } }
public void RemoveStaff(IStuff Stuff, IBagObject bagObject) { IStuff obj = HaveStuff(Stuff); if (obj != null) { bagObject.Things.Remove(obj); } }
public IStuff HaveStuffInBox(IStuff Stuff, IBagObject bagObject) { IStuff o = bagObject.Things.FirstOrDefault(s => s == Stuff); if (o != null) { return(o); } return(null); }
public IStuff GetAndRemoveStaff(IStuff Stuff, Decimal price) { IStuff obj = HaveStuff(Stuff, price); if (obj != null) { Things.Remove(obj); } return(obj); }
public IStuff GetAndRemoveStaff(IStuff Stuff) { IStuff obj = HaveStuff(Stuff); if (obj != null) { Things.Remove(obj); } return(obj); }
public IStuff HaveStuff(IStuff Stuff, Decimal price) { IStuff o = Things.FirstOrDefault(s => s == Stuff); if (o == null) { return(null); } return(o); }
public bool GetThningToBag(IStuff stuff, Box location, int count, IBagObject Bag) { IStuff st = location.GetStaff(stuff); if (player.AddStuffToBag(stuff, Bag)) { location.RemoveStaff(stuff, 1); return(true); } return(false); }
public bool GetThning(IStuff stuff, Box location, int count) { IStuff st = location.GetStaff(stuff); if (player.AddStuff(st)) { location.RemoveStaff(stuff, 1); return(true); } return(false); }
public void RemoveStaff(IStuff Stuff, Decimal price, int count) { for (int i = 0; i < count; i++) { IStuff obj = HaveStuff(Stuff, price); if (obj != null) { Things.Remove(obj); obj = null; } } }
public bool BuyThing(IStuff stuff, Shop location, int count, Decimal price) { IStuff st = location.GetStaff(stuff, price); if (player.AddStuff(st)) { location.RemoveStaff(stuff, price, 1); player.Money = player.Money - price; return(true); } return(false); }
/// <summary>Colocar um item na mochila</summary> /// <param name="aThing">Item a colocar na mochila</param> public void AddThing(IStuff aThing) { // Será que temos espaço na mochila? if (StuffCount >= stuff.Length) { // Senão tivermos podemos "lançar" uma exceção throw new InvalidOperationException("Bag is already full!"); } // Adicionar o item à mochila e depois incrementar o // número de coisas na mochila stuff[StuffCount++] = aThing; }
public IStuff GetStuffByIdSmallBag(IStuff Stuff) { if (SmallBag != null) { foreach (IStuff key in SmallBag.Things) { if (key.id == Stuff.id) { return(key); } } } return(null); }
public bool AddStuffToBag(IStuff Stuff, IBagObject bagObject) { if (bagObject.classname == "SmallBag" && Stuff.BagType == 2) { return(false); } if (bagObject != null && bagObject.MaxWeight - GetBagWeight(bagObject) > Stuff.Weight) { AddToBag(Stuff, bagObject); return(true); } return(false); }
public void UseItems() { int i = 1; string input; /* Create a new IStuff array with the size of the player * inventory plus what he has equiped */ IStuff[] myi = new IStuff[myPlayer.myInventory.Count() + 1]; // DrawHeader myDrawing.ItemInteraction("Use"); foreach (IStuff stuff in myPlayer.myInventory) { myi[i] = stuff; Console.WriteLine(i + " " + stuff); i++; } if (myi.Length > 1) { input = Console.ReadLine(); for (i = 1; i < myi.Length; i++) { if (myi[i] != null && input == Convert.ToString(i)) { if (myi[i] is Food && myPlayer.Hp < 100) { myPlayer.Hp += (myi[i] as Food).Heal; myPlayer.myInventory.Remove(myi[i]); if (myPlayer.Hp > 100) { myPlayer.Hp = 100; } } else if (myi[i] is Weapon) { if (myPlayer.equiptSlot != null) { myPlayer.myInventory.Add(myPlayer.equiptSlot); } myPlayer.equiptSlot = (myi[i] as Weapon); myPlayer.myInventory.Remove(myi[i]); } } } NpcChecker(); } }
/// <summary> /// Pick up items from the ground /// </summary> public void PickItems() { int i = 1; string input; IStuff[] myi = new IStuff[10]; // Draw Header myDrawing.ItemInteraction("PickUp"); foreach (Object obj in myWorld.myTiles[myPlayer.y, myPlayer.x].GetList().ToList()) { if (obj is IStuff) { myi[i] = (obj as IStuff); Console.WriteLine(i + " " + obj); i++; } else if (obj is Map) { myGenerator.myMap.UseMap(myWorld); myWorld.myTiles[myPlayer.y, myPlayer.x].Remove(obj); return; } } if (myi[1] != null) { input = Console.ReadLine(); for (i = 0; i < myi.Length; i++) { if (myi[i] != null && input == Convert.ToString(i)) { if (((myPlayer.myInventory.Weight + myi[i].Weight) / myPlayer.Weight) <= 1) { myWorld.myTiles[myPlayer.y, myPlayer.x].Remove(myi[i]); myPlayer.myInventory.Add(myi[i]); } else { Console.WriteLine("Not enough Space!"); Console.ReadKey(); } } } NpcChecker(); } }
/// <summary>Método que testa este projeto</summary> private void TestProject() { // Instanciar um jogador com 70 quilos Player p = new Player(70.0f); // // Adicionar vários itens à mochila do jogador: // // Pão com 2 dias, 500 gramas p.BagOfStuff.AddThing(new Food(FoodType.Bread, 2, 0.500f)); // 300 gramas de vegetais com 5 dias p.BagOfStuff.AddThing(new Food(FoodType.Vegetables, 5, 0.300f)); // Pistola com 1.5kg + 50 gramas por bala, carregada com 10 balas, // com um custo de 250€ p.BagOfStuff.AddThing(new Gun(1.5f, 0.050f, 10, 250f)); // 200 gramas de fruta fresca p.BagOfStuff.AddThing(new Food(FoodType.Fruit, 0, 0.200f)); // Mais uma arma p.BagOfStuff.AddThing(new Gun(2f, 0.09f, 25, 325f)); // Mostrar informação acerca dos conteúdos da mochila Console.WriteLine(p.BagOfStuff); // Percorrer itens na mochila e tentar "imprimir" cada um for (int i = 0; i < p.BagOfStuff.StuffCount; i++) { IStuff aThing = p.BagOfStuff.GetThing(i); Console.WriteLine($"\t=> {aThing}"); // Se item atual for uma arma, disparar a mesma if (aThing is Gun) { (aThing as Gun).Shoot(); } } // Mostrar de novo informação sobre a mochila Console.WriteLine(p.BagOfStuff); }
public bool AddStuff(IStuff Stuff, bool ForceNone = false) { if (Stuff.Nobag == true || ForceNone) { AddNone(Stuff); return(true); } else if (Stuff.BagType == 0) { if (Bag != null && Bag.MaxWeight - GetBagWeight(Bag) > Stuff.Weight) { AddBag(Stuff); return(true); } else if (SmallBag != null && SmallBag.MaxWeight - GetBagWeight(SmallBag) > Stuff.Weight) { AddSmallBag(Stuff); return(true); } } else if (Stuff.BagType == 1 && SmallBag != null) { if (SmallBag.MaxWeight - GetBagWeight(SmallBag) > Stuff.Weight) { AddSmallBag(Stuff); return(true); } } else if (Stuff.BagType == 2 && Bag != null) { if (Bag.MaxWeight - GetBagWeight(Bag) > Stuff.Weight) { AddBag(Stuff); return(true); } } return(false); }
public IStuff HaveStuff(IStuff Stuff) { if (SmallBag != null) { foreach (IStuff key in SmallBag.Things) { if (key == Stuff) { return(key); } } } if (Bag != null) { foreach (IStuff key in Bag.Things) { if (key == Stuff) { return(key); } } } return(null); }
public IStuff GetStaff(IStuff Stuff) { return(HaveStuff(Stuff)); }
public void CreateMock() { mock = new DynamicMock(typeof(IStuff)); instance = (IStuff)mock.MockInstance; }
// Method to update the player and all the enemies public void Update() { //Console.WriteLine("Stage: " + _stage); //Console.WriteLine("Level: " + _level); _player.CurrentWeapon.Update(); _player.Update(); UpdateList(); UpdateLevel(); UpdatePackage(); OpenDoor(); for (int i = 0; i < _count; i++) { Vector place; if (this._enemies[i].Effect == "Sheep") { place = this.CreateRandomPosition(); } else if (this._enemies[i].Effect == "Hypnose") { if (this._enemies[i].Target == null) { float target = 80f; int ennemiesTarget = 0; for (int a = 0; a < _count; a++) { Vector distanceVect = new Vector(); if (a != i) { float distanceMin = distanceVect.Distance(this._enemies[i].Place, this._enemies[a].Place); if (target > distanceMin) { target = distanceMin; ennemiesTarget = a; } } } this._enemies[i].Target = this._enemies[ennemiesTarget]; this._enemies[i].TargetID = ennemiesTarget; } place = this._enemies[i].Target.Place; } else { place = this._player.Place; } this._enemies[i].Move(place); } UpdateEffect(_enemies); if (_boss != null && _boss.isDead == false) { this._boss.UpdateBoss(); this._boss.Move(this.Player.Place); } _time++; _timeForWeaponSpawn++; if (_time == 120 && this._spawn != null) { _count += _spawn.Count; if (_count > this._enemies.Length) { _count = this.Enemies.Length; } } if (_timeForWeaponSpawn == 300) { int factoryIndex = _random.Next(0, _stuffFactories.Count); IStuffFactory randomStuffFactory = _stuffFactories[factoryIndex]; IStuff stuff = randomStuffFactory.Create(); _stuffList.Add(stuff); _timeForWeaponSpawn = 0; } }
public IStuff GetStaff(IStuff Stuff, Decimal price) { return(HaveStuff(Stuff, price)); }
public bool WearToMe(IWear stuff, Wardrobe location) { IStuff st = location.GetStaff(stuff); switch (stuff.WearSlot) { case 1: if (player.Hat != null) { location.MoveStuff(player.Hat, 1); player.Hat = null; } break; case 2: if (stuff.ConflictSlot == 3 && player.BottomDress != null) { return(false); } if (player.TopDress != null) { location.MoveStuff(player.TopDress, 1); player.TopDress = null; } break; case 3: if (stuff.ConflictSlot == 2 && player.TopDress != null && player.TopDress.ConflictSlot == 3) { return(false); } if (player.BottomDress != null) { location.MoveStuff(player.BottomDress, 1); player.BottomDress = null; } break; case 4: if (player.Shoes != null) { location.MoveStuff(player.Shoes, 1); player.Shoes = null; } break; case 5: if (player.Stockings != null) { location.MoveStuff(player.Stockings, 1); player.Stockings = null; } break; case 6: if (player.Coat != null) { location.MoveStuff(player.Coat, 1); player.Coat = null; } break; case 7: if (player.Bra != null) { location.MoveStuff(player.Bra, 1); player.Bra = null; } break; case 8: if (player.Panties != null) { location.MoveStuff(player.Panties, 1); player.Panties = null; } break; case 9: if (player.SmallBag != null) { location.MoveStuff(player.SmallBag, 1); player.SmallBag = null; } break; case 10: if (player.Bag != null) { location.MoveStuff(player.Bag, 1); player.Bag = null; } break; } if (player.WearStuff(stuff)) { location.RemoveStaff(stuff, 1); return(true); } return(false); }
public void CreateMockForNonMBRClassFails() { DynamicMock classMock = new DynamicMock( typeof( NonMBRClass ) ); instance = classMock.MockInstance as IStuff; }
public void CreateMockForNonMBRClassFails() { DynamicMock classMock = new DynamicMock(typeof(NonMBRClass)); instance = classMock.MockInstance as IStuff; }
public void CreateMock() { mock = new DynamicMock( typeof( IStuff ) ); instance = (IStuff)mock.MockInstance; }