public void FillBoost()
    {
        boost.ApplyChange(boostFillRate);

        if (boost.Value > 1)
        {
            boost.SetValue(1f);
        }
    }
Exemplo n.º 2
0
    public void TakeDamage(float damage)
    {
        currentHP.ApplyChange(-damage);

        if (IsDeath())
        {
            currentHP.SetValue(0.0f);
        }
    }
Exemplo n.º 3
0
    public void ConsumeMP(float mana)
    {
        currentMP.ApplyChange(-mana);

        if (IsEmptyMana())
        {
            currentMP.SetValue(0.0f);
        }
    }
Exemplo n.º 4
0
 void OnTriggerEnter2D(Collider2D collision)
 {
     if (Random.value > 0.25)
     {
         point.ApplyChange(1);
     }
     else
     {
         point.ApplyChange(2);
     }
 }
    void EndMatch()
    {
        if (totalRuns > totalEnemyRuns)
        {
            m_result.text = "WIN!";
            m_money.ApplyChange(3);
            m_fame.ApplyChange(3);
        }
        else if (totalRuns == totalEnemyRuns)
        {
            m_result.text = "DRAW";
            //m_money.ApplyChange(m_fame.Value);
        }
        else
        {
            m_result.text = "LOST";
            //m_money.ApplyChange(m_fame.Value);
            //m_fame.ApplyChange(-1);
        }


        for (int i = 0; i < m_orderManager.order.Length; i++)
        {
            m_orderManager.order[i].stats.Refresh();
        }

        m_totalScores.ApplyChange(totalRuns);
    }
Exemplo n.º 6
0
 private void IncrementScore()
 {
     if (score != null)
     {
         score.ApplyChange(50);
     }
 }
Exemplo n.º 7
0
    /// <summary>
    /// Обновляем количество ХП у игрока
    /// </summary>
    /// <param name="value"></param>
    /// <param name="equalize"></param>
    private void ChangeHP(float value, bool equalize = false)
    {
        if (currentHP != null)
        {
            if (equalize)
            {
                currentHP.SetValue(value);
            }
            else
            {
                currentHP.ApplyChange(value);
            }
        }
        else
        {
            Debug.LogError("CurrentHP is null for @" + this.name);
        }

        if (hpValueChangedEvent != null)
        {
            hpValueChangedEvent.Raise();
        }
        else
        {
            Debug.LogError("HPValueChangedEvent is null for @" + this.name);
        }
    }
Exemplo n.º 8
0
    private void CollectCoin()
    {
        if (scoreVariable != null && coinValue != null)
        {
            scoreVariable.ApplyChange(coinValue);
        }
        else
        {
            Debug.LogError("ScoreVariable or/and CoinValue is null for " + this.name);
        }

        if (coinCollectedEvent != null)
        {
            coinCollectedEvent.Raise();
        }
        else
        {
            Debug.LogError("CoinCollectedEvent is null for " + this.name);
        }

        if (energizer)
        {
            if (energizerCollectedEvent != null)
            {
                energizerCollectedEvent.Raise();
            }
            else
            {
                Debug.LogError("EnergizerCollectedEvent is null for " + this.name);
            }
        }
        this.gameObject.SetActive(false);
    }
Exemplo n.º 9
0
        public void AddScore()
        {
            float score = 100 * scoreMultiplier.GetValue();

            totalScore.ApplyChange(score);
            currentScore.ApplyChange(score);
        }
Exemplo n.º 10
0
    public void scorePointsRespawn()
    {
        float pointsToAdd = levelTimeVar.Value * 2f;

        score.ApplyChange(pointsToAdd);
        resetTimer();
        scorePoint.Invoke();
    }
Exemplo n.º 11
0
    private IEnumerator InitiateDash(Vector2 inputAxis)
    {
        OnStartDash.Raise();

        if (inputAxis == Vector2.zero)
        {
            inputAxis = Vector2.up;
        }

        m_Rigidbody.useGravity = false;
        m_Rigidbody.velocity   = Vector3.zero;

        canDash.SetValue(false);
        isDashing.SetValue(true);
        m_Rigidbody.drag = dashDrag.Value;
        currentDashCooldown.SetValue(0);

        float currentDashDuration = 0;

        while (currentDashCooldown.Value <= dashDuration)
        {
            m_Rigidbody.velocity = inputAxis * dashSpeed.Value;
            currentDashCooldown.ApplyChange(Time.deltaTime);

            yield return(null);
        }

        OnFinishDash.Raise();

        isDashing.SetValue(false);
        m_Rigidbody.velocity = m_Rigidbody.velocity.normalized * currentTargetSpeed.Value;


        while (currentDashCooldown.Value <= dashCooldown)
        {
            currentDashCooldown.ApplyChange(Time.deltaTime);
            yield return(null);
        }
        currentDashCooldown.SetValue(0);
        canDash.SetValue(true);

        OnFinishDashCD.Raise();


        yield return(0);
    }
Exemplo n.º 12
0
 private void DealDamage(FloatReference damage)
 {
     HP.ApplyChange(-damage);
     if (HP.Value <= 0.0f)
     {
         DeathEvent.Invoke();
     }
 }
Exemplo n.º 13
0
 IEnumerator count()
 {
     while (levelTimeVar.Value > -1)
     {
         levelTimeVar.ApplyChange(-1f);
         updateTimer.Invoke();
         yield return(new WaitForSeconds(1f));
     }
 }
Exemplo n.º 14
0
 public void looseLife()
 {
     lives.ApplyChange(-1f);
     looseLive.Invoke();
     if (lives.Value <= 0f)
     {
         deathEvent.Invoke();
     }
 }
