Esempio n. 1
0
        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();
            }
        }
Esempio n. 2
0
        /// <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);
        }
Esempio n. 3
0
 public void MoveStuff(IStuff Stuff, int count)
 {
     for (int i = 0; i < count; i++)
     {
         Things.Add(Stuff);
     }
 }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        public void OverrideMethodOnDynamicMock()
        {
            DynamicMock derivedMock     = new DerivedMock();
            IStuff      derivedInstance = (IStuff)derivedMock.MockInstance;

            Assert.AreEqual(17, derivedInstance.Add(5, 12));
            derivedMock.Verify();
        }
Esempio n. 6
0
 public void AddStuff(IStuff Stuff, int count)
 {
     for (int i = 0; i < count; i++)
     {
         IStuff st = GameStuff.DeepClone <IStuff>(Stuff);
         Things.Add(st);
     }
 }
Esempio n. 7
0
 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);
     }
 }
Esempio n. 8
0
        public void RemoveStaff(IStuff Stuff, IBagObject bagObject)
        {
            IStuff obj = HaveStuff(Stuff);

            if (obj != null)
            {
                bagObject.Things.Remove(obj);
            }
        }
Esempio n. 9
0
        public IStuff HaveStuffInBox(IStuff Stuff, IBagObject bagObject)
        {
            IStuff o = bagObject.Things.FirstOrDefault(s => s == Stuff);

            if (o != null)
            {
                return(o);
            }
            return(null);
        }
Esempio n. 10
0
        public IStuff GetAndRemoveStaff(IStuff Stuff, Decimal price)
        {
            IStuff obj = HaveStuff(Stuff, price);

            if (obj != null)
            {
                Things.Remove(obj);
            }
            return(obj);
        }
Esempio n. 11
0
        public IStuff GetAndRemoveStaff(IStuff Stuff)
        {
            IStuff obj = HaveStuff(Stuff);

            if (obj != null)
            {
                Things.Remove(obj);
            }
            return(obj);
        }
Esempio n. 12
0
        public IStuff HaveStuff(IStuff Stuff, Decimal price)
        {
            IStuff o = Things.FirstOrDefault(s => s == Stuff);

            if (o == null)
            {
                return(null);
            }
            return(o);
        }
Esempio n. 13
0
        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);
        }
Esempio n. 14
0
        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);
        }
Esempio n. 15
0
 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;
         }
     }
 }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
        /// <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;
        }
Esempio n. 18
0
 public IStuff GetStuffByIdSmallBag(IStuff Stuff)
 {
     if (SmallBag != null)
     {
         foreach (IStuff key in SmallBag.Things)
         {
             if (key.id == Stuff.id)
             {
                 return(key);
             }
         }
     }
     return(null);
 }
Esempio n. 19
0
 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);
 }
Esempio n. 20
0
        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();
            }
        }
Esempio n. 21
0
        /// <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();
            }
        }
Esempio n. 22
0
        /// <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);
        }
Esempio n. 23
0
 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);
 }
Esempio n. 24
0
 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);
 }
Esempio n. 25
0
 public IStuff GetStaff(IStuff Stuff)
 {
     return(HaveStuff(Stuff));
 }
Esempio n. 26
0
 public void CreateMock()
 {
     mock     = new DynamicMock(typeof(IStuff));
     instance = (IStuff)mock.MockInstance;
 }
Esempio n. 27
0
        // 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;
            }
        }
Esempio n. 28
0
 public IStuff GetStaff(IStuff Stuff, Decimal price)
 {
     return(HaveStuff(Stuff, price));
 }
Esempio n. 29
0
        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);
        }
Esempio n. 30
0
		public void CreateMockForNonMBRClassFails()
		{
			DynamicMock classMock = new DynamicMock( typeof( NonMBRClass ) );
			instance = classMock.MockInstance as IStuff;
		}
Esempio n. 31
0
        public void CreateMockForNonMBRClassFails()
        {
            DynamicMock classMock = new DynamicMock(typeof(NonMBRClass));

            instance = classMock.MockInstance as IStuff;
        }
Esempio n. 32
0
		public void CreateMock()
		{
			mock = new DynamicMock( typeof( IStuff ) );
			instance = (IStuff)mock.MockInstance;
		}