새로운 적 캐릭터 추가까지 진행된 소스코드
using UnityEngine;
using System.Collections;
public class ShotObj : MonoBehaviour {
protected float attackPower = 1;
public void InitShotObj(float setupAttackPower)
{
attackPower = setupAttackPower;
}
void OnTriggerEnter2D(Collider2D other)
{
if(other.CompareTag("enemy") || other.CompareTag("boss") )
{
AttackAndDestroy(other);
}
}
protected void AttackAndDestroy(Collider2D other)
{
IDamageable damageTarget =
(IDamageable)other.GetComponent(typeof(IDamageable));
damageTarget.Damage(attackPower);
transform.position = (Vector3.right * 30) + (Vector3.up * 10);
rigidbody2D.velocity = Vector2.zero;
}
}