예제 #1
0
        private void Awake()
        {
            _instance = this;

            text           = GetComponentInChildren <TextMeshPro>();
            rigidBody      = GetComponent <Rigidbody2D>();
            spriteRenderer = GetComponent <SpriteRenderer>();
            camera         = Camera.main;
            arm            = transform.Find("Arm");
            _invulnerable  = 0.2f;

            _score  = 0;
            _health = 6;
            UpdateHealthText();
            menu.SetActive(false);
        }
예제 #2
0
        public void HurtMe(Vector3 direction)
        {
            if (_invulnerable > 0)
            {
                return;
            }
            rigidBody.AddForce(
                direction.normalized * 8 + Vector3.up * 2,
                ForceMode2D.Impulse
                );
            health       -= 1;
            _invulnerable = 1.5f;

            if (health < 0)
            {
                HackAndSlasher.IncreaseScore();
                Destroy(gameObject);
            }
        }