Commit 0ea6b148 authored by 18손재민's avatar 18손재민

이제 맵 에디터에서 여러개의 시작 지점을 지정할 수 있음. 시작 지점이 여러개일 경우 플레이어는 그 위치에 모두 생성됨. 현재 플레이어 하나만 선택해서 이동하는 기능 구현 중

parent 320dacb7
fileFormatVersion: 2
guid: 20fb0f72e3df40c488f15711aa30ac6e
guid: 49597164dd7e7454ca5a790c491a214e
PrefabImporter:
externalObjects: {}
userData:
......
This diff is collapsed.
fileFormatVersion: 2
guid: bec0ce48aa2c7d14abcf504346360066
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -237,85 +237,6 @@ MonoBehaviour:
m_VerticalOverflow: 0
m_LineSpacing: 1
m_Text: Create
--- !u!1 &563908795
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 563908796}
- component: {fileID: 563908797}
m_Layer: 0
m_Name: StartPosition
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &563908796
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 563908795}
m_LocalRotation: {x: 0.7071068, y: -0, z: -0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 3}
m_LocalScale: {x: 2, y: 2, z: 1}
m_Children: []
m_Father: {fileID: 1444571408780882984}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!212 &563908797
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 563908795}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: b489da500f22d7a4b8c478cae46976ad, type: 3}
m_Color: {r: 1, g: 0.09648319, b: 0, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.16, y: 0.16}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &591598817
GameObject:
m_ObjectHideFlags: 0
......@@ -433,12 +354,12 @@ MonoBehaviour:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1444571408780882988}
m_MethodName: SetStartPosition
m_Mode: 1
m_MethodName: SwitchMode
m_Mode: 3
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_IntArgument: 3
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
......@@ -2143,7 +2064,6 @@ Transform:
- {fileID: 1444571407667829093}
- {fileID: 1549724122}
- {fileID: 250553723}
- {fileID: 563908796}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
......@@ -2167,9 +2087,12 @@ MonoBehaviour:
tile: {fileID: 7449840556337937162, guid: 90d0ab9f40a0ddc4c871130319d86cd5, type: 3}
modeSign: {fileID: 153720729}
clickSign: {fileID: 250553721}
startSign: {fileID: 563908795}
startSign: {fileID: 1215997560627761150, guid: 106914c4661964b47ad09efcc4bfba69,
type: 3}
mapSizeSetter: {fileID: 8774990006778924709}
mapEditorTiles: {fileID: 1549724121}
editWallMat: {fileID: 2100000, guid: c741ce421701e7c43b7a48c4045a116b, type: 2}
realWallMat: {fileID: 2100000, guid: 9274dfd686c38aa4f91d973c6de1c8e9, type: 2}
--- !u!1 &1444571408998523813
GameObject:
m_ObjectHideFlags: 0
......
......@@ -27,7 +27,7 @@ Transform:
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 8597978733200129170}
m_LocalRotation: {x: 0.000001809995, y: 0, z: -0, w: 1}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
......@@ -59,7 +59,7 @@ MeshRenderer:
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: af605edc8af008346a3f42f355847da6, type: 2}
- {fileID: 2100000, guid: f0de6d201d8a4e54bb76ea3e3dc84ee3, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
......
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &1215997560627761150
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 6760263712793251648}
- component: {fileID: 1421645228545211072}
m_Layer: 0
m_Name: Start Sign
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &6760263712793251648
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1215997560627761150}
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 2}
m_LocalScale: {x: 2, y: 2, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 90, y: 0, z: 0}
--- !u!212 &1421645228545211072
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1215997560627761150}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: b489da500f22d7a4b8c478cae46976ad, type: 3}
m_Color: {r: 1, g: 0.093779884, b: 0, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 0.16, y: 0.16}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
fileFormatVersion: 2
guid: 106914c4661964b47ad09efcc4bfba69
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -46,8 +46,9 @@ MonoBehaviour:
isMapEditingOn: 0
floor: {fileID: 19711883686801522, guid: 71931eea896a59a4683986cfd369b8ee, type: 3}
wall: {fileID: 3736402816908646744, guid: a4dcd71ec9f819f4e88c7b5ac24f4b0d, type: 3}
player: {fileID: 0}
players: []
player: {fileID: 8862060874303168220, guid: 6ba287375b5ad4b458a7b7b99c6d6a08, type: 3}
currentMap: {fileID: 0}
surface: {fileID: 0}
stage:
- {fileID: 5554172594464001467, guid: 20fb0f72e3df40c488f15711aa30ac6e, type: 3}
- {fileID: 6311566525947587311, guid: 49597164dd7e7454ca5a790c491a214e, type: 3}
......@@ -12,7 +12,7 @@ GameObject:
- component: {fileID: 8862060874303168216}
- component: {fileID: 8862060874303168217}
- component: {fileID: 8862060874303168222}
- component: {fileID: 8862060874303168223}
- component: {fileID: 857076055737488221}
- component: {fileID: 8862060874303168218}
m_Layer: 8
m_Name: Player
......@@ -94,7 +94,7 @@ CapsuleCollider:
m_Height: 2
m_Direction: 1
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &8862060874303168223
--- !u!114 &857076055737488221
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
......@@ -103,7 +103,7 @@ MonoBehaviour:
m_GameObject: {fileID: 8862060874303168220}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0bef204316f94854e9cbe8217d86842d, type: 3}
m_Script: {fileID: 11500000, guid: ceb8a784e77658342887555993532b12, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!195 &8862060874303168218
......
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &3084434388615582932
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 7144820693024262881}
- component: {fileID: 7305835109978716895}
m_Layer: 0
m_Name: PlayerController
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &7144820693024262881
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3084434388615582932}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &7305835109978716895
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 3084434388615582932}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0bef204316f94854e9cbe8217d86842d, type: 3}
m_Name:
m_EditorClassIdentifier:
fileFormatVersion: 2
guid: e84ad2e2416a25447b16b00fbe19964e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
......@@ -280,7 +280,7 @@ Light:
m_SpotAngle: 30
m_CookieSize: 10
m_Shadows:
m_Type: 2
m_Type: 0
m_Resolution: -1
m_CustomResolution: -1
m_Strength: 1
......
This diff is collapsed.
fileFormatVersion: 2
guid: f6226b2548447a54486acfc694a44e4d
guid: 5bc10e17adc09f34d8d61ffefb655889
folderAsset: yes
DefaultImporter:
externalObjects: {}
......
......@@ -11,7 +11,7 @@ public class Map : MonoBehaviour
private Dictionary<Vector2, Wall> wallGrid;
public GameObject floors;
public GameObject walls;
public Floor startFloor;
public List<Floor> startFloors;
/// <summary>
/// Get floor at position.
......@@ -144,7 +144,8 @@ public class Map : MonoBehaviour
Vector2 wallPos = (Vector2)(floor1.mapPos + floor2.mapPos) / 2;
if (!wallGrid.ContainsKey(wallPos))
{
if(Mathf.Abs(floor1.mapPos.x - floor2.mapPos.x) > 1 || Mathf.Abs(floor1.mapPos.y - floor2.mapPos.y) > 1)
if(Mathf.Abs(floor1.mapPos.x - floor2.mapPos.x) > 1 || Mathf.Abs(floor1.mapPos.y - floor2.mapPos.y) > 1 ||
(Mathf.Abs(floor1.mapPos.x - floor2.mapPos.x) == 1 && Mathf.Abs(floor1.mapPos.y - floor2.mapPos.y) == 1))
{
Debug.Log("Two floors are not adjacent floors.");
return;
......@@ -212,13 +213,20 @@ public class Map : MonoBehaviour
}
}
private void Awake()
public void InitiateMap()
{
floorGrid = new Dictionary<Vector2Int, Floor>();
wallGrid = new Dictionary<Vector2, Wall>();
LoadObjects();
maxMapSize = 5 * Mathf.Max(testInputSizeX, testInputSizeY);
//CreateFloor(new Vector2Int(0, 0), new Vector2Int(9, 9));
startFloors = new List<Floor>();
//LoadObjects();
}
private void Awake()
{
/*floorGrid = new Dictionary<Vector2Int, Floor>();
wallGrid = new Dictionary<Vector2, Wall>();
startFloors = new List<Floor>();
LoadObjects();*/
}
// Start is called before the first frame update
......
......@@ -11,26 +11,30 @@ public class MapEditor : SingletonBehaviour<MapEditor>
public Map currentMap;
public Map[] stage;
public MapEditorTile tile;
public enum TileMode { None, Floor, Wall };
public enum TileMode { None, Floor, Wall, StartFloor };
TileMode currentMode;
public Text modeSign;
public GameObject clickSign;
public GameObject startSign;
public Dictionary<Floor, GameObject> startSigns;
public GameObject mapSizeSetter;
public GameObject mapEditorTiles;
public Material editWallMat;
public Material realWallMat;
Vector2Int[] wallInputFloors;
bool isWallClicked;
bool isEditorStarted;
bool isCreateMode;
bool isStartPositionSetter;
public void LoadMap(Map _newMap)
public void StartMap(Map _newMap)
{
if (currentMap != null)
Destroy(currentMap.gameObject);
currentMap = Instantiate(_newMap);
currentMap.transform.position = new Vector3(0, 0, 0);
currentMap.InitiateMap();
}
/// <summary>
/// Saves map to Assets folder.
......@@ -42,12 +46,20 @@ public class MapEditor : SingletonBehaviour<MapEditor>
string localPath = "Assets/SavedMap_" + time.ToShortDateString() + "-" + time.Hour + "-" + time.Minute + "-" + time.Second + ".prefab";
if (AssetDatabase.LoadAssetAtPath(localPath, typeof(GameObject)))
Debug.Log("Object with same name already exists.");
else if(currentMap.startFloor == null)
else if(currentMap.startFloors.Count == 0)
Debug.Log("There is no start floor.");
else
{
foreach(Transform child in currentMap.walls.transform)
{
child.gameObject.GetComponent<MeshRenderer>().material = realWallMat;
}
PrefabUtility.SaveAsPrefabAsset(_newMap.gameObject, localPath);
Debug.Log("Map saved at " + localPath);
foreach (Transform child in currentMap.walls.transform)
{
child.gameObject.GetComponent<MeshRenderer>().material = editWallMat;
}
}
}
public void SaveCurrentMap()
......@@ -89,36 +101,25 @@ public class MapEditor : SingletonBehaviour<MapEditor>
void SetModeSign()
{
string sign = "Mode : " + currentMode.ToString();
if (isStartPositionSetter)
modeSign.text = "Set start position";
else if (isCreateMode)
if (isCreateMode)
modeSign.text = sign + " Create";
else
modeSign.text = sign + " Destroy";
}
public void SetStartPosition()
{
if(!isStartPositionSetter)
isStartPositionSetter = true;
else
isStartPositionSetter = false;
SetModeSign();
}
private void Awake()
{
MapManager.inst.isMapEditingOn = true;
clickSign.SetActive(false);
startSign.SetActive(false);
isEditorStarted = false;
isCreateMode = true;
isStartPositionSetter = false;
startSigns = new Dictionary<Floor, GameObject>();
}
// Start is called before the first frame update
void Start()
{
LoadMap(stage[0]);
StartMap(stage[0]);
wallInputFloors = new Vector2Int[2];
isWallClicked = false;
SwitchMode(0);
......@@ -135,15 +136,7 @@ public class MapEditor : SingletonBehaviour<MapEditor>
{
Debug.Log(hit.transform.position);
Vector2Int clickedPos = new Vector2Int((int)hit.transform.position.x, (int)hit.transform.position.z);
if (isStartPositionSetter)
{
currentMap.startFloor = currentMap.GetFloorAtPos(clickedPos);
startSign.SetActive(true);
startSign.transform.position = currentMap.startFloor.transform.position + new Vector3(0, 1, 0);
isStartPositionSetter = false;
SetModeSign();
}
else if(currentMode == TileMode.Floor)
if(currentMode == TileMode.Floor)
{
if (isCreateMode)
currentMap.CreateFloor(clickedPos);
......@@ -163,13 +156,47 @@ public class MapEditor : SingletonBehaviour<MapEditor>
{
wallInputFloors[1] = clickedPos;
if (isCreateMode)
{
currentMap.CreateWall(currentMap.GetFloorAtPos(wallInputFloors[0]), currentMap.GetFloorAtPos(wallInputFloors[1]));
if(currentMap.GetWallAtPos(currentMap.GetFloorAtPos(wallInputFloors[0]), currentMap.GetFloorAtPos(wallInputFloors[1])) != null)
currentMap.GetWallAtPos(currentMap.GetFloorAtPos(wallInputFloors[0]), currentMap.GetFloorAtPos(wallInputFloors[1]))
.gameObject.GetComponent<MeshRenderer>().material = editWallMat;
}
else
currentMap.RemoveWall(currentMap.GetFloorAtPos(wallInputFloors[0]), currentMap.GetFloorAtPos(wallInputFloors[1]));
clickSign.SetActive(false);
isWallClicked = false;
}
}
else if(currentMode == TileMode.StartFloor)
{
if (isCreateMode)
{
if(currentMap.startFloors.Contains(currentMap.GetFloorAtPos(clickedPos)))
{
Debug.Log("Start floor already exists at : (" + clickedPos.x + ", " + clickedPos.y + ")");
}
else
{
currentMap.startFloors.Add(currentMap.GetFloorAtPos(clickedPos));
startSigns.Add(currentMap.GetFloorAtPos(clickedPos), Instantiate(startSign));
startSigns[currentMap.GetFloorAtPos(clickedPos)].transform.position = new Vector3(clickedPos.x, 2, clickedPos.y);
}
}
else
{
if (!currentMap.startFloors.Contains(currentMap.GetFloorAtPos(clickedPos)))
{
Debug.Log("Start floor doesn't exist at : (" + clickedPos.x + ", " + clickedPos.y + ")");
}
else
{
currentMap.startFloors.Remove(currentMap.GetFloorAtPos(clickedPos));
Destroy(startSigns[currentMap.GetFloorAtPos(clickedPos)].gameObject);
startSigns.Remove(currentMap.GetFloorAtPos(clickedPos));
}
}
}
}
}
}
......
......@@ -5,16 +5,4 @@ using UnityEngine;
public class MapEditorTile : MonoBehaviour
{
public Vector2 mapPos;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
......@@ -9,6 +9,7 @@ public class MapManager : SingletonBehaviour<MapManager>
public bool isMapEditingOn;
public Floor floor;
public Wall wall;
public List<GameObject> players;
public GameObject player;
public Map currentMap;
public NavMeshSurface surface;
......@@ -21,7 +22,8 @@ public class MapManager : SingletonBehaviour<MapManager>
currentMap = Instantiate(_newMap);
currentMap.transform.position = new Vector3(0, 0, 0);
surface.BuildNavMesh();
player.transform.position = currentMap.startFloor.transform.position + new Vector3(0, 1.5f, 0);
for (int i = 0; i < currentMap.startFloors.Count; i++)
players.Add(Instantiate(player, currentMap.startFloors[i].transform.position + new Vector3(0, 1.5f, 0), Quaternion.identity));
}
public IEnumerator Rebaker()
{
......@@ -31,7 +33,7 @@ public class MapManager : SingletonBehaviour<MapManager>
private void Awake()
{
player = GameObject.Find("Player");
players = new List<GameObject>();
}
// Start is called before the first frame update
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
public void SetCurrentPlayer()
{
transform.localScale = new Vector3(1, 2, 1);
}
public void ResetCurrentPlayer()
{
transform.localScale = new Vector3(1, 1, 1);
PlayerController.inst.currentPlayer = null;
}
public void MovePlayer()
{
}
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
fileFormatVersion: 2
guid: ceb8a784e77658342887555993532b12
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -3,8 +3,10 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AI;
public class PlayerController : MonoBehaviour
public class PlayerController : SingletonBehaviour<PlayerController>
{
public Player currentPlayer;
// Start is called before the first frame update
void Start()
{
......@@ -18,12 +20,25 @@ public class PlayerController : MonoBehaviour
{
Ray mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(mouseRay, out hit) && hit.collider.gameObject.tag.Equals("floor"))
if (Physics.Raycast(mouseRay, out hit) && hit.collider.gameObject.tag.Equals("Player"))
{
if(currentPlayer != null)
currentPlayer.ResetCurrentPlayer();
currentPlayer = hit.transform.gameObject.GetComponent<Player>();
currentPlayer.SetCurrentPlayer();
Debug.Log(hit.collider.gameObject.tag);
}
else if(hit.collider == null)
{
if (currentPlayer != null)
currentPlayer.ResetCurrentPlayer();
}
/*if (Physics.Raycast(mouseRay, out hit) && hit.collider.gameObject.tag.Equals("floor"))
{
GetComponent<NavMeshAgent>().SetDestination(hit.collider.gameObject.transform.position);
Debug.Log(hit.collider.gameObject.GetComponent<Floor>().mapPos);
Debug.Log(hit.collider.gameObject.tag);
}
}*/
}
}
}
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