Exemplo n.º 1
0
        // Heals the entity by a certain amount, allows the specification of a heal type.
        public virtual bool Heal(int amount, HealType type)
        {
            // Doesn't heal because health is above max or overloaded max.
            if (type == HealType.Regular && health >= maxHealth)
            {
                return(false);
            }
            if (type == HealType.Overload && health >= maxOverloadedHealth)
            {
                return(false);
            }

            health += amount; // Adds the health.

            // Ensures not going above max health.
            if (type == HealType.Regular && health > maxHealth)
            {
                health = maxHealth;
            }
            else if (type == HealType.Overload && health > maxOverloadedHealth)
            {
                health = maxOverloadedHealth;
            }

            // Handles any changes that have to be made when modifying health.
            OnChangeHealth();

            return(true);
        }
Exemplo n.º 2
0
        public void Heal(int amount, int healerId = 0, HealType healType = HealType.HEALTH)
        {
            if (amount < 0)
            {
                return;
            }

            switch (healType)
            {
            case HealType.HEALTH:
                if (CurrentHitPoints + amount > MaxHitPoints)
                {
                    amount = MaxHitPoints - CurrentHitPoints;
                }
                CurrentHitPoints += amount;
                break;

            case HealType.SHIELD:
                if (CurrentShieldPoints + amount > MaxShieldPoints)
                {
                    amount = MaxShieldPoints - CurrentShieldPoints;
                }
                CurrentShieldPoints += amount;
                break;
            }

            var healPacket = "0|A|HL|" + healerId + "|" + Id + "|" + (healType == HealType.HEALTH ? "HPT" : "SHD") + "|" + CurrentHitPoints + "|" + amount;

            if (this is Player player)
            {
                if (!Invisible)
                {
                    foreach (var otherPlayers in InRangeCharacters.Values)
                    {
                        if (otherPlayers.Selected == this)
                        {
                            if (otherPlayers is Player)
                            {
                                (otherPlayers as Player).SendPacket(healPacket);
                            }
                        }
                    }
                }

                player.SendPacket(healPacket);
            }
            else if (this is Activatable)
            {
                foreach (var character in Spacemap.Characters.Values)
                {
                    if (character.Selected == this && character is Player && character.Position.DistanceTo(Position) < RenderRange)
                    {
                        (character as Player).SendPacket(healPacket);
                    }
                }
            }

            UpdateStatus();
        }
Exemplo n.º 3
0
            public UniversalHealOrb(HurtBox target, GameObject effectPrefab, Boolean useSkin, UInt32 skin, Vector3 origin, Single value, Single speed, HealType healType = HealType.Flat, HealTarget healTarget = HealTarget.Health)
            {
                base.target = target;
                base.origin = origin;

                this.effectPrefab = effectPrefab;
                this.value        = value;
                this.speed        = speed;
                this.healType     = healType;
                this.healTarget   = healTarget;
                this.useSkin      = useSkin;
                this.skin         = skin;
            }
Exemplo n.º 4
0
        public virtual bool Heal(int amount, HealType type, AudioClip feedbackAudio)
        {
            // Tries to heal the entity.
            bool healed = base.Heal(amount, type);

            // If the entity was healed plays the player feedback sound.
            if (healed && feedbackAudio != null)
            {
                PlayerController.Instance.feedbackAudioSource.PlayOneShot(feedbackAudio, 1.0f);
            }

            return(healed);
        }
Exemplo n.º 5
0
        public void Heal(int amount, int healerId = 0, HealType healType = HealType.HEALTH)
        {
            if (amount < 0)
            {
                return;
            }

            switch (healType)
            {
            case HealType.HEALTH:
                if (CurrentHitPoints + amount > MaxHitPoints)
                {
                    amount = MaxHitPoints - CurrentHitPoints;
                }
                CurrentHitPoints += amount;
                break;

            case HealType.SHIELD:
                if (CurrentShieldPoints + amount > MaxShieldPoints)
                {
                    amount = MaxShieldPoints - CurrentShieldPoints;
                }
                CurrentShieldPoints += amount;
                break;
            }

            if (this is Player player)
            {
                var healPacket = "0|A|HL|" + healerId + "|" + Id + "|" + (healType == HealType.HEALTH ? "HPT" : "SHD") + "|" + CurrentHitPoints + "|" + amount;

                if (!Invisible)
                {
                    foreach (var otherPlayers in InRangeCharacters.Values)
                    {
                        if (otherPlayers.Selected == this)
                        {
                            if (otherPlayers is Player)
                            {
                                (otherPlayers as Player).SendPacket(healPacket);
                            }
                        }
                    }
                }

                player.SendPacket(healPacket);
            }

            UpdateStatus();
        }
