コード例 #1
0
ファイル: WarController.cs プロジェクト: GeorgievPP/SoftUni
        public string AddItemToPool(string[] args)
        {
            string name = args[0];

            if (name != nameof(HealthPotion) && name != nameof(FirePotion))
            {
                throw new ArgumentException($"Invalid item \"{ name }\"!");
            }

            Item item = null;

            if (name == nameof(HealthPotion))
            {
                item = new HealthPotion();
            }
            else if (name == nameof(FirePotion))
            {
                item = new FirePotion();
            }


            this.pool.Add(item);

            return($"{name} added to pool.");
        }
コード例 #2
0
        public string UseItem(string[] args)
        {
            string characterName = args[0];
            string itemName      = args[1];

            var character = this.party.FirstOrDefault(x => x.Name == characterName);

            if (character == null)
            {
                throw new ArgumentException($"Character {characterName} not found!");
            }
            Item item = null;

            if (itemName == "HealthPotion")
            {
                item = new HealthPotion();
            }
            else if (itemName == "FirePotion")
            {
                item = new FirePotion();
            }

            character.UseItem(item);

            return($"{character.Name} used {itemName}.");
        }
コード例 #3
0
        public string AddItemToPool(string[] args)
        {
            var itemName = args[0];

            Item item = null;

            switch (itemName)
            {
            case "FirePotion":
                item = new FirePotion();
                break;

            case "HealthPotion":
                item = new HealthPotion();
                break;

            default:
                var msg = string.Format(ExceptionMessages.InvalidItem, itemName);
                throw new ArgumentException(msg);
            }

            this.items.Add(item);
            var outputMsg = string.Format(SuccessMessages.AddItemToPool, itemName);

            return(outputMsg);
        }
コード例 #4
0
    protected override void PerformPickupAction()
    {
        EnemyHealth health = SpiritPotion.GetSpiritHealth(CharacterController.instance);

        fillAmount = HealthPotion.HealTarget(fillAmount, healScale, health);
        base.PerformPickupAction();
    }
コード例 #5
0
        public Item CreateItem(string type)
        {
            Item item = null;

            if (type == "ArmorRepairKit")
            {
                item = new ArmorRepairKit();
                return(item);
            }

            else if (type == "HealthPotions")
            {
                item = new HealthPotion();
                return(item);
            }

            else if (type == "PosionPotion")
            {
                item = new PoisonPotion();
                return(item);
            }


            throw new ArgumentException(string.Format(ErrorMessages.InvalidItem, type));
        }
コード例 #6
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.Z))
     {
         Bag bag = (Bag)Instantiate(items[0]);
         bag.Initialize(16);
         bag.Use();
     }
     if (Input.GetKeyDown(KeyCode.T))
     {
         Bag bag = (Bag)Instantiate(items[0]);
         bag.Initialize(16);
         AddItem(bag);
     }
     if (Input.GetKeyDown(KeyCode.Q))
     {
         HealthPotion potion = (HealthPotion)Instantiate(items[1]);
         AddItem(potion);
     }
     if (Input.GetKeyDown(KeyCode.E))
     {
         AddItem((Armor)Instantiate(items[2]));
         AddItem((Armor)Instantiate(items[3]));
         AddItem((Armor)Instantiate(items[4]));
         AddItem((Armor)Instantiate(items[5]));
         AddItem((Armor)Instantiate(items[6]));
         AddItem((Armor)Instantiate(items[7]));
         AddItem((Armor)Instantiate(items[8]));
         AddItem((Armor)Instantiate(items[9]));
     }
 }
