/// <summary> /// 특수능력(플레이어의 속도감소)를 처리하는 함수이다. /// </summary> /// <param name="target"> 특수능력을 적용할 대상 (플레이어) </param> /// <param name="triggerType"> 유효성 검사 </param> public void PlayEffect(GameObject target, CatchGameStarTriggerType triggerType) { if (triggerType != TriggerType) { return; } target.GetComponent <DogPlayerController>().OnEnterSlowDownStar(_downSpeedAmount); _effect.ShowEffect(transform.position + Vector3.up * 2.0f); }
/* [독립성] 두번째 매개변수로 CatchGameStarTriggerType을 둔 이유 * 이 함수 내부에서 유효성검사(이 함수가 호출될 수 있는 경우인지 검사)를 해주기 위해서이다. * 따라서 이 함수를 호출하는 객체는 두번째 매개변수의 값을 적절히 전달해주면 별도의 유효성검사를 하지 않아도 된다. * 이는, 새로운 특성효과(새로운 클래스)를 추가한다고 하더라도, 이 함수를 호출하는 객체를 수정하지 않게 해준다. (독립성을 확보해준다.) */ /// <summary> /// 특수능력(순간이동)을 발동처리하는 함수이다. /// </summary> /// <param name="target"> 특수능력를 적용시키는 대상 </param> /// <param name="type"> 유효성 검사 </param> public void PlayEffect(GameObject target, CatchGameStarTriggerType type) { if (type != TriggerType) { return; } if (IsTeleportSuccess(_teleportSuccessPercent)) { Vector3 posBeforeTeleport = transform.position; transform.position = _stageEnvSet.GetRandomPointOnGenGround(); /// 오브젝트가 젠될 수 있는 위치를 랜덤으로 반환한다. _effect.ShowEffect(posBeforeTeleport + Vector3.up * 2.0f); AudioMgr.instance.PlaySoundEffect("Teleport"); } _teleportSuccessPercent -= 20.0f; }
CatchGameStageEnvSet _stageEnvSet; /// 현재 맵 정보 /// <summary> /// 게임시작시, 단 한번만 초기화해줘도 되는 부분을 이 함수에서 처리한다. /// </summary> void Awake() { TriggerType = CatchGameStarTriggerType.OnSight; /// 별의 시야에 플레이어가 들어오면, 특수능력(순간이동)이 발동된다. _teleportSuccessPercent = _initTeleportSuccessPercent; _stageEnvSet = GameObject.FindWithTag("StageEnv").GetComponent <CatchGameStageEnvSet>(); }
const float _downSpeedAmount = 1.0f; /// 플레이어의 속도를 얼마나 낮출지 /// <summary> /// 게임시작시, 단 한번만 초기화해줘도 되는 부분을 이 함수에서 처리한다. /// </summary> void Awake() { TriggerType = CatchGameStarTriggerType.OnEnter; /// 플레이어가 별과 접촉하면 특수능력이 발동된다. }