コード例 #1
0
        public override int ReceiveAndCalculateDamage(GameObject damagedBy, int damage, DamageType damageType,
                                                      BodyPartType bodyPartAim)
        {
            base.ReceiveAndCalculateDamage(damagedBy, damage, damageType, bodyPartAim);

            BodyPartBehaviour bodyPart = findBodyPart(bodyPartAim);             //randomise a bit here?

            bodyPart.ReceiveDamage(damageType, damage);

            if (isServer)
            {
                int bloodLoss = (int)(damage * BleedFactor(damageType));
                LoseBlood(bloodLoss);

                // don't start bleeding if limb is in ok condition after it received damage
                switch (bodyPart.Severity)
                {
                case DamageSeverity.Moderate:
                case DamageSeverity.Bad:
                case DamageSeverity.Critical:
                    AddBloodLoss(bloodLoss);
                    break;
                }
                if (headCritical(bodyPart))
                {
                    Crit();
                }
            }
            return(damage);
        }
コード例 #2
0
        /// placeholder based on old code
        public void SetBodyTypeOverlay(BodyPartBehaviour bodyPart)
        {
            foreach (var listener in UIManager.Instance.GetComponentsInChildren <DamageMonitorListener>())
            {
                if (listener.bodyPartType != bodyPart.Type)
                {
                    continue;
                }
                Sprite sprite;
                switch (bodyPart.Severity)
                {
                case DamageSeverity.None:
                    sprite = bodyPart.GreenDamageMonitorIcon; break;

                case DamageSeverity.Moderate:
                    sprite = bodyPart.YellowDamageMonitorIcon; break;

                case DamageSeverity.Bad:
                    sprite = bodyPart.OrangeDamageMonitorIcon; break;

                case DamageSeverity.Critical:
                    sprite = bodyPart.RedDamageMonitorIcon; break;

                default:
                    sprite = bodyPart.GrayDamageMonitorIcon; break;
                }
                listener.GetComponent <Image>().sprite = sprite;
            }
        }
コード例 #3
0
    /// <summary>
    /// Determine if there is any blood damage (toxin, oxygen loss) or bleeding that needs to occur
    /// Server only!
    /// </summary>
    public void AffectBloodState(BodyPartType bodyPartType, DamageType damageType, float amount, bool isHeal = false)
    {
        BodyPartBehaviour bodyPart = livingHealthBehaviour.FindBodyPart(bodyPartType);

        if (isHeal)
        {
            CheckHealing(bodyPart, damageType, amount);
            return;
        }

        //Check if limb should start bleeding (Bleeding is only for Players, not animals)
        if (damageType == DamageType.Brute)
        {
            int bloodLoss = (int)(Mathf.Clamp(amount, 0f, 10f) * BleedFactor(damageType));
            // start bleeding if the limb is really damaged
            if (bodyPart.BruteDamage > 40)
            {
                AddBloodLoss(bloodLoss, bodyPart);
            }
        }

        if (damageType == DamageType.Tox)
        {
            ToxinLevel += amount;
        }
    }
コード例 #4
0
 public override void TriggerReaction(BodyPartBehaviour from, InteractionAction.InteractionActionType actionType, string jsonParam)
 {
     if (actionType == InteractionAction.InteractionActionType.BounceOff)
     {
         rigidBody.AddForce((from.transform.position - transform.position).normalized * -1 * pushOffForceRatio, ForceMode2D.Force);
         rigidBody.velocity = Vector2.ClampMagnitude(rigidBody.velocity, maximumSpeed);
     }
 }
コード例 #5
0
 /// <summary>
 /// Subtract an amount of blood from the player. Server Only
 /// </summary>
 public void AddBloodLoss(int amount, BodyPartBehaviour bodyPart)
 {
     if (amount <= 0)
     {
         return;
     }
     TryBleed(bodyPart);
 }
コード例 #6
0
 public override void TriggerReaction(BodyPartBehaviour from, InteractionAction.InteractionActionType actionType, string jsonParam)
 {
     if (actionType == InteractionAction.InteractionActionType.Destroy)
     {
         Instantiate(destroyParticleEffect, transform.position, Quaternion.identity);
         Destroy(gameObject);
     }
 }
