Resource.Remove C# (CSharp) Method

Remove() public method

public Remove ( float amount ) : void
amount float
return void
    public void Remove(float amount)
    {
        amountLeft -= amount;
        if (amountLeft < 0)
        {
            amountLeft = 0;
        }
        if (hitPoints > (int)amountLeft)
        {
            TakeDamage(hitPoints - (int)amountLeft);
        }
    }

Usage Example

Exemplo n.º 1
0
    private void Collect()
    {
        if (audioElement != null && Time.timeScale > 0)
        {
            audioElement.Play(harvestSound);
        }
        float collect = collectionAmount * Time.deltaTime;

        // Make sure that the harvester cannot collect more than it can carry
        if (currentLoad + collect > capacity)
        {
            collect = capacity - currentLoad;
        }

        if (resourceDeposit.isEmpty())
        {
            Arms[] arms = GetComponentsInChildren <Arms>();
            foreach (Arms arm in arms)
            {
                arm.renderer.enabled = false;
            }
            DecideWhatToDo();
        }
        else
        {
            resourceDeposit.Remove(collect);
        }

        currentLoad += collect;
    }
All Usage Examples Of Resource::Remove