コード例 #7
0
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.J))// add bag to bags slot
        {
            Bag bag = (Bag)Instantiate(items[0]);
            bag.Initialized(16);
            bag.Use();
        }
        if (Input.GetKeyDown(KeyCode.Alpha8))//add bag to inventory
        {
            Bag bag = (Bag)Instantiate(items[0]);
            bag.Initialized(16);
            AddItem(bag);
        }
        if (Input.GetKeyDown(KeyCode.Alpha7))//add potion to inventory
        {
            HealthPotion potion = (HealthPotion)Instantiate(items[1]);
            AddItem(potion);
        }
        if (Input.GetKeyDown(KeyCode.Alpha6))//add armor to inventory
        {
            AddItem((Armor)Instantiate(items[2]));
            AddItem((Armor)Instantiate(items[3]));
            AddItem((Armor)Instantiate(items[4]));
            AddItem((Armor)Instantiate(items[5]));

            AddItem((Armor)Instantiate(items[6]));
            AddItem((Armor)Instantiate(items[7]));
            AddItem((Armor)Instantiate(items[8]));
        }
    }
コード例 #8
0
ファイル: Bag.cs プロジェクト: dimitrov1fit/SoftUni
        public Item GetItem(string name)
        {
            if (!items.Any())
            {
                throw new InvalidOperationException(ExceptionMessages.EmptyBag);
            }

            if (name != "FirePotion" && name != "HealthPotion")
            {
                throw new ArgumentException($"No item with name {name} in bag!");
            }

            Item item = null;

            if (name == "FirePotion")
            {
                if (!items.Exists(x => x.GetType().Name == "FirePotion"))
                {
                    throw new ArgumentException($"No item with name {name} in bag!");
                }
                item = new FirePotion();
            }
            else if (name == "HealthPotion")
            {
                if (!items.Exists(x => x.GetType().Name == "HealthPotion"))
                {
                    throw new ArgumentException($"No item with name {name} in bag!");
                }
                item = new HealthPotion();
            }
            items.Remove(item);
            return(item);
        }
コード例 #9
0
    void OnCollision(Collision col)
    {
        DroneEnemy enemy = Utility.FindAncestor <DroneEnemy>(col.gameObject);

        if (enemy != null && graceTime < 0f)
        {
            health--;
            graceTime = 2f;
            AudioSource.PlayClipAtPoint(hurtClip, transform.position);
            Utility.Instantiate(hurtFx, transform.position);

            if (health == 0)
            {
                isDead = true;
            }
            return;
        }

        HealthPotion hp = Utility.FindAncestor <HealthPotion>(col.gameObject);

        if (hp != null)
        {
            AudioSource.PlayClipAtPoint(healClip, transform.position);
            Utility.Instantiate(healFx, transform.position);
            health += hp.amount;
            hp.OnConsumed();
        }
    }
コード例 #10
0
        static void Main(string[] args)
        {
            // Construct class objects
            Player       player   = new Player("Leydin", 10, 10, 0, 0, 1);
            Location     location = new Location(1, "Home", "This is your tidy spot in the village of Amoro");
            Quest        quest    = new Quest(1, "Do The Dishes", "Every great adventurer has their humble beginnings and you are no different. Your dishes have been piling up for weeks so please get those done as soon as possible so that a monster doesn't spawn from them, ok? I mean, seriously, who let's their dishes go on for so long. Thats disgusting. You should know better.", 10, 10);
            HealthPotion pot      = new HealthPotion(1, "Pot", "Pots", 10);
            Weapon       knife    = new Weapon(1, "rusty knife", "rusty knives", 2, 5);
            Monster      mouse    = new Monster(1, "A cute little mouse", 1, 1, 2, 5, 5);


            // Screen Output

            Console.WriteLine("WELCOME TO AMORO");

            Console.WriteLine($"PLAYER: {player.Name}\n" +
                              $"LEVEL:  {player.Level}\n" +
                              $"HP:     {player.CurrentHealthPoints} / {player.MaxHealthPoints}\n" +
                              $"GOLD:   {player.Money}\n" +
                              $"XP:     {player.ExperiencePoints}\n");

            Console.WriteLine($"Current Location: {location.Name} - {location.Description}");
            Console.WriteLine($"Current Quest:    {quest.Name} - {quest.Details}. Reward: {quest.ExperienceReward}xp and {quest.FinancialReward} schmoney");
            Console.WriteLine($"Current Item:     {pot.Name} that heals for {pot.HealAmount}");
            Console.WriteLine($"Current Weapon:   {knife.Name}. Damage Dealt: {knife.MinDamage} - {knife.MaxDamage}");
            Console.WriteLine($"Current Foe:      {mouse.Name}.");

            Console.ReadLine();
        }
