예제 #1
0
    private void Update()
    {
        if (CurrentHp <= 0)
        {
            print("OBJECT: " + gameObject.name + " WAS DESTROYED!");
            Ship      attachedShip      = GetComponent <Ship>();
            Structure attachedStructure = GetComponent <Structure>();

            if (attachedShip != null)
            {
                ShipsManager.RemoveShip(attachedShip);
            }
            else if (attachedStructure != null)
            {
                BuildingsManager.RemoveBuilding(attachedStructure);
            }

            Destroy(gameObject);
        }

        if (CurrentHp < maxHp)
        {
            if (Time.time >= afterCombatHealTimer)
            {
                if (Time.time >= timeBetweenHealsTimer)
                {
                    timeBetweenHealsTimer = Time.time + timeBetweenHeals;
                    CurrentHp            += healAmount;

                    if (CurrentHp > maxHp)
                    {
                        CurrentHp = maxHp;
                    }
                }
            }
        }
    }