Example #1
0
    public void Damage()
    {
        EnemyHP -= 1;

        //ボスが倒されたらクリアを呼ぶ
        if (EnemyHP <= 0)
        {
            GodTouches.RestartScript ResS = Maincamera.GetComponent <GodTouches.RestartScript> ();
            ResS.ClearAfter1Sec();
            this.gameObject.SetActive(false);
        }
    }
//敵に当たったら1ダメージ+無敵に入る
    void OnTriggerStay2D(Collider2D other)
    {
        if ((other.tag == "enemy" || other.tag == "nonDestroyableEnemy" || other.tag == "Boss") && muteki == false)
        {
            playerHP        -= 1;
            muteki           = true;
            rend.enabled     = false;
            HPbar.fillAmount = playerHP / playerFullHP;
            PlayerSEscript SEscript = this.gameObject.GetComponent <PlayerSEscript>();
            SEscript.damageSound();

            if (playerHP <= 0)
            {
                GodTouches.RestartScript ResS = Maincamera.GetComponent <GodTouches.RestartScript> ();
                ResS.GameOver();
                this.gameObject.SetActive(false);
            }
        }
    }