コード例 #7
0
 private void TryBleed(BodyPartBehaviour bodyPart)
 {
     bodyPart.isBleeding = true;
     //don't start another coroutine when already bleeding
     if (!IsBleeding)
     {
         IsBleeding = true;
     }
 }
コード例 #8
0
ファイル: HealsTheLiving.cs プロジェクト: ynot01/unitystation
    private void ServerApplyHeal(BodyPartBehaviour targetBodyPart)
    {
        targetBodyPart.HealDamage(40, healType);
        stackable.ServerConsume(1);

        HealthBodyPartMessage.Send(targetBodyPart.livingHealthBehaviour.gameObject, targetBodyPart.livingHealthBehaviour.gameObject,
                                   targetBodyPart.Type, targetBodyPart.livingHealthBehaviour.GetTotalBruteDamage(),
                                   targetBodyPart.livingHealthBehaviour.GetTotalBurnDamage());
    }
コード例 #9
0
 /// <summary>
 /// Stops bleeding on all bodyparts. Server Only.
 /// </summary>
 public void StopBleedingAll()
 {
     for (int i = 0; i < livingHealthBehaviour.BodyParts.Count; i++)
     {
         BodyPartBehaviour BPB = livingHealthBehaviour.BodyParts[i];
         BPB.isBleeding = false;
     }
     IsBleeding = false;
 }
コード例 #10
0
 private void ApplyHeal(BodyPartBehaviour targetBodyPart)
 {
     targetBodyPart.HealDamage(40, healType);
     amount--;
     if (amount == 0)
     {
         DisappearObject();
     }
 }
コード例 #11
0
 private void ApplyHeal(BodyPartBehaviour targetBodyPart)
 {
     targetBodyPart.HealDamage(40, healType);
     amount--;
     if (amount == 0)
     {
         GetComponent <CustomNetTransform>().DisappearFromWorldServer();
     }
 }
コード例 #12
0
    private void ServerSelfHeal(GameObject originator, BodyPartBehaviour targetBodyPart)
    {
        void ProgressComplete()
        {
            ServerApplyHeal(targetBodyPart);
        }

        StandardProgressAction.Create(ProgressConfig, ProgressComplete)
        .ServerStartProgress(originator.RegisterTile(), 5f, originator);
    }
コード例 #13
0
 private void ApplyHeal(BodyPartBehaviour targetBodyPart)
 {
     targetBodyPart.HealDamage(40, healType);
     timesUsed++;
     Logger.LogTraceFormat("{0} uses left.", Category.Health, uses - timesUsed);
     if (uses == timesUsed)
     {
         GetComponent <CustomNetTransform>().DisappearFromWorldServer();
     }
 }
コード例 #14
0
 private void ApplyHeal(BodyPartBehaviour targetBodyPart)
 {
     targetBodyPart.HealDamage(40, healType);
     timesUsed++;
     Logger.LogTraceFormat("{0} uses left.", Category.Health, uses - timesUsed);
     if (uses == timesUsed)
     {
         Despawn.ServerSingle(gameObject);
     }
 }
コード例 #15
0
 public override void TriggerReaction(BodyPartBehaviour from, InteractionAction.InteractionActionType actionType, string jsonParam)
 {
     if (actionType == InteractionAction.InteractionActionType.SuckToMe)
     {
         rigidBody.AddForce((from.transform.position - transform.position).normalized * suckForceRatio, ForceMode2D.Force);
         rigidBody.velocity = Vector2.ClampMagnitude(rigidBody.velocity, maximumSpeed);
         if (Vector2.SqrMagnitude(transform.position - from.transform.position) <= 1f)
         {
             Destroy(gameObject);
         }
     }
 }
