Commit c2df5852 authored by 18손재민's avatar 18손재민

Merge branch 'interact'

parents f7d46633 759643e8
This diff is collapsed.
...@@ -9,6 +9,7 @@ GameObject: ...@@ -9,6 +9,7 @@ GameObject:
serializedVersion: 6 serializedVersion: 6
m_Component: m_Component:
- component: {fileID: 52444459818764335} - component: {fileID: 52444459818764335}
- component: {fileID: 2122327709}
m_Layer: 0 m_Layer: 0
m_Name: GameManager m_Name: GameManager
m_TagString: Untagged m_TagString: Untagged
...@@ -30,3 +31,18 @@ Transform: ...@@ -30,3 +31,18 @@ Transform:
m_Father: {fileID: 0} m_Father: {fileID: 0}
m_RootOrder: 0 m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2122327709
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 52444459818764334}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f94477ce50cfef746baa12d77bb9d4eb, type: 3}
m_Name:
m_EditorClassIdentifier:
mirrorMaterial: {fileID: 0}
clearIndex: 000000000000000000000000000000000000000000000000000000000000000000000000
clearCounter: 0
...@@ -52,15 +52,15 @@ MonoBehaviour: ...@@ -52,15 +52,15 @@ MonoBehaviour:
- {fileID: 2534561534465535505, guid: 0b323beb318071144aef94132be66541, type: 3} - {fileID: 2534561534465535505, guid: 0b323beb318071144aef94132be66541, type: 3}
- {fileID: 6001025753464815805, guid: df6f1d8b9377ec346af4255abe290fbb, type: 3} - {fileID: 6001025753464815805, guid: df6f1d8b9377ec346af4255abe290fbb, type: 3}
- {fileID: 33432975985984805, guid: ec20e06c4a993924791d02d7a4c9375c, type: 3} - {fileID: 33432975985984805, guid: ec20e06c4a993924791d02d7a4c9375c, type: 3}
players: []
player: {fileID: 494213313239918027, guid: 449b2ca4d925da541bb45c84b63aab98, type: 3}
currentMap: {fileID: 0}
surface: {fileID: 0}
stage:
- {fileID: 2496973653136699540, guid: dbb2e09c19fe5ad49b11a6b95e5ac9e8, type: 3}
truthBullet: {fileID: 7554112578236620015, guid: bfe2c93abf5421b4a9b142f60d689533, truthBullet: {fileID: 7554112578236620015, guid: bfe2c93abf5421b4a9b142f60d689533,
type: 3} type: 3}
fakeBullet: {fileID: 5866539243986221368, guid: a1830defb592fe841ab1732fd18f73a1, fakeBullet: {fileID: 5866539243986221368, guid: a1830defb592fe841ab1732fd18f73a1,
type: 3} type: 3}
mirrorBullet: {fileID: 3200095709359611570, guid: bb70103aa487bc346a6df423335477a2, mirrorBullet: {fileID: 3200095709359611570, guid: bb70103aa487bc346a6df423335477a2,
type: 3} type: 3}
players: []
player: {fileID: 494213313239918027, guid: 449b2ca4d925da541bb45c84b63aab98, type: 3}
currentMap: {fileID: 0}
surface: {fileID: 0}
stage:
- {fileID: 2496973653136699540, guid: dbb2e09c19fe5ad49b11a6b95e5ac9e8, type: 3}
...@@ -802,11 +802,6 @@ PrefabInstance: ...@@ -802,11 +802,6 @@ PrefabInstance:
m_Modification: m_Modification:
m_TransformParent: {fileID: 0} m_TransformParent: {fileID: 0}
m_Modifications: m_Modifications:
- target: {fileID: 7277015661519863741, guid: 20dee07e28273f049a9093ae4453912f,
type: 3}
propertyPath: m_NavMeshData
value:
objectReference: {fileID: 0}
- target: {fileID: 7277015661519863740, guid: 20dee07e28273f049a9093ae4453912f, - target: {fileID: 7277015661519863740, guid: 20dee07e28273f049a9093ae4453912f,
type: 3} type: 3}
propertyPath: m_Name propertyPath: m_Name
...@@ -817,6 +812,11 @@ PrefabInstance: ...@@ -817,6 +812,11 @@ PrefabInstance:
propertyPath: m_IsActive propertyPath: m_IsActive
value: 1 value: 1
objectReference: {fileID: 0} objectReference: {fileID: 0}
- target: {fileID: 7277015661519863741, guid: 20dee07e28273f049a9093ae4453912f,
type: 3}
propertyPath: m_NavMeshData
value:
objectReference: {fileID: 0}
- target: {fileID: 7277015661519863742, guid: 20dee07e28273f049a9093ae4453912f, - target: {fileID: 7277015661519863742, guid: 20dee07e28273f049a9093ae4453912f,
type: 3} type: 3}
propertyPath: m_LocalPosition.x propertyPath: m_LocalPosition.x
......
...@@ -20,6 +20,7 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor ...@@ -20,6 +20,7 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor
public void Init(Floor floor) public void Init(Floor floor)
{ {
if (GameManager.aCase >= 0) MapManager.inst.currentMap.clearConditions[GameManager.aCase].goal++;
this.floor = floor; this.floor = floor;
PlayerController.inst.OnPlayerMove += Interact; PlayerController.inst.OnPlayerMove += Interact;
} }
...@@ -29,7 +30,16 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor ...@@ -29,7 +30,16 @@ public class Briefcase : MonoBehaviour, IObject, IPlayerInteractor
Debug.Log(Position + " " + position); Debug.Log(Position + " " + position);
if (Position == position) if (Position == position)
{ {
IngameManager.inst.BriefcaseCount++; if (GameManager.aCase >= 0)
{
MapManager.inst.currentMap.clearConditions[GameManager.aCase].count++;
MapManager.inst.currentMap.clearConditions[GameManager.aCase].IsDone();
}
if (GameManager.nCase >= 0)
{
MapManager.inst.currentMap.clearConditions[GameManager.nCase].count++;
MapManager.inst.currentMap.clearConditions[GameManager.nCase].IsDone();
}
Destroy(gameObject); Destroy(gameObject);
} }
} }
......
...@@ -7,26 +7,38 @@ public class GameManager : SingletonBehaviour<GameManager> ...@@ -7,26 +7,38 @@ public class GameManager : SingletonBehaviour<GameManager>
{ {
public Material mirrorMaterial; public Material mirrorMaterial;
public int[] clearIndex = new int[9];
public int clearCounter = 0;
public static int nFloor, nTurret, nCase, nPlayer, aFloor, aTurret, aCase, white, black;
/* public void SetClearIndex(Map map)
private List<IPlayerInteractor> playerInteractors; {
for (int i = 0; i < 9; i++) clearIndex[i] = -1;
public void UpdateInteractorList() foreach (var child in map.clearConditions)
{ {
playerInteractors = FindObjectsOfType<MonoBehaviour>().OfType<IPlayerInteractor>().ToList(); clearIndex[(int)child.type] = map.clearConditions.IndexOf(child);
clearCounter++;
}
nFloor = clearIndex[(int)ClearType.NFloor];
nTurret = clearIndex[(int)ClearType.NTurret];
nCase = clearIndex[(int)ClearType.NCase];
nPlayer = clearIndex[(int)ClearType.NPlayer];
aFloor = clearIndex[(int)ClearType.AllFloor];
aTurret = clearIndex[(int)ClearType.AllTurret];
aCase = clearIndex[(int)ClearType.AllCase];
white = clearIndex[(int)ClearType.White];
black = clearIndex[(int)ClearType.Black];
} }
public void AddInteractor() public void ClearStage()
{ {
Debug.Log("Stage Clear!");
} }
public void TriggerPlayerInteractors(Vector2Int pos) // Start is called before the first frame update
{ void Start()
foreach (var interactor in playerInteractors)
{ {
interactor.Interact(pos); if (!MapManager.inst.isMapEditingOn)
} MapManager.inst.LoadMap(MapManager.inst.stage[0]);
} }
*/
} }
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public enum ClearType
{
NFloor,
NTurret,
NCase,
NPlayer,
AllFloor,
AllTurret,
AllCase,
White,
Black
}
[System.Serializable]
public class ClearCondition
{
public ClearType type;
public int count;
public int goal;
bool isDone = false;
public ClearCondition(ClearType _type, int _goal)
{
type = _type;
goal = _goal;
count = 0;
}
public void IsDone()
{
if (!isDone)
{
if (goal <= count)
{
GameManager.inst.clearCounter--;
GameManager.inst.clearIndex[(int)type] = -1;
isDone = true;
if (GameManager.inst.clearCounter == 0)
GameManager.inst.ClearStage();
}
}
}
}
fileFormatVersion: 2
guid: 4899567b2a08a374da0108b53f6d6683
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
...@@ -8,6 +8,8 @@ public class Floor : MonoBehaviour ...@@ -8,6 +8,8 @@ public class Floor : MonoBehaviour
/// Position of this floor at the map. /// Position of this floor at the map.
/// </summary> /// </summary>
public Vector2Int mapPos; public Vector2Int mapPos;
public bool isPassed;
public bool isGoalFloor = false;
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
......
...@@ -5,7 +5,7 @@ using System.IO; ...@@ -5,7 +5,7 @@ using System.IO;
public class Map : MonoBehaviour public class Map : MonoBehaviour
{ {
public int testInputSizeX, testInputSizeY; [Header("Map Data")]
public int maxMapSize; public int maxMapSize;
public Dictionary<Vector2Int, Floor> floorGrid; public Dictionary<Vector2Int, Floor> floorGrid;
public Dictionary<Vector2, Wall> wallGrid; public Dictionary<Vector2, Wall> wallGrid;
...@@ -15,6 +15,8 @@ public class Map : MonoBehaviour ...@@ -15,6 +15,8 @@ public class Map : MonoBehaviour
public GameObject objects; public GameObject objects;
public List<Floor> startFloors; public List<Floor> startFloors;
public List<ClearCondition> clearConditions;
/// <summary> /// <summary>
/// Get floor at position. /// Get floor at position.
/// </summary> /// </summary>
...@@ -57,6 +59,9 @@ public class Map : MonoBehaviour ...@@ -57,6 +59,9 @@ public class Map : MonoBehaviour
{ {
floorGrid.Add(pos, Instantiate(MapManager.inst.floor, new Vector3(pos.x, 0, pos.y), Quaternion.identity, floors.transform).GetComponent<Floor>()); floorGrid.Add(pos, Instantiate(MapManager.inst.floor, new Vector3(pos.x, 0, pos.y), Quaternion.identity, floors.transform).GetComponent<Floor>());
floorGrid[pos].mapPos = pos; floorGrid[pos].mapPos = pos;
floorGrid[pos].isPassed = false;
if (GameManager.aFloor >= 0)
MapManager.inst.currentMap.clearConditions[GameManager.aFloor].goal++;
StartCoroutine(MapManager.inst.Rebaker()); StartCoroutine(MapManager.inst.Rebaker());
} }
else else
......
...@@ -7,16 +7,17 @@ using UnityEngine.AI; ...@@ -7,16 +7,17 @@ using UnityEngine.AI;
public class MapManager : SingletonBehaviour<MapManager> public class MapManager : SingletonBehaviour<MapManager>
{ {
public bool isMapEditingOn; public bool isMapEditingOn;
[Header("Instances")]
public Floor floor; public Floor floor;
public NormalWall normalWall; public NormalWall normalWall;
public Mirror mirror; public Mirror mirror;
public GameObject[] objects; public GameObject[] objects;
public GameObject truthBullet, fakeBullet, mirrorBullet;
public List<GameObject> players; public List<GameObject> players;
public GameObject player; public GameObject player;
public Map currentMap; public Map currentMap;
public NavMeshSurface surface; public NavMeshSurface surface;
public Map[] stage; public Map[] stage;
public GameObject truthBullet, fakeBullet, mirrorBullet;
public BulletFactory bulletFactory; public BulletFactory bulletFactory;
public void LoadMap(Map _newMap) public void LoadMap(Map _newMap)
...@@ -26,8 +27,9 @@ public class MapManager : SingletonBehaviour<MapManager> ...@@ -26,8 +27,9 @@ public class MapManager : SingletonBehaviour<MapManager>
currentMap = Instantiate(_newMap); currentMap = Instantiate(_newMap);
currentMap.transform.position = new Vector3(0, 0, 0); currentMap.transform.position = new Vector3(0, 0, 0);
surface.BuildNavMesh(); surface.BuildNavMesh();
GameManager.inst.SetClearIndex(currentMap);
for (int i = 0; i < currentMap.startFloors.Count; i++) for (int i = 0; i < currentMap.startFloors.Count; i++)
players.Add(Instantiate(player, currentMap.startFloors[i].transform.position + new Vector3(0, 0.1f, 0), Quaternion.identity)); PlayerController.inst.CreatePlayer(currentMap.startFloors[i]);
} }
public IEnumerator Rebaker() public IEnumerator Rebaker()
{ {
...@@ -44,8 +46,7 @@ public class MapManager : SingletonBehaviour<MapManager> ...@@ -44,8 +46,7 @@ public class MapManager : SingletonBehaviour<MapManager>
// Start is called before the first frame update // Start is called before the first frame update
void Start() void Start()
{ {
if(!isMapEditingOn)
LoadMap(stage[0]);
} }
// Update is called once per frame // Update is called once per frame
......
...@@ -15,6 +15,8 @@ public class Player : MonoBehaviour ...@@ -15,6 +15,8 @@ public class Player : MonoBehaviour
public GameObject shootingArm; public GameObject shootingArm;
Animator anim; Animator anim;
public Floor currentFloor;
/// <summary> /// <summary>
/// Set this player as the current player. /// Set this player as the current player.
/// </summary> /// </summary>
...@@ -55,10 +57,8 @@ public class Player : MonoBehaviour ...@@ -55,10 +57,8 @@ public class Player : MonoBehaviour
GetComponent<NavMeshAgent>().SetDestination(destination); GetComponent<NavMeshAgent>().SetDestination(destination);
} }
else else
{
Debug.Log("Destination is not reachable."); Debug.Log("Destination is not reachable.");
} }
}
/// <summary> /// <summary>
/// Check if player is arrived at the destination. /// Check if player is arrived at the destination.
/// </summary> /// </summary>
...@@ -68,10 +68,10 @@ public class Player : MonoBehaviour ...@@ -68,10 +68,10 @@ public class Player : MonoBehaviour
{ {
anim.SetBool("isWalking", true); anim.SetBool("isWalking", true);
while (Mathf.Abs(transform.position.x - destination.x) > 0.01f || Mathf.Abs(transform.position.z - destination.z) > 0.01f) while (Mathf.Abs(transform.position.x - destination.x) > 0.01f || Mathf.Abs(transform.position.z - destination.z) > 0.01f)
{
yield return null; yield return null;
}
transform.position = new Vector3(destination.x, transform.position.y, destination.z); transform.position = new Vector3(destination.x, transform.position.y, destination.z);
currentFloor = MapManager.inst.currentMap.GetFloorAtPos(new Vector2Int((int)destination.x, (int)destination.z));
PlayerController.inst.CheckCurrentFloors();
anim.SetBool("isWalking", false); anim.SetBool("isWalking", false);
PlayerController.inst.isPlayerMoving = false; PlayerController.inst.isPlayerMoving = false;
} }
......
...@@ -27,6 +27,42 @@ public class PlayerController : SingletonBehaviour<PlayerController> ...@@ -27,6 +27,42 @@ public class PlayerController : SingletonBehaviour<PlayerController>
public event Action<Vector2Int> OnPlayerMove; public event Action<Vector2Int> OnPlayerMove;
public void CreatePlayer(Floor floor)
{
GameObject player = Instantiate(MapManager.inst.player, floor.transform.position + new Vector3(0, 0.1f, 0), Quaternion.identity);
player.GetComponent<Player>().currentFloor = floor;
MapManager.inst.players.Add(player);
if (GameManager.nPlayer >= 0)
{
MapManager.inst.currentMap.clearConditions[GameManager.nPlayer].count = MapManager.inst.players.Count;
MapManager.inst.currentMap.clearConditions[GameManager.nPlayer].IsDone();
}
CheckCurrentFloors();
}
public void CheckCurrentFloors()
{
int goalFloorCount = 0;
foreach (GameObject child in MapManager.inst.players)
{
Debug.Log("df");
if (child.GetComponent<Player>().currentFloor.isGoalFloor)
goalFloorCount++;
Debug.Log(goalFloorCount);
}
if (GameManager.aFloor >= 0)
{
MapManager.inst.currentMap.clearConditions[GameManager.aFloor].count = goalFloorCount;
MapManager.inst.currentMap.clearConditions[GameManager.aFloor].IsDone();
}
if (GameManager.nFloor >= 0)
{
MapManager.inst.currentMap.clearConditions[GameManager.nFloor].count = goalFloorCount;
MapManager.inst.currentMap.clearConditions[GameManager.nFloor].IsDone();
}
}
//For test
public string GetCurrentBullet() public string GetCurrentBullet()
{ {
return bulletList.Count > 0 ? bulletList[bulletCount].ToString() : null; return bulletList.Count > 0 ? bulletList[bulletCount].ToString() : null;
...@@ -58,7 +94,7 @@ public class PlayerController : SingletonBehaviour<PlayerController> ...@@ -58,7 +94,7 @@ public class PlayerController : SingletonBehaviour<PlayerController>
{ {
if (prePos != MapPos) if (prePos != MapPos)
{ {
Debug.Log(MapPos); //Debug.Log(MapPos);
OnPlayerMove?.Invoke(MapPos); OnPlayerMove?.Invoke(MapPos);
prePos = MapPos; prePos = MapPos;
} }
...@@ -80,13 +116,13 @@ public class PlayerController : SingletonBehaviour<PlayerController> ...@@ -80,13 +116,13 @@ public class PlayerController : SingletonBehaviour<PlayerController>
currentPlayer = hit.transform.gameObject.GetComponent<Player>(); currentPlayer = hit.transform.gameObject.GetComponent<Player>();
StartCoroutine(currentPlayer.SetCurrentPlayer()); StartCoroutine(currentPlayer.SetCurrentPlayer());
StartCoroutine(currentPlayer.CountPlayerClick(Time.time)); StartCoroutine(currentPlayer.CountPlayerClick(Time.time));
Debug.Log(hit.collider.gameObject.tag); //Debug.Log(hit.collider.gameObject.tag);
} }
else if (Physics.Raycast(mouseRay, out hit) && hit.collider.gameObject.tag.Equals("floor")) else if (Physics.Raycast(mouseRay, out hit) && hit.collider.gameObject.tag.Equals("floor"))
{ {
if (currentPlayer != null) if (currentPlayer != null)
currentPlayer.MovePlayer(hit.collider.gameObject.transform.position); currentPlayer.MovePlayer(hit.collider.gameObject.transform.position);
Debug.Log(hit.collider.gameObject.tag); //Debug.Log(hit.collider.gameObject.tag);
} }
else if (hit.collider == null) else if (hit.collider == null)
{ {
......
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