IEnumerator UseFireExtinguisher() // 소화기 사용 코드 { _anim.SetBool("IsFireExt", true); InteractEffector effector = new InteractEffector(currentTilePos, Floor, InteractEffector.Type.Diamond, 2); effector.Enable(); //좌표 값 변경으로 인해 수정해야 할 코드 while (true) { Vector3Int mousePos = GetMousePosOnTilemap(); bool isPossible = effector.IsInArea(mousePos) && TileMgr.Instance.ExistFire(mousePos, floor); effector.Set(mousePos, isPossible); if (Input.GetMouseButton(0)) { if (isPossible) { _anim.SetTrigger("ShootExt"); TileMgr.Instance.RemoveFire(mousePos, floor); GameMgr.Instance.OnUseTool(); } break; } else if (Input.GetMouseButtonDown(1) || IsMoving) { // 움직이면 취소 break; } yield return(null); } _anim.SetBool("IsFireExt", false); effector.Disable(); }
IEnumerator UseStickyBomb() // 점착폭탄 설치 { InteractEffector effector = new InteractEffector(currentTilePos, Floor, InteractEffector.Type.Cross, 1); effector.Enable(); while (true) { Vector3Int mousePos = GetMousePosOnTilemap(); bool isPossible = effector.IsInArea(mousePos) && TileMgr.Instance.ExistTempWall(mousePos, Floor); effector.Set(mousePos, isPossible); if (Input.GetMouseButtonDown(0)) { if (isPossible) { TileMgr.Instance.RemoveTempWall(mousePos, floor); _anim.SetTrigger("Throw"); GameMgr.Instance.OnUseTool(); } break; } else if (Input.GetMouseButtonDown(1) || IsMoving) { break; } yield return(null); } effector.Disable(); }
IEnumerator RescueHammer() { UI_Actives.SetActive(false); // UI 숨기기 _anim.SetBool("IsUsingActive", true); InteractEffector effector = new InteractEffector(currentTilePos, Floor, InteractEffector.Type.Cross, 1); effector.Enable(); while (true) // 클릭 작용시까지 반복 { Vector3Int mousePos = GetMousePosOnTilemap(); bool existTempWall = TileMgr.Instance.ExistTempWall(mousePos, floor); bool isPossible = effector.IsInArea(mousePos) && existTempWall; effector.Set(mousePos, isPossible); if (Input.GetMouseButtonDown(0)) { if (isPossible) // 클릭 좌표에 장애물이 있다면 제거 { SoundManager.instance.PlayWallCrash(); _anim.SetTrigger("ActiveSkillTrigger"); yield return(new WaitForSeconds(1.7f)); TileMgr.Instance.RemoveTempWall(mousePos, floor); overcomeTraumaCount++; if (overcomeTraumaCount >= 5) { isOverComeTrauma = true; } AddO2(-GetSkillUseO2()); if (isOverComeTrauma) { AddO2(10.0f); } else if (GameMgr.Instance.GetSurvivorAt(mousePos + (mousePos - TileMgr.Instance.WorldToCell(transform.position, floor)), floor)) { playerAct = Action.Panic; // 턴제한 추가 필요 } } break; } else if (IsMoving) { break; } yield return(null); } _anim.SetBool("IsUsingActive", false); effector.Disable(); }
protected virtual IEnumerator Rescue() // 구조 버튼 누를 시 호출되는 함수 { InteractEffector effector = new InteractEffector(currentTilePos, Floor, InteractEffector.Type.Cross, 1); effector.Enable(); while (true) { Vector3Int mousePos = GetMousePosOnTilemap(); Survivor survivor = GameMgr.Instance.GetSurvivorAt(mousePos, floor); bool isPossible = effector.IsInArea(mousePos) && survivor != null; effector.Set(mousePos, isPossible); if (Input.GetMouseButtonDown(0)) { if (isPossible) { _rescuingSurvivor = survivor; _rescuingSurvivor.OnStartCarried(); GameMgr.Instance.OnCarrySurvivor(survivor); playerAct = Action.Carry; // 업는 상태로 변경 _anim.SetBool("IsRescue", true); if (_rescuingSurvivor.CarryCount <= 0) { _rescuingSurvivor.OnStartRescued(); playerAct = Action.Rescue; // Rescue 상태로 변경 _anim.SetBool("IsRescue", false); if (isInSafetyArea) { RescueSuccess(); } } } break; } else if (Input.GetMouseButtonDown(1) || IsMoving) // 움직일 시 취소 { break; } yield return(null); } effector.Disable(); }
IEnumerator Heal() { UI_Actives.SetActive(false); // UI 숨기기 InteractEffector effector = new InteractEffector(currentTilePos, Floor, InteractEffector.Type.Cross, 1); effector.Enable(); while (true) // 클릭 작용시까지 반복 { Vector3Int mousePos = GetMousePosOnTilemap(); List <Player> targetPlayers = GameMgr.Instance.GetPlayersAt(mousePos, floor); bool isPossible = effector.IsInArea(mousePos) && targetPlayers.Count > 0; effector.Set(mousePos, isPossible); if (Input.GetMouseButtonDown(0)) { if (isPossible) { foreach (Player targetPlayer in targetPlayers) { targetPlayer.AddHP(30.0f); targetPlayer.AddO2(20.0f); // 산소 소비 AddO2(-GetSkillUseO2()); break; } } break; } else if (IsMoving) { break; } yield return(null); } effector.Disable(); }
IEnumerator UseFlare() // 조명탄 사용 { InteractEffector effector = new InteractEffector(currentTilePos, floor, InteractEffector.Type.Diamond, 2); effector.Enable(); while (true) { Vector3Int mousePos = GetMousePosOnTilemap(); bool isPossible = effector.IsInArea(mousePos); if (TileMgr.Instance.ExistEnvironment(mousePos, floor) || TileMgr.Instance.ExistObject(mousePos, floor) || GameMgr.Instance.GetPlayersAt(mousePos, floor).Count > 0 || GameMgr.Instance.GetSurvivorAt(mousePos, floor) != null) { isPossible = false; } effector.Set(mousePos, isPossible); if (Input.GetMouseButtonDown(0)) { if (isPossible) { Vector3 targetPos = TileMgr.Instance.CellToWorld(mousePos, floor); Instantiate(flarePrefab, targetPos, Quaternion.identity); GameMgr.Instance.OnUseTool(); } break; } else if (Input.GetMouseButtonDown(1) || IsMoving) { break; } yield return(null); } effector.Disable(); }
IEnumerator UseFireWall() // 방화벽 설치 { InteractEffector effector = new InteractEffector(currentTilePos, Floor, InteractEffector.Type.Cross, 1); effector.Enable(); while (true) { Vector3Int mousePos = GetMousePosOnTilemap(); bool isPossible = effector.IsInArea(mousePos); if (TileMgr.Instance.ExistEnvironment(mousePos, Floor) || TileMgr.Instance.ExistObject(mousePos, floor) || GameMgr.Instance.GetPlayersAt(mousePos, floor).Count > 0 || GameMgr.Instance.GetSurvivorAt(mousePos, floor) != null) { isPossible = false; } effector.Set(mousePos, isPossible); if (Input.GetMouseButtonDown(0)) { if (isPossible) { if ((mousePos - currentTilePos).x == 0) // 가로 3 { for (int i = -1; i <= 1; i++) { Vector3Int targetPos = mousePos; targetPos.x += i; if (TileMgr.Instance.ExistEnvironment(targetPos, Floor) || TileMgr.Instance.ExistObject(targetPos, floor) || GameMgr.Instance.GetPlayersAt(targetPos, floor).Count > 0 || GameMgr.Instance.GetSurvivorAt(targetPos, floor) != null) { continue; } TileMgr.Instance.CreateFireWall(targetPos, floor); } } else { for (int i = -1; i <= 1; i++) // 세로 3 { Vector3Int targetPos = mousePos; targetPos.y += i; if (TileMgr.Instance.ExistEnvironment(targetPos, Floor) || TileMgr.Instance.ExistObject(targetPos, floor) || GameMgr.Instance.GetPlayersAt(targetPos, floor).Count > 0 || GameMgr.Instance.GetSurvivorAt(targetPos, floor) != null) { continue; } TileMgr.Instance.CreateFireWall(targetPos, floor); } } _anim.SetTrigger("UseFireWall"); GameMgr.Instance.OnUseTool(); } break; } else if (Input.GetMouseButtonDown(1) || IsMoving) { break; } yield return(null); } effector.Disable(); }