Exemplo n.º 15
0
 private void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.CompareTag("Player") && !enterThisField.Value)
     {
         points.ApplyChange(pointsEarned);
         scorePoints.Invoke();
         enterThisField.setValue(true);
     }
 }
Exemplo n.º 16
0
    private void OnTriggerEnter(Collider other)
    {
        DamageDealer damage = other.gameObject.GetComponent <DamageDealer>();

        if (damage != null)
        {
            HP.ApplyChange(-damage.DamageAmount);
        }
    }
    private void OnTriggerEnter(Collider other)
    {
        PointIncrease point = other.gameObject.GetComponent <PointIncrease>();

        if (point != null)
        {
            Points.ApplyChange(+point.PointAmount);
            PointAdd.Invoke();
            Destroy(gameObject);
        }
    }
Exemplo n.º 18
0
 public void TakeDamage(float damage)
 {
     if (damage > 0)
     {
         HP.ApplyChange(-damage);
         OnPlayerDamagedEvent.Invoke();
     }
     if (HP.Value <= 0)
     {
         OnPlayerDeathEvent.Invoke();
     }
 }
Exemplo n.º 19
0
        public override void Exit()
        {
            base.Exit();
            if (hasBroken)
            {
                scoreMultiplier.ApplyChange(multipliers.comboMultiplier);
                OnBreak?.Invoke();
            }

            breakableList.Clear();
            pendingBlocks.Clear();
        }
Exemplo n.º 20
0
    private void OnTriggerEnter(Collider other)
    {
        ProjectileBase projectile = other.gameObject.GetComponent <ProjectileBase>();

        currentHealth.ApplyChange(-projectile.DamageAmount);

        if (currentHealth.Value <= 0)
        {
            Debug.Log("The PLayer is Dead!");
            Destroy(gameObject);
        }
    }
Exemplo n.º 21
0
    public void ConstantUpdate()
    {
        YearsPlayed.ApplyChange(Time.deltaTime);

        elapsedTime += Time.deltaTime;

        if (elapsedTime >= UpdateSeconds)
        {
            UpdateResourcesValue();

            elapsedTime = 0;
        }
    }
Exemplo n.º 22
0
    private void HandleDamage(DamageDealer damage)
    {
        if (damage != null)
        {
            HP.ApplyChange(-damage.DamageAmount);
            DamageEvent.Invoke();
        }

        if (HP.Value <= 0.0f)
        {
            DeathEvent.Invoke();
        }
    }
Exemplo n.º 23
0
 // Update is called once per frame
 void FixedUpdate()
 {
     if (playerAlive.value == true)
     {
         if (Time.timeScale > 0f)
         {
             score.ApplyChange(Time.deltaTime * 100);
         }
     }
     else if (!visible)
     {
         GameOver();
     }
 }
    IEnumerator RegenResource()
    {
        while (currentValue.Value < startingValue.Value)
        {
            yield return(new WaitForSeconds(1f));

            if (currentValue.Value >= startingValue.Value)
            {
                regenerating = false;
            }
            else
            {
                if (RegenRate != null)
                {
                    currentValue.ApplyChange(RegenRate.Value);
                }
                else
                {
                    currentValue.ApplyChange(0f);
                }
            }
        }
    }
Exemplo n.º 25
0
    private void OnTriggerEnter(Collider other)
    {
        DamageDeal damage = other.gameObject.GetComponent <DamageDeal>();

        if (damage != null)
        {
            HP.ApplyChange(-damage.DamageAmount);
            DamageEvent.Invoke();
        }

        if (HP.Value <= 0.0f)
        {
            DeathEvent.Invoke();
        }
    }
Exemplo n.º 26
0
 void FixedUpdate()
 {
     if (playerAlive.value == true)
     {
         if (Time.timeScale > 0f)
         {
             score.ApplyChange(Time.deltaTime * 100);
         }
     }
     else if (visible != true)
     {
         GameOver();
         pauseButton.transform.localScale = Vector3.zero;
     }
 }
Exemplo n.º 27
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.CompareTag("Player"))
        {
            timesLevelIsComplete.ApplyChange(1f);

            if (timesLevelIsComplete.Value >= 3)
            {
                completeLevel.Invoke();
            }
            else
            {
                respawn.Invoke();
            }
        }
    }
Exemplo n.º 28
0
    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.GetComponent <CarController>())
        {
            if (trialsDone.Value >= maxTrials.Value)
            {
                TrainingHandler.Instance.GoToMainExperiment();
                _resetPosition = respawnPointTrialFailed.transform;
            }

            ResetCar(other.gameObject);
            trialsDone.ApplyChange(1);

            StartCoroutine(TakeAwayControl(other));
        }
    }
Exemplo n.º 29
0
 /// <summary>
 /// Проверяем окончен ли уроень
 /// </summary>
 private void EndLvlController()
 {
     if (activeCoinsSet.Items.Count <= 0)
     {
         gameOver = true;
         currentLvl.ApplyChange(+1);
         if (updateLVLEvent != null)
         {
             updateLVLEvent.Raise();
         }
         else
         {
             Debug.LogError("UpdateLVLEvent is null for @" + this.name);
         }
         StartLvl();
     }
 }
Exemplo n.º 30
0
    /// <summary>
    /// Takes the damage.
    /// </summary>
    /// <returns>The damage really taken.</returns>
    /// <param name="damage">Damage.</param>
    public float TakeDamage(float damage)
    {
        if (Time.time > nextTime)
        {
            HP.ApplyChange(-damage);
            nextTime = Time.time + invincibleTime;
            Debug.Log("apply health change " + Time.time + ", " + nextTime);

            if (HP.Value <= 0.0f)
            {
                DeathEvent.Invoke();
            }
            return(damage);
        }
        else
        {
            return(0);
        }
    }