Example #1
0
    public void CalcAndApplyExplosionDamage(string thanksTo)
    {
        Vector2 explosionPos = objectBehaviour.AssumedLocation().To2Int();
        int     length       = colliders.Count;
        Dictionary <GameObject, int> toBeDamaged = new Dictionary <GameObject, int>();

        for (int i = 0; i < length; i++)
        {
            Collider2D localCollider = colliders[i];
            GameObject localObject   = localCollider.gameObject;

            Vector2 localObjectPos = localObject.transform.position;
            float   distance       = Vector3.Distance(explosionPos, localObjectPos);
            float   effect         = 1 - ((distance + distance) / ((radius + radius) + minDamage));
            int     actualDamage   = (int)(damage * effect);

            if (NotSameObject(localCollider) && HasHealthComponent(localCollider))
            //todo check why it's reaching negative values anyway)
            {
                if (IsWithinReach(explosionPos, localObjectPos, distance) && HasEffectiveDamage(actualDamage))
                {
                    toBeDamaged[localObject] = actualDamage;
                }
            }
        }

        foreach (KeyValuePair <GameObject, int> pair in toBeDamaged)
        {
            pair.Key.GetComponent <LivingHealthBehaviour>()
            .ApplyDamage(pair.Key, pair.Value, DamageType.Burn);
        }
    }
Example #2
0
    private void MonitorSystem()
    {
        if (!livingHealthBehaviour.IsDead)
        {
            Vector3Int   position = objectBehaviour.AssumedLocation().RoundToInt();
            MetaDataNode node     = MatrixManager.GetMetaDataAt(position);
            PressureStatus = CheckPressureStatus(node.GasMix.Pressure);
            TempStatus     = CheckTempStatus(node.GasMix.Temperature);
            if (!IsEVACompatible())
            {
                CheckPressureDamage(node.GasMix.Pressure);
            }

            if (livingHealthBehaviour.OverallHealth >= HealthThreshold.SoftCrit)
            {
                if (Breathe(node))
                {
                    AtmosManager.Update(node);
                }
            }
            else
            {
                bloodSystem.OxygenDamage += 1;
            }
        }
    }
Example #3
0
 //returns position of highest object this object is contained in
 public Vector3 AssumedLocation()
 {
     //If this object is contained in another, run until highest layer layer is reached
     if (parentContainer != null)
     {
         return(parentContainer.AssumedLocation());
     }
     return(transform.position);
 }
Example #4
0
    //returns position of highest object this object is contained in
    public Vector3 AssumedLocation()
    {
        //If this object is contained in another, run until highest layer layer is reached
        if (parentContainer != null)
        {
            lastNonHiddenPosition = parentContainer.AssumedLocation();
        }
        else if (registerTile.WorldPosition != TransformState.HiddenPos)
        {
            lastNonHiddenPosition = registerTile.WorldPosition;
        }

        return(lastNonHiddenPosition);
    }
    // Handles rendering logic, only runs when this sprite is on camera
    private void OnWillRenderObject()
    {
        //don't run check until player is created
        if (PlayerManager.LocalPlayer == null)
        {
            return;
        }
        //Allows getting parent's assumed position if inside object
        ObjectBehaviour objectBehaviour = PlayerManager.LocalPlayerScript.pushPull;

        //recalculate if it is facing the player
        bool visible = wallmountBehavior.IsFacingPosition(objectBehaviour.AssumedLocation());

        spriteRenderer.color = new Color(spriteRenderer.color.r, spriteRenderer.color.g, spriteRenderer.color.b, visible ? 1 : 0);
    }
Example #6
0
    private void MonitorSystem()
    {
        if (!livingHealthBehaviour.IsDead)
        {
            Vector3Int   position = objectBehaviour.AssumedLocation().RoundToInt();
            MetaDataNode node     = MatrixManager.GetMetaDataAt(position);

            if (!IsEVACompatible())
            {
                CheckPressureDamage(node.GasMix.Pressure);
            }

            if (Breathe(node))
            {
                AtmosManager.Update(node);
            }
        }
    }