Ejemplo n.º 1
0
    protected void UpdateHitPoints()
    {
        if (_hitPointsText == null)
        {
            //_hitPointsText = GameObject.FindGameObjectWithTag("HUD_HitPointsText").GetComponent<TextManager>();
            _hitPointHearts = GameObject.Find("HitPointHearts").GetComponent <HitPointScript>();
        }

        //_hitPointsText.ChangeText($"Hit Points: {CurrentHitPoints}/{MaxHitPoints}");

        if (CurrentHitPoints <= 0)
        {
            SceneManagerScript.RestartLevel();
        }

        _hitPointHearts.UpdateHitHearts(CurrentHitPoints);
    }
Ejemplo n.º 2
0
    protected override void OnTriggerEnter2D(Collider2D collision)
    {
        var gameObj      = collision.gameObject;
        var colliderType = collision.GetType();

        if (gameObj.layer == 9)
        {
            var displayText = gameObj.GetComponent <Portal>().DialogueText;
            var isLocked    = gameObj.GetComponent <Portal>().IsLocked;

            //trigger dialogue
            ActivateConfirmBox(displayText);
        }

        if (gameObj.tag == "Enemy" && colliderType == typeof(CircleCollider2D))
        {
            if (HitEnemy)
            {
                HitEnemy = false;
            }
            else
            {
                CurrentHitPoints--;
                UpdateHitPoints();
                Debug.Log($"Hit Points Now {CurrentHitPoints}");
                HitEnemy = true;
            }



            //HitEnemy = true;
            //gameObj.SetActive(false);
            //HitEnemy = false;

            //_returnPortal.SetActive(true);
        }

        if (gameObj.tag == "DeathTrigger")
        {
            SceneManagerScript.RestartLevel();
        }
    }