コード例 #16
0
 /// <summary>
 /// Stops bleeding on the selected bodypart. The bloodsystem continues bleeding if there's another bodypart bleeding. Server Only.
 /// </summary>
 public void StopBleeding(BodyPartBehaviour bodyPart)
 {
     bodyPart.isBleeding = false;
     for (int i = 0; i < livingHealthBehaviour.BodyParts.Count; i++)
     {
         BodyPartBehaviour BPB = livingHealthBehaviour.BodyParts[i];
         if (BPB.isBleeding)
         {
             return;
         }
     }
     IsBleeding = false;
 }
コード例 #17
0
    /// <summary>
    /// Update the PlayerHealth body part hud icon
    /// </summary>
    /// <param name="bodyPart"> Body part that requires updating </param>
    public void SetBodyTypeOverlay(BodyPartBehaviour bodyPart)
    {
        for (int i = 0; i < bodyPartListeners.Count; i++)
        {
            if (bodyPartListeners[i].bodyPartType != bodyPart.Type)
            {
                continue;
            }
            if (bodyPartListeners[i] != null)
            {
                Color damageColor;
                Color bodyPartColor = Color.white;
                switch (bodyPart.Severity)
                {
                case DamageSeverity.None:
                    damageColor = damageMonitorColors[0];
                    break;

                case DamageSeverity.Light:
                    damageColor = damageMonitorColors[1];
                    break;

                case DamageSeverity.LightModerate:
                    damageColor = damageMonitorColors[2];
                    break;

                case DamageSeverity.Moderate:
                    damageColor = damageMonitorColors[3];
                    break;

                case DamageSeverity.Bad:
                    damageColor = damageMonitorColors[4];
                    break;

                case DamageSeverity.Critical:
                    damageColor   = damageMonitorColors[5];
                    bodyPartColor = disabledBodyPartColor;
                    break;

                case DamageSeverity.Max:
                default:
                    damageColor   = damageMonitorColors[6];
                    bodyPartColor = destroyedBodyPartColor;
                    break;
                }

                bodyPartListeners[i].SetDamageColor(damageColor);
                bodyPartListeners[i].SetBodyPartColor(bodyPartColor);
            }
        }
    }
コード例 #18
0
    /// <summary>
    /// Update the PlayerHealth body part hud icon
    /// </summary>
    /// <param name="bodyPart"> Body part that requires updating </param>
    public void SetBodyTypeOverlay(BodyPartBehaviour bodyPart)
    {
        for (int i = 0; i < bodyPartListeners.Count; i++)
        {
            if (bodyPartListeners[i].bodyPartType != bodyPart.Type)
            {
                continue;
            }
            Sprite sprite;
            switch (bodyPart.Severity)
            {
            case DamageSeverity.None:
                sprite = bodyPart.BlueDamageMonitorIcon;
                break;

            case DamageSeverity.Light:
                sprite = bodyPart.GreenDamageMonitorIcon;
                break;

            case DamageSeverity.LightModerate:
                sprite = bodyPart.YellowDamageMonitorIcon;
                break;

            case DamageSeverity.Moderate:
                sprite = bodyPart.OrangeDamageMonitorIcon;
                break;

            case DamageSeverity.Bad:
                sprite = bodyPart.DarkOrangeDamageMonitorIcon;
                break;

            case DamageSeverity.Critical:
                sprite = bodyPart.RedDamageMonitorIcon;
                break;

            case DamageSeverity.Max:
            default:
                sprite = bodyPart.GrayDamageMonitorIcon;
                break;
            }
            if (sprite != null && bodyPartListeners[i] != null && bodyPartListeners[i].image != null)
            {
                bodyPartListeners[i].image.sprite = sprite;
            }
        }
    }
コード例 #19
0
    /// <summary>
    /// Where the blood pumping action happens
    /// </summary>
    void PumpBlood()
    {
        if (IsBleeding)
        {
            float bleedVolume = 0;
            for (int i = 0; i < livingHealthBehaviour.BodyParts.Count; i++)
            {
                BodyPartBehaviour BPB = livingHealthBehaviour.BodyParts[i];
                if (BPB.isBleeding)
                {
                    bleedVolume += (BPB.BruteDamage * 0.013f);
                }
            }
            LoseBlood(bleedVolume);
        }

        //TODO things that could affect heart rate, like low blood, crit status etc
    }