コード例 #11
0
        public Item CreateItem(string itemName)
        {
            if (itemName != "ArmorRepairKit" && itemName != "HealthPotion" && itemName != "PoisonPotion")
            {
                throw new ArgumentException(string.Format(ExceptionMessages.InvalidItemException, itemName));
            }

            Item item = null;

            if (itemName == "ArmorRepairKit")
            {
                item = new ArmorRepairKit();
            }
            else if (itemName == "HealthPotion")
            {
                item = new HealthPotion();
            }
            else if (itemName == "PoisonPotion")
            {
                item = new PoisonPotion();
            }
            else
            {
                throw new ArgumentException(string.Format(ExceptionMessages.InvalidItemException, itemName));
            }

            return(item);
        }
コード例 #12
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.J))
     {
         Bag bag = (Bag)Instantiate(items[8]);
         bag.Initialize(16);
         bag.Use();
     }
     if (Input.GetKeyDown(KeyCode.K))//used for debugging to add bags to inventory
     {
         Bag bag = (Bag)Instantiate(items[8]);
         bag.Initialize(16);
         AddItem(bag);
     }
     if (Input.GetKeyDown(KeyCode.L))
     {
         HealthPotion potion = (HealthPotion)Instantiate(items[9]);
         AddItem(potion);
     }
     if (Input.GetKeyDown(KeyCode.H))
     {
         AddItem((Armor)Instantiate(items[0]));
         AddItem((Armor)Instantiate(items[1]));
         AddItem((Armor)Instantiate(items[2]));
         AddItem((Armor)Instantiate(items[3]));
         AddItem((Armor)Instantiate(items[4]));
         AddItem((Armor)Instantiate(items[5]));
         AddItem((Armor)Instantiate(items[6]));
         AddItem((Armor)Instantiate(items[7]));
         AddItem((Armor)Instantiate(items[10]));
     }
 }
コード例 #13
0
ファイル: InventoryScript.cs プロジェクト: oberonqa/Ultima
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.J))
        {
            AddItem((Armor)Instantiate(items[3]));
            AddItem((Armor)Instantiate(items[4]));
            AddItem((Armor)Instantiate(items[5]));
            AddItem((Armor)Instantiate(items[6]));
            AddItem((Armor)Instantiate(items[7]));
            AddItem((Armor)Instantiate(items[8]));
            AddItem((Armor)Instantiate(items[9]));
            AddItem((Armor)Instantiate(items[9]));
            AddItem((Armor)Instantiate(items[10]));
            AddItem((Armor)Instantiate(items[11]));
            AddItem((Armor)Instantiate(items[12]));
            AddItem((Armor)Instantiate(items[13]));
            AddItem((Armor)Instantiate(items[14]));
        }

        if (Input.GetKeyDown(KeyCode.K))
        {
            Bag bag = (Bag)Instantiate(items[0]);
            bag.Initialize(20);
            AddItem(bag);
        }

        if (Input.GetKeyDown(KeyCode.L))
        {
            HealthPotion potion = (HealthPotion)Instantiate(items[1]);
            AddItem(potion);
        }
    }
コード例 #14
0
    public Potion MakePotion()
    {
        Potion potion = null;

        switch (result)
        {
        case Result.HealthPotion:
            potion = new HealthPotion();
            break;

        case Result.SuperHealthPotion:
            potion = new SuperHealthPotion();
            break;

        case Result.DoubleDamagePotion:
            potion = new DoubleDamagePotion();
            break;

        case Result.FrozenHeartPotion:
            potion = new FrozenHeartPotion();
            break;

        case Result.InvisibilityPotion:
            potion = new InvisibilityPotion();
            break;

        case Result.NightWalkerPotion:
            potion = new NightWalkerPotion();
            break;
        }

        return(potion);
    }
