Inheritance: MonoBehaviour
Exemplo n.º 1
0
    IEnumerator itemSelected(Collider2D hitCollider)
    {
        if (hitCollider != this.GetComponentInChildren <Collider2D>())
        {
            yield break;
        }

        if (containingItem.type == itemType.Potion && alreadyGotThatOne == false)
        {
            PotionInventory.addLeaf(containingItem);
            sound.clip = pickUpPotionSound;
            sound.Play();
            GetComponentInChildren <SpriteRenderer>().sprite = null;
            GetComponentInChildren <Collider2D>().gameObject.SetActive(false);
            alreadyGotThatOne = true;
            yield return(new WaitForSeconds(1f));

            Destroy(gameObject);
        }
        else if (alreadyGotThatOne == false)
        {
            Inventory.addItem(containingItem);
            sound.clip = pickUpItemSound;
            sound.Play();
            GetComponentInChildren <SpriteRenderer>().sprite = null;
            alreadyGotThatOne = true;
            yield return(new WaitForSeconds(1f));

            Destroy(gameObject);
        }
        yield break;
    }
Exemplo n.º 2
0
        public static void GetInput(Player player, Map map, string _type)
        {
            Console.WriteLine();
            Console.WriteLine();
            Console.WriteLine("Enter Letter:");

            //int i = Convert.ToInt32(Console.ReadLine());
            ConsoleKey cInput = Console.ReadKey(true).Key; //true hides input

            if (cInput == ConsoleKey.Escape)
            {
                return; //? is this the correct way to do this
            }

            int i = (int)cInput - 65; //a == 0

            if (_type == "potion")
            {
                if (PotionInventory[i].Name == "Health Potion" && Health.Cast(player))
                {
                    PotionInventory.RemoveAt(i);
                }
            }
            if (_type == "scroll")
            {
                if (ScrollInventory[i].Name == "Teleportation Scroll")
                {
                    Teleportation.Cast(player, map);
                }

                ScrollInventory.RemoveAt(i);
            }
        }
Exemplo n.º 3
0
    public void clearStats()
    {
        PopUp.instance.showPopUp("Are you sure you want to reset your players stats permanently?",
                                 new string[] { "Yes", "No" },
                                 new System.Action[] {
            new System.Action(() => {
                PlayerPrefs.DeleteAll();

                PotionInventory.clear();
                Inventory.clear();
                Tutorial.clear();
                StoryOverlord.currentLevel = 0;


                health.Value        = 100;
                maxHealth           = 110;
                gold.Value          = 0;
                experience.Value    = 0;
                totalDistance.Value = 0;
                level.Value         = 0;
                equippedWeapon      = ItemList.noItem;
                equippedArmor       = ItemList.noItem;
                equippedAccessory   = ItemList.noItem;


                savePlayer();
                GameState.loadScene(GameState.scene.CAMPSITE);
            }),
            new System.Action(() => { })
        });
    }
Exemplo n.º 4
0
 public void loadOthers()
 {
     Inventory.load();
     PotionInventory.load();
     EnemyWatchdog.instance.loadQueue();
     Tutorial.load();
 }
Exemplo n.º 5
0
	public void Setup(string e) {
		player = GameObject.Find("Player").transform;
		pi = player.GetComponent<PotionInventory>();
		GameObject potion = gameObject;
		liquid = potion.transform.Find("Liquid").gameObject;

		liquid.GetComponent<Renderer>().material = Instantiate(Resources.Load("Materials/Color/Diffuse")) as Material;

		yMod = potionYMod[shape];
		scale = potionScale[shape];

		
		SetColor(PotionGen.GetColor(effect));
	}
Exemplo n.º 6
0
 public void makeAttackPot()
 {
     if (PotionInventory.numBlueLeaf >= BLUE_LEAVES_FOR_POWER && Player.gold.Value >= attackPotPrice)
     {
         Player.takeGold(attackPotPrice);
         PotionInventory.removeLeaf(blueLeaf, BLUE_LEAVES_FOR_POWER);
         PotionInventory.addPotion(attackPot);
         sound.clip = success;
         sound.Play();
     }
     else
     {
         PopUp.instance.showPopUp("You don't have the neccessary items!", new string[] { "Okay" });
         sound.clip = negative;
         sound.Play();
     };
 }
Exemplo n.º 7
0
 public void makeCritPot()
 {
     if (PotionInventory.numYellowLeaf >= YELLOW_LEAVES_FOR_CRIT && Player.gold.Value >= critPotPrice)
     {
         Player.takeGold(critPotPrice);
         PotionInventory.removeLeaf(yellowLeaf, YELLOW_LEAVES_FOR_CRIT);
         PotionInventory.addPotion(critPot);
         sound.clip = success;
         sound.Play();
     }
     else
     {
         PopUp.instance.showPopUp("You don't have the neccessary items!", new string[] { "Okay" });
         sound.clip = negative;
         sound.Play();
     };
 }
Exemplo n.º 8
0
        /// <summary>
        /// Adds potion bonuses, takes care if they are above the maximum and removes the potion from the inventory
        /// </summary>
        /// <param name="potionType"></param>
        public void ConsumePotion(PotionType potionType)
        {
            var foundPotion = PotionInventory.FirstOrDefault(p => p.PotionType == potionType);

            if (foundPotion == null)
            {
                Visualization.Visualisator.PrintUnderTheBattleField(PotionsConstants.UnavaiblePotion + potionType + "s!");
                return;
            }
            switch (potionType)
            {
            case PotionType.HealthPotion:
                Visualization.Visualisator.PrintUnderTheBattleField(PotionsConstants.ConsumedPotion + foundPotion.HealthBonus + " health!");
                break;

            case PotionType.XpPotion:
                Visualization.Visualisator.PrintUnderTheBattleField(PotionsConstants.ConsumedPotion + foundPotion.XpBonus + " experience!");
                break;

            case PotionType.BonusDamagePotion:
                Visualization.Visualisator.PrintUnderTheBattleField(PotionsConstants.ConsumedPotion + foundPotion.DamageBonus + " bonus damage!");
                break;

            default:
                break;
            }

            this.health     += foundPotion.HealthBonus;
            this.damage     += foundPotion.DamageBonus;
            this.experience += foundPotion.XpBonus;
            if (this.experience >= NeedExperience)
            {
                LevelUp();
            }
            if (this.health > MaxHealth)
            {
                this.health = MaxHealth;
            }

            var indexOfCurrentPotion = potionInventory.IndexOf(foundPotion);

            if (indexOfCurrentPotion != -1)
            {
                potionInventory.RemoveAt(indexOfCurrentPotion);
            }
        }
Exemplo n.º 9
0
 public void makeHealthPot()
 {
     if (PotionInventory.numRedLeaf >= RED_LEAVES_FOR_HEALTH &&
         Player.gold.Value >= healthPotPrice)
     {
         Player.takeGold(healthPotPrice);
         PotionInventory.removeLeaf(redLeaf, RED_LEAVES_FOR_HEALTH);
         PotionInventory.addPotion(healthPot);
         sound.clip = success;
         sound.Play();
     }
     else
     {
         PopUp.instance.showPopUp("You don't have the neccessary items!", new string[] { "Okay" });
         sound.clip = negative;
         sound.Play();
     };
 }