plantilla base para movimiento básico
This commit is contained in:
Robii Aragon
2026-02-05 05:07:55 -08:00
parent 195b696771
commit 779f2c8b20
14443 changed files with 23840465 additions and 452 deletions

View File

@@ -0,0 +1,126 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GKC_Triangulator_Utils
{
List<Vector2> m_points = new List<Vector2> ();
public GKC_Triangulator_Utils (List<Vector2> points)
{
m_points = new List<Vector2> (points);
}
public int[] Triangulate ()
{
List<int> indices = new List<int> ();
int n = m_points.Count;
if (n < 3) {
return indices.ToArray ();
}
int[] V = new int[n];
if (Area () > 0) {
for (int v = 0; v < n; v++) {
V [v] = v;
}
} else {
for (int v = 0; v < n; v++) {
V [v] = (n - 1) - v;
}
}
int nv = n;
int count = 2 * nv;
for (int m = 0, v = nv - 1; nv > 2;) {
if ((count--) <= 0) {
return indices.ToArray ();
}
int u = v;
if (nv <= u) {
u = 0;
}
v = u + 1;
if (nv <= v) {
v = 0;
}
int w = v + 1;
if (nv <= w) {
w = 0;
}
if (Snip (u, v, w, nv, V)) {
int a, b, c, s, t;
a = V [u];
b = V [v];
c = V [w];
indices.Add (a);
indices.Add (b);
indices.Add (c);
m++;
for (s = v, t = v + 1; t < nv; s++, t++) {
V [s] = V [t];
}
nv--;
count = 2 * nv;
}
}
indices.Reverse ();
return indices.ToArray ();
}
float Area ()
{
int n = m_points.Count;
float A = 0.0f;
for (int p = n - 1, q = 0; q < n; p = q++) {
Vector2 pval = m_points [p];
Vector2 qval = m_points [q];
A += pval.x * qval.y - qval.x * pval.y;
}
return (A * 0.5f);
}
bool Snip (int u, int v, int w, int n, int[] V)
{
int p;
Vector2 A = m_points [V [u]];
Vector2 B = m_points [V [v]];
Vector2 C = m_points [V [w]];
if (Mathf.Epsilon > (((B.x - A.x) * (C.y - A.y)) - ((B.y - A.y) * (C.x - A.x)))) {
return false;
}
for (p = 0; p < n; p++) {
if ((p == u) || (p == v) || (p == w)) {
continue;
}
Vector2 P = m_points [V [p]];
if (InsideTriangle (A, B, C, P)) {
return false;
}
}
return true;
}
bool InsideTriangle (Vector2 A, Vector2 B, Vector2 C, Vector2 P)
{
float ax, ay, bx, by, cx, cy, apx, apy, bpx, bpy, cpx, cpy;
float cCROSSap, bCROSScp, aCROSSbp;
ax = C.x - B.x;
ay = C.y - B.y;
bx = A.x - C.x;
by = A.y - C.y;
cx = B.x - A.x;
cy = B.y - A.y;
apx = P.x - A.x;
apy = P.y - A.y;
bpx = P.x - B.x;
bpy = P.y - B.y;
cpx = P.x - C.x;
cpy = P.y - C.y;
aCROSSbp = ax * bpy - ay * bpx;
cCROSSap = cx * apy - cy * apx;
bCROSScp = bx * cpy - by * cpx;
return ((aCROSSbp >= 0.0f) && (bCROSScp >= 0.0f) && (cCROSSap >= 0.0f));
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 3102031c74af2644fb87593b2f9c8da9
timeCreated: 1551058274
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Map/GKC_Triangulator_Utils.cs
uploadId: 814740

View File

@@ -0,0 +1,192 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class addMapObjectInformation : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool activateAtStart;
public bool activateOnEnable;
public bool callCreateMapIconInfoIfComponentExists;
public string mainMapCreatorManagerName = "Map Creator";
[Space]
[Header ("Map Settings")]
[Space]
public bool addMapIcon;
public string mapObjectName;
public string mapObjectTypeName;
[TextArea (3, 10)] public string description;
public bool visibleInAllBuildings;
public bool visibleInAllFloors;
public bool calculateFloorAtStart;
public bool setFloorNumber;
public int buildingIndex;
public int floorNumber;
[Space]
[Header ("Objective Screen Icon Settings")]
[Space]
public bool addIconOnScreen;
public float triggerRadius;
public bool showOffScreenIcon;
public bool useCloseDistance;
public bool showMapWindowIcon;
public bool showDistance;
public bool showDistanceOffScreen;
public string objectiveIconName;
public float objectiveOffset;
public bool useCustomObjectiveColor;
public Color objectiveColor;
public bool removeCustomObjectiveColor;
public string mainManagerName = "Screen Objectives Manager";
mapObjectInformation mapObjectInformationManager;
mapCreator mapCreatorManager;
screenObjectivesSystem mainscreenObjectivesSystem;
bool componentAlreadyExists;
void Start ()
{
if (activateAtStart) {
activateMapObject ();
}
}
void OnEnable ()
{
if (activateOnEnable) {
activateMapObject ();
}
}
public void checkGetMapCreatorManager ()
{
bool mapCreatorManagerAssigned = (mapCreatorManager != null);
if (!mapCreatorManagerAssigned) {
mapCreatorManager = mapCreator.Instance;
mapCreatorManagerAssigned = mapCreatorManager != null;
}
if (!mapCreatorManagerAssigned) {
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (mapCreator.getMainManagerName (), typeof(mapCreator), true);
mapCreatorManager = mapCreator.Instance;
mapCreatorManagerAssigned = (mapCreatorManager != null);
}
if (!mapCreatorManagerAssigned) {
mapCreatorManager = FindObjectOfType<mapCreator> ();
}
}
public void activateMapObject ()
{
if (addMapIcon) {
checkGetMapCreatorManager ();
if (mapCreatorManager == null) {
print ("Warning: there is no map system configured, so the object " + gameObject.name + " won't use a new map object icon");
return;
}
if (mapObjectInformationManager == null) {
mapObjectInformationManager = gameObject.AddComponent<mapObjectInformation> ();
} else {
componentAlreadyExists = true;
}
if (mapObjectInformationManager == null) {
mapObjectInformationManager = gameObject.GetComponent<mapObjectInformation> ();
}
mapObjectInformationManager.assignID (mapCreatorManager.getAndIncreaselastMapObjectInformationIDAssigned ());
mapObjectInformationManager.setMapObjectName (mapObjectName);
if (addIconOnScreen) {
mapObjectInformationManager.setCustomValues (visibleInAllBuildings, visibleInAllFloors, calculateFloorAtStart, useCloseDistance,
triggerRadius, showOffScreenIcon, showMapWindowIcon, showDistance, showDistanceOffScreen, objectiveIconName, useCustomObjectiveColor, objectiveColor, removeCustomObjectiveColor);
}
if (setFloorNumber) {
mapObjectInformationManager.floorIndex = floorNumber;
mapObjectInformationManager.buildingIndex = buildingIndex;
}
mapObjectInformationManager.getMapObjectInformation ();
mapObjectInformationManager.getIconTypeIndexByName (mapObjectTypeName);
mapObjectInformationManager.description = description;
if (componentAlreadyExists) {
if (callCreateMapIconInfoIfComponentExists) {
mapObjectInformationManager.createMapIconInfo ();
}
}
} else {
if (addIconOnScreen) {
bool mainscreenObjectivesSystemLocated = mainscreenObjectivesSystem != null;
if (!mainscreenObjectivesSystemLocated) {
mainscreenObjectivesSystem = screenObjectivesSystem.Instance;
mainscreenObjectivesSystemLocated = mainscreenObjectivesSystem != null;
}
if (!mainscreenObjectivesSystemLocated) {
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (screenObjectivesSystem.getMainManagerName (), typeof(screenObjectivesSystem), true);
mainscreenObjectivesSystem = screenObjectivesSystem.Instance;
mainscreenObjectivesSystemLocated = mainscreenObjectivesSystem != null;
}
if (mainscreenObjectivesSystemLocated) {
mainscreenObjectivesSystem.addElementToScreenObjectiveList (gameObject, useCloseDistance, triggerRadius, showOffScreenIcon,
showDistance, showDistanceOffScreen, objectiveIconName, useCustomObjectiveColor, objectiveColor, removeCustomObjectiveColor, objectiveOffset);
}
}
}
}
public void removeMapObject ()
{
bool mainscreenObjectivesSystemLocated = mainscreenObjectivesSystem != null;
if (!mainscreenObjectivesSystemLocated) {
mainscreenObjectivesSystem = screenObjectivesSystem.Instance;
mainscreenObjectivesSystemLocated = mainscreenObjectivesSystem != null;
}
if (!mainscreenObjectivesSystemLocated) {
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (screenObjectivesSystem.getMainManagerName (), typeof(screenObjectivesSystem), true);
mainscreenObjectivesSystem = screenObjectivesSystem.Instance;
mainscreenObjectivesSystemLocated = mainscreenObjectivesSystem != null;
}
if (mainscreenObjectivesSystemLocated) {
mainscreenObjectivesSystem.removeGameObjectFromList (gameObject);
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 2c1850c60f89a9e44bb89e99dc9b7aaa
timeCreated: 1519420619
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Map/addMapObjectInformation.cs
uploadId: 814740

View File

@@ -0,0 +1,29 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class buildingAndFloorObjectInfoSystem : MonoBehaviour
{
public mapCreator mapCreatorManager;
public Transform buildingParent;
public Transform floorParent;
GameObject currentObjectToChangeBuildingInfo;
public void setCurrentObjectToChangeBuildingInfo (GameObject newObject)
{
currentObjectToChangeBuildingInfo = newObject;
}
public void setBuildingAndFloorInfoToObject ()
{
mapCreatorManager.setBuildingAndFloorInfoToObject (currentObjectToChangeBuildingInfo, buildingParent, floorParent);
}
public void setBuildingFloorInfo (Transform newBuildingParent, Transform newFloorParent, mapCreator newMapCreator)
{
mapCreatorManager = newMapCreator;
buildingParent = newBuildingParent;
floorParent = newFloorParent;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 78f4e670e25e46647a25099a095735d4
timeCreated: 1534649322
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Map/buildingAndFloorObjectInfoSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,7 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class glossaryElement : MonoBehaviour {
public mapSystem.glossaryElementInfo glossaryInfo;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 75c3ff7bea959f44a861309b65f2b54c
timeCreated: 1501351191
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Map/glossaryElement.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 017e6af74335cde4f8c354af0a8cd4a3
timeCreated: 1466693656
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Map/mapCreator.cs
uploadId: 814740

View File

@@ -0,0 +1,16 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class mapIconType
{
public string typeName;
public RectTransform icon;
public bool showIconPreview;
public bool enabled;
public bool useCompassIcon;
public GameObject compassIconPrefab;
public float verticalOffset;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: a3d42d43e329be044adf4f7adebbed6e
timeCreated: 1551058080
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Map/mapIconType.cs
uploadId: 814740

View File

@@ -0,0 +1,687 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.Events;
public class mapObjectInformation : MonoBehaviour
{
public string mapObjectName;
[TextArea (3, 10)]
public string description;
public GameObject mapObject;
public float offsetRadius;
public bool showOffScreenIcon = true;
public bool showMapWindowIcon = true;
public bool showDistance = true;
public bool showDistanceOffScreen;
public bool isActivate = true;
public bool visibleInAllBuildings;
public bool visibleInAllFloors;
public bool calculateFloorAtStart;
public bool useCloseDistance = true;
public float triggerRadius = 5;
public Color triggerColor = Color.blue;
public float gizmoLabelOffset;
public Color gizmoLabelColor = Color.white;
public int typeIndex;
public string typeName;
public string[] typeNameList;
public int floorIndex;
public string currentFloor;
public string[] floorList;
public float extraIconSizeOnMap;
public bool followCameraRotation;
public bool followObjectRotation;
public Vector3 offset;
public mapSystem mapManager;
public bool useCustomObjectiveColor;
public Color objectiveColor;
public bool removeCustomObjectiveColor;
public float objectiveOffset;
public bool removeComponentWhenObjectiveReached = true;
public bool disableWhenPlayerHasReached;
public int buildingIndex;
public string buildingName;
public string[] buildingList;
public string currentBuilding;
public bool belongToMapPart;
public string mapPartName;
public string[] mapPartList;
public int mapPartIndex;
public mapCreator mapCreatorManager;
bool mapCreatorManagerAssigned;
public bool useCustomValues;
public int ID;
public bool callEventWhenPointReached;
public UnityEvent pointReachedEvent = new UnityEvent ();
public bool useEventsOnChangeFloor;
public bool useEventOnEnabledFloor;
public UnityEvent evenOnEnabledFloor;
public bool useEventOnDisabledFloor;
public UnityEvent evenOnDisabledFloor;
public bool canChangeBuildingAndFloor;
public bool activateAtStart = true;
public Color offsetGizmoColor;
public bool offsetShowGizmo;
public bool showGizmo;
string objectiveIconName;
public mapSystem.mapObjectInfo currentMapObjectInfo;
public bool setCustomCompassSettings;
public bool useCompassIcon;
public GameObject compassIconPrefab;
public float verticalOffset;
public bool mapObjectAssigned;
public string mainScreenObjectivesManagerName = "Screen Objectives Manager";
public string mainMapCreatorManagerName = "Map Creator";
screenObjectivesSystem screenObjectivesManager;
bool mapObjectRemoved;
bool screenObjectivesManagerChecked;
void Start ()
{
checkAssignMapObject ();
if (activateAtStart) {
createMapIconInfo ();
}
StartCoroutine (checkIfBelongToMapPartCoroutine ());
}
IEnumerator checkIfBelongToMapPartCoroutine ()
{
WaitForSeconds delay = new WaitForSeconds (0.01f);
yield return delay;
checkIfBelongToMapPart ();
}
void checkIfBelongToMapPart ()
{
checkGetMapCreatorManager ();
bool mapObjectAssignedCorrectly = false;
if (belongToMapPart) {
if (mapCreatorManager != null) {
if (buildingIndex < mapCreatorManager.buildingList.Count) {
List<mapCreator.floorInfo> temporalBuildingFloorsList = mapCreatorManager.buildingList [buildingIndex].buildingFloorsList;
if (floorIndex < temporalBuildingFloorsList.Count) {
List<mapTileBuilder> temporalMapTileBuilder = temporalBuildingFloorsList [floorIndex].mapTileBuilderList;
if (mapPartIndex < temporalMapTileBuilder.Count) {
if (!temporalMapTileBuilder [mapPartIndex].mapPartEnabled) {
//print ("inactive");
mapCreatorManager.enableOrDisableSingleMapIconByID (ID, false);
}
mapObjectAssignedCorrectly = true;
}
}
}
if (!mapObjectAssignedCorrectly) {
string objectName = gameObject.name;
if (mapObject != null) {
objectName = mapObject.name;
}
print ("WARNING: map object information not properly configured in object " + objectName);
}
}
}
}
public void checkAssignMapObject ()
{
if (!mapObjectAssigned) {
mapObject = gameObject;
mapObjectAssigned = true;
}
}
public void createMapIconInfo ()
{
checkAssignMapObject ();
if (!belongToMapPart) {
mapPartIndex = -1;
}
if (typeName != "") {
if (disableWhenPlayerHasReached) {
if (showMapWindowIcon) {
checkGetMapCreatorManager ();
if (mapCreatorManager != null) {
mapCreatorManager.addMapObject (visibleInAllBuildings, visibleInAllFloors, false, mapObject,
typeName, offset, -1, -1, buildingIndex, extraIconSizeOnMap, followCameraRotation,
followObjectRotation, setCustomCompassSettings, useCompassIcon, compassIconPrefab, verticalOffset);
mapObjectRemoved = false;
}
}
getScreenObjectivesManager ();
screenObjectivesManagerChecked = true;
if (screenObjectivesManager != null) {
screenObjectivesManager.addElementToScreenObjectiveList (mapObject, useCloseDistance, triggerRadius, showOffScreenIcon,
showDistance, showDistanceOffScreen, typeName, useCustomObjectiveColor, objectiveColor, removeCustomObjectiveColor, objectiveOffset);
}
} else {
checkGetMapCreatorManager ();
if (mapCreatorManager != null) {
mapCreatorManager.addMapObject (visibleInAllBuildings, visibleInAllFloors, calculateFloorAtStart, mapObject,
typeName, offset, ID, mapPartIndex, buildingIndex, extraIconSizeOnMap, followCameraRotation,
followObjectRotation, setCustomCompassSettings, useCompassIcon, compassIconPrefab, verticalOffset);
mapObjectRemoved = false;
}
if (useCustomValues) {
getScreenObjectivesManager ();
if (screenObjectivesManager != null) {
screenObjectivesManager.addElementToScreenObjectiveList (mapObject, useCloseDistance, triggerRadius,
showOffScreenIcon, showDistance, showDistanceOffScreen, objectiveIconName, useCustomObjectiveColor, objectiveColor,
removeCustomObjectiveColor, 0);
}
}
screenObjectivesManagerChecked = true;
}
} else {
string objectName = gameObject.name;
if (mapObject != null) {
objectName = mapObject.name;
}
print ("WARNING: map object information not properly configured in object " + objectName);
}
}
public void getScreenObjectivesManager ()
{
bool screenObjectivesManagerLocated = screenObjectivesManager != null;
if (!screenObjectivesManagerLocated) {
screenObjectivesManager = screenObjectivesSystem.Instance;
screenObjectivesManagerLocated = screenObjectivesManager != null;
}
if (!screenObjectivesManagerLocated) {
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (screenObjectivesSystem.getMainManagerName (), typeof(screenObjectivesSystem), true);
screenObjectivesManager = screenObjectivesSystem.Instance;
}
}
public void addMapObject (string mapIconType)
{
checkAssignMapObject ();
if (mapCreatorManager != null) {
mapCreatorManager.addMapObject (visibleInAllBuildings, visibleInAllFloors, calculateFloorAtStart, mapObject,
mapIconType, offset, ID, mapPartIndex, buildingIndex, extraIconSizeOnMap, followCameraRotation,
followObjectRotation, setCustomCompassSettings, useCompassIcon, compassIconPrefab, verticalOffset);
mapObjectRemoved = false;
}
}
public bool checkIfIncludedOnScreenObjectiveOnRemoveMapObject;
public void removeMapObject ()
{
checkAssignMapObject ();
if (screenObjectivesManagerChecked || checkIfIncludedOnScreenObjectiveOnRemoveMapObject) {
getScreenObjectivesManager ();
//remove the object from the screen objective system in case it was added as a mark
if (screenObjectivesManager != null) {
screenObjectivesManager.removeGameObjectFromList (mapObject);
}
}
if (mapCreatorManagerAssigned) {
//remove object of the map
if (mapCreatorManager != null) {
mapCreatorManager.removeMapObject (mapObject, false);
}
}
mapObjectRemoved = true;
}
void OnDestroy ()
{
if (GKC_Utils.isApplicationPlaying () && Time.deltaTime > 0) {
// print ("DESTROYYYYYY map checking if playing");
if (!mapObjectRemoved) {
removeMapObject ();
}
}
}
public void setPathElementInfo (bool showOffScreenIconInfo, bool showMapWindowIconInfo, bool showDistanceInfo)
{
typeName = "Path Element";
showGizmo = true;
showOffScreenIcon = showOffScreenIconInfo;
showMapWindowIcon = showMapWindowIconInfo;
showDistance = showDistanceInfo;
}
public void getMapIconTypeList ()
{
checkGetMapManager ();
if (mapManager != null) {
typeNameList = new string[mapManager.mapIconTypes.Count];
for (int i = 0; i < mapManager.mapIconTypes.Count; i++) {
typeNameList [i] = mapManager.mapIconTypes [i].typeName;
}
updateComponent ();
}
}
public void getBuildingList ()
{
checkGetMapManager ();
checkGetMapCreatorManager ();
if (mapManager != null) {
if (mapManager.buildingList.Count > 0) {
buildingList = new string[mapManager.buildingList.Count];
for (int i = 0; i < mapManager.buildingList.Count; i++) {
string newName = mapManager.buildingList [i].Name;
buildingList [i] = newName;
}
updateComponent ();
} else {
print ("Not buildings were found. To use the map object information component, first add and configure different floors in the map " +
"creator component. Check the documentation of the asset related to the Map System for a better explanation");
}
}
}
public void getFloorList ()
{
if (mapManager != null && mapCreatorManager != null) {
if (mapManager.buildingList.Count > 0) {
if (buildingIndex >= 0 && buildingIndex < mapCreatorManager.buildingList.Count) {
List<mapSystem.floorInfo> temporalFloors = mapManager.buildingList [buildingIndex].floors;
if (temporalFloors.Count > 0) {
floorList = new string[temporalFloors.Count ];
for (int i = 0; i < temporalFloors.Count; i++) {
if (temporalFloors [i].floor != null) {
string newName = temporalFloors [i].floor.gameObject.name;
floorList [i] = newName;
}
}
updateComponent ();
if (belongToMapPart) {
getMapPartList ();
}
}
}
} else {
print ("Not floors were found. To use the map object information component, first add and configure different floors in the map creator component. Check" +
"the documentation of the asset related to the Map System for a better explanation");
}
}
}
public void checkGetMapManager ()
{
if (mapManager == null) {
mapManager = FindObjectOfType<mapSystem> ();
}
}
public void checkGetMapCreatorManager ()
{
mapCreatorManagerAssigned = (mapCreatorManager != null);
if (!mapCreatorManagerAssigned) {
mapCreatorManager = mapCreator.Instance;
mapCreatorManagerAssigned = mapCreatorManager != null;
}
if (!mapCreatorManagerAssigned) {
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (mapCreator.getMainManagerName (), typeof(mapCreator), true);
mapCreatorManager = mapCreator.Instance;
mapCreatorManagerAssigned = (mapCreatorManager != null);
}
if (!mapCreatorManagerAssigned) {
mapCreatorManager = FindObjectOfType<mapCreator> ();
mapCreatorManagerAssigned = mapCreatorManager != null;
}
}
public void getCurrentMapManager ()
{
checkGetMapManager ();
checkGetMapCreatorManager ();
updateComponent ();
}
public void getMapPartList ()
{
if (mapCreatorManager != null) {
if (floorIndex >= 0 && buildingIndex >= 0) {
bool mapAssignedCorrectly = false;
List<mapCreator.buildingInfo> temporalBuildingList = mapCreatorManager.buildingList;
if (buildingIndex < temporalBuildingList.Count) {
List<mapCreator.floorInfo> temporalBuildingFloorsList = temporalBuildingList [buildingIndex].buildingFloorsList;
if (floorIndex < temporalBuildingFloorsList.Count) {
mapPartList = new string[temporalBuildingFloorsList [floorIndex].mapPartsList.Count];
for (int i = 0; i < temporalBuildingFloorsList [floorIndex].mapPartsList.Count; i++) {
string newName = temporalBuildingFloorsList [floorIndex].mapPartsList [i].name;
mapPartList [i] = newName;
}
mapAssignedCorrectly = true;
}
}
if (!mapAssignedCorrectly) {
floorIndex = 0;
mapPartList = new string[0];
}
updateComponent ();
}
}
}
public void getIconTypeIndexByName (string iconTypeName)
{
int index = mapManager.getIconTypeIndexByName (iconTypeName);
if (index != -1) {
typeIndex = index;
typeName = iconTypeName;
}
}
public void getMapObjectInformation ()
{
getBuildingList ();
getFloorList ();
getMapIconTypeList ();
}
public void checkIfMapObjectInformationFound ()
{
if (mapManager != null) {
if (mapManager.buildingList.Count == 0) {
buildingList = new string[0];
} else {
if (buildingIndex > mapManager.buildingList.Count - 1 || buildingIndex < 0) {
buildingIndex = 0;
floorList = new string[0];
floorIndex = -1;
}
if (floorIndex > floorList.Length - 1) {
floorIndex = 0;
}
}
}
updateComponent ();
}
public void setCustomValues (bool visibleInAllBuildingsValue, bool visibleInAllFloorsValue, bool calculateFloorAtStartValue, bool useCloseDistanceValue,
float triggerRadiusValue, bool showOffScreenIconValue, bool showMapWindowIconValue, bool showDistanceValue, bool showDistanceOffScreenValue, string objectiveIconNameValue,
bool useCustomObjectiveColorValue, Color objectiveColorValue, bool removeCustomObjectiveColorValue)
{
useCustomValues = true;
visibleInAllBuildings = visibleInAllBuildingsValue;
visibleInAllFloors = visibleInAllFloorsValue;
calculateFloorAtStart = calculateFloorAtStartValue;
useCloseDistance = useCloseDistanceValue;
triggerRadius = triggerRadiusValue;
showOffScreenIcon = showOffScreenIconValue;
showMapWindowIcon = showMapWindowIconValue;
showDistance = showDistanceValue;
showDistanceOffScreen = showDistanceOffScreenValue;
objectiveIconName = objectiveIconNameValue;
useCustomObjectiveColor = useCustomObjectiveColorValue;
objectiveColor = objectiveColorValue;
removeCustomObjectiveColor = removeCustomObjectiveColorValue;
}
public void changeMapObjectIconFloor (int newFloorIndex)
{
checkAssignMapObject ();
mapCreatorManager.changeMapObjectIconFloor (mapObject, newFloorIndex);
}
public void changeMapObjectIconFloorByPosition ()
{
checkAssignMapObject ();
mapCreatorManager.changeMapObjectIconFloorByPosition (mapObject);
}
public void enableSingleMapIconByID ()
{
mapCreatorManager.enableOrDisableSingleMapIconByID (ID, true);
}
public void assignID (int newID)
{
ID = newID;
updateComponent ();
}
public void checkPointReachedEvent ()
{
if (callEventWhenPointReached) {
if (pointReachedEvent.GetPersistentEventCount () > 0) {
pointReachedEvent.Invoke ();
}
}
}
//Functions called and used to link a map object information and a map object info in the map system, so if the state changes in one of them, the other can update its state too
public void checkEventOnChangeFloor (int currentBuildingIndex, int currentFloorIndex)
{
if (useEventsOnChangeFloor) {
if (currentBuildingIndex == buildingIndex && floorIndex == currentFloorIndex) {
if (useEventOnEnabledFloor) {
evenOnEnabledFloor.Invoke ();
}
} else {
if (useEventOnDisabledFloor) {
evenOnDisabledFloor.Invoke ();
}
}
}
}
public void setCurrentMapObjectInfo (mapSystem.mapObjectInfo newMapObjectInfo)
{
if (canChangeBuildingAndFloor) {
currentMapObjectInfo = newMapObjectInfo;
}
}
public void setNewBuildingAndFloorIndex (int newBuildingIndex, int newFloorIndex)
{
if (canChangeBuildingAndFloor) {
buildingIndex = newBuildingIndex;
floorIndex = newFloorIndex;
mapCreatorManager.setnewBuilingAndFloorIndexToMapObject (currentMapObjectInfo, newBuildingIndex, newFloorIndex);
}
}
public void setNewBuildingAndFloorIndexByInspector ()
{
if (canChangeBuildingAndFloor) {
mapCreatorManager.setnewBuilingAndFloorIndexToMapObject (currentMapObjectInfo, buildingIndex, floorIndex);
}
}
public void setNewBuildingIndex (int newBuildingIndex)
{
buildingIndex = newBuildingIndex;
}
public void setNewFloorIndex (int newFloorIndex)
{
floorIndex = newFloorIndex;
}
public int getBuildingIndex ()
{
return buildingIndex;
}
public int getFloorIndex ()
{
return floorIndex;
}
public bool removeComponentWhenObjectiveReachedEnabled ()
{
return removeComponentWhenObjectiveReached;
}
public void setMapObjectName (string newName)
{
mapObjectName = newName;
}
public string getMapObjectName ()
{
if (mapObjectName == "") {
return this.name;
} else {
return mapObjectName;
}
}
public void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Map Object Information Element " + gameObject.name, gameObject);
}
#if UNITY_EDITOR
void OnDrawGizmos ()
{
if (!showGizmo) {
return;
}
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
DrawGizmos ();
}
}
void OnDrawGizmosSelected ()
{
DrawGizmos ();
}
void DrawGizmos ()
{
if (showGizmo) {
Gizmos.color = Color.blue;
Gizmos.DrawWireSphere (transform.position, triggerRadius);
if (offsetShowGizmo) {
Gizmos.color = offsetGizmoColor;
Gizmos.DrawSphere (transform.position + offset, offsetRadius);
}
}
}
#endif
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 69d4c2c8aae3ca649a0b7c20bf5d8aed
timeCreated: 1467506821
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Map/mapObjectInformation.cs
uploadId: 814740

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: fe4b6c2a742439f4a921b5962595cde2
timeCreated: 1466696714
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Map/mapSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,959 @@
using UnityEngine;
using System.Collections.Generic;
using System.Collections;
public class mapTileBuilder : MonoBehaviour
{
public Transform mapPartParent;
public int mapPartBuildingIndex;
public int mapPartFloorIndex;
public int mapPartIndex;
public List<Transform> verticesPosition = new List<Transform> ();
public List<GameObject> eventTriggerList = new List<GameObject> ();
public List<GameObject> extraMapPartsToActive = new List<GameObject> ();
public mapCreator mapManager;
public float mapPartRendererOffset;
public Vector2 newPositionOffset;
public bool mapPartEnabled = true;
public bool useOtherColorIfMapPartDisabled;
public Color colorIfMapPartDisabled;
public bool showGizmo = true;
public bool showEnabledTrigger = true;
public bool showVerticesDistance;
public Color mapPartMaterialColor = Color.white;
public Vector3 cubeGizmoScale = Vector3.one;
public Color gizmoLabelColor = Color.white;
public Color mapLinesColor = Color.yellow;
public bool useHandleForVertex;
public float handleRadius = 0.1f;
public bool showVertexHandles;
public List<GameObject> textMeshList = new List<GameObject> ();
public Vector3 center;
public string mapPartName;
public string internalName;
public bool generate3dMapPartMesh;
public bool onlyUse3dMapPartMesh;
public bool generate3dMeshesShowGizmo;
public GameObject mapPart3dGameObject;
public Vector3 mapPart3dOffset;
public float mapPart3dHeight = 1;
public bool mapPart3dMeshCreated;
public GameObject mapTileRenderer;
public MeshFilter mapTileMeshFilter;
public bool mapTileCreated;
public MeshRenderer mainMeshRenderer;
GameObject eventTriggerParent;
GameObject textMeshParent;
MeshRenderer mapPart3dMeshRenderer;
Color originalMapPart3dMeshRendererColor;
Vector3 current3dOffset;
public void createMapTileElement ()
{
if (!mapTileCreated) {
calculateMapTileMesh ();
generateMapPart3dMesh (mapPart3dHeight);
mapTileCreated = true;
}
if (!mapPartEnabled) {
if (useOtherColorIfMapPartDisabled) {
setWallRendererMaterialColor (colorIfMapPartDisabled);
enableOrDisableTextMesh (false);
} else {
disableMapPart ();
}
enableOrDisableMapPart3dMesh (false);
} else {
if (onlyUse3dMapPartMesh) {
if (mapTileRenderer != null) {
if (mapTileRenderer.activeSelf) {
mapTileRenderer.SetActive (false);
}
}
}
}
}
public void calculateMapTileMesh ()
{
List<Vector2> vertices2D = new List<Vector2> ();
int verticesPositionCount = verticesPosition.Count;
Vector3 currentPosition = Vector3.zero;
for (int i = 0; i < verticesPositionCount; i++) {
currentPosition = verticesPosition [i].localPosition;
vertices2D.Add (new Vector2 (currentPosition.x, currentPosition.y));
}
// Use the triangulator to get indices for creating triangles
GKC_Triangulator_Utils tr = new GKC_Triangulator_Utils (vertices2D);
int[] triangles = tr.Triangulate ();
// Create the Vector3 vertices
Vector3[] vertices = new Vector3[vertices2D.Count];
int verticesLength = vertices.Length;
Vector2 current2DPosition = Vector2.zero;
for (int i = 0; i < verticesLength; i++) {
current2DPosition = vertices2D [i];
vertices [i] = new Vector3 (current2DPosition.x, current2DPosition.y, 0);
}
// Create the mesh
Mesh msh = new Mesh ();
msh.vertices = vertices;
msh.triangles = triangles;
msh.RecalculateNormals ();
msh.RecalculateBounds ();
// Set up game object with mesh;
if (mapTileRenderer == null) {
mapTileRenderer = new GameObject ();
mapTileRenderer.transform.SetParent (transform);
mapTileRenderer.layer = LayerMask.NameToLayer (mapManager.mapLayer);
mapTileRenderer.transform.localPosition = Vector3.zero;
mapTileRenderer.transform.localPosition -= mapTileRenderer.transform.forward * mapPartRendererOffset;
mapTileRenderer.transform.localRotation = Quaternion.identity;
mapTileRenderer.name = "Map Tile Renderer";
mainMeshRenderer = mapTileRenderer.AddComponent (typeof(MeshRenderer)) as MeshRenderer;
Material newMaterial = new Material (mapManager.floorMaterial);
mainMeshRenderer.material = newMaterial;
}
if (mapTileMeshFilter == null) {
mapTileMeshFilter = mapTileRenderer.AddComponent (typeof(MeshFilter)) as MeshFilter;
}
mapTileMeshFilter.mesh = msh;
setWallRendererMaterialColor (mapPartMaterialColor);
mapTileCreated = true;
}
public void removeMapTileRenderer ()
{
if (mapTileRenderer != null) {
DestroyImmediate (mapTileRenderer);
}
if (mapTileMeshFilter != null) {
DestroyImmediate (mapTileMeshFilter);
}
if (mainMeshRenderer != null) {
DestroyImmediate (mainMeshRenderer);
}
mapTileCreated = false;
updateComponent ();
}
public void setWallRendererMaterialColor (Color newColor)
{
if (mainMeshRenderer != null) {
if (Application.isPlaying) {
mainMeshRenderer.material.color = newColor;
} else {
mainMeshRenderer.sharedMaterial.color = newColor;
}
}
}
public void set3dMapPartMaterialColor (Color newColor)
{
if (mapPart3dMeshRenderer != null) {
mapPart3dMeshRenderer.material.color = newColor;
}
}
public void setOriginal3dMapPartMaterialColor ()
{
if (mapPart3dMeshRenderer != null) {
mapPart3dMeshRenderer.material.color = originalMapPart3dMeshRendererColor;
}
}
public void enableMapPart ()
{
if (!mapPartEnabled) {
if (!onlyUse3dMapPartMesh) {
if (!mapTileRenderer.activeSelf) {
mapTileRenderer.SetActive (true);
}
}
enableOrDisableTextMesh (true);
mapPartEnabled = true;
mapManager.enableOrDisableSingleMapIconByMapPartIndex (mapPartBuildingIndex, mapPartIndex, mapPartFloorIndex, true);
enableOrDisableEventTriggerList (false);
int extraMapPartsToActiveCount = extraMapPartsToActive.Count;
for (int i = 0; i < extraMapPartsToActiveCount; i++) {
if (extraMapPartsToActive [i] != null) {
extraMapPartsToActive [i].GetComponent<mapTileBuilder> ().enableMapPart ();
}
}
enableOrDisableMapPart3dMesh (true);
}
mapManager.setCurrentMapPartIndex (mapPartIndex);
}
public void enableOrDisableEventTriggerList (bool state)
{
int eventTriggerListCount = eventTriggerList.Count;
for (int i = 0; i < eventTriggerListCount; i++) {
if (eventTriggerList [i] != null) {
if (eventTriggerList [i].activeSelf != state) {
eventTriggerList [i].SetActive (state);
}
}
}
}
public void disableMapPart ()
{
if (mapTileRenderer.activeSelf) {
mapTileRenderer.SetActive (false);
}
enableOrDisableTextMesh (false);
mapPartEnabled = false;
}
public void setMapPartEnabledState (bool state)
{
mapPartEnabled = state;
}
public void enableOrDisableTextMesh (bool state)
{
if (textMeshList.Count > 0) {
int textMeshListCount = textMeshList.Count;
for (int i = 0; i < textMeshListCount; i++) {
if (textMeshList [i] != null && textMeshList [i].activeSelf != state) {
textMeshList [i].SetActive (state);
}
}
if (useOtherColorIfMapPartDisabled) {
if (state) {
setWallRendererMaterialColor (mapPartMaterialColor);
} else {
setWallRendererMaterialColor (colorIfMapPartDisabled);
}
}
}
}
public void addEventTriggerToActive ()
{
if (eventTriggerList.Count == 0 || eventTriggerParent == null) {
eventTriggerParent = new GameObject ();
eventTriggerParent.name = "Triggers Parent";
eventTriggerParent.transform.SetParent (transform);
eventTriggerParent.transform.localPosition = Vector3.zero;
eventTriggerParent.transform.localRotation = Quaternion.identity;
}
mapPartEnabled = false;
GameObject trigger = new GameObject ();
trigger.AddComponent<BoxCollider> ().isTrigger = true;
trigger.AddComponent<eventTriggerSystem> ().setSimpleFunctionByTag ("enableMapPart", gameObject, "Player");
trigger.transform.SetParent (eventTriggerParent.transform);
if (mapManager.useRaycastToPlaceElements) {
Camera currentCameraEditor = GKC_Utils.getCameraEditor ();
if (currentCameraEditor != null) {
Vector3 editorCameraPosition = currentCameraEditor.transform.position;
Vector3 editorCameraForward = currentCameraEditor.transform.forward;
RaycastHit hit;
if (Physics.Raycast (editorCameraPosition, editorCameraForward, out hit, Mathf.Infinity, mapManager.layerToPlaceElements)) {
trigger.transform.position = hit.point + Vector3.up * 0.1f;
}
}
} else {
trigger.transform.localPosition = Vector3.zero;
}
trigger.transform.rotation = Quaternion.identity;
if (mapManager.mapPartEnabledTriggerScale != Vector3.zero) {
trigger.transform.localScale = mapManager.mapPartEnabledTriggerScale;
}
trigger.layer = LayerMask.NameToLayer ("Ignore Raycast");
trigger.name = "Map Part Enabled Trigger " + (eventTriggerList.Count + 1);
eventTriggerList.Add (trigger);
updateComponent ();
}
public void setMapPartEnabledStateFromEditor (bool state)
{
mapPartEnabled = state;
updateComponent ();
}
public void removeEventTrigger (int eventTriggerIndex)
{
GameObject currentEventTrigger = eventTriggerList [eventTriggerIndex];
if (currentEventTrigger != null) {
DestroyImmediate (currentEventTrigger);
}
eventTriggerList.RemoveAt (eventTriggerIndex);
if (eventTriggerList.Count == 0) {
if (eventTriggerParent != null) {
DestroyImmediate (eventTriggerParent);
}
}
updateComponent ();
}
public void removeAllEventTriggers ()
{
for (int i = 0; i < eventTriggerList.Count; i++) {
if (eventTriggerList [i] != null) {
DestroyImmediate (eventTriggerList [i]);
}
}
eventTriggerList.Clear ();
if (eventTriggerParent != null) {
DestroyImmediate (eventTriggerParent);
}
updateComponent ();
}
public void addMapPartTextMesh ()
{
string prefabsPath = pathInfoValues.getMainPrefabsFolderPath ();
prefabsPath += "Map System/mapPartTextMesh.prefab";
GameObject textMesh = GKC_Utils.getLoadAssetAtPath (prefabsPath);
if (textMesh != null) {
if (textMeshList.Count == 0 || textMeshParent == null) {
textMeshParent = new GameObject ();
textMeshParent.name = "Text Mesh Parent";
textMeshParent.transform.SetParent (transform);
textMeshParent.transform.localPosition = Vector3.zero;
textMeshParent.transform.localRotation = Quaternion.identity;
}
textMesh = (GameObject)Instantiate (textMesh, transform.position, Quaternion.identity, textMeshParent.transform);
Vector3 textMeshPosition = transform.position;
if (verticesPosition.Count > 0) {
textMeshPosition = center;
}
textMesh.transform.position = textMeshPosition + textMesh.transform.forward;
textMesh.transform.localRotation = Quaternion.identity;
textMesh.name = "Map Part Text Mesh " + (textMeshList.Count + 1).ToString ("000");
textMeshList.Add (textMesh);
} else {
print ("Prefab not found");
}
}
public void removeTextMesh (int textMeshIndex)
{
GameObject currentTextMesh = textMeshList [textMeshIndex];
if (currentTextMesh != null) {
DestroyImmediate (currentTextMesh);
}
textMeshList.RemoveAt (textMeshIndex);
if (textMeshList.Count == 0) {
if (textMeshParent != null) {
DestroyImmediate (textMeshParent);
}
}
updateComponent ();
}
public void removeAllTextMesh ()
{
for (int i = 0; i < textMeshList.Count; i++) {
if (textMeshList [i] != null) {
DestroyImmediate (textMeshList [i]);
}
}
textMeshList.Clear ();
if (textMeshParent != null) {
DestroyImmediate (textMeshParent);
}
updateComponent ();
}
public void addNewVertex (int insertAtIndex)
{
GameObject newTransform = new GameObject ();
newTransform.transform.SetParent (transform);
newTransform.transform.localRotation = Quaternion.identity;
if (verticesPosition.Count > 0) {
Vector3 lastPosition = verticesPosition [verticesPosition.Count - 1].localPosition;
newTransform.transform.localPosition = new Vector3 (lastPosition.x + newPositionOffset.x + 1, lastPosition.y + newPositionOffset.y + 1, lastPosition.z);
} else {
newTransform.transform.localPosition = new Vector3 (newPositionOffset.x + 1, newPositionOffset.y + 1, 0);
}
newTransform.name = (verticesPosition.Count + 1).ToString ("000");
if (insertAtIndex > -1) {
if (verticesPosition.Count > 0) {
Vector3 vertexPosition = verticesPosition [insertAtIndex].localPosition;
newTransform.transform.localPosition = new Vector3 (vertexPosition.x + newPositionOffset.x + 1, vertexPosition.y + newPositionOffset.y + 1, vertexPosition.z);
}
verticesPosition.Insert (insertAtIndex + 1, newTransform.transform);
newTransform.transform.SetSiblingIndex (insertAtIndex + 1);
renameAllVertex ();
} else {
verticesPosition.Add (newTransform.transform);
}
updateComponent ();
}
public void removeVertex (int vertexIndex)
{
Transform currentVertex = verticesPosition [vertexIndex];
if (currentVertex != null) {
DestroyImmediate (currentVertex.gameObject);
}
verticesPosition.RemoveAt (vertexIndex);
updateComponent ();
}
public void removeAllVertex ()
{
for (int i = 0; i < verticesPosition.Count; i++) {
if (verticesPosition [i] != null) {
DestroyImmediate (verticesPosition [i].gameObject);
}
}
verticesPosition.Clear ();
updateComponent ();
}
public void renameAllVertex ()
{
for (int i = 0; i < verticesPosition.Count; i++) {
if (verticesPosition [i] != null) {
verticesPosition [i].name = (i + 1).ToString ("000");
}
}
updateComponent ();
}
public void reverVertexOrder ()
{
verticesPosition.Reverse ();
updateComponent ();
}
public void setInternalName (string nameToConfigure)
{
internalName = nameToConfigure;
renameMapPart ();
}
public void renameMapPart ()
{
string newName = internalName;
if (mapPartName != "") {
newName += " (" + mapPartName + ")";
}
gameObject.name = newName;
updateComponent ();
}
public void updateMapPart3dMeshPositionFromEditor ()
{
updateMapPart3dMeshPosition (mapPart3dOffset);
}
public void updateMapPart3dMeshPosition (Vector3 offset)
{
if (mapPart3dMeshCreated) {
mapPart3dGameObject.transform.position = center + offset;
}
}
public void enableOrDisableMapPart3dMesh (bool state)
{
if (mapPart3dMeshCreated) {
if (mapPart3dGameObject.activeSelf != state) {
mapPart3dGameObject.SetActive (state);
}
}
}
public void removeMapPart3dMesh ()
{
if (mapPart3dMeshCreated && mapPart3dGameObject != null) {
DestroyImmediate (mapPart3dGameObject);
mapPart3dMeshCreated = false;
}
}
public void removeMapPart3dMeshFromEditor ()
{
if (mapPart3dMeshCreated && mapPart3dGameObject != null) {
DestroyImmediate (mapPart3dGameObject);
mapPart3dMeshCreated = false;
updateComponent ();
}
}
public void setGenerate3dMapPartMeshState (bool state)
{
generate3dMapPartMesh = state;
}
public void setGenerate3dMapPartMeshStateFromEditor (bool state)
{
generate3dMapPartMesh = state;
updateComponent ();
}
public void generateMapPart3dMeshFromEditor ()
{
generateMapPart3dMesh (mapPart3dHeight);
updateComponent ();
}
public void generateMapPart3dMesh (float meshHeight)
{
if ((!generate3dMapPartMesh && (!generate3dMapPartMesh && !mapManager.generateFull3dMapMeshes)) || !mapManager.generate3dMeshesActive) {
return;
}
removeMapPart3dMesh ();
mapPart3dMeshCreated = true;
mapPart3dGameObject = new GameObject ();
mapPart3dGameObject.name = gameObject.name + " - 3d Mesh";
mapPart3dGameObject.isStatic = true;
mapPart3dGameObject.layer = LayerMask.NameToLayer (mapManager.mapLayer);
mapPart3dGameObject.transform.SetParent (transform);
mapPart3dGameObject.transform.position = center + mapPart3dOffset;
MeshRenderer mapPart3dRenderer = mapPart3dGameObject.AddComponent<MeshRenderer> ();
mapPart3dMeshRenderer = mapPart3dRenderer;
MeshFilter mapPart3dMeshFilter = mapPart3dGameObject.AddComponent<MeshFilter> ();
Mesh mapPart3dMesh = mapPart3dMeshFilter.mesh;
mapPart3dRenderer.material = mapManager.mapPart3dMeshMaterial;
originalMapPart3dMeshRendererColor = mapPart3dMeshRenderer.material.color;
mapPart3dMesh.Clear ();
mapPart3dMesh.ClearBlendShapes ();
int verticesPositionCount = verticesPosition.Count;
Vector3 position1 = verticesPosition [0].position;
Vector3 position2 = verticesPosition [1].position;
Vector3 direction1 = center - position1;
direction1 = direction1 / direction1.magnitude;
Vector3 direction2 = center - position2;
direction2 = direction2 / direction2.magnitude;
float angle1 = Vector3.Angle (direction1, Vector3.forward);
float angle2 = Vector3.Angle (direction2, Vector3.forward);
// print (gameObject.name + " " + angle1 + " " + angle2);
if (angle1 < angle2) {
verticesPosition.Reverse ();
}
Vector3[] downCorners = new Vector3[verticesPositionCount];
int downCornersLength = downCorners.Length;
for (int x = 0; x < downCornersLength; x++) {
downCorners [x] = mapPart3dGameObject.transform.InverseTransformPoint (verticesPosition [x].position);
}
Vector3[] topCorners = new Vector3[verticesPositionCount];
downCorners.CopyTo (topCorners, 0);
int topCornersLength = topCorners.Length;
for (int x = 0; x < topCornersLength; x++) {
topCorners [x] += new Vector3 (0, meshHeight, 0);
}
Vector3[] cornersCombined = new Vector3[downCorners.Length + topCorners.Length];
downCorners.CopyTo (cornersCombined, 0);
topCorners.CopyTo (cornersCombined, downCorners.Length);
mapPart3dMesh.vertices = cornersCombined;
List<Vector2> downVertices2D = new List<Vector2> ();
for (int i = 0; i < downCorners.Length; i++) {
downVertices2D.Add (new Vector2 (downCorners [i].x, downCorners [i].z));
}
GKC_Triangulator_Utils donwTr = new GKC_Triangulator_Utils (downVertices2D);
int[] downIndices = donwTr.Triangulate ();
int[] reverseDownIndices = new int[downIndices.Length];
downIndices.CopyTo (reverseDownIndices, 0);
for (int x = 0; x < downIndices.Length - 1; x++) {
int leftValue = downIndices [x];
int rightValue = downIndices [x + 2];
reverseDownIndices [x] = rightValue;
reverseDownIndices [x + 2] = leftValue;
x += 2;
}
reverseDownIndices.CopyTo (downIndices, 0);
int[] middleIndices = new int[verticesPositionCount * 6];
int middleIndicesIndex = 0;
for (int x = 0; x < verticesPositionCount; x++) {
int leftIndex = x;
int rightIndex = x + 1;
if (x == verticesPositionCount - 1) {
rightIndex = 0;
}
middleIndices [middleIndicesIndex] = rightIndex;
middleIndicesIndex++;
middleIndices [middleIndicesIndex] = leftIndex;
middleIndicesIndex++;
if (x == verticesPositionCount - 1) {
middleIndices [middleIndicesIndex] = (verticesPositionCount * 2) - 1;
} else {
middleIndices [middleIndicesIndex] = rightIndex + verticesPositionCount - 1;
}
middleIndicesIndex++;
middleIndices [middleIndicesIndex] = leftIndex + verticesPositionCount;
middleIndicesIndex++;
if (x == verticesPositionCount - 1) {
middleIndices [middleIndicesIndex] = verticesPositionCount;
} else {
middleIndices [middleIndicesIndex] = rightIndex + verticesPositionCount;
}
middleIndicesIndex++;
if (x == verticesPositionCount - 1) {
middleIndices [middleIndicesIndex] = 0;
} else {
middleIndices [middleIndicesIndex] = rightIndex;
}
middleIndicesIndex++;
}
List<Vector2> topVertices2D = new List<Vector2> ();
for (int i = 0; i < topCorners.Length; i++) {
topVertices2D.Add (new Vector2 (topCorners [i].x, topCorners [i].z));
}
GKC_Triangulator_Utils topTr = new GKC_Triangulator_Utils (topVertices2D);
int[] topdIndices = topTr.Triangulate ();
for (int i = 0; i < topdIndices.Length; i++) {
topdIndices [i] += verticesPositionCount;
}
int[] combinedIndices = new int[downIndices.Length + topdIndices.Length + middleIndices.Length];
downIndices.CopyTo (combinedIndices, 0);
middleIndices.CopyTo (combinedIndices, downIndices.Length);
topdIndices.CopyTo (combinedIndices, downIndices.Length + middleIndices.Length);
mapPart3dMesh.triangles = combinedIndices;
mapPart3dMesh.RecalculateNormals ();
mapManager.addMapPart3dMeshToFloorParent (mapPart3dGameObject, gameObject);
}
public void setMapManager (mapCreator currentMapManager)
{
mapManager = currentMapManager;
updateComponent ();
}
public void setMapPartParent (Transform currentMapPartParent)
{
mapPartParent = currentMapPartParent;
updateComponent ();
}
public void setMapPartBuildingIndex (int newIndex)
{
mapPartBuildingIndex = newIndex;
updateComponent ();
}
public void setMapPartFlooorIndex (int newIndex)
{
mapPartFloorIndex = newIndex;
updateComponent ();
}
public void setMapPartIndex (int newIndex)
{
mapPartIndex = newIndex;
updateComponent ();
}
public void setRandomMapPartColor ()
{
mapPartMaterialColor = new Vector4 (Random.Range (0f, 1f), Random.Range (0f, 1f), Random.Range (0f, 1f), 1);
updateComponent ();
}
public void updateComponent ()
{
GKC_Utils.updateComponent (this);
GKC_Utils.updateDirtyScene ("Update Map Tile Renderer " + gameObject.name, gameObject);
}
//draw every floor position and a line between floors
#if UNITY_EDITOR
void OnDrawGizmos ()
{
if (!showGizmo) {
return;
}
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
DrawGizmos ();
}
}
void OnDrawGizmosSelected ()
{
DrawGizmos ();
}
//draw the pivot and the final positions of every door
void DrawGizmos ()
{
if (showGizmo && mapManager.showMapPartsGizmo && !Application.isPlaying) {
center = Vector3.zero;
for (int i = 0; i < verticesPosition.Count; i++) {
if (verticesPosition [i] != null) {
if (i + 1 < verticesPosition.Count) {
if (verticesPosition [i + 1] != null) {
if (mapManager.useSameLineColor) {
Gizmos.color = mapManager.mapLinesColor;
} else {
Gizmos.color = mapLinesColor;
}
Gizmos.DrawLine (verticesPosition [i].position, verticesPosition [i + 1].position);
}
}
if (i == verticesPosition.Count - 1) {
if (verticesPosition [0] != null) {
if (mapManager.useSameLineColor) {
Gizmos.color = mapManager.mapLinesColor;
} else {
Gizmos.color = mapLinesColor;
}
Gizmos.DrawLine (verticesPosition [i].position, verticesPosition [0].position);
}
}
center += verticesPosition [i].position;
}
}
center /= verticesPosition.Count;
if (showEnabledTrigger && mapManager.showMapPartEnabledTrigger) {
for (int i = 0; i < eventTriggerList.Count; i++) {
if (eventTriggerList [i] != null) {
Gizmos.color = mapManager.enabledTriggerGizmoColor;
Gizmos.DrawCube (eventTriggerList [i].transform.position, eventTriggerList [i].transform.localScale);
Gizmos.color = Color.yellow;
Gizmos.DrawLine (eventTriggerList [i].transform.position, center);
}
}
}
if (mapManager.showMapPartsTextGizmo && textMeshList.Count > 0) {
for (int i = 0; i < textMeshList.Count; i++) {
if (textMeshList [i] != null) {
Gizmos.color = Color.red;
Gizmos.DrawSphere (textMeshList [i].transform.position, 0.1f);
Gizmos.color = Color.blue;
Gizmos.DrawLine (textMeshList [i].transform.position, center);
}
}
}
if (generate3dMapPartMesh && (mapManager.generate3dMeshesShowGizmo || generate3dMeshesShowGizmo)) {
current3dOffset = Vector3.up * mapPart3dHeight;
Gizmos.color = Color.white;
Gizmos.DrawLine (center + mapPart3dOffset, center + mapPart3dOffset + current3dOffset);
Gizmos.color = Color.yellow;
Gizmos.DrawSphere (center + mapPart3dOffset, 0.2f);
Gizmos.DrawSphere (center + mapPart3dOffset + current3dOffset, 0.2f);
for (int i = 0; i < verticesPosition.Count; i++) {
if (verticesPosition [i] != null) {
if (i + 1 < verticesPosition.Count) {
if (verticesPosition [i + 1] != null) {
if (mapManager.useSameLineColor) {
Gizmos.color = mapManager.mapLinesColor;
} else {
Gizmos.color = mapLinesColor;
}
Gizmos.DrawLine (verticesPosition [i].position + current3dOffset, verticesPosition [i + 1].position + current3dOffset);
}
}
if (i == verticesPosition.Count - 1) {
if (verticesPosition [0] != null) {
if (mapManager.useSameLineColor) {
Gizmos.color = mapManager.mapLinesColor;
} else {
Gizmos.color = mapLinesColor;
}
Gizmos.DrawLine (verticesPosition [i].position + current3dOffset, verticesPosition [0].position + current3dOffset);
}
}
}
Gizmos.DrawLine (verticesPosition [i].position, verticesPosition [i].position + current3dOffset);
}
}
Gizmos.color = mapPartMaterialColor;
Gizmos.DrawCube (center, cubeGizmoScale);
}
}
#endif
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: d0e2cb61da8dc9643a9642acdc71f4d4
timeCreated: 1466646122
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Map/mapTileBuilder.cs
uploadId: 814740

View File

@@ -0,0 +1,414 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
public class mapUISystem : ingameMenuPanel
{
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public bool componentsAssigned;
public bool menuOpened;
public bool mainMapSystemAssigned;
[Space]
[Header ("Main Map Elements")]
[Space]
public GameObject mapContent;
public GameObject mapMenu;
public RectTransform mapWindowTargetPosition;
public RectTransform mapRender;
public RectTransform mapWindow;
public RectTransform playerMapIcon;
public RectTransform playerIconChild;
public Image removeMarkButtonImage;
public Image quickTravelButtonImage;
public Text mapObjectNameField;
public Text mapObjectInfoField;
public Text currentFloorNumberText;
public Text currentMapZoneText;
public GameObject mapIndexWindow;
public GameObject mapIndexWindowContent;
public Scrollbar mapIndexWindowScroller;
[Space]
[Header ("Other Elements")]
[Space]
public RectTransform mapWindowMask;
public GameObject mapCursor;
public RectTransform mapCursorRectTransform;
public GameObject currenMapIconPressed;
public Scrollbar zoomScrollbar;
public Transform mapCircleTransform;
[Space]
[Header ("Compass Elements")]
[Space]
public RectTransform compassWindow;
public RectTransform compassElementsParent;
public RectTransform north;
public RectTransform south;
public RectTransform east;
public RectTransform west;
public RectTransform northEast;
public RectTransform southWest;
public RectTransform southEast;
public RectTransform northWest;
[Space]
[Header ("Components")]
[Space]
public mapSystem mainMapSystem;
void Start ()
{
if (!mainMapSystemAssigned) {
if (mainMapSystem != null) {
mainMapSystemAssigned = true;
}
}
}
public override void initializeMenuPanel ()
{
if (mainMapSystem == null) {
checkMenuComponents ();
}
}
void checkMenuComponents ()
{
if (!componentsAssigned) {
if (pauseManager != null) {
playerComponentsManager currentPlayerComponentsManager = pauseManager.getPlayerControllerGameObject ().GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
mainMapSystem = currentPlayerComponentsManager.getMapSystem ();
mainMapSystemAssigned = mainMapSystem != null;
}
}
componentsAssigned = true;
}
}
public override void openOrCloseMenuPanel (bool state)
{
if (state) {
if (!pauseManager.checkIfMenuCanBeUsedByName (menuPanelName)) {
return;
}
}
base.openOrCloseMenuPanel (state);
menuOpened = state;
checkMenuComponents ();
if (state) {
} else {
}
if (mainMapSystemAssigned) {
mainMapSystem.openOrCloseMap (menuOpened);
}
}
public void setMapContentActiveState (bool state)
{
if (mapContent.activeSelf != state) {
mapContent.SetActive (state);
}
}
public void setMapMenuActiveState (bool state)
{
if (mapMenu.activeSelf != state) {
mapMenu.SetActive (state);
}
}
public Transform getMapMenuTransform ()
{
return mapMenu.transform;
}
public void removeMapObjectInfo ()
{
mapObjectInfoField.text = "";
mapObjectNameField.text = "";
}
public void setMapObjectInfoText (string mapObjectInfoFieldText, string mapObjectNameFieldText)
{
mapObjectInfoField.text = mapObjectInfoFieldText;
mapObjectNameField.text = mapObjectNameFieldText;
}
public void setCurrentFloorNumberText (string newText)
{
currentFloorNumberText.text = newText;
}
public void setCurrentMapZoneText (string newText)
{
currentMapZoneText.text = newText;
}
public void setMapIndexWindowScrollerValue (int newValue)
{
mapIndexWindowScroller.value = newValue;
}
public void setZoomScrollbarValue (float newValue)
{
zoomScrollbar.value = newValue;
}
public void enableOrDisableCompass (bool state)
{
if (compassWindow.gameObject.activeSelf != state) {
compassWindow.gameObject.SetActive (state);
}
}
public RectTransform getCompassElementsParent ()
{
return compassElementsParent;
}
public void disableMainCompassDirections ()
{
if (northEast.gameObject.activeSelf) {
northEast.gameObject.SetActive (false);
}
if (southWest.gameObject.activeSelf) {
southWest.gameObject.SetActive (false);
}
if (southEast.gameObject.activeSelf) {
southEast.gameObject.SetActive (false);
}
if (northWest.gameObject.activeSelf) {
northWest.gameObject.SetActive (false);
}
}
public void checkCurrentMapIconPressedParent ()
{
if (currenMapIconPressed != null) {
currenMapIconPressed.transform.SetParent (mapWindow);
currenMapIconPressedActiveState (false);
}
}
public void currenMapIconPressedActiveState (bool state)
{
if (currenMapIconPressed.activeSelf != state) {
currenMapIconPressed.SetActive (state);
}
}
public void checkCurrentIconPressed (bool state, Transform mapIconTransform)
{
if (state) {
currenMapIconPressed.transform.SetParent (mapIconTransform);
currenMapIconPressed.transform.localPosition = Vector3.zero;
}
currenMapIconPressedActiveState (state);
}
public Vector3 getMapCursorRectTransformPosition ()
{
return mapCursorRectTransform.position;
}
public void setMapCursorActiveState (bool state)
{
if (mapCursor != null) {
if (mapCursor.activeSelf != state) {
mapCursor.SetActive (state);
}
}
}
public void setMapCursorAsLastSibling ()
{
mapCursor.transform.SetAsLastSibling ();
}
public void setMapIndexWindowActiveState (bool state)
{
if (mapIndexWindow.activeSelf != state) {
mapIndexWindow.SetActive (state);
}
}
public void setRemoveMarkButtonImageColor (Color newColor)
{
removeMarkButtonImage.color = newColor;
}
public void setQuickTravelButtonImageColor (Color newColor)
{
quickTravelButtonImage.color = newColor;
}
public RectTransform getMapRender ()
{
return mapRender;
}
public RectTransform getMapWindow ()
{
return mapWindow;
}
public RectTransform getPlayerMapIcon ()
{
return playerMapIcon;
}
public RectTransform getPlayerIconChild ()
{
return playerIconChild;
}
public Image getRemoveMarkButtonImage ()
{
return removeMarkButtonImage;
}
public Image getQuickTravelButtonImage ()
{
return quickTravelButtonImage;
}
public void changeMapIndexWindowState ()
{
mainMapSystem.changeMapIndexWindowState ();
}
public void enableOrDisableAllMapIconType (Slider iconSlider)
{
mainMapSystem.enableOrDisableAllMapIconType (iconSlider);
}
public void enableOrDisableMapIconType (Slider iconSlider)
{
mainMapSystem.enableOrDisableMapIconType (iconSlider);
}
public void zoomInEnabled ()
{
mainMapSystem.zoomInEnabled ();
}
public void zoomInDisabled ()
{
mainMapSystem.zoomInDisabled ();
}
public void zoomOutEnabled ()
{
mainMapSystem.zoomOutEnabled ();
}
public void zoomOutDisabled ()
{
mainMapSystem.zoomOutDisabled ();
}
public void checkNextFloor ()
{
mainMapSystem.checkNextFloor ();
}
public void checkPrevoiusFloor ()
{
mainMapSystem.checkPrevoiusFloor ();
}
public void placeMark ()
{
mainMapSystem.placeMark ();
}
public void removeMark ()
{
mainMapSystem.removeMark ();
}
public void activateQuickTravel ()
{
mainMapSystem.activateQuickTravel ();
}
public void set2dOr3ddMapView (bool state)
{
mainMapSystem.set2dOr3ddMapView (state);
}
public void recenterCameraPosition ()
{
mainMapSystem.recenterCameraPosition ();
}
public void setUsingScrollbarZoomState (bool state)
{
mainMapSystem.setUsingScrollbarZoomState (state);
}
public void setZoomByScrollBar (Scrollbar mainZoomScrollbar)
{
mainMapSystem.setZoomByScrollBar (mainZoomScrollbar);
}
public void checkNextBuilding ()
{
mainMapSystem.checkNextBuilding ();
}
public void checkPrevoiusBuilding ()
{
mainMapSystem.checkPrevoiusBuilding ();
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 9a635ac7b8d3da342a4035bcd94f84b0
timeCreated: 1669548290
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Map/mapUISystem.cs
uploadId: 814740

View File

@@ -0,0 +1,164 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
public class mapZoneUnlocker : MonoBehaviour
{
public List<buildingInfo> buildingList = new List<buildingInfo> ();
public float initialIndex = 0;
public float finalIndex = 0;
public string mainMapCreatorManagerName = "Map Creator";
mapCreator mapCreatorManager;
public void checkGetMapCreatorManager ()
{
bool mapCreatorManagerAssigned = (mapCreatorManager != null);
if (!mapCreatorManagerAssigned) {
mapCreatorManager = mapCreator.Instance;
mapCreatorManagerAssigned = mapCreatorManager != null;
}
if (!mapCreatorManagerAssigned) {
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (mapCreator.getMainManagerName (), typeof(mapCreator), true);
mapCreatorManager = mapCreator.Instance;
mapCreatorManagerAssigned = (mapCreatorManager != null);
}
if (!mapCreatorManagerAssigned) {
mapCreatorManager = FindObjectOfType<mapCreator> ();
mapCreatorManagerAssigned = mapCreatorManager != null;
}
}
public void unlockMapZone ()
{
checkGetMapCreatorManager ();
if (mapCreatorManager != null) {
for (int i = 0; i < buildingList.Count; i++) {
for (int j = 0; j < buildingList [i].buildingFloorsList.Count; j++) {
if (buildingList [i].buildingFloorsList [j].floorEnabled) {
for (int k = 0; k < buildingList [i].buildingFloorsList [j].mapPartsList.Count; k++) {
if (buildingList [i].buildingFloorsList [j].mapPartsList [k].mapPartEnabled) {
mapCreatorManager.buildingList [i].buildingFloorsList [j].mapTileBuilderList [k].enableMapPart ();
}
}
}
}
}
}
}
public void enableOrDisableAllFloorParts (bool state, int buildingIndex, int floorIndex)
{
for (int j = 0; j < buildingList [buildingIndex].buildingFloorsList [floorIndex].mapPartsList.Count; j++) {
buildingList [buildingIndex].buildingFloorsList [floorIndex].mapPartsList [j].mapPartEnabled = state;
}
updateComponent ();
}
public void enableOrDisableMapPartsRange (bool state, int buildingIndex, int floorIndex)
{
for (int j = 0; j < buildingList [buildingIndex].buildingFloorsList [floorIndex].mapPartsList.Count; j++) {
if (j >= Mathf.Round (initialIndex) && j < Mathf.Round (finalIndex)) {
buildingList [buildingIndex].buildingFloorsList [floorIndex].mapPartsList [j].mapPartEnabled = state;
} else {
buildingList [buildingIndex].buildingFloorsList [floorIndex].mapPartsList [j].mapPartEnabled = false;
}
}
updateComponent ();
}
public void searchBuildingList ()
{
checkGetMapCreatorManager ();
if (mapCreatorManager != null) {
buildingList.Clear ();
for (int i = 0; i < mapCreatorManager.buildingList.Count; i++) {
buildingInfo newBuildingInfo = new buildingInfo ();
newBuildingInfo.Name = mapCreatorManager.buildingList [i].Name;
for (int j = 0; j < mapCreatorManager.buildingList [i].buildingFloorsList.Count; j++) {
floorInfo newFloorInfo = new floorInfo ();
newFloorInfo.Name = mapCreatorManager.buildingList [i].buildingFloorsList [j].Name;
newFloorInfo.floorEnabled = mapCreatorManager.buildingList [i].buildingFloorsList [j].floorEnabled;
newFloorInfo.mapPartsList = new List<mapPartInfo> ();
for (int k = 0; k < mapCreatorManager.buildingList [i].buildingFloorsList [j].mapTileBuilderList.Count; k++) {
mapTileBuilder currentMapTileBuilder = mapCreatorManager.buildingList [i].buildingFloorsList [j].mapTileBuilderList [k];
mapPartInfo newMapPartInfo = new mapPartInfo ();
if (currentMapTileBuilder != null) {
newMapPartInfo.mapTileBuilderManager = currentMapTileBuilder;
newMapPartInfo.mapPartName = currentMapTileBuilder.mapPartName;
} else {
print ("Warning, map tile builder component not found, make sure to use the button Set All Buildings Info or Get All Floor parts in every building " +
"in the Map Creator inspector, too assign the elements needed to the map system");
}
newFloorInfo.mapPartsList.Add (newMapPartInfo);
}
newBuildingInfo.buildingFloorsList.Add (newFloorInfo);
}
buildingList.Add (newBuildingInfo);
}
}
updateComponent ();
}
public void clearAllBuildingList ()
{
buildingList.Clear ();
updateComponent ();
}
public void updateComponent ()
{
GKC_Utils.updateComponent (this);
}
[System.Serializable]
public class floorInfo
{
public string Name;
public bool floorEnabled;
public List<mapPartInfo> mapPartsList = new List<mapPartInfo> ();
}
[System.Serializable]
public class buildingInfo
{
public string Name;
public List<floorInfo> buildingFloorsList = new List<floorInfo> ();
}
[System.Serializable]
public class mapPartInfo
{
public string mapPartName;
public bool mapPartEnabled;
public mapTileBuilder mapTileBuilderManager;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: b843e496fd3a2784fb0a6fe7ba532f5e
timeCreated: 1487001826
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Map/mapZoneUnlocker.cs
uploadId: 814740

View File

@@ -0,0 +1,10 @@
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class objectiveIconInfo : MonoBehaviour
{
public GameObject onScreenIcon;
public GameObject offScreenIcon;
public Text iconText;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: b38cc9bf47e07214c8642cfc6d55afc8
timeCreated: 1503939638
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Map/objectiveIconInfo.cs
uploadId: 814740

View File

@@ -0,0 +1,163 @@
using UnityEngine;
using System.Collections;
using GameKitController.Audio;
using UnityEngine.Events;
public class quickTravelStationSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public Transform quickTravelTransform;
public LayerMask layer;
public float maxDistanceToCheck = 4;
public string animationName;
public AudioClip enterAudioSound;
public AudioElement enterAudioElement;
public bool activateAtStart;
public bool setGravityDirection;
[Space]
[Header ("Other Settings")]
[Space]
public string mainMapCreatorManagerName = "Map Creator";
[Space]
[Header ("Events Settings")]
[Space]
public bool callEventOnTeleport;
public UnityEvent eventOnTeleport;
public bool callEventOnEveryTeleport;
[Space]
[Header ("Debug")]
[Space]
public bool stationActivated;
[Space]
[Header ("Components")]
[Space]
public setGravity setGravityManager;
public AudioSource audioSource;
public Animation stationAnimation;
public mapObjectInformation mapObjectInformationManager;
public mapCreator mapCreatorManager;
bool eventCalled;
RaycastHit hit;
private void InitializeAudioElements ()
{
if (audioSource == null) {
audioSource = GetComponent<AudioSource> ();
}
if (audioSource != null) {
enterAudioElement.audioSource = audioSource;
}
if (enterAudioSound != null) {
enterAudioElement.clip = enterAudioSound;
}
}
void Start ()
{
if (stationAnimation == null) {
stationAnimation = GetComponent<Animation> ();
}
InitializeAudioElements ();
if (mapObjectInformationManager == null) {
mapObjectInformationManager = GetComponent<mapObjectInformation> ();
}
if (activateAtStart) {
activateStation ();
}
bool mapCreatorManagerAssigned = (mapCreatorManager != null);
if (!mapCreatorManagerAssigned) {
mapCreatorManager = mapCreator.Instance;
mapCreatorManagerAssigned = mapCreatorManager != null;
}
if (!mapCreatorManagerAssigned) {
GKC_Utils.instantiateMainManagerOnSceneWithTypeOnApplicationPlaying (mapCreator.getMainManagerName (), typeof(mapCreator), true);
mapCreatorManager = mapCreator.Instance;
mapCreatorManagerAssigned = (mapCreatorManager != null);
}
if (!mapCreatorManagerAssigned) {
mapCreatorManager = FindObjectOfType<mapCreator> ();
mapCreatorManagerAssigned = mapCreatorManager != null;
}
}
public void travelToThisStation (Transform currentPlayer)
{
Vector3 positionToTravel = quickTravelTransform.position;
if (Physics.Raycast (quickTravelTransform.position, -transform.up, out hit, maxDistanceToCheck, layer)) {
positionToTravel = hit.point + transform.up * 0.3f;
}
currentPlayer.position = positionToTravel;
currentPlayer.rotation = quickTravelTransform.rotation;
if (mapCreatorManager != null) {
mapCreatorManager.changeCurrentBuilding (mapObjectInformationManager.getBuildingIndex (), currentPlayer.gameObject);
}
if (setGravityDirection && setGravityManager != null) {
Collider currentCollider = currentPlayer.GetComponent<Collider> ();
if (currentCollider != null) {
setGravityManager.checkTriggerType (currentCollider, true);
}
}
if (callEventOnTeleport) {
if (!eventCalled || callEventOnEveryTeleport) {
eventOnTeleport.Invoke ();
eventCalled = true;
}
}
}
public void OnTriggerEnter (Collider col)
{
if (!stationActivated && col.CompareTag ("Player")) {
AudioPlayer.PlayOneShot (enterAudioElement, gameObject);
activateStation ();
}
}
public void activateStation ()
{
if (stationAnimation != null && animationName != "") {
stationAnimation [animationName].speed = 1;
stationAnimation.Play (animationName);
}
mapObjectInformationManager.createMapIconInfo ();
stationActivated = true;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 3956574a33b210e49b6c7ac0bc55af1b
timeCreated: 1485192764
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Map/quickTravelStationSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,41 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class setMapOrientationSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public mapCameraMovement mapCameraMovementType;
public Transform mapOrientationTransform;
public enum mapCameraMovement
{
XY,
XZ,
YZ
}
GameObject currentPlayer;
public void setMapOrientation ()
{
if (currentPlayer != null) {
playerComponentsManager mainPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
mapSystem currentMapSystem = mainPlayerComponentsManager.getMapSystem ();
if (currentMapSystem != null) {
currentMapSystem.setMapOrientation ((int)mapCameraMovementType, mapOrientationTransform);
}
}
}
public void setCurrentPlayer (GameObject newPlayer)
{
currentPlayer = newPlayer;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: bae4ee331b72d3a4792437b3c21d2219
timeCreated: 1542483400
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 40995
packageName: Game Kit Controller - Shooter Melee Adventure Creator 3D + 2.5D
packageVersion: 3.77g
assetPath: Assets/Game Kit Controller/Scripts/Map/setMapOrientationSystem.cs
uploadId: 814740