Commit 487461c5 authored by 18손재민's avatar 18손재민

Merge remote-tracking branch 'origin/map' into polish

parents 083a5304 1731374a
...@@ -12,8 +12,14 @@ public abstract class Bullet : MonoBehaviour ...@@ -12,8 +12,14 @@ public abstract class Bullet : MonoBehaviour
rb = GetComponent<Rigidbody>(); rb = GetComponent<Rigidbody>();
} }
private void OnDestroy()
{
GameManager.inst.isBulletFlying = false;
}
public void Init(Vector3 velocity) public void Init(Vector3 velocity)
{ {
GameManager.inst.isBulletFlying = true;
GetComponent<Rigidbody>().velocity = velocity; GetComponent<Rigidbody>().velocity = velocity;
Destroy(gameObject, MapManager.inst.currentMap.maxMapSize / velocity.magnitude); Destroy(gameObject, MapManager.inst.currentMap.maxMapSize / velocity.magnitude);
} }
......
...@@ -80,23 +80,32 @@ public class CameraController : MonoBehaviour ...@@ -80,23 +80,32 @@ public class CameraController : MonoBehaviour
Vector3 posDiff = (player.head.transform.position - transform.position) / 40; Vector3 posDiff = (player.head.transform.position - transform.position) / 40;
float fovDiff = (shootingFov - mapFov) / 40f; float fovDiff = (shootingFov - mapFov) / 40f;
float angleDiff = -30f / 40f; float angleDiff = -30f / 40f;
PlayerController.inst.isZooming = true; 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,
transform.eulerAngles.z > 180 ? transform.eulerAngles.z - 360 : transform.eulerAngles.z); 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; yield return null;
if (Input.GetMouseButtonDown(0))
break;
transform.position += posDiff; transform.position += posDiff;
transform.eulerAngles += new Vector3(angleDiff, 0, 0); transform.eulerAngles += new Vector3(angleDiff, 0, 0);
Camera.main.fieldOfView += fovDiff; 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); player.transform.eulerAngles = new Vector3(player.transform.eulerAngles.x, transform.eulerAngles.y, player.transform.eulerAngles.z);
transform.position = player.head.transform.position; transform.position = player.head.transform.position;
rotationX = transform.eulerAngles.y; rotationX = transform.eulerAngles.y;
rotationY = transform.eulerAngles.x; rotationY = transform.eulerAngles.x;
PlayerController.inst.isZooming = false; GameManager.inst.isZooming = false;
player.laser.SetActive(true); player.laser.SetActive(true);
player.anim.SetBool("isShooting", true); player.anim.SetBool("isShooting", true);
player.head.transform.Find("Head 19").gameObject.layer = LayerMask.NameToLayer("Head"); player.head.transform.Find("Head 19").gameObject.layer = LayerMask.NameToLayer("Head");
...@@ -115,7 +124,7 @@ public class CameraController : MonoBehaviour ...@@ -115,7 +124,7 @@ public class CameraController : MonoBehaviour
Vector3 posDiff = (previousPos - transform.position) / 40; Vector3 posDiff = (previousPos - transform.position) / 40;
float fovDiff = (mapFov - shootingFov) / 40f; float fovDiff = (mapFov - shootingFov) / 40f;
player.laser.SetActive(false); player.laser.SetActive(false);
PlayerController.inst.isZooming = true; 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);
...@@ -126,16 +135,25 @@ public class CameraController : MonoBehaviour ...@@ -126,16 +135,25 @@ public class CameraController : MonoBehaviour
angleDiff = new Vector3(angleDiff.x > 180 ? 360 - angleDiff.x : angleDiff.x, angleDiff = new Vector3(angleDiff.x > 180 ? 360 - angleDiff.x : angleDiff.x,
angleDiff.y > 180 ? 360 - angleDiff.y : angleDiff.y, angleDiff.y > 180 ? 360 - angleDiff.y : angleDiff.y,
angleDiff.z > 180 ? 360 - angleDiff.z : angleDiff.z); 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; yield return null;
if (Input.GetMouseButtonDown(0))
break;
transform.position += posDiff; transform.position += posDiff;
transform.eulerAngles += angleDiff; transform.eulerAngles += angleDiff;
Camera.main.fieldOfView += fovDiff; 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; transform.position = previousPos;
PlayerController.inst.isPlayerShooting = false; GameManager.inst.isPlayerShooting = false;
PlayerController.inst.isZooming = false; GameManager.inst.isZooming = false;
// Visible mouse cursor // Visible mouse cursor
Cursor.visible = true; Cursor.visible = true;
...@@ -153,22 +171,10 @@ public class CameraController : MonoBehaviour ...@@ -153,22 +171,10 @@ public class CameraController : MonoBehaviour
// Update is called once per frame // Update is called once per frame
void Update() void Update()
{ {
if (!PlayerController.inst.isZooming) if (!GameManager.inst.isZooming)
{ {
if (!PlayerController.inst.isPlayerShooting) if (!GameManager.inst.isPlayerShooting)
{ {
CameraMove(); CameraMove();
CameraDrag(); CameraDrag();
} }
......
...@@ -27,14 +27,13 @@ public class CameraTurret : MonoBehaviour, IObject, IBreakable, IPlayerInteracto ...@@ -27,14 +27,13 @@ public class CameraTurret : MonoBehaviour, IObject, IBreakable, IPlayerInteracto
public void Interact(Vector2Int pos) public void Interact(Vector2Int pos)
{ {
if(!GameManager.inst.isGameOver) if(!GameManager.inst.isGameOver && PlayerController.inst.currentPlayer != null)
{ {
if (Position.IsInAdjacentArea(pos, 1) && MapManager.inst.currentMap.GetWallAtPos((Vector2)(Position + pos) / 2) == null) if (Position.IsInAdjacentArea(pos, 1) && MapManager.inst.currentMap.GetWallAtPos((Vector2)(Position + pos) / 2) == null)
{ {
GameManager.inst.isGameOver = true; GameManager.inst.isGameOver = true;
StartCoroutine(GameManager.inst.RestartStage()); StartCoroutine(GameManager.inst.RestartStage());
GameManager.inst.uiGenerator.ResetAllClearUIs(); GameManager.inst.uiGenerator.ResetAllClearUIs();
//TODO : Restart Level //TODO : Restart Level
} }
} }
......
...@@ -70,18 +70,15 @@ public class Mannequin : MonoBehaviour, IObject, IBulletInteractor ...@@ -70,18 +70,15 @@ public class Mannequin : MonoBehaviour, IObject, IBulletInteractor
transform.Rotate(new Vector3(0, Random.Range(0, 4) * 90, 0)); transform.Rotate(new Vector3(0, Random.Range(0, 4) * 90, 0));
isWhite = true; isWhite = true;
Color = Color.white; Color = Color.white;
if (GameManager.white >= 0) MapManager.inst.currentMap.clearConditions[GameManager.white].IsDone(1); //if (GameManager.white >= 0) MapManager.inst.currentMap.clearConditions[GameManager.white].IsDone(1);
} }
public void SetColor(bool isWhite) public void SetColor(bool isWhite)
{ {
Color = isWhite ? Color.white : Color.black; Color = isWhite ? Color.white : Color.black;
this.isWhite = isWhite; this.isWhite = isWhite;
if (GameManager.black >= 0 && !isWhite) if (GameManager.black >= 0 && !isWhite) MapManager.inst.currentMap.clearConditions[GameManager.black].count++;
{ if (GameManager.white >= 0 && isWhite) MapManager.inst.currentMap.clearConditions[GameManager.white].count++;
MapManager.inst.currentMap.clearConditions[GameManager.black].count++;
if (GameManager.white >= 0) MapManager.inst.currentMap.clearConditions[GameManager.white].count--;
}
} }
#region IObject Override #region IObject Override
......
...@@ -13,6 +13,7 @@ public class GameManager : SingletonBehaviour<GameManager> ...@@ -13,6 +13,7 @@ public class GameManager : SingletonBehaviour<GameManager>
[Space(10)] [Space(10)]
public bool isGameOver = false; public bool isGameOver = false;
public bool isPlayerMoving, isPlayerShooting, isZooming, isBulletFlying;
public int[] clearIndex = new int[9]; public int[] clearIndex = new int[9];
public int clearCounter = 0; public int clearCounter = 0;
......
...@@ -91,15 +91,13 @@ public class MapManager : SingletonBehaviour<MapManager> ...@@ -91,15 +91,13 @@ public class MapManager : SingletonBehaviour<MapManager>
if (!child.GetComponent<Mannequin>().isWhite && GameManager.black >= 0) if (!child.GetComponent<Mannequin>().isWhite && GameManager.black >= 0)
currentMap.clearConditions[GameManager.black].IsDone(1); currentMap.clearConditions[GameManager.black].IsDone(1);
} }
} }
for (int i = 0; i < currentMap.startFloors.Count; i++) for (int i = 0; i < currentMap.startFloors.Count; i++)
PlayerController.inst.CreatePlayer(currentMap.startFloors[i]); PlayerController.inst.CreatePlayer(currentMap.startFloors[i]);
for (int i = 0; i < loadedMapData.bullets.Count; i++) for (int i = 0; i < loadedMapData.bullets.Count; i++)
PlayerController.inst.AddBullet(loadedMapData.bullets[i]); PlayerController.inst.AddBullet(loadedMapData.bullets[i]);
} }
public IEnumerator Rebaker() public IEnumerator Rebaker()
{ {
yield return null; yield return null;
......
...@@ -25,14 +25,15 @@ public class ClearCondition ...@@ -25,14 +25,15 @@ public class ClearCondition
count += _count; count += _count;
goal += _goal; goal += _goal;
assignedClearUI.RefreshClearCondition(); assignedClearUI.RefreshClearCondition();
if (goal <= count && !isDone) if ((type == ClearType.White || type == ClearType.Black) ? goal == count : goal <= count && !isDone)
{ {
GameManager.inst.clearCounter--; GameManager.inst.clearCounter--;
isDone = true; isDone = true;
Debug.Log(GameManager.inst.clearCounter);
if (GameManager.inst.clearCounter == 0) if (GameManager.inst.clearCounter == 0)
GameManager.inst.StartCoroutine(GameManager.inst.ClearStage()); GameManager.inst.StartCoroutine(GameManager.inst.ClearStage());
} }
else if (goal > count) else if ((type == ClearType.White || type == ClearType.Black) ? goal != count : goal > count && isDone)
{ {
GameManager.inst.clearCounter++; GameManager.inst.clearCounter++;
isDone = false; isDone = false;
......
...@@ -266,9 +266,9 @@ public class Map : MonoBehaviour ...@@ -266,9 +266,9 @@ public class Map : MonoBehaviour
else if(objectGrid[pos].GetType() == ObjType.Mannequin) else if(objectGrid[pos].GetType() == ObjType.Mannequin)
{ {
if(objectGrid[pos].GetObject().GetComponent<Mannequin>().isWhite && GameManager.white >= 0) if(objectGrid[pos].GetObject().GetComponent<Mannequin>().isWhite && GameManager.white >= 0)
clearConditions[GameManager.white].IsDone(0, -1); clearConditions[GameManager.white].IsDone(-1);
else if (!objectGrid[pos].GetObject().GetComponent<Mannequin>().isWhite && GameManager.black >= 0) else if (!objectGrid[pos].GetObject().GetComponent<Mannequin>().isWhite && GameManager.black >= 0)
clearConditions[GameManager.black].IsDone(0, -1); clearConditions[GameManager.black].IsDone(-1);
} }
if(objectGrid[pos].GetType() != ObjType.Mannequin) if(objectGrid[pos].GetType() != ObjType.Mannequin)
PlayerController.inst.OnPlayerMove -= objectGrid[pos].GetObject().GetComponent<IPlayerInteractor>().Interact; PlayerController.inst.OnPlayerMove -= objectGrid[pos].GetObject().GetComponent<IPlayerInteractor>().Interact;
......
...@@ -59,7 +59,7 @@ public class Player : MonoBehaviour ...@@ -59,7 +59,7 @@ public class Player : MonoBehaviour
agent.CalculatePath(destination, path); agent.CalculatePath(destination, path);
if(path.status == NavMeshPathStatus.PathComplete) if(path.status == NavMeshPathStatus.PathComplete)
{ {
PlayerController.inst.isPlayerMoving = true; GameManager.inst.isPlayerMoving = true;
playerArrivalCheck = StartCoroutine(CheckIfPlayerArrived(destination)); playerArrivalCheck = StartCoroutine(CheckIfPlayerArrived(destination));
GetComponent<NavMeshAgent>().SetDestination(destination); GetComponent<NavMeshAgent>().SetDestination(destination);
} }
...@@ -82,7 +82,7 @@ public class Player : MonoBehaviour ...@@ -82,7 +82,7 @@ public class Player : MonoBehaviour
currentFloor.isPlayerOn = true; currentFloor.isPlayerOn = true;
PlayerController.inst.CheckCurrentFloors(); PlayerController.inst.CheckCurrentFloors();
anim.SetBool("isWalking", false); anim.SetBool("isWalking", false);
PlayerController.inst.isPlayerMoving = false; GameManager.inst.isPlayerMoving = false;
} }
/// <summary> /// <summary>
/// Count 2 second to make player in shooting mode. /// Count 2 second to make player in shooting mode.
...@@ -102,7 +102,7 @@ public class Player : MonoBehaviour ...@@ -102,7 +102,7 @@ public class Player : MonoBehaviour
} }
if (time > endTime) if (time > endTime)
{ {
PlayerController.inst.isPlayerShooting = true; GameManager.inst.isPlayerShooting = true;
StartCoroutine(Camera.main.GetComponent<CameraController>().ZoomInAtPlayer(this)); StartCoroutine(Camera.main.GetComponent<CameraController>().ZoomInAtPlayer(this));
} }
} }
......
...@@ -7,7 +7,6 @@ using UnityEngine.AI; ...@@ -7,7 +7,6 @@ using UnityEngine.AI;
public class PlayerController : SingletonBehaviour<PlayerController> public class PlayerController : SingletonBehaviour<PlayerController>
{ {
public Player currentPlayer; public Player currentPlayer;
public bool isPlayerMoving, isPlayerShooting, isZooming;
public List<BulletCode> bulletList = new List<BulletCode>(); public List<BulletCode> bulletList = new List<BulletCode>();
private Vector2Int prePos; private Vector2Int prePos;
public Vector2Int MapPos public Vector2Int MapPos
...@@ -144,12 +143,12 @@ public class PlayerController : SingletonBehaviour<PlayerController> ...@@ -144,12 +143,12 @@ public class PlayerController : SingletonBehaviour<PlayerController>
} }
//Control player only if camera is not zooming in to or out from the current player //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)) if (Input.GetMouseButtonDown(0))
{ {
//Move the current player. //Move the current player.
if (!isPlayerMoving && !isPlayerShooting) if (!GameManager.inst.isPlayerMoving && !GameManager.inst.isPlayerShooting)
{ {
Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition); Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit; RaycastHit hit;
...@@ -174,7 +173,7 @@ public class PlayerController : SingletonBehaviour<PlayerController> ...@@ -174,7 +173,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
currentPlayer.ResetCurrentPlayer(); currentPlayer.ResetCurrentPlayer();
} }
} }
else if (isPlayerShooting) else if (GameManager.inst.isPlayerShooting)
{ {
if (bulletList.Count > 0) if (bulletList.Count > 0)
{ {
...@@ -182,7 +181,7 @@ public class PlayerController : SingletonBehaviour<PlayerController> ...@@ -182,7 +181,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)); StartCoroutine(Camera.main.GetComponent<CameraController>().ZoomOutFromPlayer(currentPlayer));
currentPlayer.shootingArm.rotation = currentPlayer.armRotation; currentPlayer.shootingArm.rotation = currentPlayer.armRotation;
...@@ -197,7 +196,7 @@ public class PlayerController : SingletonBehaviour<PlayerController> ...@@ -197,7 +196,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
{ {
if (currentPlayer.GetComponent<NavMeshAgent>().velocity.magnitude > 0) if (currentPlayer.GetComponent<NavMeshAgent>().velocity.magnitude > 0)
transform.rotation = Quaternion.LookRotation(currentPlayer.GetComponent<NavMeshAgent>().velocity.normalized); 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)); 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); 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