敵の作成③(スーパークラスの作成)



EnemyBaseの作成
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// ★「abstract」キーワードを追加すると「抽象クラス」になる(ポイント)
public abstract class EnemyBase : MonoBehaviour
{
public int HP;
// ★「virtual」キーワードを追加すると、メソッドを「オーバーライド」できるようになる(ポイント)
public virtual void TakeDamage(int missilePower)
{
HP -= missilePower;
if (HP < 0)
{
Destroy(gameObject);
}
}
}


【2021版】Danmaku(基礎/全55回)
他のコースを見る


EnemyBaseの作成
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// ★「abstract」キーワードを追加すると「抽象クラス」になる(ポイント)
public abstract class EnemyBase : MonoBehaviour
{
public int HP;
// ★「virtual」キーワードを追加すると、メソッドを「オーバーライド」できるようになる(ポイント)
public virtual void TakeDamage(int missilePower)
{
HP -= missilePower;
if (HP < 0)
{
Destroy(gameObject);
}
}
}


敵の作成③(スーパークラスの作成)