using System;
namespace Study04
{
public class App
{
public App()
{
Console.WriteLine("App클래스 생성자 호출됨");
Marine marine = new Marine(40); //매개변수 의미 : 최대 체력
marine.HitDamage(100, () => {
Console.WriteLine("마린이 죽었습니다.");
});
}
}
}
using System;
namespace Study04
{
public class Marine
{
public int maxHp;
public Marine(int maxHp)
{
this.maxHp = maxHp;
}
public void HitDamage(int damage, Action callback)
{
maxHp -= damage;
if (maxHp < 0)
{
callback();
}
}
}
}
'게임 알고리즘' 카테고리의 다른 글
3일차 람다식 연습문제6 (0) | 2024.08.16 |
---|---|
3일차 람다식 연습문제5 (0) | 2024.08.16 |
3일차 람다식 연습문제3 (0) | 2024.08.16 |
3일차 람다식 연습문제2 (0) | 2024.08.16 |
3일차 람다식 연습문제 1 (0) | 2024.08.16 |