コード例 #20
0
    /// <summary>
    /// Determine if there is any blood damage (toxin, oxygen loss) or bleeding that needs to occur
    /// Server only!
    /// </summary>
    public void AffectBloodState(BodyPartType bodyPartType, DamageType damageType, float amount, bool isHeal = false)
    {
        BodyPartBehaviour bodyPart = livingHealthBehaviour.FindBodyPart(bodyPartType);

        if (isHeal)
        {
            CheckHealing(bodyPart, damageType, amount);
            return;
        }

        //Check if limb should start bleeding (Bleeding is only for Players, not animals)
        if (damageType == DamageType.Brute)
        {
            int bloodLoss = (int)(Mathf.Clamp(amount, 0f, 10f) * BleedFactor(damageType));
            // don't start bleeding if limb is in ok condition after it received damage
            switch (bodyPart.Severity)
            {
            case DamageSeverity.Light:
            case DamageSeverity.LightModerate:
            case DamageSeverity.Moderate:
            case DamageSeverity.Bad:
            case DamageSeverity.Critical:
                LoseBlood(bloodLoss);
                AddBloodLoss(bloodLoss);
                break;

            default:
                //For particularly powerful hits when a body part is fine
                if (amount > 40)
                {
                    LoseBlood(bloodLoss);
                    AddBloodLoss(bloodLoss);
                }
                break;
            }
        }

        if (damageType == DamageType.Tox)
        {
            ToxinLevel += amount;
        }
    }
コード例 #21
0
 private void SelfHeal(GameObject originator, BodyPartBehaviour targetBodyPart)
 {
     if (!isSelfHealing)
     {
         var progressFinishAction = new FinishProgressAction(
             reason =>
         {
             if (reason == FinishProgressAction.FinishReason.INTERRUPTED)
             {
                 isSelfHealing = false;
             }
             else if (reason == FinishProgressAction.FinishReason.COMPLETED)
             {
                 ApplyHeal(targetBodyPart);
                 isSelfHealing = false;
             }
         }
             );
         isSelfHealing = true;
         UIManager.ProgressBar.StartProgress(originator.transform.position.RoundToInt(), 5f, progressFinishAction, originator);
     }
 }
コード例 #22
0
 //Do any healing stuff:
 private void CheckHealing(BodyPartBehaviour bodyPart, DamageType damageType, float healAmt)
 {
     //TODO: PRIORITY! Do Blood healing!
     Logger.Log("Not implemented: Blood healing.", Category.Health);
 }
コード例 #23
0
    private static void Bleed(PlayerScript ps, TortureSeverity severity)
    {
        BodyPartBehaviour bodyPart = ps.playerHealth.FindBodyPart(BodyPartType.Chest);

        ps.playerHealth.bloodSystem.AddBloodLoss(( int )Mathf.Pow(2, ( float )severity), bodyPart);
    }
コード例 #24
0
    private void SelfHeal(GameObject originator, BodyPartBehaviour targetBodyPart)
    {
        var progressFinishAction = new ProgressCompleteAction(() => ApplyHeal(targetBodyPart));

        UIManager.ServerStartProgress(ProgressAction.SelfHeal, originator.transform.position.RoundToInt(), 5f, progressFinishAction, originator);
    }
コード例 #25
0
 public abstract void TriggerReaction(BodyPartBehaviour from, InteractionAction.InteractionActionType actionType, string jsonParam);
コード例 #26
0
 private void ServerApplyHeal(BodyPartBehaviour targetBodyPart)
 {
     targetBodyPart.HealDamage(40, healType);
     stackable.ServerConsume(1);
 }
コード例 #27
0
 //Do any healing stuff:
 private void CheckHealing(BodyPartBehaviour bodyPart, DamageType damageType, int healAmt)
 {
     Debug.Log("TODO PRIORITY: Do Blood Healing!!");
 }
コード例 #28
0
 private static bool headCritical(BodyPartBehaviour bodyPart)
 {
     return(bodyPart.Type.Equals(BodyPartType.HEAD) && bodyPart.Severity == DamageSeverity.Critical);
 }