Commit 1731374a authored by 18손재민's avatar 18손재민

발사 모드로 들어갈 때 클릭하면 애니메이션 스킵 됨, 총알이 날아가는 도중에는 조작 불가

parent b06be162
......@@ -12,8 +12,14 @@ public abstract class Bullet : MonoBehaviour
rb = GetComponent<Rigidbody>();
}
private void OnDestroy()
{
GameManager.inst.isBulletFlying = false;
}
public void Init(Vector3 velocity)
{
GameManager.inst.isBulletFlying = true;
GetComponent<Rigidbody>().velocity = velocity;
Destroy(gameObject, MapManager.inst.currentMap.maxMapSize / velocity.magnitude);
}
......
......@@ -10,6 +10,6 @@ public class FakeBullet : Bullet
{
other.GetComponent<IBulletInteractor>().Interact(this);
}
Destroy(gameObject);
Destroy(gameObject);
}
}
......@@ -80,23 +80,32 @@ public class CameraController : MonoBehaviour
Vector3 posDiff = (player.head.transform.position - transform.position) / 40;
float fovDiff = (shootingFov - mapFov) / 40f;
float angleDiff = -30f / 40f;
PlayerController.inst.isZooming = true;
GameManager.inst.isZooming = true;
previousPos = transform.position;
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.z > 180 ? transform.eulerAngles.z - 360 : transform.eulerAngles.z);
for (int i = 0; i < 40; i++)
int i;
for (i = 0; i < 40; i++)
{
yield return null;
if (Input.GetMouseButtonDown(0))
break;
transform.position += posDiff;
transform.eulerAngles += new Vector3(angleDiff, 0, 0);
Camera.main.fieldOfView += fovDiff;
}
if(i < 40)
{
transform.position += posDiff * (40 - i);
transform.eulerAngles += new Vector3(angleDiff * (40 - i), 0, 0);
Camera.main.fieldOfView += fovDiff * (40 - i);
}
player.transform.eulerAngles = new Vector3(player.transform.eulerAngles.x, transform.eulerAngles.y, player.transform.eulerAngles.z);
transform.position = player.head.transform.position;
rotationX = transform.eulerAngles.y;
rotationY = transform.eulerAngles.x;
PlayerController.inst.isZooming = false;
GameManager.inst.isZooming = false;
player.laser.SetActive(true);
player.anim.SetBool("isShooting", true);
player.head.transform.Find("Head 19").gameObject.layer = LayerMask.NameToLayer("Head");
......@@ -115,7 +124,7 @@ public class CameraController : MonoBehaviour
Vector3 posDiff = (previousPos - transform.position) / 40;
float fovDiff = (mapFov - shootingFov) / 40f;
player.laser.SetActive(false);
PlayerController.inst.isZooming = true;
GameManager.inst.isZooming = true;
player.anim.SetBool("isShooting", false);
player.head.transform.Find("Head 19").gameObject.layer = LayerMask.NameToLayer("Player");
player.head.SetActive(true);
......@@ -126,16 +135,25 @@ public class CameraController : MonoBehaviour
angleDiff = new Vector3(angleDiff.x > 180 ? 360 - angleDiff.x : angleDiff.x,
angleDiff.y > 180 ? 360 - angleDiff.y : angleDiff.y,
angleDiff.z > 180 ? 360 - angleDiff.z : angleDiff.z);
for (int i = 0; i < 40; i++)
int i;
for (i = 0; i < 40; i++)
{
yield return null;
if (Input.GetMouseButtonDown(0))
break;
transform.position += posDiff;
transform.eulerAngles += angleDiff;
Camera.main.fieldOfView += fovDiff;
}
if (i < 40)
{
transform.position += posDiff * (40 - i);
transform.eulerAngles += angleDiff * (40 - i);
Camera.main.fieldOfView += fovDiff * (40 - i);
}
transform.position = previousPos;
PlayerController.inst.isPlayerShooting = false;
PlayerController.inst.isZooming = false;
GameManager.inst.isPlayerShooting = false;
GameManager.inst.isZooming = false;
// Visible mouse cursor
Cursor.visible = true;
......@@ -153,22 +171,10 @@ public class CameraController : MonoBehaviour
// Update is called once per frame
void Update()
{
if (!PlayerController.inst.isZooming)
if (!GameManager.inst.isZooming)
{
if (!PlayerController.inst.isPlayerShooting)
if (!GameManager.inst.isPlayerShooting)
{
CameraMove();
CameraDrag();
}
......
......@@ -12,6 +12,7 @@ public class GameManager : SingletonBehaviour<GameManager>
[Space(10)]
public bool isGameOver = false;
public bool isPlayerMoving, isPlayerShooting, isZooming, isBulletFlying;
public int[] clearIndex = new int[9];
public int clearCounter = 0;
......
......@@ -59,7 +59,7 @@ public class Player : MonoBehaviour
agent.CalculatePath(destination, path);
if(path.status == NavMeshPathStatus.PathComplete)
{
PlayerController.inst.isPlayerMoving = true;
GameManager.inst.isPlayerMoving = true;
playerArrivalCheck = StartCoroutine(CheckIfPlayerArrived(destination));
GetComponent<NavMeshAgent>().SetDestination(destination);
}
......@@ -82,7 +82,7 @@ public class Player : MonoBehaviour
currentFloor.isPlayerOn = true;
PlayerController.inst.CheckCurrentFloors();
anim.SetBool("isWalking", false);
PlayerController.inst.isPlayerMoving = false;
GameManager.inst.isPlayerMoving = false;
}
/// <summary>
/// Count 2 second to make player in shooting mode.
......@@ -102,7 +102,7 @@ public class Player : MonoBehaviour
}
if (time > endTime)
{
PlayerController.inst.isPlayerShooting = true;
GameManager.inst.isPlayerShooting = true;
StartCoroutine(Camera.main.GetComponent<CameraController>().ZoomInAtPlayer(this));
}
}
......
......@@ -7,7 +7,6 @@ using UnityEngine.AI;
public class PlayerController : SingletonBehaviour<PlayerController>
{
public Player currentPlayer;
public bool isPlayerMoving, isPlayerShooting, isZooming;
public List<BulletCode> bulletList = new List<BulletCode>();
private Vector2Int prePos;
public Vector2Int MapPos
......@@ -143,12 +142,12 @@ public class PlayerController : SingletonBehaviour<PlayerController>
}
//Control player only if camera is not zooming in to or out from the current player
if (!isZooming)
if (!GameManager.inst.isZooming && !GameManager.inst.isBulletFlying)
{
if (Input.GetMouseButtonDown(0))
{
//Move the current player.
if (!isPlayerMoving && !isPlayerShooting)
if (!GameManager.inst.isPlayerMoving && !GameManager.inst.isPlayerShooting)
{
Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
......@@ -173,7 +172,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
currentPlayer.ResetCurrentPlayer();
}
}
else if (isPlayerShooting)
else if (GameManager.inst.isPlayerShooting)
{
if (bulletList.Count > 0)
{
......@@ -181,7 +180,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
}
}
}
else if (Input.GetMouseButtonDown(1) && isPlayerShooting)
else if (Input.GetMouseButtonDown(1) && GameManager.inst.isPlayerShooting)
{
StartCoroutine(Camera.main.GetComponent<CameraController>().ZoomOutFromPlayer(currentPlayer));
currentPlayer.shootingArm.rotation = currentPlayer.armRotation;
......@@ -196,7 +195,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
{
if (currentPlayer.GetComponent<NavMeshAgent>().velocity.magnitude > 0)
transform.rotation = Quaternion.LookRotation(currentPlayer.GetComponent<NavMeshAgent>().velocity.normalized);
if (isPlayerShooting)
if (GameManager.inst.isPlayerShooting)
{
Quaternion destinationRotation = Quaternion.Euler(new Vector3(transform.eulerAngles.x, Camera.main.transform.eulerAngles.y, currentPlayer.transform.eulerAngles.z));
currentPlayer.transform.rotation = Quaternion.Lerp(currentPlayer.transform.rotation, destinationRotation, Time.deltaTime * 10);
......
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