コード例 #15
0
        public void HealthPotionUnitTest()
        {
            OutputHelper.Display.ClearUserOutput();
            Player player = new Player("test", PlayerClassType.Archer)
            {
                MaxHitPoints = 100,
                HitPoints    = 10,
                Inventory    = new List <IItem> {
                    new HealthPotion(PotionStrength.Minor)
                }
            };
            int potionIndex = player.Inventory.FindIndex(f => f.GetType() == typeof(HealthPotion));

            string[] input      = new[] { "drink", "health" };
            string   potionName = InputHelper.ParseInput(input);

            Assert.AreEqual("health", potionName);
            int          baseHealth = player.HitPoints;
            HealthPotion potion     = player.Inventory[potionIndex] as HealthPotion;
            int          healAmount = potion.HealthAmount;

            player.AttemptDrinkPotion(InputHelper.ParseInput(input));
            string drankHealthString = $"You drank a potion and replenished {healAmount} health.";

            Assert.AreEqual(drankHealthString, OutputHelper.Display.Output[0][2]);
            Assert.AreEqual(baseHealth + healAmount, player.HitPoints);
            Assert.IsEmpty(player.Inventory);
            player.AttemptDrinkPotion(InputHelper.ParseInput(input));
            Assert.AreEqual("What potion did you want to drink?", OutputHelper.Display.Output[1][2]);
        }
コード例 #16
0
    public string AddItemToPool(string[] args)
    {
        if (args[0] != nameof(ArmorRepairKit) && args[0] != nameof(PoisonPotion) && args[0] != nameof(HealthPotion))
        {
            throw new ArgumentException($"Invalid item \"{args[0]}\"!");
        }

        Item temp = null;

        switch (args[0])
        {
        case nameof(ArmorRepairKit):
            temp = new ArmorRepairKit();
            break;

        case nameof(PoisonPotion):
            temp = new PoisonPotion();
            break;

        case nameof(HealthPotion):
            temp = new HealthPotion();
            break;
        }

        itemPool.Push(temp);
        return($"{args[0]} added to pool!");
    }
コード例 #17
0
	public void recreateFighterItem(int x, int y, int i){
		Item item;
		if(PlayerPrefs.GetString("Fighter Item type" + i) == "ManaPotion"){
			item = new ManaPotion();
			inventory.addItem(x,y,item, inventorySlots, inventoryItems);
		}
		else if(PlayerPrefs.GetString("Fighter Item type"  + i) == "HealthPotion"){
			item = new HealthPotion();
			inventory.addItem(x,y,item, inventorySlots, inventoryItems);
		}
		else if(PlayerPrefs.GetString("Fighter Item type"  + i) == "Axe"){
			item = new Axe();
			inventory.addItem(x,y,item, inventorySlots, inventoryItems);
		}
		else if(PlayerPrefs.GetString( "Fighter Item type" + i) == "Ring"){
			item = new Ring();
			inventory.addItem(x,y,item, inventorySlots, inventoryItems);
		}
		else if(PlayerPrefs.GetString("Fighter Item type" + i) == "Chest"){
			item = new Chest();
			inventory.addItem(x,y,item, inventorySlots, inventoryItems);
		}
		else if(PlayerPrefs.GetString("Fighter Item type" + i) == "Boots"){
			item = new Boots();
			inventory.addItem(x,y,item, inventorySlots, inventoryItems);
		}
		else if(PlayerPrefs.GetString("Fighter Item type"  + i) == "Amulet"){
			item = new Amulet();
			inventory.addItem(x,y,item, inventorySlots, inventoryItems);
		}
		else if(PlayerPrefs.GetString( "Fighter Item type" + i) == "Sword"){
			item = new Sword();
			inventory.addItem(x,y,item, inventorySlots, inventoryItems);
		}
	}
コード例 #18
0
 public void Interact()
 {
     if (isOpen)
     {
         StopInteract();
     }
     else
     {
         AddItems();
         if (!FirstOpened)
         {
             FirstOpened = true;
             for (int i = 0; i < 4; i++)
             {
                 GoldNugget nugget = (GoldNugget)Instantiate(debugItems[0]);
                 MyBag.AddItem(nugget);
                 HealthPotion potion = (HealthPotion)Instantiate(debugItems[1]);
                 MyBag.AddItem(potion);
             }
         }
         isOpen = true;
         spriteRenderer.sprite      = openSprite;
         canvasGroup.alpha          = 1;
         canvasGroup.blocksRaycasts = true;
     }
 }
コード例 #19
0
        public string AddItemToPool(string[] args)
        {
            var  itemName = args[0];
            Item item;

            switch (itemName)
            {
            case "HealthPotion":
                item = new HealthPotion();
                break;

            case "PoisonPotion":
                item = new PoisonPotion();
                break;

            case "ArmorRepairKit":
                item = new ArmorRepairKit();
                break;

            default:
                throw new ArgumentException($"Invalid item \"{itemName}\"");
            }

            itemPool.Push(item);

            return($"{itemName} added to pool!");
        }
コード例 #20
0
 private void Update()
 {
     if (Input.GetKeyDown(KeyCode.J))
     {
         Bag bag = (Bag)Instantiate(items[8]);
         bag.Initialize(8);
         AddItem(bag);
     }
     if (Input.GetKeyDown(KeyCode.K))//Debugging for adding a bag to the inventory
     {
         Bag bag = (Bag)Instantiate(items[8]);
         bag.Initialize(20);
         AddItem(bag);
     }
     if (Input.GetKeyDown(KeyCode.L))
     {
         HealthPotion potion = (HealthPotion)Instantiate(items[9]);
         AddItem(potion);
     }
     if (Input.GetKeyDown(KeyCode.H))
     {
         AddItem((Armor)Instantiate(items[0]));
         AddItem((Armor)Instantiate(items[1]));
         AddItem((Armor)Instantiate(items[2]));
         AddItem((Armor)Instantiate(items[3]));
         AddItem((Armor)Instantiate(items[4]));
         AddItem((Armor)Instantiate(items[5]));
         AddItem((Armor)Instantiate(items[6]));
         AddItem((Armor)Instantiate(items[7]));
         AddItem((Armor)Instantiate(items[10]));
     }
 }
コード例 #21
0
        public string AddItemToPool(string[] args)
        {
            string itemName = args[0];

            Item item;

            if (itemName == "ArmorRepairKit")
            {
                item = new ArmorRepairKit();
            }
            else if (itemName == "HealthPotion")
            {
                item = new HealthPotion();
            }
            else if (itemName == "PoisonPotion")
            {
                item = new PoisonPotion();
            }
            else
            {
                throw new ArgumentException("Invalid item \"{ name }\"!");
            }

            itemsPool.Push(item);
            return($"{itemName} added to pool.");
        }
コード例 #22
0
ファイル: InventoryScript.cs プロジェクト: spartann123/TCCRPG
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.V))   //debug
        {
            Bag bag = (Bag)Instantiate(items[0]);
            bag.Initialize(16);
            bag.Use();
        }

        if (Input.GetKeyDown(KeyCode.C))   //debug
        {
            Bag bag = (Bag)Instantiate(items[0]);
            bag.Initialize(16);
            AddItem(bag);
        }

        if (Input.GetKeyDown(KeyCode.H))   //debug
        {
            HealthPotion potion = (HealthPotion)Instantiate(items[1]);
            AddItem(potion);
        }
        if (Input.GetKeyDown(KeyCode.Y))   //debug
        {
            ManaPotion potion = (ManaPotion)Instantiate(items[2]);
            AddItem(potion);
        }
    }
