Esempio n. 1
0
        public override void OnCollision(Collidable col)
        {
            EnemyGameObject enemy = col as EnemyGameObject;

            if (enemy != null && enemy == target)
            {
                isCloseEnoughToAttack = true;
                return;
            }

            HealthPotion hPotion = col as HealthPotion;

            if (hPotion != null && retrieveItem)
            {
                hPotion.flagForRemoval = true;
                HealPlayer(50);
                retrieveItem = false;
                return;
            }

            StrengthPotion sPotion = col as StrengthPotion;

            if (sPotion != null && retrieveItem)
            {
                sPotion.flagForRemoval = true;
                EmboldenPlayer(2);
                retrieveItem = false;
                return;
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Response to enemy dying event. Random chance that the enemy drops a potion at their position
        /// </summary>
        /// <param name="position"></param>
        public void SpawnPotion(object sender, EventArgs e)
        {
            EnemyGameObject enemy = sender as EnemyGameObject;

            if (enemy != null && !enemy.droppedPotion)
            {
                int random = Utilities.Rand();
                PotionGameObject potion;

                if (random % 2 == 0)
                {
                    potion = new HealthPotion(enemy.Position);
                }
                else
                {
                    potion = new StrengthPotion(enemy.Position);
                }

                potion.LoadContent(Resources);

                potions.Add(potion);
                entities.Add(potion);
                GameInfo.Instance.HealthPotionInfoArray.Add(new HealthPotionInfo(enemy.Position));

                InitialiseCollidableObjects();

                enemy.droppedPotion = true;
            }
        }