コード例 #1
0
    void Update()
    {
        invulnTimer -= Time.deltaTime;
        if (invulnTimer <= 0)
        {
            gameObject.layer = correctlayer;
            if (spriteRend != null)
            {
                spriteRend.enabled = true;
            }
            else
            {
                if (spriteRend != null)
                {
                    spriteRend.enabled = !spriteRend.enabled; //invert state to toggle on/off
                }
            }
        }
        if (health <= 0)
        {
            gameController.AddScore(ScoreValue); //Using Strategy Pattern:to call Gamecontroller to add to the score when an enemy is killed.
            EDead();

            AudioManager.Instance.PlaySFX(deathsfx, 3.0f);

            Debug.Log("Enemy dead add score");
        }
    }