コード例 #23
0
    public Item CreateItem(string[] args)
    {
        string typeOfItem = args[0];

        Item newlyCreatedItem = null;

        try
        {
            switch (typeOfItem)
            {
            case "ArmorRepairKit":
                newlyCreatedItem = new ArmorRepairKit();
                return(newlyCreatedItem);

            case "HealthPotion":
                newlyCreatedItem = new HealthPotion();
                return(newlyCreatedItem);

            case "PoisonPotion":
                newlyCreatedItem = new PoisonPotion();
                return(newlyCreatedItem);

            default: throw new ArgumentException($"Invalid item \"{typeOfItem}\"!");
            }
        }
        catch (InvalidOperationException oe) {
            throw new InvalidOperationException(oe.Message);
        }
    }
コード例 #24
0
ファイル: Player.cs プロジェクト: knzapryanov/RPGGame
        public HealthPotionSize AddHealthPotionToInventory(Items.Item item)
        {
            HealthPotion currentHealthPotion = item as HealthPotion;

            this.inventory.Add(currentHealthPotion);
            return(currentHealthPotion.HealthPotionSize);
        }
コード例 #25
0
    public void CompleteQuest()
    {
        if (selectedQuest.isComplete)
        {
            for (int i = 0; i < questGiver.MyQuests.Length; i++)
            {
                if (selectedQuest == questGiver.MyQuests[i])
                {
                    questGiver.MyQuests[i] = null; //remove quest
                }
            }

            foreach (CollectObjective o in selectedQuest.CollectObjectives)
            {
                Backpack.MyInstance.itemCountChangedEvent -= new ItemCountChanged(o.UpdateItemCount);
                o.UpdateItemCount();
                o.Complete();
            }

            foreach (KillObjective o in selectedQuest.MyKillObjectives)
            {
                Character.MyInstance.killConfirmedEvent -= new KillConfirmed(o.UpdateKillCount);
            }
            Player.myInstance.gainExperience(selectedQuest.MyXp);
            if (selectedQuest.MyReward != null)
            {
                foreach (Object o in selectedQuest.MyReward)
                {
                    if (o is HealthPotion)
                    {
                        HealthPotion hp = (HealthPotion)Instantiate(Resources.Load("HealthPotion"));
                        Backpack.MyInstance.AddItem(hp);
                    }
                    else
                    {
                        Backpack.MyInstance.AddItem(o as Item);
                    }
                }
            }

            if (selectedQuest.Next != "")
            {
                questGiver.activeQuest(selectedQuest.Next);
            }
            if (selectedQuest.MyTitle == "Getting ready for battle.")
            {
                BackgroundMusic.MyInstance.setToFight();
            }
            if (selectedQuest.MyTitle == "Final")
            {
                FindObjectOfType <GameManager>().GameWin();
            }

            QuestLog.MyInstance.RemoveQuest(selectedQuest.MyQuestScript);


            Back();
        }
    }
コード例 #26
0
 void Awake()
 {
     health = 100;
     maxHealth = 100;
     myTransform = transform;
     health_bar = transform.FindChild("EnemyCanvas").FindChild("HealthBG").FindChild("EnemyHealth").GetComponent<Image>();
     reward = new HealthPotion(10, 0, 0, 8);
 }
コード例 #27
0
    public override Pickup Clone()
    {
        //Debug.Log("HealthPotion cloning");

        HealthPotion health = Instantiate <GameObject>(this.gameObject).GetComponent <HealthPotion>();

        return(health);
    }
コード例 #28
0
 public void Setup()
 {
     potion = new HealthPotion(PotionStrength.Minor);
     player = new Player("test", PlayerClassType.Archer)
     {
         Inventory = new List <IItem>()
     };
 }
