Пример #1
0
    // ReSharper disable Unity.PerformanceAnalysis
    public void AngleChecker()
    {
        if (Mathf.Abs(transform.rotation.z) > 0.5f)
        {
            if (!CompetitorMode)
            {
                if ((int)_angleTime == (int)AngleTIMER)
                {
                    HudObj.TurnOverCounter(true);
                }

                _angleTime -= Time.fixedDeltaTime;

                if (_angleTime <= 0)
                {
                    var position = transform.position;
                    position           = new Vector3(position.x, position.y + 2f, position.z);
                    transform.position = position;
                    transform.rotation = Quaternion.Euler(0, 0, 0);
                    CarObj.RecountHealth(-1);

                    HudObj.TurnOverCounter(false);
                    _angleTime = AngleTIMER;
                }
                else
                {
                    var obj = HudObj.AngleTimerObj;
                    if (obj is { })
Пример #2
0
    private void OnItemCollision(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("Coin"))
        {
            Destroy(collision.gameObject);
            CarObj.Coins += 1;
            if (!CarObj.CompetitorMode)
            {
                HudObj.ShowCoinsUI();
            }
            if (SfxManagerObj != null)
            {
                SfxManagerObj.PlayCoinSfx();
            }
        }

        if (!collision.gameObject.CompareTag($"HP"))
        {
            return;
        }
        Destroy(collision.gameObject);
        if (CarObj != null)
        {
            CarObj.RecountHealth(+1);
        }
    }
Пример #3
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.CompareTag("MaxX"))  // Finish
        {
            ScoreboardObj.PushPlaceholderValue(gameObject.name);

            //Finish Scene
            if (gameObject.layer == LayerMask.NameToLayer("Player") && !CarObj.IsFinished)
            {
                CarObj.IsFinished = true;
                HudObj.Finish();
            }
        }

        OnItemCollision(collision);
    }
Пример #4
0
    public void RecountHealth(int deltaHealth)
    {
        Health += deltaHealth;

        if (Health <= 0)
        {
            Health = 0;
            if (!CompetitorMode)
            {
                HudObj.MakeRestartScreen();
            }
        }

        if (Health > MAXHealth)
        {
            Health = MAXHealth;
        }

        if (!CompetitorMode)
        {
            HudObj.MakeHp();
        }
    }