bombCrate -> crate, parachute
FloatDown 애니(떨어질때 흔들흔들하는모션) 와 BombLanding(떨어지고 나서 낙하산이 없어지는모션) 애니로 구성되있음
landed -> 현재 땅인지 체크
폭탄은 서클 콜라이더와 박스 콜라이더로 구성되있고 서클콜라이더는 is Trigger 체크 되있음
그래서 OnTriggerEnter 함수를 호출할수잇음. 박스콜라이더는 땅과 부딪히게 할려고 부착한 상태인듯. isTrigger 시 충돌 무시해버리고 통과되기때문.
Player 와 부딪힐 경우에는 플레이어의 폭탄 개수를 늘려주고 삭제해버림.
그리고 땅과 부딪힐경우에는 else if(other.tag == "ground" && !landed)
Ladn 애니메이션을 실행시키고
Create 폭탄의 부모 오브젝트를 null값으로 만들어준다.
그리고 리지드바디를 추가시킴(추가가 안될시 플레이어와 물리효과를 집어널수없기때문,.)
explosionParticle -> 은 히어라이키에 한개만 존재함 이함수를 재활요해서 계속 사용함
폭탄관련함수
if(transform.root == transform)
StartCoroutine(BombDetonation());
플레이어가 알트 버튼을 눌러서 폭파 시킬때 실행됨 최상위 오브젝트가 없을때(Create일때) -> LayBombs 스크립트에서 실행
Explode() -> 외부에서 실행됨 폭탄이 내려오는데 플레이어가 총으로 맞춘다던가
bombLaid 를 false로 만들어줌.
pickupSpawner -> 픽업매니저 스크립트 -> PickupSpawner 구급상자와 폭탄 생성
pickupSpawner.StartCoroutine(pickupSpawner.DeliverPickup()); -> 아이템 재생성
Collider2D[] enemies = Physics2D.OverlapCircleAll(transform.position, bombRadius, 1 << LayerMask.NameToLayer("Enemies"));
적들의 체력을 0으로 만들고 적들을 튕겨내버림
explosionFX.transform.position = transform.position;
explosionFX.Play();
이펙트 위치 설정 및 실행
플레이어에 붙어있는 스크립트
bombLaid -> 폭탄 발사여부 - > Explode 함수가 실행되야 false로 변함
bombCount -> 폭탄 개수
알트 버튼 누르면 발사
'잡다한것들전부 > 공식예제' 카테고리의 다른 글
| 몬스터 관련 함수 - Enemy 스크립트 (0) | 2014.02.25 |
|---|---|
| 점수 표현 - Score (0) | 2014.02.25 |
| 폭탄과 구급 상자 - Bomb Pickup, Bomb (0) | 2014.02.25 |
| 물체 파괴 함수 -> Destroyer 스크립트 (0) | 2014.02.25 |
| killTrigger -> 모든 적과 주인공 충돌(강) - Removver 스크립트 (0) | 2014.02.25 |
| 플레이어의 체력 - PlayerHealth (0) | 2014.02.25 |
explosionCircle -> 폭탄 사용시 잠시 원처럼 뜨는것.
ui_100points -> 적 죽이면 점수 화면에 뿌려줄때
Splash 와 Score 는 에니메이션으로 구성되있고 에니메이션 이벤트의 마지막에 -> DestroyGameObject를 실행시킨다.
explosionCircle 은 발생과 동시에 0.1초만에 오브젝트를 삭제시킨다.
destroyOnAwake -> 시작과 동시에 삭제시킬지 여부
findChild -> 자기의 자식을 삭제시킬지 여부
namedChild - > 자식을 삭제시킬때 삭제시킬 자식 이름
DestroyChildGameObject -> 자식 삭제
DisableChildGameObject -> 자식을 비활성화로
DestroyGameObject -> 자기 자신 삭제
'잡다한것들전부 > 공식예제' 카테고리의 다른 글
| 점수 표현 - Score (0) | 2014.02.25 |
|---|---|
| 폭탄과 구급 상자 - Bomb Pickup, Bomb (0) | 2014.02.25 |
| 물체 파괴 함수 -> Destroyer 스크립트 (0) | 2014.02.25 |
| killTrigger -> 모든 적과 주인공 충돌(강) - Removver 스크립트 (0) | 2014.02.25 |
| 플레이어의 체력 - PlayerHealth (0) | 2014.02.25 |
| 플레이어 무기 발사 - gun 스크립트 (0) | 2014.02.25 |
강물 위치에 배치되있음.
Remover 스크립트가 할당되있고, 몬스터가 강물에 빠지면 해당 오브젝트를 제거하고 플레이어가 빠지면 특정 작업을 한후 재시작함.
// If the player hits the trigger...
if(col.gameObject.tag == "Player")
{
// .. stop the camera tracking the player
GameObject.FindGameObjectWithTag("MainCamera").GetComponent<CameraFollow>().enabled = false;
// .. stop the Health Bar following the player
if(GameObject.FindGameObjectWithTag("HealthBar").activeSelf)
{
GameObject.FindGameObjectWithTag("HealthBar").SetActive(false);
}
// ... instantiate the splash where the player falls in.
Instantiate(splash, col.transform.position, transform.rotation);
// ... destroy the player.
Destroy (col.gameObject);
// ... reload the level.
StartCoroutine("ReloadGame");
}
else
{
// ... instantiate the splash where the enemy falls in.
Instantiate(splash, col.transform.position, transform.rotation);
// Destroy the enemy.
}
메인카메라의 CameraFollow 스크립트 기능 끄기
HealthBar 활성화 상태이면 안보이게 하기 (activeSelf -> 오브젝트 활성화 여부 체크)
Splash 프리팹 생성 -> 강물 빠지는 모양 -> 프리팹에는 Destroyer 스크립트 연결되있음(애니메이션 마지막 부부분에서 자기자신을 삭제해줌)
플레이어 제거
ReloadGame 코루틴 실행
IEnumerator ReloadGame()
{
// ... pause briefly
yield return new WaitForSeconds(2);
// ... and then reload the level.
Application.LoadLevel(Application.loadedLevel);
}
2초후 게임 다시 실행
'잡다한것들전부 > 공식예제' 카테고리의 다른 글
| 폭탄과 구급 상자 - Bomb Pickup, Bomb (0) | 2014.02.25 |
|---|---|
| 물체 파괴 함수 -> Destroyer 스크립트 (0) | 2014.02.25 |
| killTrigger -> 모든 적과 주인공 충돌(강) - Removver 스크립트 (0) | 2014.02.25 |
| 플레이어의 체력 - PlayerHealth (0) | 2014.02.25 |
| 플레이어 무기 발사 - gun 스크립트 (0) | 2014.02.25 |
| 주인공을 따라다니는 카메라 (0) | 2014.02.25 |