コード例 #29
0
ファイル: HealthPowerup.cs プロジェクト: aferystic/Game-2D
 public void OnTriggerEnter2D(Collider2D other)
 {
     if (other.CompareTag("Player") && !other.isTrigger)
     {
         HealthPotion healthPotion = (HealthPotion)Instantiate(Resources.Load("HealthPotion"));
         backpack.AddItem(healthPotion);
         Destroy(this.gameObject);
     }
 }
コード例 #30
0
        public void CanAddItemToBackpack()
        {
            Backpack     b = new Backpack();
            HealthPotion p = new HealthPotion();

            AddItemStatus actual = b.AddItem(p);

            Assert.AreEqual(AddItemStatus.Ok, actual);
        }
コード例 #31
0
        public void PotionSatchelRequiresPotions()
        {
            PotionSatchel p = new PotionSatchel();
            HealthPotion  h = new HealthPotion();
            GreatAxe      g = new GreatAxe();

            Assert.AreEqual(AddItemStatus.Ok, p.AddItem(h));
            Assert.AreEqual(AddItemStatus.ItemWrongType, p.AddItem(g));
        }
コード例 #32
0
ファイル: ContainerTests.cs プロジェクト: jrwake89/repository
        public void CanAddItemToBackpack()
        {
            Backpack     b = new Backpack();
            HealthPotion p = new HealthPotion();

            bool actual = b.AddItem(p);

            Assert.AreEqual(true, actual);
        }
コード例 #33
0
	void recreateItem(){
		if(selectedItem == healthIndex){
			sell[selectedItem] = new HealthPotion();
		}
		else if(selectedItem == manaIndex){
			sell[selectedItem] = new ManaPotion();
		}
		else if(selectedItem == amuletIndex){
			sell[selectedItem] = new Amulet();
		}
		else if(selectedItem == ringIndex){
			sell[selectedItem] = new Ring();
		}
	}
コード例 #34
0
ファイル: ActionTest.cs プロジェクト: densjizz/Osiris
        public void ConsumeAndItem()
        {
            var caster = new Mock<ISceneActor>();
            var target = new Mock<ISceneActor>();

            HealthPotion hpPotion = new HealthPotion() { Value = 50.0f};
            UseItem useItem = new UseItem() { Item = hpPotion };
            useItem.Target = target.Object;
            useItem.Caster= caster.Object;

            target.Setup(x => x.GetDerivativeStatNamed("Health")).Returns(new DerivativeStat(new Stat("Strenght", 10), 15));
            useItem.Resolve();
            var targetHP = target.Object.GetDerivativeStatNamed("Health");
            Assert.AreEqual(targetHP.CurrentValue, 200.0f);
        }
コード例 #35
0
ファイル: GameApp.cs プロジェクト: hkostadinov/SoftUni
        private static void SeedInitialPlayerInventory(IPlayer player)
        {
            Position defaultPosition = new Position(0, 0);

            ICollectible healthPotion = new HealthPotion(defaultPosition);
            healthPotion.State = ItemState.Collected;

            ICollectible shield = new RegularShield(defaultPosition);
            shield.State = ItemState.Collected;

            ICollectible sword = new RegularSword(defaultPosition);
            sword.State = ItemState.Collected;

            player.AddItemToInventory(healthPotion);
            player.AddItemToInventory(healthPotion);
            player.AddItemToInventory(shield);
            player.AddItemToInventory(sword);
        }
コード例 #36
0
	void recreateItem(){
		if(selectedItem == healthIndex){
			sell[selectedItem] = new HealthPotion();
		}
		else if(selectedItem == manaIndex){
			sell[selectedItem] = new ManaPotion();
		}
		else if(selectedItem == swordIndex){
			sell[selectedItem] = new Sword();
		}
		else if(selectedItem == axeIndex){
			sell[selectedItem] = new Axe();
		}
		else if(selectedItem == chestIndex){
			sell[selectedItem] = new Chest();
		}
		else if(selectedItem == bootsIndex){
			sell[selectedItem] = new Boots();
		}
	}