示例#1
0
    private void TradeBloodForAmmo(float amountOfBlood)
    {
        if (HealthData.Value <= minimumHealth)
        {
            return;
        }

        float currentAmmo = AmmoData.Value;

        float usedBlood = (HealthData.Value - amountOfBlood < minimumHealth) ? HealthData.Value - minimumHealth : amountOfBlood;



        int gainedAmmo = (int)usedBlood * AmmoPerHealth;

        AmmoData.ApplyChange(usedBlood * AmmoPerHealth);

        // If there was a change in the ammo amount then call
        // events and deduct health
        if (currentAmmo != AmmoData.Value)
        {
            HealthData.ApplyChange(-usedBlood);
            OnBloodForAmmo.Invoke();
            OnBloodForAmmo_AmmoAmount.Invoke(gainedAmmo);
            OnBloodForAmmo_BloodAmount.Invoke(usedBlood);
        }
    }
 protected override void Attack()
 {
     if (thunderPowerData < minimumThunder)
     {
         return;
     }
     thunderPowerData.ApplyChange(-thunderLeechRate * Time.deltaTime);
 }
示例#3
0
    public void Activate()
    {
        // Debug.Log("Power Activation!");
        isFinished        = false;
        _defaultBoolValue = affectedBoolData ?? false;
        if (IsNumerical)
        {
            _defaultNumberValue = affectedFloatData.Value;
            affectedFloatData.ApplyChange(immediateFloatChange);
        }



        affectedBoolData?.SetValue(newValue);

        _beginningTime = Time.realtimeSinceStartup;

        if (!IsNotInstant)
        {
            isFinished = true;
        }
        Debug.Log($"Activate: {powerName}");
    }
示例#4
0
    private void Update()
    {
        currentPower.ApplyChange(ReplenishmentCurve.Value.Evaluate((currentPower.Value / maxPower.Value)) * Time.deltaTime);

        if (currentPower.Value > maxPower.Value)
        {
            currentPower.SetValue(maxPower.Value);
        }

        /*print(ReplenishmentCurve.Value.Evaluate(
         *      (currentPower / maxPower)) * Time.deltaTime);*/

        //print("Current Power = " + currentPower.Value);
    }
    public void EnemyDeath()
    {
        if (!_died)
        {
            _died = true;
        }

        if (hasDeathAnimation)
        {
            anim.SetTrigger("Die");
        }


        if (_usesWaypointMovement)
        {
            GetComponent <WaypointMovement>().GetCurrentWaypoint().ToggleOccupation();
        }
        else if (usesNavmesh)
        {
            GetComponent <NavMeshAgent>().enabled = false;
        }

        if (_lastDamageSource is Shotgun)
        {
            currentThunderPower.ApplyChange(ThunderPowerGift);
            OnShotgunKill.Invoke();
        }
        else if (_lastDamageSource is AreaofEffect)
        {
            OnAoEKill.Invoke();
        }
        else
        {
            OnDefaultKill.Invoke();
        }

        StartCoroutine(DestroyInSecs(0.4f));
    }