add ckg
plantilla base para movimiento básico
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class basicSingleManager : MonoBehaviour
|
||||
{
|
||||
public virtual void getComponentInstance ()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 463b1d14ea8df4445806d0fc88dbd252
|
||||
timeCreated: 1688284755
|
||||
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/Game Manager/basicSingleManager.cs
|
||||
uploadId: 814740
|
||||
838
Assets/Game Kit Controller/Scripts/Game Manager/gameManager.cs
Normal file
838
Assets/Game Kit Controller/Scripts/Game Manager/gameManager.cs
Normal file
@@ -0,0 +1,838 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
public class gameManager : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool limitFps;
|
||||
|
||||
public bool updateLimitFpsIfChangeDetected;
|
||||
|
||||
public int targetFps = 60;
|
||||
|
||||
[Space]
|
||||
[Header ("Chapter Info")]
|
||||
[Space]
|
||||
|
||||
public string chapterInfo;
|
||||
|
||||
[Space]
|
||||
[Header ("Save Info")]
|
||||
[Space]
|
||||
|
||||
public bool loadEnabled;
|
||||
|
||||
public bool useRelativePath;
|
||||
|
||||
public bool loadPlayerPositionEnabled = true;
|
||||
|
||||
public bool loadPlayerPositionOnSceneChangeEnabled = true;
|
||||
|
||||
public bool checkPlayerDrivingStateOnLoadEnabled = true;
|
||||
|
||||
public bool deleteAllPlayerPrefsOnLoadEnabled = true;
|
||||
|
||||
[Space]
|
||||
|
||||
public bool saveInfoListToLoadOnStartOnAllScenesEnabledOnlyWhenLoading;
|
||||
|
||||
[Space]
|
||||
[Header ("Load Screen Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useLoadScreen;
|
||||
|
||||
public int loadScreenScene = 1;
|
||||
|
||||
public bool useLastSceneIndexAsLoadScreen = true;
|
||||
|
||||
public string sceneToLoadAsyncPrefsName = "SceneToLoadAsync";
|
||||
|
||||
public bool checkLoadingScreenSceneConfigured = true;
|
||||
|
||||
public string loadingScreenSceneName = "Loading Screen Scene";
|
||||
|
||||
[Space]
|
||||
[Header ("Version Number Settings")]
|
||||
[Space]
|
||||
|
||||
public string versionNumber = "3-01";
|
||||
|
||||
[Space]
|
||||
[Header ("Save File Names Settings")]
|
||||
[Space]
|
||||
|
||||
public string saveGameFolderName = "Save";
|
||||
public string saveFileName = "Save State";
|
||||
|
||||
public string saveCaptureFolder = "Captures";
|
||||
public string saveCaptureFileName = "Photo";
|
||||
|
||||
public string touchControlsPositionFolderName = "Touch Buttons Position";
|
||||
public string touchControlsPositionFileName = "Touch Positions";
|
||||
|
||||
public string saveInputFileFolderName = "Input";
|
||||
public string saveInputFileName = "Input File";
|
||||
|
||||
public string defaultInputSaveFileName = "Default Input File";
|
||||
|
||||
public string fileExtension = ".txt";
|
||||
|
||||
public int slotBySaveStation;
|
||||
|
||||
public bool saveCameraCapture = true;
|
||||
|
||||
[Space]
|
||||
[Header ("Other Settings")]
|
||||
[Space]
|
||||
|
||||
public LayerMask layer;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug Settings")]
|
||||
[Space]
|
||||
|
||||
public int saveNumberToLoad = -1;
|
||||
|
||||
public string currentPersistentDataPath;
|
||||
|
||||
public string currentSaveDataPath;
|
||||
|
||||
[Space]
|
||||
[Header ("Save List Debug")]
|
||||
[Space]
|
||||
|
||||
public List<saveGameSystem.saveStationInfo> saveList = new List<saveGameSystem.saveStationInfo> ();
|
||||
|
||||
[Space]
|
||||
[Header ("Current Game State Debug")]
|
||||
[Space]
|
||||
|
||||
public bool gamePaused;
|
||||
|
||||
public bool useTouchControls = false;
|
||||
|
||||
public bool touchPlatform;
|
||||
|
||||
public float playTime;
|
||||
|
||||
[Space]
|
||||
[Header ("Game Manager Elements")]
|
||||
[Space]
|
||||
|
||||
public playerCharactersManager charactersManager;
|
||||
|
||||
public Camera mainCamera;
|
||||
|
||||
public GameObject mainPlayerGameObject;
|
||||
public GameObject mainPlayerCameraGameObject;
|
||||
public playerCamera currentPlayerCamera;
|
||||
|
||||
RaycastHit hit;
|
||||
|
||||
int lastSaveNumber = -1;
|
||||
|
||||
bool FPSLimitAdjusted;
|
||||
|
||||
|
||||
|
||||
private static gameManager _gameManagerInstance;
|
||||
|
||||
public static gameManager Instance { get { return _gameManagerInstance; } }
|
||||
|
||||
bool instanceInitialized;
|
||||
|
||||
public void getComponentInstance ()
|
||||
{
|
||||
if (instanceInitialized) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (_gameManagerInstance != null && _gameManagerInstance != this) {
|
||||
Destroy (this.gameObject);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_gameManagerInstance = this;
|
||||
|
||||
instanceInitialized = true;
|
||||
}
|
||||
|
||||
public void getComponentInstanceOnApplicationPlaying ()
|
||||
{
|
||||
if (Application.isPlaying) {
|
||||
getComponentInstance ();
|
||||
}
|
||||
}
|
||||
|
||||
void Awake ()
|
||||
{
|
||||
getComponentInstance ();
|
||||
|
||||
if (limitFps) {
|
||||
QualitySettings.vSyncCount = 0;
|
||||
Application.targetFrameRate = targetFps;
|
||||
} else {
|
||||
Application.targetFrameRate = -1;
|
||||
}
|
||||
|
||||
touchPlatform = touchJoystick.checkTouchPlatform ();
|
||||
|
||||
if (touchPlatform) {
|
||||
useRelativePath = false;
|
||||
}
|
||||
|
||||
checkGameInfoToLoad ();
|
||||
}
|
||||
|
||||
void checkGameInfoToLoad ()
|
||||
{
|
||||
int lastSaveNumberValue = getLastSaveNumber ();
|
||||
|
||||
bool charactersManagerLocated = charactersManager != null;
|
||||
|
||||
if (!saveInfoListToLoadOnStartOnAllScenesEnabledOnlyWhenLoading && lastSaveNumberValue <= -1) {
|
||||
if (charactersManagerLocated) {
|
||||
charactersManager.checkSaveInfoListToLoadOnStartOnAllScenes ();
|
||||
}
|
||||
}
|
||||
|
||||
if (isLoadGameEnabled () && lastSaveNumberValue > -1) {
|
||||
if (saveInfoListToLoadOnStartOnAllScenesEnabledOnlyWhenLoading) {
|
||||
if (charactersManagerLocated) {
|
||||
charactersManager.checkSaveInfoListToLoadOnStartOnAllScenes ();
|
||||
}
|
||||
}
|
||||
|
||||
string extraFileString = " " + getVersionNumber () + getFileExtension ();
|
||||
|
||||
lastSaveNumber = -1;
|
||||
|
||||
if (PlayerPrefs.HasKey ("saveNumber")) {
|
||||
lastSaveNumber = PlayerPrefs.GetInt ("saveNumber");
|
||||
} else if (saveNumberToLoad >= 0) {
|
||||
lastSaveNumber = saveNumberToLoad;
|
||||
}
|
||||
|
||||
currentSaveDataPath = getDataPath ();
|
||||
|
||||
if (charactersManagerLocated) {
|
||||
charactersManager.checkGameInfoToLoad (lastSaveNumber, currentSaveDataPath, extraFileString);
|
||||
}
|
||||
} else {
|
||||
if (charactersManagerLocated) {
|
||||
charactersManager.checkComponentsToInitialize ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void deleteGameInfo (int saveNumberToDelete)
|
||||
{
|
||||
if (isLoadGameEnabled ()) {
|
||||
|
||||
string extraFileString = " " + getVersionNumber () + getFileExtension ();
|
||||
|
||||
currentSaveDataPath = getDataPath ();
|
||||
|
||||
if (charactersManager != null) {
|
||||
charactersManager.deleteGameInfo (saveNumberToDelete, currentSaveDataPath, extraFileString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void showSaveInfoDebug (int saveNumberToShow)
|
||||
{
|
||||
if (isLoadGameEnabled ()) {
|
||||
|
||||
string extraFileString = " " + getVersionNumber () + getFileExtension ();
|
||||
|
||||
currentSaveDataPath = getDataPath ();
|
||||
|
||||
if (charactersManager != null) {
|
||||
charactersManager.showSaveInfoDebug (saveNumberToShow, currentSaveDataPath, extraFileString);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void saveGameInfoFromEditor (string infoTypeName)
|
||||
{
|
||||
if (isLoadGameEnabled () && saveNumberToLoad > -1) {
|
||||
|
||||
string extraFileString = " " + getVersionNumber () + getFileExtension ();
|
||||
|
||||
charactersManager.saveGameInfoFromEditor (saveNumberToLoad, infoTypeName, extraFileString);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveGameWhenReturningHomeMenu ()
|
||||
{
|
||||
if (isLoadGameEnabled ()) {
|
||||
charactersManager.saveGameWhenReturningHomeMenu ();
|
||||
}
|
||||
}
|
||||
|
||||
void Start ()
|
||||
{
|
||||
currentPersistentDataPath = Application.persistentDataPath;
|
||||
|
||||
if (loadEnabled && mainPlayerGameObject != null) {
|
||||
if (PlayerPrefs.HasKey ("chapterInfo")) {
|
||||
chapterInfo = PlayerPrefs.GetString ("chapterInfo");
|
||||
}
|
||||
|
||||
if (PlayerPrefs.HasKey ("loadingGame")) {
|
||||
if (PlayerPrefs.GetInt ("loadingGame") == 1) {
|
||||
|
||||
bool setPlayerPositionResult = true;
|
||||
|
||||
Vector3 newPlayerPosition = Vector3.zero;
|
||||
Quaternion newPlayerRotation = Quaternion.identity;
|
||||
|
||||
bool savingGameToChangeScene = false;
|
||||
|
||||
if (PlayerPrefs.GetInt ("savingGameToChangeScene") == 1) {
|
||||
|
||||
int levelManagerIDToLoad = PlayerPrefs.GetInt ("levelManagerIDToLoad");
|
||||
|
||||
bool targetFound = false;
|
||||
|
||||
levelManagerIngame [] levelManagerIngameList = FindObjectsOfType<levelManagerIngame> ();
|
||||
|
||||
int levelManagerIngameListLength = levelManagerIngameList.Length;
|
||||
|
||||
for (int i = 0; i < levelManagerIngameListLength; i++) {
|
||||
|
||||
levelManagerIngame currentLevelManagerIngame = levelManagerIngameList [i] as levelManagerIngame;
|
||||
|
||||
if (!targetFound && currentLevelManagerIngame.levelManagerID == levelManagerIDToLoad) {
|
||||
newPlayerPosition = currentLevelManagerIngame.spawPlayerPositionTransform.position;
|
||||
newPlayerRotation = currentLevelManagerIngame.spawPlayerPositionTransform.rotation;
|
||||
|
||||
targetFound = true;
|
||||
|
||||
savingGameToChangeScene = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!loadPlayerPositionOnSceneChangeEnabled) {
|
||||
setPlayerPositionResult = false;
|
||||
}
|
||||
} else {
|
||||
newPlayerPosition =
|
||||
new Vector3 (PlayerPrefs.GetFloat ("saveStationPositionX"), PlayerPrefs.GetFloat ("saveStationPositionY"), PlayerPrefs.GetFloat ("saveStationPositionZ"));
|
||||
|
||||
newPlayerRotation =
|
||||
Quaternion.Euler (PlayerPrefs.GetFloat ("saveStationRotationX"), PlayerPrefs.GetFloat ("saveStationRotationY"), PlayerPrefs.GetFloat ("saveStationRotationZ"));
|
||||
|
||||
if (!loadPlayerPositionEnabled) {
|
||||
setPlayerPositionResult = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (PlayerPrefs.GetInt ("useRaycastToPlacePlayer") == 1) {
|
||||
if (Physics.Raycast (newPlayerPosition + Vector3.up, -Vector3.up, out hit, Mathf.Infinity, layer)) {
|
||||
newPlayerPosition = hit.point;
|
||||
}
|
||||
}
|
||||
|
||||
bool isPlayerDriving = PlayerPrefs.GetInt ("isPlayerDriving") == 1;
|
||||
|
||||
if (!checkPlayerDrivingStateOnLoadEnabled) {
|
||||
isPlayerDriving = false;
|
||||
}
|
||||
|
||||
//set player position and rotation
|
||||
if (setPlayerPositionResult) {
|
||||
mainPlayerGameObject.transform.position = newPlayerPosition;
|
||||
mainPlayerGameObject.transform.rotation = newPlayerRotation;
|
||||
}
|
||||
|
||||
Quaternion newCameraRotation = newPlayerRotation;
|
||||
|
||||
if (savingGameToChangeScene) {
|
||||
newCameraRotation = newPlayerRotation;
|
||||
} else {
|
||||
if (PlayerPrefs.GetInt ("usePlayerCameraOrientation") == 1) {
|
||||
newCameraRotation =
|
||||
Quaternion.Euler (PlayerPrefs.GetFloat ("playerCameraRotationX"), PlayerPrefs.GetFloat ("playerCameraRotationY"), PlayerPrefs.GetFloat ("playerCameraRotationZ"));
|
||||
|
||||
float playerCameraPivotRotationX = PlayerPrefs.GetFloat ("playerCameraPivotRotationX");
|
||||
|
||||
float newLookAngle = playerCameraPivotRotationX;
|
||||
|
||||
if (newLookAngle > 180) {
|
||||
newLookAngle -= 360;
|
||||
}
|
||||
|
||||
Vector2 newPivotRotation = new Vector2 (0, newLookAngle);
|
||||
|
||||
currentPlayerCamera.setLookAngleValue (newPivotRotation);
|
||||
|
||||
currentPlayerCamera.getPivotCameraTransform ().localRotation = Quaternion.Euler (playerCameraPivotRotationX, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
if (setPlayerPositionResult) {
|
||||
mainPlayerCameraGameObject.transform.position = newPlayerPosition;
|
||||
mainPlayerCameraGameObject.transform.rotation = newCameraRotation;
|
||||
}
|
||||
|
||||
if (isPlayerDriving) {
|
||||
string vehicleName = PlayerPrefs.GetString ("currentVehicleName");
|
||||
|
||||
// print ("PLAYER PREVIOUSLY DRIVING " + vehicleName);
|
||||
|
||||
prefabsManager newPrefabsManager = FindObjectOfType<prefabsManager> ();
|
||||
|
||||
if (newPrefabsManager == null) {
|
||||
newPrefabsManager = GKC_Utils.addPrefabsManagerToScene ();
|
||||
}
|
||||
|
||||
if (newPrefabsManager != null) {
|
||||
GameObject vehiclePrefab = newPrefabsManager.getPrefabGameObject (vehicleName);
|
||||
|
||||
if (vehiclePrefab != null) {
|
||||
mainPlayerGameObject.transform.position = newPlayerPosition + Vector3.right * 4;
|
||||
|
||||
Vector3 vehiclePosition = Vector3.zero;
|
||||
|
||||
if (Physics.Raycast (newPlayerPosition + Vector3.up * 3, -Vector3.up, out hit, Mathf.Infinity, layer)) {
|
||||
vehiclePosition = hit.point;
|
||||
}
|
||||
|
||||
vehiclePosition += Vector3.up * newPrefabsManager.getPrefabSpawnOffset (vehicleName);
|
||||
|
||||
Vector3 newPlayerRotationEulerAngles = newPlayerRotation.eulerAngles;
|
||||
|
||||
newPlayerRotationEulerAngles = new Vector3 (0, newPlayerRotationEulerAngles.y, 0);
|
||||
|
||||
newPlayerRotation = Quaternion.Euler (newPlayerRotationEulerAngles);
|
||||
|
||||
GameObject newVehicle = (GameObject)Instantiate (vehiclePrefab, vehiclePosition, newPlayerRotation);
|
||||
|
||||
newVehicle.name = vehiclePrefab.name;
|
||||
|
||||
IKDrivingSystem currentIKDrivingSystem = newVehicle.GetComponent<IKDrivingSystem> ();
|
||||
|
||||
GKCSimpleRiderSystem mainGKCSimpleRiderSystem = null;
|
||||
|
||||
if (currentIKDrivingSystem != null) {
|
||||
currentIKDrivingSystem.setPlayerToStartGameOnThisVehicle (mainPlayerGameObject);
|
||||
} else {
|
||||
mainGKCSimpleRiderSystem = newVehicle.GetComponentInChildren<GKCSimpleRiderSystem> ();
|
||||
|
||||
if (mainGKCSimpleRiderSystem == null) {
|
||||
GKCRiderSocketSystem currentGKCRiderSocketSystem = newVehicle.GetComponentInChildren<GKCRiderSocketSystem> ();
|
||||
|
||||
if (currentGKCRiderSocketSystem != null) {
|
||||
mainRiderSystem currentmainRiderSystem = currentGKCRiderSocketSystem.getMainRiderSystem ();
|
||||
|
||||
mainGKCSimpleRiderSystem = currentmainRiderSystem.GetComponent<GKCSimpleRiderSystem> ();
|
||||
}
|
||||
}
|
||||
|
||||
if (mainGKCSimpleRiderSystem != null) {
|
||||
mainGKCSimpleRiderSystem.setPlayerToStartGameOnThisVehicle (mainPlayerGameObject);
|
||||
}
|
||||
}
|
||||
|
||||
elementOnSceneHelper vehicleElementOnSceneHelper = newVehicle.GetComponentInChildren<elementOnSceneHelper> ();
|
||||
|
||||
if (vehicleElementOnSceneHelper == null) {
|
||||
if (mainGKCSimpleRiderSystem != null) {
|
||||
vehicleElementOnSceneHelper = mainGKCSimpleRiderSystem.gameObject.GetComponentInChildren<elementOnSceneHelper> ();
|
||||
}
|
||||
}
|
||||
|
||||
if (vehicleElementOnSceneHelper != null) {
|
||||
vehicleElementOnSceneHelper.setNewInstantiatedElementOnSceneManagerIngameWithInfo ();
|
||||
|
||||
int currentVehicleElementScene = PlayerPrefs.GetInt ("currentVehicleElementScene");
|
||||
int currentVehicleElementID = PlayerPrefs.GetInt ("currentVehicleElementID");
|
||||
|
||||
vehicleElementOnSceneHelper.setStatsSearchingByInfo (currentVehicleElementScene, currentVehicleElementID);
|
||||
}
|
||||
} else {
|
||||
print ("WARNING: No prefab of the vehicle called " + vehicleName + " was found. Make sure a prefab with that name is configured in the prefabs manager");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
deletePlayerPrefsOnLoad ();
|
||||
}
|
||||
}
|
||||
|
||||
StartCoroutine (checkDeletePlayerPrefsActive ());
|
||||
} else {
|
||||
deletePlayerPrefsOnLoad ();
|
||||
}
|
||||
}
|
||||
|
||||
IEnumerator checkDeletePlayerPrefsActive ()
|
||||
{
|
||||
yield return new WaitForSeconds (0.3f);
|
||||
|
||||
if (PlayerPrefs.HasKey ("Delete Player Prefs Active")) {
|
||||
if (PlayerPrefs.GetInt ("Delete Player Prefs Active") == 1) {
|
||||
deletePlayerPrefsOnLoad ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void deletePlayerPrefsOnLoad ()
|
||||
{
|
||||
if (deleteAllPlayerPrefsOnLoadEnabled) {
|
||||
PlayerPrefs.DeleteAll ();
|
||||
} else {
|
||||
GKC_Utils.deletePlayerPrefByName ("loadingGame");
|
||||
|
||||
GKC_Utils.deletePlayerPrefByName ("saveNumber");
|
||||
|
||||
GKC_Utils.deletePlayerPrefByName ("currentSaveStationId");
|
||||
|
||||
GKC_Utils.deletePlayerPrefByName ("saveStationPositionX");
|
||||
GKC_Utils.deletePlayerPrefByName ("saveStationPositionY");
|
||||
GKC_Utils.deletePlayerPrefByName ("saveStationPositionZ");
|
||||
GKC_Utils.deletePlayerPrefByName ("saveStationRotationX");
|
||||
GKC_Utils.deletePlayerPrefByName ("saveStationRotationY");
|
||||
GKC_Utils.deletePlayerPrefByName ("saveStationRotationZ");
|
||||
|
||||
GKC_Utils.deletePlayerPrefByName ("usePlayerCameraOrientation");
|
||||
|
||||
GKC_Utils.deletePlayerPrefByName ("playerCameraRotationX");
|
||||
GKC_Utils.deletePlayerPrefByName ("playerCameraRotationY");
|
||||
GKC_Utils.deletePlayerPrefByName ("playerCameraRotationZ");
|
||||
GKC_Utils.deletePlayerPrefByName ("playerCameraPivotRotationX");
|
||||
|
||||
GKC_Utils.deletePlayerPrefByName ("useRaycastToPlacePlayer");
|
||||
|
||||
GKC_Utils.deletePlayerPrefByName ("savingGameToChangeScene");
|
||||
|
||||
GKC_Utils.deletePlayerPrefByName ("levelManagerIDToLoad");
|
||||
|
||||
GKC_Utils.deletePlayerPrefByName ("isPlayerDriving");
|
||||
GKC_Utils.deletePlayerPrefByName ("currentVehicleName");
|
||||
GKC_Utils.deletePlayerPrefByName ("currentVehicleElementScene");
|
||||
GKC_Utils.deletePlayerPrefByName ("currentVehicleElementID");
|
||||
|
||||
GKC_Utils.deletePlayerPrefByName ("saveNumber");
|
||||
|
||||
GKC_Utils.deletePlayerPrefByName ("Delete Player Prefs Active");
|
||||
}
|
||||
}
|
||||
|
||||
void Update ()
|
||||
{
|
||||
playTime += Time.unscaledDeltaTime;
|
||||
|
||||
if (limitFps) {
|
||||
if (updateLimitFpsIfChangeDetected || !FPSLimitAdjusted) {
|
||||
if (Application.targetFrameRate != targetFps) {
|
||||
Application.targetFrameRate = targetFps;
|
||||
}
|
||||
|
||||
if (!updateLimitFpsIfChangeDetected) {
|
||||
FPSLimitAdjusted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getPlayerPrefsInfo (saveGameSystem.saveStationInfo save)
|
||||
{
|
||||
PlayerPrefs.SetInt ("loadingGame", 1);
|
||||
|
||||
PlayerPrefs.SetInt ("saveNumber", save.saveNumber);
|
||||
|
||||
PlayerPrefs.SetInt ("currentSaveStationId", save.id);
|
||||
|
||||
PlayerPrefs.SetFloat ("saveStationPositionX", save.saveStationPositionX);
|
||||
PlayerPrefs.SetFloat ("saveStationPositionY", save.saveStationPositionY);
|
||||
PlayerPrefs.SetFloat ("saveStationPositionZ", save.saveStationPositionZ);
|
||||
PlayerPrefs.SetFloat ("saveStationRotationX", save.saveStationRotationX);
|
||||
PlayerPrefs.SetFloat ("saveStationRotationY", save.saveStationRotationY);
|
||||
PlayerPrefs.SetFloat ("saveStationRotationZ", save.saveStationRotationZ);
|
||||
|
||||
if (save.usePlayerCameraOrientation) {
|
||||
PlayerPrefs.SetInt ("usePlayerCameraOrientation", 1);
|
||||
} else {
|
||||
PlayerPrefs.SetInt ("usePlayerCameraOrientation", 0);
|
||||
}
|
||||
|
||||
PlayerPrefs.SetFloat ("playerCameraRotationX", save.playerCameraRotationX);
|
||||
PlayerPrefs.SetFloat ("playerCameraRotationY", save.playerCameraRotationY);
|
||||
PlayerPrefs.SetFloat ("playerCameraRotationZ", save.playerCameraRotationZ);
|
||||
PlayerPrefs.SetFloat ("playerCameraPivotRotationX", save.playerCameraPivotRotationX);
|
||||
|
||||
if (save.useRaycastToPlacePlayer) {
|
||||
PlayerPrefs.SetInt ("useRaycastToPlacePlayer", 1);
|
||||
}
|
||||
|
||||
if (save.savingGameToChangeScene) {
|
||||
PlayerPrefs.SetInt ("savingGameToChangeScene", 1);
|
||||
} else {
|
||||
PlayerPrefs.SetInt ("savingGameToChangeScene", 0);
|
||||
}
|
||||
|
||||
PlayerPrefs.SetInt ("levelManagerIDToLoad", save.checkpointID);
|
||||
|
||||
if (save.isPlayerDriving) {
|
||||
PlayerPrefs.SetInt ("isPlayerDriving", 1);
|
||||
PlayerPrefs.SetString ("currentVehicleName", save.currentVehicleName);
|
||||
PlayerPrefs.SetInt ("currentVehicleElementScene", save.currentVehicleElementScene);
|
||||
PlayerPrefs.SetInt ("currentVehicleElementID", save.currentVehicleElementID);
|
||||
|
||||
} else {
|
||||
PlayerPrefs.SetInt ("isPlayerDriving", 0);
|
||||
}
|
||||
|
||||
// print ("setting prefs to load " + save.saveStationScene + " " + loadScreenScene);
|
||||
|
||||
GKC_Utils.loadScene (save.saveStationScene, useLoadScreen, loadScreenScene, sceneToLoadAsyncPrefsName,
|
||||
useLastSceneIndexAsLoadScreen, checkLoadingScreenSceneConfigured, loadingScreenSceneName);
|
||||
}
|
||||
|
||||
public string getDataPath ()
|
||||
{
|
||||
string dataPath = "";
|
||||
|
||||
if (useRelativePath) {
|
||||
dataPath = saveGameFolderName;
|
||||
} else {
|
||||
dataPath = Application.persistentDataPath + "/" + saveGameFolderName;
|
||||
}
|
||||
|
||||
if (!Directory.Exists (dataPath)) {
|
||||
Directory.CreateDirectory (dataPath);
|
||||
}
|
||||
|
||||
dataPath += "/";
|
||||
|
||||
return dataPath;
|
||||
}
|
||||
|
||||
public string getDataName ()
|
||||
{
|
||||
return saveFileName + " " + versionNumber;
|
||||
}
|
||||
|
||||
public string getVersionNumber ()
|
||||
{
|
||||
return versionNumber;
|
||||
}
|
||||
|
||||
public string getFileExtension ()
|
||||
{
|
||||
return fileExtension;
|
||||
}
|
||||
|
||||
public List<saveGameSystem.saveStationInfo> getCurrentSaveList ()
|
||||
{
|
||||
return saveList;
|
||||
}
|
||||
|
||||
public void setSaveList (List<saveGameSystem.saveStationInfo> currentList)
|
||||
{
|
||||
saveList = currentList;
|
||||
}
|
||||
|
||||
public int getLastSaveNumber ()
|
||||
{
|
||||
lastSaveNumber = -1;
|
||||
|
||||
if (PlayerPrefs.HasKey ("saveNumber")) {
|
||||
lastSaveNumber = PlayerPrefs.GetInt ("saveNumber");
|
||||
|
||||
} else if (saveNumberToLoad >= 0) {
|
||||
lastSaveNumber = saveNumberToLoad;
|
||||
}
|
||||
|
||||
return lastSaveNumber;
|
||||
}
|
||||
|
||||
public int getSlotBySaveStation ()
|
||||
{
|
||||
return slotBySaveStation;
|
||||
}
|
||||
|
||||
public void setGamePauseState (bool state)
|
||||
{
|
||||
gamePaused = state;
|
||||
}
|
||||
|
||||
public bool isGamePaused ()
|
||||
{
|
||||
return gamePaused;
|
||||
}
|
||||
|
||||
public bool isUsingTouchControls ()
|
||||
{
|
||||
return useTouchControls;
|
||||
}
|
||||
|
||||
public void setUseTouchControlsState (bool state)
|
||||
{
|
||||
useTouchControls = state;
|
||||
}
|
||||
|
||||
public void setCharactersManagerPauseState (bool state)
|
||||
{
|
||||
charactersManager.setCharactersManagerPauseState (state);
|
||||
}
|
||||
|
||||
public playerController getMainPlayerController ()
|
||||
{
|
||||
return charactersManager.getMainPlayerController ();
|
||||
}
|
||||
|
||||
public bool anyCharacterDead ()
|
||||
{
|
||||
return charactersManager.anyCharacterDead ();
|
||||
}
|
||||
|
||||
public string getSaveCaptureFolder ()
|
||||
{
|
||||
return saveCaptureFolder;
|
||||
}
|
||||
|
||||
public string getSaveCaptureFileName ()
|
||||
{
|
||||
return saveCaptureFileName;
|
||||
}
|
||||
|
||||
public string getTouchControlsPositionFolderName ()
|
||||
{
|
||||
return touchControlsPositionFolderName;
|
||||
}
|
||||
|
||||
public string getTouchControlsPositionFileName ()
|
||||
{
|
||||
return touchControlsPositionFileName + " " + versionNumber;
|
||||
}
|
||||
|
||||
public bool isLoadGameEnabled ()
|
||||
{
|
||||
return loadEnabled;
|
||||
}
|
||||
|
||||
public void setNewChapterName (string newName)
|
||||
{
|
||||
chapterInfo = newName;
|
||||
}
|
||||
|
||||
public string getChapterName ()
|
||||
{
|
||||
return chapterInfo;
|
||||
}
|
||||
|
||||
public float getPlayTime ()
|
||||
{
|
||||
return playTime;
|
||||
}
|
||||
|
||||
public void setPlayTimeValue (float newValue)
|
||||
{
|
||||
playTime = newValue;
|
||||
}
|
||||
|
||||
public void setMainCamera (Camera newCamera)
|
||||
{
|
||||
mainCamera = newCamera;
|
||||
}
|
||||
|
||||
public void setMainPlayerGameObject (GameObject newMainPlayerGameObject)
|
||||
{
|
||||
mainPlayerGameObject = newMainPlayerGameObject;
|
||||
}
|
||||
|
||||
public void setMainPlayerCameraGameObject (GameObject newMainPlayerCameraGameObject)
|
||||
{
|
||||
mainPlayerCameraGameObject = newMainPlayerCameraGameObject;
|
||||
}
|
||||
|
||||
public void setCurrentPlayerCamera (playerCamera newCurrentPlayerCamera)
|
||||
{
|
||||
currentPlayerCamera = newCurrentPlayerCamera;
|
||||
}
|
||||
|
||||
public void updateMainPlayerComponentsOnGameManager (GameObject newPlayerParent)
|
||||
{
|
||||
playerComponentsManager currentPlayerComponentsManager = newPlayerParent.GetComponentInChildren<playerComponentsManager> ();
|
||||
|
||||
if (currentPlayerComponentsManager != null) {
|
||||
mainPlayerGameObject = currentPlayerComponentsManager.getPlayerController ().gameObject;
|
||||
|
||||
currentPlayerCamera = currentPlayerComponentsManager.getPlayerCamera ();
|
||||
|
||||
mainCamera = currentPlayerCamera.getMainCamera ();
|
||||
|
||||
mainPlayerCameraGameObject = currentPlayerCamera.gameObject;
|
||||
|
||||
print ("Updating Main Player Components on Game Manager");
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
}
|
||||
|
||||
//EDITOR FUNCTIONS
|
||||
public void setUseTouchControlsStateFromEditor (bool state)
|
||||
{
|
||||
useTouchControls = state;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setCurrentPersistentDataPath ()
|
||||
{
|
||||
currentPersistentDataPath = Application.persistentDataPath;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void deletePlayerPrefs ()
|
||||
{
|
||||
PlayerPrefs.DeleteAll ();
|
||||
|
||||
print ("Player Prefs Deleted");
|
||||
}
|
||||
|
||||
public void openCurrentSaveFolder ()
|
||||
{
|
||||
getCurrentDataPath ();
|
||||
|
||||
showExplorer (currentSaveDataPath);
|
||||
}
|
||||
|
||||
public void showExplorer (string itemPath)
|
||||
{
|
||||
if (Directory.Exists (itemPath)) {
|
||||
itemPath = itemPath.Replace (@"/", @"\");
|
||||
System.Diagnostics.Process.Start ("explorer.exe", "/select," + itemPath);
|
||||
}
|
||||
}
|
||||
|
||||
public void getCurrentDataPath ()
|
||||
{
|
||||
setCurrentPersistentDataPath ();
|
||||
|
||||
currentSaveDataPath = getDataPath ();
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Game Manager " + gameObject.name, gameObject);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,593 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System;
|
||||
using System.Runtime.Serialization.Formatters.Binary;
|
||||
|
||||
public class gameManager : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool limitFps;
|
||||
|
||||
public bool updateLimitFpsIfChangeDetected;
|
||||
|
||||
public int targetFps = 60;
|
||||
|
||||
[Space]
|
||||
[Header ("Chapter Info")]
|
||||
[Space]
|
||||
|
||||
public string chapterInfo;
|
||||
|
||||
[Space]
|
||||
[Header ("Save Info")]
|
||||
[Space]
|
||||
|
||||
public bool loadEnabled;
|
||||
|
||||
public bool useRelativePath;
|
||||
|
||||
[Space]
|
||||
[Header ("Load Screen Settings")]
|
||||
[Space]
|
||||
|
||||
public bool useLoadScreen;
|
||||
|
||||
public int loadScreenScene = 1;
|
||||
|
||||
public bool useLastSceneIndexAsLoadScreen = true;
|
||||
|
||||
public string sceneToLoadAsyncPrefsName = "SceneToLoadAsync";
|
||||
|
||||
[Space]
|
||||
[Header ("Version Number Settings")]
|
||||
[Space]
|
||||
|
||||
public string versionNumber = "3-01";
|
||||
|
||||
[Space]
|
||||
[Header ("Save File Names Settings")]
|
||||
[Space]
|
||||
|
||||
public string saveGameFolderName = "Save";
|
||||
public string saveFileName = "Save State";
|
||||
|
||||
public string saveCaptureFolder = "Captures";
|
||||
public string saveCaptureFileName = "Photo";
|
||||
|
||||
public string touchControlsPositionFolderName = "Touch Buttons Position";
|
||||
public string touchControlsPositionFileName = "Touch Positions";
|
||||
|
||||
public string saveInputFileFolderName = "Input";
|
||||
public string saveInputFileName = "Input File";
|
||||
|
||||
public string defaultInputSaveFileName = "Default Input File";
|
||||
|
||||
public string fileExtension = ".txt";
|
||||
|
||||
public int slotBySaveStation;
|
||||
|
||||
public bool saveCameraCapture = true;
|
||||
|
||||
public LayerMask layer;
|
||||
|
||||
[Space]
|
||||
[Header ("Debug Settings")]
|
||||
[Space]
|
||||
|
||||
public int saveNumberToLoad = -1;
|
||||
|
||||
public string currentPersistentDataPath;
|
||||
|
||||
public string currentSaveDataPath;
|
||||
|
||||
public float playTime;
|
||||
|
||||
[Space]
|
||||
[Header ("Current Game State")]
|
||||
[Space]
|
||||
|
||||
public bool gamePaused;
|
||||
|
||||
public bool useTouchControls = false;
|
||||
|
||||
public bool touchPlatform;
|
||||
|
||||
[Space]
|
||||
[Header ("Game Manager Elements")]
|
||||
[Space]
|
||||
|
||||
public playerCharactersManager charactersManager;
|
||||
|
||||
public Camera mainCamera;
|
||||
|
||||
public GameObject mainPlayerGameObject;
|
||||
public GameObject mainPlayerCameraGameObject;
|
||||
public playerCamera currentPlayerCamera;
|
||||
|
||||
List<saveGameSystem.saveStationInfo> saveList = new List<saveGameSystem.saveStationInfo> ();
|
||||
|
||||
RaycastHit hit;
|
||||
|
||||
int lastSaveNumber = -1;
|
||||
|
||||
bool FPSLimitAdjusted;
|
||||
|
||||
void Awake ()
|
||||
{
|
||||
if (limitFps) {
|
||||
QualitySettings.vSyncCount = 0;
|
||||
Application.targetFrameRate = targetFps;
|
||||
} else {
|
||||
Application.targetFrameRate = -1;
|
||||
}
|
||||
|
||||
touchPlatform = touchJoystick.checkTouchPlatform ();
|
||||
|
||||
if (touchPlatform) {
|
||||
useRelativePath = false;
|
||||
}
|
||||
|
||||
checkGameInfoToLoad ();
|
||||
}
|
||||
|
||||
void checkGameInfoToLoad ()
|
||||
{
|
||||
if (isLoadGameEnabled () && getLastSaveNumber () > -1) {
|
||||
|
||||
string extraFileString = " " + getVersionNumber () + getFileExtension ();
|
||||
|
||||
lastSaveNumber = -1;
|
||||
if (PlayerPrefs.HasKey ("saveNumber")) {
|
||||
lastSaveNumber = PlayerPrefs.GetInt ("saveNumber");
|
||||
} else if (saveNumberToLoad >= 0) {
|
||||
lastSaveNumber = saveNumberToLoad;
|
||||
}
|
||||
|
||||
currentSaveDataPath = getDataPath ();
|
||||
|
||||
if (charactersManager != null) {
|
||||
charactersManager.checkGameInfoToLoad (lastSaveNumber, currentSaveDataPath, extraFileString);
|
||||
}
|
||||
} else {
|
||||
if (charactersManager != null) {
|
||||
charactersManager.checkComponentsToInitialize ();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void saveGameInfoFromEditor (string infoTypeName)
|
||||
{
|
||||
if (isLoadGameEnabled () && saveNumberToLoad > -1) {
|
||||
|
||||
string extraFileString = " " + getVersionNumber () + getFileExtension ();
|
||||
|
||||
charactersManager.saveGameInfoFromEditor (saveNumberToLoad, infoTypeName, extraFileString);
|
||||
}
|
||||
}
|
||||
|
||||
public void saveGameWhenReturningHomeMenu ()
|
||||
{
|
||||
if (isLoadGameEnabled ()) {
|
||||
charactersManager.saveGameWhenReturningHomeMenu ();
|
||||
}
|
||||
}
|
||||
|
||||
void Start ()
|
||||
{
|
||||
currentPersistentDataPath = Application.persistentDataPath;
|
||||
|
||||
if (loadEnabled && mainPlayerGameObject != null) {
|
||||
if (PlayerPrefs.HasKey ("chapterInfo")) {
|
||||
chapterInfo = PlayerPrefs.GetString ("chapterInfo");
|
||||
}
|
||||
|
||||
if (PlayerPrefs.HasKey ("loadingGame")) {
|
||||
if (PlayerPrefs.GetInt ("loadingGame") == 1) {
|
||||
|
||||
Vector3 newPlayerPosition = Vector3.zero;
|
||||
Quaternion newPlayerRotation = Quaternion.identity;
|
||||
|
||||
bool savingGameToChangeScene = false;
|
||||
|
||||
if (PlayerPrefs.GetInt ("savingGameToChangeScene") == 1) {
|
||||
|
||||
int levelManagerIDToLoad = PlayerPrefs.GetInt ("levelManagerIDToLoad");
|
||||
bool targetFound = false;
|
||||
|
||||
levelManagerIngame[] levelManagerIngameList = FindObjectsOfType<levelManagerIngame> ();
|
||||
|
||||
foreach (levelManagerIngame currentLevelManagerIngame in levelManagerIngameList) {
|
||||
if (!targetFound && currentLevelManagerIngame.levelManagerID == levelManagerIDToLoad) {
|
||||
newPlayerPosition = currentLevelManagerIngame.spawPlayerPositionTransform.position;
|
||||
newPlayerRotation = currentLevelManagerIngame.spawPlayerPositionTransform.rotation;
|
||||
|
||||
targetFound = true;
|
||||
|
||||
savingGameToChangeScene = true;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
newPlayerPosition =
|
||||
new Vector3 (PlayerPrefs.GetFloat ("saveStationPositionX"), PlayerPrefs.GetFloat ("saveStationPositionY"), PlayerPrefs.GetFloat ("saveStationPositionZ"));
|
||||
|
||||
newPlayerRotation =
|
||||
Quaternion.Euler (PlayerPrefs.GetFloat ("saveStationRotationX"), PlayerPrefs.GetFloat ("saveStationRotationY"), PlayerPrefs.GetFloat ("saveStationRotationZ"));
|
||||
}
|
||||
|
||||
if (PlayerPrefs.GetInt ("useRaycastToPlacePlayer") == 1) {
|
||||
if (Physics.Raycast (newPlayerPosition + Vector3.up, -Vector3.up, out hit, Mathf.Infinity, layer)) {
|
||||
newPlayerPosition = hit.point;
|
||||
}
|
||||
}
|
||||
|
||||
bool isPlayerDriving = PlayerPrefs.GetInt ("isPlayerDriving") == 1;
|
||||
|
||||
//set player position and rotation
|
||||
mainPlayerGameObject.transform.position = newPlayerPosition;
|
||||
mainPlayerGameObject.transform.rotation = newPlayerRotation;
|
||||
|
||||
Quaternion newCameraRotation = newPlayerRotation;
|
||||
|
||||
if (savingGameToChangeScene) {
|
||||
newCameraRotation = newPlayerRotation;
|
||||
} else {
|
||||
if (PlayerPrefs.GetInt ("usePlayerCameraOrientation") == 1) {
|
||||
newCameraRotation =
|
||||
Quaternion.Euler (PlayerPrefs.GetFloat ("playerCameraRotationX"), PlayerPrefs.GetFloat ("playerCameraRotationY"), PlayerPrefs.GetFloat ("playerCameraRotationZ"));
|
||||
|
||||
float playerCameraPivotRotationX = PlayerPrefs.GetFloat ("playerCameraPivotRotationX");
|
||||
|
||||
float newLookAngle = playerCameraPivotRotationX;
|
||||
|
||||
if (newLookAngle > 180) {
|
||||
newLookAngle -= 360;
|
||||
}
|
||||
|
||||
Vector2 newPivotRotation = new Vector2 (0, newLookAngle);
|
||||
|
||||
currentPlayerCamera.setLookAngleValue (newPivotRotation);
|
||||
|
||||
currentPlayerCamera.getPivotCameraTransform ().localRotation = Quaternion.Euler (playerCameraPivotRotationX, 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
mainPlayerCameraGameObject.transform.position = newPlayerPosition;
|
||||
mainPlayerCameraGameObject.transform.rotation = newCameraRotation;
|
||||
|
||||
if (isPlayerDriving) {
|
||||
string vehicleName = PlayerPrefs.GetString ("currentVehicleName");
|
||||
|
||||
print ("PLAYER PREVIOUSLY DRIVING " + vehicleName);
|
||||
|
||||
prefabsManager newPrefabsManager = FindObjectOfType<prefabsManager> ();
|
||||
|
||||
if (newPrefabsManager == null) {
|
||||
newPrefabsManager = GKC_Utils.addPrefabsManagerToScene ();
|
||||
}
|
||||
|
||||
if (newPrefabsManager != null) {
|
||||
GameObject vehiclePrefab = newPrefabsManager.getPrefabGameObject (vehicleName);
|
||||
|
||||
if (vehiclePrefab != null) {
|
||||
mainPlayerGameObject.transform.position = newPlayerPosition + Vector3.right * 4;
|
||||
|
||||
Vector3 vehiclePosition = Vector3.zero;
|
||||
|
||||
if (Physics.Raycast (newPlayerPosition + Vector3.up * 20, -Vector3.up, out hit, Mathf.Infinity, layer)) {
|
||||
vehiclePosition = hit.point;
|
||||
}
|
||||
|
||||
vehiclePosition += Vector3.up * newPrefabsManager.getPrefabSpawnOffset (vehicleName);
|
||||
|
||||
Vector3 newPlayerRotationEulerAngles = newPlayerRotation.eulerAngles;
|
||||
|
||||
newPlayerRotationEulerAngles = new Vector3 (0, newPlayerRotationEulerAngles.y, 0);
|
||||
|
||||
newPlayerRotation = Quaternion.Euler (newPlayerRotationEulerAngles);
|
||||
|
||||
GameObject newVehicle = (GameObject)Instantiate (vehiclePrefab, vehiclePosition, newPlayerRotation);
|
||||
|
||||
newVehicle.name = vehiclePrefab.name;
|
||||
|
||||
IKDrivingSystem currentIKDrivingSystem = newVehicle.GetComponent<IKDrivingSystem> ();
|
||||
|
||||
if (currentIKDrivingSystem != null) {
|
||||
currentIKDrivingSystem.setPlayerToStartGameOnThisVehicle (mainPlayerGameObject);
|
||||
} else {
|
||||
GKCSimpleRiderSystem mainGKCSimpleRiderSystem = newVehicle.GetComponentInChildren<GKCSimpleRiderSystem> ();
|
||||
|
||||
if (mainGKCSimpleRiderSystem == null) {
|
||||
GKCRiderSocketSystem currentGKCRiderSocketSystem = newVehicle.GetComponentInChildren<GKCRiderSocketSystem> ();
|
||||
|
||||
if (currentGKCRiderSocketSystem != null) {
|
||||
mainRiderSystem currentmainRiderSystem = currentGKCRiderSocketSystem.getMainRiderSystem ();
|
||||
|
||||
mainGKCSimpleRiderSystem = currentmainRiderSystem.GetComponent<GKCSimpleRiderSystem> ();
|
||||
}
|
||||
}
|
||||
|
||||
if (mainGKCSimpleRiderSystem != null) {
|
||||
mainGKCSimpleRiderSystem.setPlayerToStartGameOnThisVehicle (mainPlayerGameObject);
|
||||
}
|
||||
}
|
||||
|
||||
elementOnSceneHelper vehicleElementOnSceneHelper = newVehicle.GetComponentInChildren<elementOnSceneHelper> ();
|
||||
|
||||
if (vehicleElementOnSceneHelper != null) {
|
||||
vehicleElementOnSceneHelper.setNewInstantiatedElementOnSceneManagerIngameWithInfo ();
|
||||
|
||||
int currentVehicleElementScene = PlayerPrefs.GetInt ("currentVehicleElementScene");
|
||||
int currentVehicleElementID = PlayerPrefs.GetInt ("currentVehicleElementID");
|
||||
|
||||
vehicleElementOnSceneHelper.setStatsSearchingByInfo (currentVehicleElementScene, currentVehicleElementID);
|
||||
}
|
||||
} else {
|
||||
print ("WARNING: No prefab of the vehicle called " + vehicleName + " was found. Make sure a prefab with that name is configured in the prefabs manager");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PlayerPrefs.DeleteAll ();
|
||||
}
|
||||
}
|
||||
|
||||
if (PlayerPrefs.HasKey ("Delete Player Prefs Active")) {
|
||||
if (PlayerPrefs.GetInt ("Delete Player Prefs Active") == 1) {
|
||||
PlayerPrefs.DeleteAll ();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
PlayerPrefs.DeleteAll ();
|
||||
}
|
||||
}
|
||||
|
||||
void Update ()
|
||||
{
|
||||
playTime += Time.unscaledDeltaTime;
|
||||
|
||||
if (limitFps) {
|
||||
if (updateLimitFpsIfChangeDetected || !FPSLimitAdjusted) {
|
||||
if (Application.targetFrameRate != targetFps) {
|
||||
Application.targetFrameRate = targetFps;
|
||||
}
|
||||
|
||||
if (!updateLimitFpsIfChangeDetected) {
|
||||
FPSLimitAdjusted = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void getPlayerPrefsInfo (saveGameSystem.saveStationInfo save)
|
||||
{
|
||||
PlayerPrefs.SetInt ("loadingGame", 1);
|
||||
|
||||
PlayerPrefs.SetInt ("saveNumber", save.saveNumber);
|
||||
|
||||
PlayerPrefs.SetInt ("currentSaveStationId", save.id);
|
||||
|
||||
PlayerPrefs.SetFloat ("saveStationPositionX", save.saveStationPositionX);
|
||||
PlayerPrefs.SetFloat ("saveStationPositionY", save.saveStationPositionY);
|
||||
PlayerPrefs.SetFloat ("saveStationPositionZ", save.saveStationPositionZ);
|
||||
PlayerPrefs.SetFloat ("saveStationRotationX", save.saveStationRotationX);
|
||||
PlayerPrefs.SetFloat ("saveStationRotationY", save.saveStationRotationY);
|
||||
PlayerPrefs.SetFloat ("saveStationRotationZ", save.saveStationRotationZ);
|
||||
|
||||
if (save.usePlayerCameraOrientation) {
|
||||
PlayerPrefs.SetInt ("usePlayerCameraOrientation", 1);
|
||||
} else {
|
||||
PlayerPrefs.SetInt ("usePlayerCameraOrientation", 0);
|
||||
}
|
||||
|
||||
PlayerPrefs.SetFloat ("playerCameraRotationX", save.playerCameraRotationX);
|
||||
PlayerPrefs.SetFloat ("playerCameraRotationY", save.playerCameraRotationY);
|
||||
PlayerPrefs.SetFloat ("playerCameraRotationZ", save.playerCameraRotationZ);
|
||||
PlayerPrefs.SetFloat ("playerCameraPivotRotationX", save.playerCameraPivotRotationX);
|
||||
|
||||
if (save.useRaycastToPlacePlayer) {
|
||||
PlayerPrefs.SetInt ("useRaycastToPlacePlayer", 1);
|
||||
}
|
||||
|
||||
if (save.savingGameToChangeScene) {
|
||||
PlayerPrefs.SetInt ("savingGameToChangeScene", 1);
|
||||
} else {
|
||||
PlayerPrefs.SetInt ("savingGameToChangeScene", 0);
|
||||
}
|
||||
|
||||
PlayerPrefs.SetInt ("levelManagerIDToLoad", save.checkpointID);
|
||||
|
||||
if (save.isPlayerDriving) {
|
||||
PlayerPrefs.SetInt ("isPlayerDriving", 1);
|
||||
PlayerPrefs.SetString ("currentVehicleName", save.currentVehicleName);
|
||||
PlayerPrefs.SetInt ("currentVehicleElementScene", save.currentVehicleElementScene);
|
||||
PlayerPrefs.SetInt ("currentVehicleElementID", save.currentVehicleElementID);
|
||||
|
||||
} else {
|
||||
PlayerPrefs.SetInt ("isPlayerDriving", 0);
|
||||
}
|
||||
|
||||
print ("setting prefs to load " + save.saveStationScene + " " + loadScreenScene);
|
||||
|
||||
GKC_Utils.loadScene (save.saveStationScene, useLoadScreen, loadScreenScene, sceneToLoadAsyncPrefsName, useLastSceneIndexAsLoadScreen);
|
||||
}
|
||||
|
||||
public string getDataPath ()
|
||||
{
|
||||
string dataPath = "";
|
||||
|
||||
if (useRelativePath) {
|
||||
dataPath = saveGameFolderName;
|
||||
} else {
|
||||
dataPath = Application.persistentDataPath + "/" + saveGameFolderName;
|
||||
}
|
||||
|
||||
if (!Directory.Exists (dataPath)) {
|
||||
Directory.CreateDirectory (dataPath);
|
||||
}
|
||||
|
||||
dataPath += "/";
|
||||
|
||||
return dataPath;
|
||||
}
|
||||
|
||||
public string getDataName ()
|
||||
{
|
||||
return saveFileName + " " + versionNumber;
|
||||
}
|
||||
|
||||
public string getVersionNumber ()
|
||||
{
|
||||
return versionNumber;
|
||||
}
|
||||
|
||||
public string getFileExtension ()
|
||||
{
|
||||
return fileExtension;
|
||||
}
|
||||
|
||||
public List<saveGameSystem.saveStationInfo> getCurrentSaveList ()
|
||||
{
|
||||
return saveList;
|
||||
}
|
||||
|
||||
public void setSaveList (List<saveGameSystem.saveStationInfo> currentList)
|
||||
{
|
||||
saveList = currentList;
|
||||
}
|
||||
|
||||
public int getLastSaveNumber ()
|
||||
{
|
||||
lastSaveNumber = -1;
|
||||
|
||||
if (PlayerPrefs.HasKey ("saveNumber")) {
|
||||
lastSaveNumber = PlayerPrefs.GetInt ("saveNumber");
|
||||
|
||||
print ("save number player prefs located " + lastSaveNumber);
|
||||
} else if (saveNumberToLoad >= 0) {
|
||||
lastSaveNumber = saveNumberToLoad;
|
||||
}
|
||||
|
||||
return lastSaveNumber;
|
||||
}
|
||||
|
||||
public void setGamePauseState (bool state)
|
||||
{
|
||||
gamePaused = state;
|
||||
}
|
||||
|
||||
public bool isGamePaused ()
|
||||
{
|
||||
return gamePaused;
|
||||
}
|
||||
|
||||
public bool isUsingTouchControls ()
|
||||
{
|
||||
return useTouchControls;
|
||||
}
|
||||
|
||||
public void setUseTouchControlsState (bool state)
|
||||
{
|
||||
useTouchControls = state;
|
||||
}
|
||||
|
||||
public void setCharactersManagerPauseState (bool state)
|
||||
{
|
||||
charactersManager.setCharactersManagerPauseState (state);
|
||||
}
|
||||
|
||||
public playerController getMainPlayerController ()
|
||||
{
|
||||
return charactersManager.getMainPlayerController ();
|
||||
}
|
||||
|
||||
public bool anyCharacterDead ()
|
||||
{
|
||||
return charactersManager.anyCharacterDead ();
|
||||
}
|
||||
|
||||
public string getSaveCaptureFolder ()
|
||||
{
|
||||
return saveCaptureFolder;
|
||||
}
|
||||
|
||||
public string getSaveCaptureFileName ()
|
||||
{
|
||||
return saveCaptureFileName;
|
||||
}
|
||||
|
||||
public string getTouchControlsPositionFolderName ()
|
||||
{
|
||||
return touchControlsPositionFolderName;
|
||||
}
|
||||
|
||||
public string getTouchControlsPositionFileName ()
|
||||
{
|
||||
return touchControlsPositionFileName + " " + versionNumber;
|
||||
}
|
||||
|
||||
public bool isLoadGameEnabled ()
|
||||
{
|
||||
return loadEnabled;
|
||||
}
|
||||
|
||||
public void setNewChapterName (string newName)
|
||||
{
|
||||
chapterInfo = newName;
|
||||
}
|
||||
|
||||
public string getChapterName ()
|
||||
{
|
||||
return chapterInfo;
|
||||
}
|
||||
|
||||
public float getPlayTime ()
|
||||
{
|
||||
return playTime;
|
||||
}
|
||||
|
||||
public void setPlayTimeValue (float newValue)
|
||||
{
|
||||
playTime = newValue;
|
||||
}
|
||||
|
||||
//EDITOR FUNCTIONS
|
||||
public void setUseTouchControlsStateFromEditor (bool state)
|
||||
{
|
||||
useTouchControls = state;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void setCurrentPersistentDataPath ()
|
||||
{
|
||||
currentPersistentDataPath = Application.persistentDataPath;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void deletePlayerPrefs ()
|
||||
{
|
||||
PlayerPrefs.DeleteAll ();
|
||||
|
||||
print ("Player Prefs Deleted");
|
||||
}
|
||||
|
||||
public void getCurrentDataPath ()
|
||||
{
|
||||
setCurrentPersistentDataPath ();
|
||||
|
||||
currentSaveDataPath = getDataPath ();
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7c8064ca8089d194f9123ff1784a3790
|
||||
timeCreated: 1657625183
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
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/Game Manager/gameManager.cs.bak
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4f253a1956dfeb9468fbfa5fd05741c5
|
||||
timeCreated: 1467245758
|
||||
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/Game Manager/gameManager.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,361 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
using UnityEditor.SceneManagement;
|
||||
#endif
|
||||
|
||||
public class mainManagerAdministrator : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool placeManagersInParent;
|
||||
|
||||
[Space]
|
||||
|
||||
[Space]
|
||||
|
||||
public List<mainManagerInfo> mainManagerInfoList = new List<mainManagerInfo> ();
|
||||
|
||||
[Space]
|
||||
|
||||
[TextArea (3, 15)]
|
||||
public string explanation =
|
||||
"This component stores the a list of prefabs which are the main managers of the game, as these objects are now separated objects" +
|
||||
"from the player it self. \n\n" +
|
||||
|
||||
"This includes elements like the main inventory list manager, faction system, mission manager, dialog manager, etc....\n\n" +
|
||||
|
||||
"Just press the button Add Main Managers to Scene and they will be spawned on the scene, " +
|
||||
"so you can configure the values on these manager and use the button Update Main Managers Info to Prefabs, to update the new info " +
|
||||
"configured. ";
|
||||
|
||||
|
||||
[Space]
|
||||
[Header ("Debug")]
|
||||
[Space]
|
||||
|
||||
public bool showDebugPrint;
|
||||
|
||||
[HideInInspector] public Transform managersParent;
|
||||
|
||||
[HideInInspector] public bool managersParentFound;
|
||||
|
||||
|
||||
private static mainManagerAdministrator _mainManagerAdministratorInstance;
|
||||
|
||||
public static mainManagerAdministrator Instance { get { return _mainManagerAdministratorInstance; } }
|
||||
|
||||
|
||||
public void getComponentInstance ()
|
||||
{
|
||||
if (_mainManagerAdministratorInstance != null && _mainManagerAdministratorInstance != this) {
|
||||
Destroy (this.gameObject);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
_mainManagerAdministratorInstance = this;
|
||||
}
|
||||
|
||||
public void getComponentInstanceOnApplicationPlaying ()
|
||||
{
|
||||
if (Application.isPlaying) {
|
||||
getComponentInstance ();
|
||||
}
|
||||
}
|
||||
|
||||
void Awake ()
|
||||
{
|
||||
getComponentInstance ();
|
||||
|
||||
|
||||
for (int i = 0; i < mainManagerInfoList.Count; i++) {
|
||||
if (mainManagerInfoList [i].spawnManagerOnAwakeEnabled) {
|
||||
addMainManagerToScene (mainManagerInfoList [i].Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setSpawnManagerOnAwakeEnabledByName (string managerName)
|
||||
{
|
||||
setSpawnManagerOnAwakeEnabledStateByName (managerName, true);
|
||||
}
|
||||
|
||||
public void setSpawnManagerOnAwakeDisableddByName (string managerName)
|
||||
{
|
||||
setSpawnManagerOnAwakeEnabledStateByName (managerName, false);
|
||||
}
|
||||
|
||||
public void setSpawnManagerOnAwakeEnabledStateByName (string managerName, bool state)
|
||||
{
|
||||
int currentIndex = mainManagerInfoList.FindIndex (s => s.Name == managerName);
|
||||
|
||||
if (currentIndex > -1) {
|
||||
mainManagerInfo currentMainManagerInfo = mainManagerInfoList [currentIndex];
|
||||
|
||||
currentMainManagerInfo.spawnManagerOnAwakeEnabled = state;
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
}
|
||||
|
||||
public void updateMainManagersInfoToPrefabs ()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
|
||||
for (int i = 0; i < mainManagerInfoList.Count; i++) {
|
||||
if (mainManagerInfoList [i].mainManagerOnScene != null && mainManagerInfoList [i].updatePrefabEnabled &&
|
||||
mainManagerInfoList [i].mainManagerPrefab != null) {
|
||||
GameObject newPrefab = GameObject.Find (mainManagerInfoList [i].mainManagerOnScene.name);
|
||||
|
||||
if (newPrefab != null) {
|
||||
//PrefabUtility.ReplacePrefab (newPrefab, mainManagerInfoList [i].mainManagerPrefab, ReplacePrefabOptions.ReplaceNameBased);
|
||||
|
||||
GKC_Utils.replacePrefabNameBased (newPrefab, mainManagerInfoList [i].mainManagerPrefab);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
public void addAllMainManagersToScene ()
|
||||
{
|
||||
for (int i = 0; i < mainManagerInfoList.Count; i++) {
|
||||
addMainManagerToScene (mainManagerInfoList [i].Name);
|
||||
}
|
||||
|
||||
if (placeManagersInParent) {
|
||||
setMainManagersOnParent ();
|
||||
}
|
||||
}
|
||||
|
||||
public void setMainManagersOnParent ()
|
||||
{
|
||||
if (placeManagersInParent) {
|
||||
checkParentForManagers ();
|
||||
|
||||
if (managersParentFound) {
|
||||
for (int i = 0; i < mainManagerInfoList.Count; i++) {
|
||||
if (mainManagerInfoList [i].mainManagerOnScene != null && mainManagerInfoList [i].mainManagerPrefab != null) {
|
||||
GameObject newManagerOnScene = GameObject.Find (mainManagerInfoList [i].mainManagerPrefab.name);
|
||||
|
||||
if (newManagerOnScene != null) {
|
||||
|
||||
newManagerOnScene.transform.SetParent (managersParent);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void checkParentForManagers ()
|
||||
{
|
||||
managersParentFound = managersParent != null;
|
||||
|
||||
if (managersParentFound) {
|
||||
return;
|
||||
}
|
||||
|
||||
GameObject newParent = GameObject.Find ("Main Managers Prefabs");
|
||||
|
||||
if (newParent != null) {
|
||||
managersParent = newParent.transform;
|
||||
} else {
|
||||
newParent = new GameObject ();
|
||||
|
||||
newParent.name = "Main Managers Prefabs";
|
||||
managersParent = newParent.transform;
|
||||
}
|
||||
|
||||
managersParentFound = true;
|
||||
}
|
||||
|
||||
public void setMainManagersOnParentFromEditor ()
|
||||
{
|
||||
placeManagersInParent = true;
|
||||
|
||||
setMainManagersOnParent ();
|
||||
}
|
||||
|
||||
public void selectMainManagersParent ()
|
||||
{
|
||||
if (managersParent == null) {
|
||||
setMainManagersOnParentFromEditor ();
|
||||
}
|
||||
|
||||
if (managersParent != null) {
|
||||
if (managersParent.childCount > 0) {
|
||||
GKC_Utils.setActiveGameObjectInEditor (managersParent.GetChild (0).gameObject);
|
||||
} else {
|
||||
GKC_Utils.setActiveGameObjectInEditor (managersParent.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addMainManagerToScene (string managerName)
|
||||
{
|
||||
int currentIndex = mainManagerInfoList.FindIndex (s => s.Name == managerName);
|
||||
|
||||
if (currentIndex > -1) {
|
||||
mainManagerInfo currentMainManagerInfo = mainManagerInfoList [currentIndex];
|
||||
|
||||
if (currentMainManagerInfo.mainManagerOnScene == null) {
|
||||
GameObject managerPrefab = currentMainManagerInfo.mainManagerPrefab;
|
||||
|
||||
if (managerPrefab != null) {
|
||||
GameObject newManagerOnScene = GameObject.Find (managerPrefab.name);
|
||||
|
||||
if (newManagerOnScene == null) {
|
||||
bool instantiateManagerLinkedToPrefabEnabled = currentMainManagerInfo.instantiateManagerLinkedToPrefabEnabled;
|
||||
|
||||
if (Application.isPlaying || !instantiateManagerLinkedToPrefabEnabled) {
|
||||
newManagerOnScene = (GameObject)Instantiate (managerPrefab, Vector3.zero, Quaternion.identity);
|
||||
|
||||
newManagerOnScene.name = managerPrefab.name;
|
||||
|
||||
currentMainManagerInfo.mainManagerOnScene = newManagerOnScene as UnityEngine.Object;
|
||||
|
||||
instantiateManagerLinkedToPrefabEnabled = false;
|
||||
}
|
||||
|
||||
if (instantiateManagerLinkedToPrefabEnabled) {
|
||||
#if UNITY_EDITOR
|
||||
UnityEngine.Object newManagerOnSceneObject = PrefabUtility.InstantiatePrefab (managerPrefab);
|
||||
|
||||
newManagerOnSceneObject.name = managerPrefab.name;
|
||||
|
||||
currentMainManagerInfo.mainManagerOnScene = newManagerOnSceneObject;
|
||||
#endif
|
||||
}
|
||||
} else {
|
||||
currentMainManagerInfo.mainManagerOnScene = newManagerOnScene as UnityEngine.Object;
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Main Manager " + managerName + " added on scene");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void addMainManagerToSceneWithType (string managerName, Type typeToSearch, bool callGetComponentInstance)
|
||||
{
|
||||
int currentIndex = mainManagerInfoList.FindIndex (s => s.Name == managerName);
|
||||
|
||||
if (currentIndex > -1) {
|
||||
mainManagerInfo currentMainManagerInfo = mainManagerInfoList [currentIndex];
|
||||
|
||||
if (currentMainManagerInfo.mainManagerOnScene == null) {
|
||||
|
||||
UnityEngine.Object typeObject = UnityEngine.Object.FindObjectOfType (typeToSearch);
|
||||
|
||||
if (typeObject != null) {
|
||||
if (showDebugPrint) {
|
||||
print (typeObject.name);
|
||||
}
|
||||
|
||||
currentMainManagerInfo.mainManagerOnScene = typeObject;
|
||||
|
||||
updateComponent ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Main Manager " + managerName + " located on scene");
|
||||
}
|
||||
|
||||
if (callGetComponentInstance) {
|
||||
GameObject currentGameObject = typeObject as GameObject;
|
||||
|
||||
if (currentGameObject != null) {
|
||||
currentGameObject.SendMessage ("getComponentInstance", SendMessageOptions.DontRequireReceiver);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
||||
GameObject managerPrefab = currentMainManagerInfo.mainManagerPrefab;
|
||||
|
||||
if (managerPrefab != null) {
|
||||
bool instantiateManagerLinkedToPrefabEnabled = currentMainManagerInfo.instantiateManagerLinkedToPrefabEnabled;
|
||||
|
||||
if (Application.isPlaying || !instantiateManagerLinkedToPrefabEnabled) {
|
||||
GameObject newManagerOnScene = (GameObject)Instantiate (managerPrefab, Vector3.zero, Quaternion.identity);
|
||||
|
||||
newManagerOnScene.name = managerPrefab.name;
|
||||
|
||||
currentMainManagerInfo.mainManagerOnScene = newManagerOnScene as UnityEngine.Object;
|
||||
|
||||
if (callGetComponentInstance) {
|
||||
newManagerOnScene.SendMessage ("getComponentInstance", SendMessageOptions.DontRequireReceiver);
|
||||
}
|
||||
|
||||
instantiateManagerLinkedToPrefabEnabled = false;
|
||||
}
|
||||
|
||||
if (instantiateManagerLinkedToPrefabEnabled) {
|
||||
#if UNITY_EDITOR
|
||||
UnityEngine.Object newManagerOnSceneObject = PrefabUtility.InstantiatePrefab (managerPrefab);
|
||||
|
||||
newManagerOnSceneObject.name = managerPrefab.name;
|
||||
|
||||
currentMainManagerInfo.mainManagerOnScene = newManagerOnSceneObject;
|
||||
#endif
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("Main Manager " + managerName + " added on scene");
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (callGetComponentInstance) {
|
||||
GameObject currentGameObject = currentMainManagerInfo.mainManagerOnScene as GameObject;
|
||||
|
||||
if (showDebugPrint) {
|
||||
print ("sending message to manager on scene " + currentGameObject.name);
|
||||
}
|
||||
|
||||
if (currentGameObject != null) {
|
||||
currentGameObject.SendMessage ("getComponentInstance", SendMessageOptions.DontRequireReceiver);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void updateComponent ()
|
||||
{
|
||||
if (!Application.isPlaying) {
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Managers Administrator elements", gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class mainManagerInfo
|
||||
{
|
||||
public string Name;
|
||||
public GameObject mainManagerPrefab;
|
||||
|
||||
public UnityEngine.Object mainManagerOnScene;
|
||||
|
||||
public bool spawnManagerOnAwakeEnabled;
|
||||
|
||||
public bool updatePrefabEnabled = true;
|
||||
|
||||
public bool instantiateManagerLinkedToPrefabEnabled = true;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 74b0322c12d530c479f04517c6c33047
|
||||
timeCreated: 1620010254
|
||||
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/Game Manager/mainManagerAdministrator.cs
|
||||
uploadId: 814740
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: a9802436b73972a40b6e4e20a2173385
|
||||
timeCreated: 1527787686
|
||||
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/Game Manager/playerCharactersManager.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,484 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
|
||||
public class prefabsManager : MonoBehaviour
|
||||
{
|
||||
public string prefabsUrl = "Assets/Game Kit Controller/Prefabs/";
|
||||
public List<prefabTypeInfo> prefabTypeInfoList = new List<prefabTypeInfo> ();
|
||||
public LayerMask layerToPlaceObjects;
|
||||
|
||||
public float placeObjectsOffset = 0.5f;
|
||||
|
||||
public List<prefabTypeInfo> prefabTypeInfoListToPlaceOnScene = new List<prefabTypeInfo> ();
|
||||
|
||||
public List<prefabTypeInfo> prefabSearchResultList = new List<prefabTypeInfo> ();
|
||||
|
||||
public string prefabNameToSearch;
|
||||
public string prefabCategoryNameToSearch;
|
||||
|
||||
public bool searchComplete;
|
||||
|
||||
public bool seePrefabTypesExplanation;
|
||||
|
||||
//add function to get automatically the prefabs in an specific folder
|
||||
|
||||
GameObject lastPrefabCreated;
|
||||
|
||||
|
||||
public void placePrefabInScene (int typeIndex, int prefabIndex)
|
||||
{
|
||||
Vector3 positionToInstantiate = Vector3.zero;
|
||||
|
||||
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, layerToPlaceObjects)) {
|
||||
positionToInstantiate = hit.point + Vector3.up * placeObjectsOffset;
|
||||
}
|
||||
}
|
||||
|
||||
if (typeIndex < prefabTypeInfoList.Count && prefabIndex < prefabTypeInfoList [typeIndex].prefabInfoList.Count) {
|
||||
prefabInfo newPrefabInfo = prefabTypeInfoList [typeIndex].prefabInfoList [prefabIndex];
|
||||
|
||||
GameObject prefabToInstantiate = newPrefabInfo.prefabGameObject;
|
||||
|
||||
string prefabName = newPrefabInfo.Name;
|
||||
|
||||
if (prefabToInstantiate != null) {
|
||||
positionToInstantiate += Vector3.up * newPrefabInfo.positionToSpawnOffset;
|
||||
|
||||
GameObject newObjectCreated = (GameObject)Instantiate (prefabToInstantiate, positionToInstantiate, Quaternion.identity);
|
||||
newObjectCreated.name = prefabToInstantiate.name;
|
||||
|
||||
print (prefabName + " prefab added to the scene");
|
||||
|
||||
lastPrefabCreated = newObjectCreated;
|
||||
} else {
|
||||
print ("WARNING: prefab gameObject is empty, make sure it is assigned correctly");
|
||||
}
|
||||
} else {
|
||||
print ("WARNING: prefab gameObject is empty or not assigned properly, make sure it is assigned correctly");
|
||||
}
|
||||
}
|
||||
|
||||
public void addPrefab (int prefabTypeIndex)
|
||||
{
|
||||
prefabInfo newPrefabInfo = new prefabInfo ();
|
||||
|
||||
newPrefabInfo.Name = "New Prefab";
|
||||
|
||||
prefabTypeInfoList [prefabTypeIndex].prefabInfoList.Add (newPrefabInfo);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void addPrefabType ()
|
||||
{
|
||||
prefabTypeInfo newPrefabTypeInfo = new prefabTypeInfo ();
|
||||
|
||||
newPrefabTypeInfo.Name = "New Type";
|
||||
|
||||
prefabTypeInfoList.Add (newPrefabTypeInfo);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void addPrefabType (int prefabTypeIndex)
|
||||
{
|
||||
prefabTypeInfo newPrefabTypeInfo = new prefabTypeInfo ();
|
||||
|
||||
newPrefabTypeInfo.Name = "New Type";
|
||||
|
||||
prefabTypeInfoList.Insert (prefabTypeIndex + 1, newPrefabTypeInfo);
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public string getPrefabPath (string prefabType, string prefabName)
|
||||
{
|
||||
string path = "";
|
||||
|
||||
int prefabTypeInfoListCount = prefabTypeInfoList.Count;
|
||||
|
||||
for (int i = 0; i < prefabTypeInfoListCount; i++) {
|
||||
if (prefabTypeInfoList [i].Name.Equals (prefabType)) {
|
||||
|
||||
int prefabInfoListCount = prefabTypeInfoList [i].prefabInfoList.Count;
|
||||
|
||||
for (int j = 0; j < prefabInfoListCount; j++) {
|
||||
if (prefabTypeInfoList [i].prefabInfoList [j].Name.Equals (prefabName)) {
|
||||
path = prefabsUrl + prefabTypeInfoList [i].url + "/" + prefabTypeInfoList [i].prefabInfoList [j].urlName;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return path;
|
||||
}
|
||||
|
||||
public void updatePrefabsListToPlaceOnScene ()
|
||||
{
|
||||
prefabTypeInfoListToPlaceOnScene.Clear ();
|
||||
|
||||
int prefabTypeInfoListCount = prefabTypeInfoList.Count;
|
||||
|
||||
for (int i = 0; i < prefabTypeInfoListCount; i++) {
|
||||
|
||||
prefabTypeInfo newPrefabTypeInfo = new prefabTypeInfo ();
|
||||
|
||||
newPrefabTypeInfo.Name = prefabTypeInfoList [i].Name;
|
||||
|
||||
newPrefabTypeInfo.prefabExplanation = prefabTypeInfoList [i].prefabExplanation;
|
||||
|
||||
int prefabInfoListCount = prefabTypeInfoList [i].prefabInfoList.Count;
|
||||
|
||||
for (int j = 0; j < prefabInfoListCount; j++) {
|
||||
|
||||
prefabInfo newPrefabInfo = new prefabInfo ();
|
||||
|
||||
newPrefabInfo.Name = prefabTypeInfoList [i].prefabInfoList [j].Name;
|
||||
|
||||
newPrefabInfo.prefabGameObject = prefabTypeInfoList [i].prefabInfoList [j].prefabGameObject;
|
||||
|
||||
newPrefabTypeInfo.prefabInfoList.Add (newPrefabInfo);
|
||||
}
|
||||
|
||||
prefabTypeInfoListToPlaceOnScene.Add (newPrefabTypeInfo);
|
||||
}
|
||||
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void makePrefabsSearchByName ()
|
||||
{
|
||||
prefabSearchResultList.Clear ();
|
||||
|
||||
if (prefabNameToSearch.Equals ("") || prefabNameToSearch.Equals (" ")) {
|
||||
|
||||
searchComplete = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int prefabTypeInfoListCount = prefabTypeInfoList.Count;
|
||||
|
||||
for (int i = 0; i < prefabTypeInfoListCount; i++) {
|
||||
|
||||
prefabTypeInfo newPrefabTypeInfo = new prefabTypeInfo ();
|
||||
|
||||
newPrefabTypeInfo.Name = prefabTypeInfoList [i].Name;
|
||||
|
||||
newPrefabTypeInfo.prefabExplanation = prefabTypeInfoList [i].prefabExplanation;
|
||||
|
||||
int prefabInfoListCount = prefabTypeInfoList [i].prefabInfoList.Count;
|
||||
|
||||
for (int j = 0; j < prefabInfoListCount; j++) {
|
||||
|
||||
bool prefabNameFound = false;
|
||||
|
||||
prefabNameToSearch = prefabNameToSearch.ToLower ();
|
||||
|
||||
string currentPrefabName = prefabTypeInfoList [i].prefabInfoList [j].Name.ToLower ();
|
||||
|
||||
if (prefabNameToSearch.Equals (currentPrefabName)) {
|
||||
prefabNameFound = true;
|
||||
}
|
||||
|
||||
if (!prefabNameFound) {
|
||||
if (currentPrefabName.Contains (prefabNameToSearch)) {
|
||||
prefabNameFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (prefabNameFound) {
|
||||
prefabInfo newPrefabInfo = new prefabInfo ();
|
||||
|
||||
newPrefabInfo.Name = prefabTypeInfoList [i].prefabInfoList [j].Name;
|
||||
|
||||
newPrefabInfo.prefabGameObject = prefabTypeInfoList [i].prefabInfoList [j].prefabGameObject;
|
||||
|
||||
newPrefabTypeInfo.prefabInfoList.Add (newPrefabInfo);
|
||||
}
|
||||
}
|
||||
|
||||
prefabSearchResultList.Add (newPrefabTypeInfo);
|
||||
}
|
||||
|
||||
for (int i = prefabSearchResultList.Count - 1; i >= 0; i--) {
|
||||
int prefabInfoListCount = prefabTypeInfoList [i].prefabInfoList.Count;
|
||||
|
||||
if (prefabInfoListCount == 0) {
|
||||
|
||||
prefabSearchResultList.RemoveAt (i);
|
||||
}
|
||||
}
|
||||
|
||||
searchComplete = true;
|
||||
}
|
||||
|
||||
public void makePrefabsSearchByCategory ()
|
||||
{
|
||||
prefabSearchResultList.Clear ();
|
||||
|
||||
if (prefabCategoryNameToSearch.Equals ("") || prefabCategoryNameToSearch.Equals (" ")) {
|
||||
|
||||
searchComplete = true;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int prefabTypeInfoListCount = prefabTypeInfoList.Count;
|
||||
|
||||
for (int i = 0; i < prefabTypeInfoListCount; i++) {
|
||||
|
||||
prefabTypeInfo newPrefabTypeInfo = new prefabTypeInfo ();
|
||||
|
||||
newPrefabTypeInfo.Name = prefabTypeInfoList [i].Name;
|
||||
|
||||
newPrefabTypeInfo.prefabExplanation = prefabTypeInfoList [i].prefabExplanation;
|
||||
|
||||
bool prefabNameFound = false;
|
||||
|
||||
prefabCategoryNameToSearch = prefabCategoryNameToSearch.ToLower ();
|
||||
|
||||
string currentPrefabName = prefabTypeInfoList [i].Name.ToLower ();
|
||||
|
||||
if (prefabCategoryNameToSearch.Equals (currentPrefabName)) {
|
||||
prefabNameFound = true;
|
||||
}
|
||||
|
||||
if (!prefabNameFound) {
|
||||
if (currentPrefabName.Contains (prefabCategoryNameToSearch)) {
|
||||
prefabNameFound = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (prefabNameFound) {
|
||||
int prefabInfoListCount = prefabTypeInfoList [i].prefabInfoList.Count;
|
||||
|
||||
for (int j = 0; j < prefabInfoListCount; j++) {
|
||||
|
||||
prefabInfo newPrefabInfo = new prefabInfo ();
|
||||
|
||||
newPrefabInfo.Name = prefabTypeInfoList [i].prefabInfoList [j].Name;
|
||||
|
||||
newPrefabInfo.prefabGameObject = prefabTypeInfoList [i].prefabInfoList [j].prefabGameObject;
|
||||
|
||||
newPrefabTypeInfo.prefabInfoList.Add (newPrefabInfo);
|
||||
}
|
||||
}
|
||||
|
||||
prefabSearchResultList.Add (newPrefabTypeInfo);
|
||||
}
|
||||
|
||||
for (int i = prefabSearchResultList.Count - 1; i >= 0; i--) {
|
||||
if (prefabSearchResultList [i].prefabInfoList.Count == 0) {
|
||||
|
||||
prefabSearchResultList.RemoveAt (i);
|
||||
}
|
||||
}
|
||||
|
||||
searchComplete = true;
|
||||
}
|
||||
|
||||
public void placePrefabInSceneByGameObject (GameObject objectToSearch)
|
||||
{
|
||||
int prefabTypeInfoListCount = prefabTypeInfoList.Count;
|
||||
|
||||
for (int i = 0; i < prefabTypeInfoListCount; i++) {
|
||||
|
||||
int prefabInfoListCount = prefabTypeInfoList [i].prefabInfoList.Count;
|
||||
|
||||
for (int j = 0; j < prefabInfoListCount; j++) {
|
||||
if (prefabTypeInfoList [i].prefabInfoList [j].prefabGameObject == objectToSearch) {
|
||||
placePrefabInScene (i, j);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void cleanSearchResults ()
|
||||
{
|
||||
prefabSearchResultList.Clear ();
|
||||
|
||||
prefabCategoryNameToSearch = "";
|
||||
|
||||
prefabNameToSearch = "";
|
||||
|
||||
searchComplete = false;
|
||||
}
|
||||
|
||||
public GameObject getPrefabGameObject (string prefabName)
|
||||
{
|
||||
prefabName = prefabName.ToLower ();
|
||||
|
||||
int prefabTypeInfoListCount = prefabTypeInfoList.Count;
|
||||
|
||||
for (int i = 0; i < prefabTypeInfoListCount; i++) {
|
||||
int prefabInfoListCount = prefabTypeInfoList [i].prefabInfoList.Count;
|
||||
|
||||
for (int j = 0; j < prefabInfoListCount; j++) {
|
||||
if (prefabTypeInfoList [i].prefabInfoList [j].Name.ToLower ().Equals (prefabName)) {
|
||||
return prefabTypeInfoList [i].prefabInfoList [j].prefabGameObject;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public void spawnPrefabByName (string prefabName)
|
||||
{
|
||||
prefabName = prefabName.ToLower ();
|
||||
|
||||
int prefabTypeInfoListCount = prefabTypeInfoList.Count;
|
||||
|
||||
for (int i = 0; i < prefabTypeInfoListCount; i++) {
|
||||
int prefabInfoListCount = prefabTypeInfoList [i].prefabInfoList.Count;
|
||||
|
||||
for (int j = 0; j < prefabInfoListCount; j++) {
|
||||
if (prefabTypeInfoList [i].prefabInfoList [j].Name.ToLower ().Equals (prefabName)) {
|
||||
placePrefabInScene (i, j);
|
||||
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print ("WARNING: No prefab found with the name " + prefabName + ". Make sure to configure one with that name to use it");
|
||||
}
|
||||
|
||||
|
||||
public float getPrefabSpawnOffset (string prefabName)
|
||||
{
|
||||
prefabName = prefabName.ToLower ();
|
||||
|
||||
int prefabTypeInfoListCount = prefabTypeInfoList.Count;
|
||||
|
||||
for (int i = 0; i < prefabTypeInfoListCount; i++) {
|
||||
int prefabInfoListCount = prefabTypeInfoList [i].prefabInfoList.Count;
|
||||
|
||||
for (int j = 0; j < prefabInfoListCount; j++) {
|
||||
if (prefabTypeInfoList [i].prefabInfoList [j].Name.ToLower ().Equals (prefabName)) {
|
||||
return prefabTypeInfoList [i].prefabInfoList [j].positionToSpawnOffset;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void setURLWithNames (int prefabTypeIndex)
|
||||
{
|
||||
int prefabInfoListCount = prefabTypeInfoList [prefabTypeIndex].prefabInfoList.Count;
|
||||
|
||||
for (int j = 0; j < prefabInfoListCount; j++) {
|
||||
if (prefabTypeInfoList [prefabTypeIndex].prefabInfoList [j].prefabGameObject != null) {
|
||||
prefabTypeInfoList [prefabTypeIndex].prefabInfoList [j].Name = prefabTypeInfoList [prefabTypeIndex].prefabInfoList [j].prefabGameObject.name;
|
||||
prefabTypeInfoList [prefabTypeIndex].prefabInfoList [j].urlName = prefabTypeInfoList [prefabTypeIndex].prefabInfoList [j].Name;
|
||||
} else {
|
||||
print ("WARNING: there is a prefab which hasn't a gameObject assigned, make sure to assign it on the category " + prefabTypeInfoList [prefabTypeIndex].Name);
|
||||
}
|
||||
}
|
||||
|
||||
updateComponent ();
|
||||
}
|
||||
|
||||
public void getAndSetAllPrefabsInFolder (int prefabTypeIndex, bool searchOnSubFolders)
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
|
||||
prefabTypeInfoList [prefabTypeIndex].prefabInfoList.Clear ();
|
||||
|
||||
string path = prefabsUrl + prefabTypeInfoList [prefabTypeIndex].url;
|
||||
|
||||
if (!Directory.Exists (path)) {
|
||||
print ("WARNING: " + path + " path doesn't exist, make sure the path is from an existing folder in the project");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
string[] search_results = null;
|
||||
|
||||
if (searchOnSubFolders) {
|
||||
search_results = System.IO.Directory.GetFiles (path, "*.prefab", System.IO.SearchOption.AllDirectories);
|
||||
} else {
|
||||
search_results = System.IO.Directory.GetFiles (path, "*.prefab");
|
||||
}
|
||||
|
||||
if (search_results.Length > 0) {
|
||||
|
||||
foreach (string file in search_results) {
|
||||
//must convert file path to relative-to-unity path (and watch for '\' character between Win/Mac)
|
||||
GameObject currentPrefab = UnityEditor.AssetDatabase.LoadAssetAtPath (file, typeof(GameObject)) as GameObject;
|
||||
|
||||
if (currentPrefab != null) {
|
||||
prefabInfo newPrefabInfo = new prefabInfo ();
|
||||
newPrefabInfo.prefabGameObject = currentPrefab;
|
||||
|
||||
prefabTypeInfoList [prefabTypeIndex].prefabInfoList.Add (newPrefabInfo);
|
||||
} else {
|
||||
print ("WARNING: something went wrong when trying to get the prefab in the path " + file);
|
||||
}
|
||||
}
|
||||
|
||||
print (prefabTypeInfoList [prefabTypeIndex].prefabInfoList.Count + " prefabs have been found and configured in the path " + path);
|
||||
|
||||
setURLWithNames (prefabTypeIndex);
|
||||
|
||||
updateComponent ();
|
||||
} else {
|
||||
print ("WARNING: no prefabs were found in the path " + path + "\n. Make sure the URL exist in the project folder");
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
public void selectLastPrefabSpawned ()
|
||||
{
|
||||
if (lastPrefabCreated != null) {
|
||||
GKC_Utils.setActiveGameObjectInEditor (lastPrefabCreated);
|
||||
|
||||
lastPrefabCreated = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void updateComponent ()
|
||||
{
|
||||
GKC_Utils.updateComponent (this);
|
||||
|
||||
GKC_Utils.updateDirtyScene ("Update Player Prefabs Manager", gameObject);
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class prefabTypeInfo
|
||||
{
|
||||
public string Name;
|
||||
public string url;
|
||||
public List<prefabInfo> prefabInfoList = new List<prefabInfo> ();
|
||||
|
||||
[TextArea (3, 10)] public string prefabExplanation;
|
||||
}
|
||||
|
||||
[System.Serializable]
|
||||
public class prefabInfo
|
||||
{
|
||||
public string Name;
|
||||
public string urlName;
|
||||
public GameObject prefabGameObject;
|
||||
|
||||
public float positionToSpawnOffset;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 01bc8dc86581a3b428667cc5ad48fb4f
|
||||
timeCreated: 1530309470
|
||||
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/Game Manager/prefabsManager.cs
|
||||
uploadId: 814740
|
||||
@@ -0,0 +1,92 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class switchCompanionSystem : MonoBehaviour
|
||||
{
|
||||
[Header ("Main Settings")]
|
||||
[Space]
|
||||
|
||||
public bool switchCompanionEnabled = true;
|
||||
|
||||
[Space]
|
||||
[Header ("Events Settings")]
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventToSetCharacterAsAI;
|
||||
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventToSetCharacterAsPlayer;
|
||||
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventToSetCharacterAsOnlyPlayerActive;
|
||||
|
||||
[Space]
|
||||
|
||||
public UnityEvent eventToSetCharacterAsPlayerNotActive;
|
||||
|
||||
[Space]
|
||||
[Header ("Components")]
|
||||
[Space]
|
||||
|
||||
public playerController playerControllerManager;
|
||||
public playerCharactersManager mainPlayerCharactersManager;
|
||||
|
||||
public friendListManager mainfriendListManager;
|
||||
|
||||
|
||||
public void activateEventToSetCharacterAsAI ()
|
||||
{
|
||||
eventToSetCharacterAsAI.Invoke ();
|
||||
}
|
||||
|
||||
public void activateEventToSetCharacterAsPlayer ()
|
||||
{
|
||||
eventToSetCharacterAsPlayer.Invoke ();
|
||||
}
|
||||
|
||||
public void activateEventToSetCharacterAsOnlyPlayerActive ()
|
||||
{
|
||||
eventToSetCharacterAsOnlyPlayerActive.Invoke ();
|
||||
}
|
||||
|
||||
public void activateEventToSetCharacterAsPlayerNotActive ()
|
||||
{
|
||||
eventToSetCharacterAsPlayerNotActive.Invoke ();
|
||||
}
|
||||
|
||||
public void inputSwitchToNextCharacter ()
|
||||
{
|
||||
if (!switchCompanionEnabled) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!playerControllerManager.isPlayerMenuActive () &&
|
||||
(!playerControllerManager.isUsingDevice () || playerControllerManager.isPlayerDriving ()) &&
|
||||
!playerControllerManager.isGamePaused () &&
|
||||
playerControllerManager.canPlayerMove ()) {
|
||||
|
||||
bool mainPlayerCharactersManagerLocated = mainPlayerCharactersManager != null;
|
||||
|
||||
if (!mainPlayerCharactersManagerLocated) {
|
||||
mainPlayerCharactersManager = playerCharactersManager.Instance;
|
||||
}
|
||||
|
||||
if (!mainPlayerCharactersManagerLocated) {
|
||||
mainPlayerCharactersManager = FindObjectOfType<playerCharactersManager> ();
|
||||
|
||||
mainPlayerCharactersManager.getComponentInstanceOnApplicationPlaying ();
|
||||
|
||||
mainPlayerCharactersManagerLocated = mainPlayerCharactersManager != null;
|
||||
}
|
||||
|
||||
if (mainPlayerCharactersManagerLocated) {
|
||||
|
||||
mainPlayerCharactersManager.inputSetNextCharacterToControl ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1530123f5127cbd4a8c354e1b51a7596
|
||||
timeCreated: 1670881987
|
||||
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/Game Manager/switchCompanionSystem.cs
|
||||
uploadId: 814740
|
||||
Reference in New Issue
Block a user