Commit a077febe authored by 18신대성's avatar 18신대성

더블클릭 구현 완료

parent af445032
...@@ -79,10 +79,10 @@ public class CameraController : MonoBehaviour ...@@ -79,10 +79,10 @@ public class CameraController : MonoBehaviour
/// <returns></returns> /// <returns></returns>
public IEnumerator ZoomInAtPlayer(Player player) public IEnumerator ZoomInAtPlayer(Player player)
{ {
GameManager.inst.isZooming = true;
float startTime = Time.time; float startTime = Time.time;
Vector3 posDiff = (player.head.transform.position - transform.position) / cameraMoveDuration; Vector3 posDiff = (player.head.transform.position - transform.position) / cameraMoveDuration;
float angleDiff = -30f / cameraMoveDuration; float angleDiff = -30f / cameraMoveDuration;
GameManager.inst.isZooming = true;
previousPos = transform.position; previousPos = transform.position;
previousAngle = new Vector3(transform.eulerAngles.x > 180 ? transform.eulerAngles.x - 360 : transform.eulerAngles.x, previousAngle = new Vector3(transform.eulerAngles.x > 180 ? transform.eulerAngles.x - 360 : transform.eulerAngles.x,
transform.eulerAngles.y > 180 ? transform.eulerAngles.y - 360 : transform.eulerAngles.y, transform.eulerAngles.y > 180 ? transform.eulerAngles.y - 360 : transform.eulerAngles.y,
...@@ -121,11 +121,11 @@ public class CameraController : MonoBehaviour ...@@ -121,11 +121,11 @@ public class CameraController : MonoBehaviour
/// <returns></returns> /// <returns></returns>
public IEnumerator ZoomOutFromPlayer(Player player) public IEnumerator ZoomOutFromPlayer(Player player)
{ {
GameManager.inst.isZooming = true;
float startTime = Time.time; float startTime = Time.time;
Vector3 posDiff = (previousPos - transform.position) / cameraMoveDuration; Vector3 posDiff = (previousPos - transform.position) / cameraMoveDuration;
player.laser.SetActive(false); player.laser.SetActive(false);
helpUI.SetActive(false); helpUI.SetActive(false);
GameManager.inst.isZooming = true;
player.anim.SetBool("isShooting", false); player.anim.SetBool("isShooting", false);
player.head.transform.Find("Head 19").gameObject.layer = LayerMask.NameToLayer("Player"); player.head.transform.Find("Head 19").gameObject.layer = LayerMask.NameToLayer("Player");
player.head.SetActive(true); player.head.SetActive(true);
...@@ -171,14 +171,14 @@ public class CameraController : MonoBehaviour ...@@ -171,14 +171,14 @@ public class CameraController : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if (!GameManager.inst.isGameOver && !GameManager.inst.isZooming) if (!GameManager.inst.isZooming)
{ {
if (!GameManager.inst.isPlayerShooting) if (!GameManager.inst.isPlayerShooting)
{ {
CameraMove(); CameraMove();
CameraDrag(); CameraDrag();
} }
else else if (!GameManager.inst.isGameOver)
{ {
float mouseMoveValueX = Input.GetAxis("Mouse X"); float mouseMoveValueX = Input.GetAxis("Mouse X");
float mouseMoveValueY = Input.GetAxis("Mouse Y"); float mouseMoveValueY = Input.GetAxis("Mouse Y");
......
...@@ -103,7 +103,10 @@ public class Player : MonoBehaviour ...@@ -103,7 +103,10 @@ public class Player : MonoBehaviour
public IEnumerator CountPlayerClick(float startTime) public IEnumerator CountPlayerClick(float startTime)
{ {
float time = Time.time; float time = Time.time;
float doubleClickDelay = 0.2f;
float endTime = startTime + 1f; float endTime = startTime + 1f;
bool doubleClicked = false;
bool isHoldExit = false;
aimLight.gameObject.SetActive(true); aimLight.gameObject.SetActive(true);
while (time <= endTime) while (time <= endTime)
{ {
...@@ -113,13 +116,27 @@ public class Player : MonoBehaviour ...@@ -113,13 +116,27 @@ public class Player : MonoBehaviour
time = Time.time; time = Time.time;
if (!Input.GetMouseButton(0)) if (!Input.GetMouseButton(0))
{ {
aimLight.lightMultiplier = 0; isHoldExit = true;
aimLight.spotAngle = 60;
aimLight.gameObject.SetActive(false);
break; break;
} }
} }
if (time > endTime) if (isHoldExit)
{
while (time + doubleClickDelay > Time.time)
{
yield return null;
aimLight.lightMultiplier *= 0.8f;
if (Input.GetMouseButtonDown(0))
{
doubleClicked = true;
break;
}
}
aimLight.lightMultiplier = 0;
aimLight.spotAngle = 60;
aimLight.gameObject.SetActive(false);
}
if ((!isHoldExit && time > endTime) || doubleClicked)
{ {
aimLight.lightMultiplier = 0; aimLight.lightMultiplier = 0;
aimLight.spotAngle = 60; aimLight.spotAngle = 60;
...@@ -127,6 +144,7 @@ public class Player : MonoBehaviour ...@@ -127,6 +144,7 @@ public class Player : MonoBehaviour
GameManager.inst.isPlayerShooting = true; GameManager.inst.isPlayerShooting = true;
StartCoroutine(Camera.main.GetComponent<CameraController>().ZoomInAtPlayer(this)); StartCoroutine(Camera.main.GetComponent<CameraController>().ZoomInAtPlayer(this));
} }
PlayerController.inst.zoomReady = null;
} }
public void Shoot(BulletCode bulletCode) public void Shoot(BulletCode bulletCode)
......
...@@ -25,6 +25,8 @@ public class PlayerController : SingletonBehaviour<PlayerController> ...@@ -25,6 +25,8 @@ public class PlayerController : SingletonBehaviour<PlayerController>
public event Action<Vector2Int> OnPlayerMove; public event Action<Vector2Int> OnPlayerMove;
public Coroutine zoomReady = null;
public GameObject CreatePlayer(Floor floor) public GameObject CreatePlayer(Floor floor)
{ {
foreach (var obj in MapManager.inst.players) foreach (var obj in MapManager.inst.players)
...@@ -178,7 +180,7 @@ public class PlayerController : SingletonBehaviour<PlayerController> ...@@ -178,7 +180,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
currentPlayer.ResetCurrentPlayer(); currentPlayer.ResetCurrentPlayer();
currentPlayer = hit.transform.gameObject.GetComponent<Player>(); currentPlayer = hit.transform.gameObject.GetComponent<Player>();
StartCoroutine(currentPlayer.SetCurrentPlayer()); StartCoroutine(currentPlayer.SetCurrentPlayer());
StartCoroutine(currentPlayer.CountPlayerClick(Time.time)); if (zoomReady == null) zoomReady = StartCoroutine(currentPlayer.CountPlayerClick(Time.time));
//Debug.Log(hit.collider.gameObject.tag); //Debug.Log(hit.collider.gameObject.tag);
} }
else if (Physics.Raycast(mouseRay, out hit, float.MaxValue, layerMask) && hit.collider.gameObject.tag.Equals("floor")) else if (Physics.Raycast(mouseRay, out hit, float.MaxValue, layerMask) && hit.collider.gameObject.tag.Equals("floor"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment