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,181 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor.SceneManagement;
#endif
public class levelManagerIngame : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool changeSceneEnabled = true;
public int sceneNumberToLoad;
public int levelManagerID;
public int levelManagerIDToLoad;
public Transform spawPlayerPositionTransform;
public bool changeLevelWithDelay;
public float delayToChangeLevel = 0.1f;
public bool autoSaveGameOnSceneChangeEnabled = true;
[Space]
[Header ("Gizmo Settings")]
[Space]
public bool showGizmo;
public Color gizmoColor = Color.red;
public float gizmoRadius = 0.06f;
[Space]
[Header ("Other Elements")]
[Space]
public string sceneFolderPath = "Assets//Game Kit Controller/Scenes/";
public string sceneToChangeName = "New Scene";
[Header ("Player Manual Settings")]
public bool setPlayerManually;
public bool searchPlayerByTagIfNotAssigned = true;
public GameObject playerToConfigure;
[Space]
[Space]
[TextArea (5, 20)]public string explanation = "Configure the Scene Number where the player will move using the level manager.\n\n" +
"Then, inside that new scene, you have another level manager object which has a Level Manager ID value, so set that value\n" +
"in the field Level Manager ID To Load of this component, so once the player moves to the new scene, it will appear in the level manager" +
"object with that ID.\n\n " +
"It is like an address system, in order to know to which scene to move and where spawn the player once he is there.";
GameObject currentPlayer;
saveGameSystem currentSaveGameSystem;
public void setCurrentPlayer (GameObject newPlayer)
{
currentPlayer = newPlayer;
}
public void setCurrentPlayerAndActivateChangeOfLevel (GameObject newPlayer)
{
currentPlayer = newPlayer;
activateChangeOfLevel ();
}
public void activateChangeOfLevel ()
{
if (setPlayerManually) {
currentPlayer = playerToConfigure;
}
if (currentPlayer == null) {
if (searchPlayerByTagIfNotAssigned) {
currentPlayer = GKC_Utils.findMainPlayerOnScene ();
if (currentPlayer == null) {
return;
}
} else {
return;
}
}
bool playerIsOnVehicle = false;
if (applyDamage.isVehicle (currentPlayer)) {
GameObject vehicleDriver = applyDamage.getVehicleDriver (currentPlayer);
if (vehicleDriver != null) {
currentPlayer = vehicleDriver;
playerIsOnVehicle = true;
}
}
playerComponentsManager currentPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
if (currentPlayerComponentsManager != null) {
if (playerIsOnVehicle && !currentPlayerComponentsManager.getPlayerController ().isPlayerDriving ()) {
return;
}
currentSaveGameSystem = currentPlayerComponentsManager.getSaveGameSystem ();
currentSaveGameSystem.saveGameCheckpoint (spawPlayerPositionTransform, levelManagerIDToLoad, sceneNumberToLoad, true, true, autoSaveGameOnSceneChangeEnabled);
if (changeSceneEnabled) {
if (changeLevelWithDelay) {
StartCoroutine (loadNextLevel ());
} else {
currentSaveGameSystem.activateAutoLoad ();
}
}
}
}
IEnumerator loadNextLevel ()
{
yield return new WaitForSeconds (delayToChangeLevel);
currentSaveGameSystem.activateAutoLoad ();
}
public void setChangeSceneEnabledState (bool state)
{
changeSceneEnabled = state;
}
public void openNextSceneOnEditor ()
{
string newSceneName = sceneFolderPath + sceneToChangeName + ".unity";
if (System.IO.File.Exists (newSceneName)) {
#if UNITY_EDITOR
EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo ();
EditorSceneManager.OpenScene (newSceneName);
#endif
} else {
print ("WARNING: Scene called " + sceneToChangeName + " is not located in the path " + sceneFolderPath + ".\n " +
"Make sure to configure the path or place the scene file in the current path configured");
}
}
void OnDrawGizmos ()
{
if (!showGizmo) {
return;
}
if (GKC_Utils.isCurrentSelectionActiveGameObject (gameObject)) {
DrawGizmos ();
}
}
void OnDrawGizmosSelected ()
{
DrawGizmos ();
}
void DrawGizmos ()
{
if (showGizmo) {
Gizmos.color = gizmoColor;
if (spawPlayerPositionTransform != null) {
Gizmos.DrawSphere (spawPlayerPositionTransform.position, gizmoRadius);
} else {
Gizmos.DrawSphere (transform.position, gizmoRadius);
}
}
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 26ea58138e976604ebef54fb3d5e8610
timeCreated: 1570754963
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/Level Manager/levelManagerIngame.cs
uploadId: 814740

View File

@@ -0,0 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class travelStationPanel : MonoBehaviour
{
public travelStationPanelInfo mainTravelStationPanelInfo;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 30a7235a0cfe1b240b6204cdfba8aa7a
timeCreated: 1573885071
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/Level Manager/travelStationPanel.cs
uploadId: 814740

View File

@@ -0,0 +1,13 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
[System.Serializable]
public class travelStationPanelInfo
{
public GameObject panelGameObject;
public GameObject pressedPanelIcon;
public Text panelText;
public int travelStationInfoIndex;
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 863b1ed339723cb4c9a88060026e4f97
timeCreated: 1573884945
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/Level Manager/travelStationPanelInfo.cs
uploadId: 814740

View File

@@ -0,0 +1,79 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
public class travelStationSystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public int sceneNumberToLoad;
public int levelManagerIDToLoad;
public bool allStationsUnlocked;
[Space]
[Header ("Debug")]
[Space]
public bool usingTravelStation;
[Space]
[Header ("Travel Station Info List Settings")]
[Space]
public List<travelStationInfo> travelStationInfoList = new List<travelStationInfo> ();
GameObject currentPlayer;
playerComponentsManager mainPlayerComponentsManager;
travelStationUISystem currentTravelStationUISystem;
public void setCurrentPlayer (GameObject player)
{
currentPlayer = player;
if (currentPlayer != null) {
mainPlayerComponentsManager = currentPlayer.GetComponent<playerComponentsManager> ();
currentTravelStationUISystem = mainPlayerComponentsManager.getTravelStationUISystem ();
currentTravelStationUISystem.setCurrentTravelStationSystem (this, true);
}
}
public void activateTravelStation ()
{
usingTravelStation = !usingTravelStation;
currentTravelStationUISystem.openOrCloseTravelStationMenu (usingTravelStation);
}
public void setUsingTravelStationSystemState (bool state)
{
usingTravelStation = state;
}
public List<travelStationInfo> getTravelStationInfoList ()
{
return travelStationInfoList;
}
[System.Serializable]
public class travelStationInfo
{
public string Name;
public int sceneNumberToLoad;
public int levelManagerIDToLoad;
public bool zoneFound;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 660ba506f1dfa4d46a45dad3118842d6
timeCreated: 1573878550
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/Level Manager/travelStationSystem.cs
uploadId: 814740

View File

@@ -0,0 +1,327 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.Events;
public class travelStationUISystem : MonoBehaviour
{
[Header ("Main Settings")]
[Space]
public bool travelStationUIActive = true;
public bool menuOpened;
public bool useBlurUIPanel;
public bool saveCurrentTravelStationToSaveFile = true;
public bool allStationsUnlocked;
public bool showTravelStationFoundPanel;
public float showTraveStationPanelDuration = 1;
public string travelStationFoundExtraMessage = "Travel Station Found";
[Space]
public string menuPanelName = "Travel Station System";
[Space]
[Header ("Debug")]
[Space]
public bool showDebugPrint;
public List<foundTravelStationInfo> foundTravelStationInfoList = new List<foundTravelStationInfo> ();
public travelStationSystem currentTravelStationSystem;
[Space]
[Header ("Events Settings")]
[Space]
public bool useEventIfSystemDisabled;
public UnityEvent eventIfSystemDisabled;
[Space]
[Header ("Components")]
[Space]
public GameObject travelStationMenu;
public GameObject travelStationPanelPrefab;
public Transform travelStationPanelParent;
public GameObject travelStationFoundPanel;
public Text travelStationFoundPanelText;
public menuPause pauseManager;
public playerController playerControllerManager;
public saveGameSystem mainSaveGameSystem;
public usingDevicesSystem usingDevicesManager;
List<travelStationSystem.travelStationInfo> currentTravelStationInfoList = new List<travelStationSystem.travelStationInfo> ();
List<travelStationPanelInfo> travelStationPanelInfoList = new List<travelStationPanelInfo> ();
travelStationPanelInfo currentTravelStationPanelInfo;
public void initializeTravelStationValues ()
{
if (!travelStationUIActive) {
checkEventOnSystemDisabled ();
return;
}
}
public void checkEventOnSystemDisabled ()
{
if (useEventIfSystemDisabled) {
eventIfSystemDisabled.Invoke ();
}
}
public void checkPressedButton (GameObject buttonToCheck)
{
if (currentTravelStationPanelInfo != null) {
currentTravelStationPanelInfo.pressedPanelIcon.SetActive (false);
}
for (int i = 0; i < travelStationPanelInfoList.Count; i++) {
if (travelStationPanelInfoList [i].panelGameObject == buttonToCheck) {
travelStationPanelInfoList [i].pressedPanelIcon.SetActive (true);
currentTravelStationPanelInfo = travelStationPanelInfoList [i];
return;
}
}
}
public void confirmTravelToStationSelected ()
{
if (currentTravelStationInfoList.Count > 0 && currentTravelStationPanelInfo != null && currentTravelStationPanelInfo.travelStationInfoIndex < currentTravelStationInfoList.Count) {
travelStationSystem.travelStationInfo currentTravelStationInfo = currentTravelStationInfoList [currentTravelStationPanelInfo.travelStationInfoIndex];
if (currentTravelStationInfo.sceneNumberToLoad != currentTravelStationSystem.sceneNumberToLoad ||
currentTravelStationInfo.levelManagerIDToLoad != currentTravelStationSystem.levelManagerIDToLoad) {
mainSaveGameSystem.saveGameCheckpoint (null, currentTravelStationInfo.levelManagerIDToLoad,
currentTravelStationInfo.sceneNumberToLoad, true, true, true);
mainSaveGameSystem.activateAutoLoad ();
} else {
if (showDebugPrint) {
print ("trying to travel to this station system");
}
}
}
}
public void setCurrentTravelStationSystem (travelStationSystem newTravelStationSystem, bool settingPhysicalStation)
{
currentTravelStationSystem = newTravelStationSystem;
currentTravelStationInfoList = currentTravelStationSystem.getTravelStationInfoList ();
int sceneNumberToLoad = currentTravelStationSystem.sceneNumberToLoad;
int levelManagerIDToLoad = currentTravelStationSystem.levelManagerIDToLoad;
bool travelStationFound = false;
if (settingPhysicalStation) {
for (int i = 0; i < foundTravelStationInfoList.Count; i++) {
if (foundTravelStationInfoList [i].sceneNumberToLoad == sceneNumberToLoad && foundTravelStationInfoList [i].levelManagerIDToLoad == levelManagerIDToLoad) {
travelStationFound = true;
}
}
if (!travelStationFound) {
if (showDebugPrint) {
print ("new station");
}
foundTravelStationInfo newFoundTravelStationInfo = new foundTravelStationInfo ();
newFoundTravelStationInfo.sceneNumberToLoad = sceneNumberToLoad;
newFoundTravelStationInfo.levelManagerIDToLoad = levelManagerIDToLoad;
foundTravelStationInfoList.Add (newFoundTravelStationInfo);
}
}
if (currentTravelStationSystem.allStationsUnlocked || allStationsUnlocked) {
for (int i = 0; i < currentTravelStationInfoList.Count; i++) {
currentTravelStationInfoList [i].zoneFound = true;
}
} else {
for (int i = 0; i < currentTravelStationInfoList.Count; i++) {
for (int j = 0; j < foundTravelStationInfoList.Count; j++) {
if (currentTravelStationInfoList [i].sceneNumberToLoad == foundTravelStationInfoList [j].sceneNumberToLoad &&
currentTravelStationInfoList [i].levelManagerIDToLoad == foundTravelStationInfoList [j].levelManagerIDToLoad) {
currentTravelStationInfoList [i].zoneFound = true;
}
}
if (currentTravelStationInfoList [i].sceneNumberToLoad == sceneNumberToLoad) {
if (!travelStationFound && settingPhysicalStation) {
showTravelStationFound (currentTravelStationInfoList [i].Name);
}
}
}
}
}
public void openOrCloseTravelStationMenu (bool state)
{
if (state) {
if (!pauseManager.checkIfMenuCanBeUsedByName (menuPanelName)) {
return;
}
}
menuOpened = state;
pauseManager.openOrClosePlayerMenu (menuOpened, travelStationMenu.transform, useBlurUIPanel);
travelStationMenu.SetActive (menuOpened);
pauseManager.setIngameMenuOpenedState (menuPanelName, menuOpened, false);
pauseManager.enableOrDisablePlayerMenu (menuOpened, true, false);
if (menuOpened) {
setTravelStationInfoList ();
if (travelStationPanelInfoList.Count > 0) {
GameObject panelButtonToCheck = travelStationPanelInfoList [0].panelGameObject;
if (currentTravelStationSystem) {
for (int i = 0; i < currentTravelStationInfoList.Count; i++) {
if (currentTravelStationInfoList [i].sceneNumberToLoad == currentTravelStationSystem.sceneNumberToLoad) {
if (i < travelStationPanelInfoList.Count) {
panelButtonToCheck = travelStationPanelInfoList [i].panelGameObject;
}
}
}
}
checkPressedButton (panelButtonToCheck);
}
}
}
public void setTravelStationInfoList ()
{
for (int i = 0; i < travelStationPanelInfoList.Count; i++) {
Destroy (travelStationPanelInfoList [i].panelGameObject);
}
travelStationPanelInfoList.Clear ();
if (currentTravelStationSystem == null || currentTravelStationInfoList.Count == 0) {
currentTravelStationSystem = FindObjectOfType<travelStationSystem> ();
if (currentTravelStationSystem != null) {
setCurrentTravelStationSystem (currentTravelStationSystem, false);
}
}
for (int i = 0; i < currentTravelStationInfoList.Count; i++) {
if (currentTravelStationInfoList [i].zoneFound) {
GameObject newtravelStationPanelPrefab = (GameObject)Instantiate (travelStationPanelPrefab, travelStationPanelPrefab.transform.position, Quaternion.identity, travelStationPanelParent);
if (!newtravelStationPanelPrefab.activeSelf) {
newtravelStationPanelPrefab.SetActive (true);
}
newtravelStationPanelPrefab.transform.localScale = Vector3.one;
newtravelStationPanelPrefab.transform.localPosition = Vector3.zero;
travelStationPanel currentTravelStationPanel = newtravelStationPanelPrefab.GetComponent<travelStationPanel> ();
travelStationPanelInfo currentTravelStationPanelInfo = currentTravelStationPanel.mainTravelStationPanelInfo;
currentTravelStationPanelInfo.panelText.text = currentTravelStationInfoList [i].Name;
currentTravelStationPanelInfo.travelStationInfoIndex = i;
travelStationPanelInfoList.Add (currentTravelStationPanelInfo);
}
}
}
public void openOrCloseTravelStationMenuFromTouch ()
{
if (!menuOpened) {
if (!pauseManager.checkIfMenuCanBeUsedByName (menuPanelName)) {
return;
}
}
openOrCloseTravelStationMenu (!menuOpened);
pauseManager.setIngameMenuOpenedState (menuPanelName, menuOpened, true);
}
public void checkOpenOrCloseTravelStationMenuByButton ()
{
if (pauseManager.isOpenOrClosePlayerOpenMenuByNamePaused ()) {
return;
}
oopenOrCloseTravelStationMenuByButton ();
}
public void oopenOrCloseTravelStationMenuByButton ()
{
if (playerControllerManager.isUsingDevice ()) {
usingDevicesManager.useDevice ();
if (currentTravelStationSystem) {
currentTravelStationSystem.setUsingTravelStationSystemState (menuOpened);
}
} else {
openOrCloseTravelStationMenuFromTouch ();
}
}
Coroutine showTravelStationCoroutine;
public void showTravelStationFound (string travelStationName)
{
if (!showTravelStationFoundPanel) {
return;
}
if (showTravelStationCoroutine != null) {
StopCoroutine (showTravelStationCoroutine);
}
showTravelStationCoroutine = StartCoroutine (showTravelStationFoundCoroutine (travelStationName));
}
IEnumerator showTravelStationFoundCoroutine (string travelStationName)
{
travelStationFoundPanel.SetActive (true);
travelStationFoundPanelText.text = travelStationName + " " + travelStationFoundExtraMessage;
yield return new WaitForSeconds (showTraveStationPanelDuration);
travelStationFoundPanel.SetActive (false);
}
[System.Serializable]
public class foundTravelStationInfo
{
public int sceneNumberToLoad;
public int levelManagerIDToLoad;
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: 20378862b3cdd5c4b876eb32d1c81db9
timeCreated: 1573882998
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/Level Manager/travelStationUISystem.cs
uploadId: 814740