Exemplo n.º 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="healAmount"></param>
        /// <param name="healType"></param>
        public void Heal(int healAmount, HealType healType)
        {
            int missingHealth = MaxHitPoints - CurrentHitPoints;

            if (missingHealth <= 0 || healAmount <= 0)
            {
                return;
            }

            if (missingHealth < healAmount)
            {
                healAmount = missingHealth;
            }

            Mogwai.History.Add(LogType.HEAL, $"¬C{Name}§ restores ¬G{healAmount}§ HP from {healType.ToString().ToLower()} healing.¬");
            CurrentHitPoints += healAmount;
        }
Exemplo n.º 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="healAmount"></param>
        /// <param name="healType"></param>
        public void Heal(int healAmount, HealType healType)
        {
            var missingHealth = MaxHitPoints - CurrentHitPoints;

            if (missingHealth <= 0 || healAmount <= 0)
            {
                return;
            }

            if (missingHealth < healAmount)
            {
                healAmount = missingHealth;
            }
            var activity = ActivityLog.Create(ActivityLog.ActivityType.Heal, ActivityLog.ActivityState.None, new int[] { healAmount, (int)healType }, null);

            Mogwai.Mogwai.History.Add(LogType.Info, activity);
            Adventure?.Enqueue(AdventureLog.Info(this, null, activity));

            CurrentHitPoints += healAmount;
        }
Exemplo n.º 8
0
        public void Execute(int amount, int healerId = 0, HealType healType = HealType.HEALTH)
        {
            if (amount < 0)
            {
                return;
            }

            switch (healType)
            {
            case HealType.HEALTH:
                if (Character.CurrentHealth + amount > Character.MaxHealth)
                {
                    amount = Character.MaxHealth - Character.CurrentHealth;
                }
                Character.CurrentHealth += amount;
                break;

            case HealType.SHIELD:
                if (Character.CurrentShield + amount > Character.MaxShield)
                {
                    amount = Character.MaxShield - Character.CurrentShield;
                }
                Character.CurrentShield += amount;
                break;
            }

            if (Character is Player && healType == HealType.HEALTH)
            {
                //Packet.Builder.LegacyModule(World.StorageManager.GetGameSession(Character.Id), "0|A|HL|" + healerId + "|" + Character.Id + "|HPT|" + Character.CurrentHealth + "|" +
                //                                                                               amount);
                //todo: fix
            }
            else if (Character is Player && healType == HealType.SHIELD)
            {
                //Packet.Builder.LegacyModule(World.StorageManager.GetGameSession(Character.Id), "0|A|HL|" + healerId + "|" + Character.Id + "|SHD|" + Character.CurrentShield + "|" +
                //                                                                               amount);
                //todo: fix
            }
            Character.Updaters.Update();
        }
Exemplo n.º 9
0
    public void ItemHeal(HealType healType, PlayerInventory playerInventory)
    {
        if (battleSystem.GetState() != BattleState.PlayerTurn)
        {
            return;
        }

        switch (healType)
        {
        case HealType.Paracetamol:
            if (playerInventory.paracetamolAmount > 0)
            {
                playerInventory.paracetamolAmount--;
                StartCoroutine(battleSystem.UseHealItem(true, 20, "You used Paracetamol!"));
                Debug.Log("Paracetamol");
            }
            break;

        case HealType.Ibuprofen:
            if (playerInventory.ibuprofenAmount > 0)
            {
                playerInventory.ibuprofenAmount--;
                StartCoroutine(battleSystem.UseHealItem(true, 50, "You used Ibuprofen!"));
                Debug.Log("ibuprofen");
            }
            break;

        case HealType.Morphine:
            if (playerInventory.morphineAmount > 0)
            {
                playerInventory.morphineAmount--;
                StartCoroutine(battleSystem.UseHealItem(true, 120, "You used Morphine!"));
                Debug.Log("morphine");
            }
            break;
        }
    }
Exemplo n.º 10
0
 public ItemConsumable(string name, int id, string desc, int am, HealType heal)
     : base(name, id, desc, ItemType.Consumable)
 {
     this.amount   = am;
     this.healType = heal;
 }
 public void Heal(int amount, int healerId = 0, HealType healType = HealType.HEALTH)
 {
     throw new NotImplementedException();
 }