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
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();
}
......
......@@ -27,14 +27,13 @@ public class CameraTurret : MonoBehaviour, IObject, IBreakable, IPlayerInteracto
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)
{
GameManager.inst.isGameOver = true;
StartCoroutine(GameManager.inst.RestartStage());
GameManager.inst.uiGenerator.ResetAllClearUIs();
//TODO : Restart Level
}
}
......
......@@ -70,18 +70,15 @@ public class Mannequin : MonoBehaviour, IObject, IBulletInteractor
transform.Rotate(new Vector3(0, Random.Range(0, 4) * 90, 0));
isWhite = true;
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)
{
Color = isWhite ? Color.white : Color.black;
this.isWhite = isWhite;
if (GameManager.black >= 0 && !isWhite)
{
MapManager.inst.currentMap.clearConditions[GameManager.black].count++;
if (GameManager.white >= 0) MapManager.inst.currentMap.clearConditions[GameManager.white].count--;
}
if (GameManager.black >= 0 && !isWhite) MapManager.inst.currentMap.clearConditions[GameManager.black].count++;
if (GameManager.white >= 0 && isWhite) MapManager.inst.currentMap.clearConditions[GameManager.white].count++;
}
#region IObject Override
......
......@@ -13,6 +13,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;
......
......@@ -91,15 +91,13 @@ public class MapManager : SingletonBehaviour<MapManager>
if (!child.GetComponent<Mannequin>().isWhite && GameManager.black >= 0)
currentMap.clearConditions[GameManager.black].IsDone(1);
}
}
for (int i = 0; i < currentMap.startFloors.Count; i++)
PlayerController.inst.CreatePlayer(currentMap.startFloors[i]);
for (int i = 0; i < loadedMapData.bullets.Count; i++)
PlayerController.inst.AddBullet(loadedMapData.bullets[i]);
}
public IEnumerator Rebaker()
{
yield return null;
......
......@@ -25,14 +25,15 @@ public class ClearCondition
count += _count;
goal += _goal;
assignedClearUI.RefreshClearCondition();
if (goal <= count && !isDone)
if ((type == ClearType.White || type == ClearType.Black) ? goal == count : goal <= count && !isDone)
{
GameManager.inst.clearCounter--;
isDone = true;
Debug.Log(GameManager.inst.clearCounter);
if (GameManager.inst.clearCounter == 0)
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++;
isDone = false;
......
......@@ -266,9 +266,9 @@ public class Map : MonoBehaviour
else if(objectGrid[pos].GetType() == ObjType.Mannequin)
{
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)
clearConditions[GameManager.black].IsDone(0, -1);
clearConditions[GameManager.black].IsDone(-1);
}
if(objectGrid[pos].GetType() != ObjType.Mannequin)
PlayerController.inst.OnPlayerMove -= objectGrid[pos].GetObject().GetComponent<IPlayerInteractor>().Interact;
......
......@@ -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
......@@ -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
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;
......@@ -174,7 +173,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
currentPlayer.ResetCurrentPlayer();
}
}
else if (isPlayerShooting)
else if (GameManager.inst.isPlayerShooting)
{
if (bulletList.Count > 0)
{
......@@ -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));
currentPlayer.shootingArm.rotation = currentPlayer.armRotation;
......@@ -197,7 +196,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