Thomas ICHÉ
5 年前
当前提交
e2be016c
共有 9 个文件被更改,包括 388 次插入 和 0 次删除
-
13Editor/MenuItems.cs
-
41Icons/GameLevel Icon.png
-
127Icons/GameLevel Icon.png.meta
-
12Runtime/GameLevel.cs
-
11Runtime/GameLevel.cs.meta
-
62Runtime/LevelScripting/Actions/GameLevelLoadAction.cs
-
11Runtime/LevelScripting/Actions/GameLevelLoadAction.cs.meta
-
100Runtime/Managers/Implementations/GameManager.cs
-
11Runtime/Managers/Implementations/GameManager.cs.meta
|
|||
fileFormatVersion: 2 |
|||
guid: 9921921a4e899394dbc39b4b38db93ef |
|||
TextureImporter: |
|||
internalIDToNameTable: [] |
|||
externalObjects: {} |
|||
serializedVersion: 10 |
|||
mipmaps: |
|||
mipMapMode: 0 |
|||
enableMipMap: 0 |
|||
sRGBTexture: 1 |
|||
linearTexture: 0 |
|||
fadeOut: 0 |
|||
borderMipMap: 0 |
|||
mipMapsPreserveCoverage: 0 |
|||
alphaTestReferenceValue: 0.5 |
|||
mipMapFadeDistanceStart: 1 |
|||
mipMapFadeDistanceEnd: 3 |
|||
bumpmap: |
|||
convertToNormalMap: 0 |
|||
externalNormalMap: 0 |
|||
heightScale: 0.25 |
|||
normalMapFilter: 0 |
|||
isReadable: 0 |
|||
streamingMipmaps: 0 |
|||
streamingMipmapsPriority: 0 |
|||
grayScaleToAlpha: 0 |
|||
generateCubemap: 6 |
|||
cubemapConvolution: 0 |
|||
seamlessCubemap: 0 |
|||
textureFormat: 1 |
|||
maxTextureSize: 2048 |
|||
textureSettings: |
|||
serializedVersion: 2 |
|||
filterMode: -1 |
|||
aniso: 1 |
|||
mipBias: -100 |
|||
wrapU: 1 |
|||
wrapV: 1 |
|||
wrapW: -1 |
|||
nPOTScale: 0 |
|||
lightmap: 0 |
|||
compressionQuality: 50 |
|||
spriteMode: 0 |
|||
spriteExtrude: 1 |
|||
spriteMeshType: 1 |
|||
alignment: 0 |
|||
spritePivot: {x: 0.5, y: 0.5} |
|||
spritePixelsToUnits: 100 |
|||
spriteBorder: {x: 0, y: 0, z: 0, w: 0} |
|||
spriteGenerateFallbackPhysicsShape: 1 |
|||
alphaUsage: 1 |
|||
alphaIsTransparency: 1 |
|||
spriteTessellationDetail: -1 |
|||
textureType: 2 |
|||
textureShape: 1 |
|||
singleChannelComponent: 0 |
|||
maxTextureSizeSet: 0 |
|||
compressionQualitySet: 0 |
|||
textureFormatSet: 0 |
|||
platformSettings: |
|||
- serializedVersion: 3 |
|||
buildTarget: DefaultTexturePlatform |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 0 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
- serializedVersion: 3 |
|||
buildTarget: Standalone |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 0 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
- serializedVersion: 3 |
|||
buildTarget: PS4 |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 0 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
- serializedVersion: 3 |
|||
buildTarget: XboxOne |
|||
maxTextureSize: 2048 |
|||
resizeAlgorithm: 0 |
|||
textureFormat: -1 |
|||
textureCompression: 0 |
|||
compressionQuality: 50 |
|||
crunchedCompression: 0 |
|||
allowsAlphaSplitting: 0 |
|||
overridden: 0 |
|||
androidETC2FallbackOverride: 0 |
|||
forceMaximumCompressionQuality_BC6H_BC7: 0 |
|||
spriteSheet: |
|||
serializedVersion: 2 |
|||
sprites: [] |
|||
outline: [] |
|||
physicsShape: [] |
|||
bones: [] |
|||
spriteID: |
|||
internalID: 0 |
|||
vertices: [] |
|||
indices: |
|||
edges: [] |
|||
weights: [] |
|||
secondaryTextures: [] |
|||
spritePackingTag: |
|||
pSDRemoveMatte: 0 |
|||
pSDShowRemoveMatteOption: 0 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Collections; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using GameplayIngredients.LevelStreaming; |
|||
using NaughtyAttributes; |
|||
using GameplayIngredients; |
|||
|
|||
public class GameLevel : ScriptableObject |
|||
{ |
|||
[ReorderableList, Scene] |
|||
public string[] StartupScenes; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: d0e5997dc40a2dc47afc7b9a41a9a862 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {fileID: 2800000, guid: 9921921a4e899394dbc39b4b38db93ef, type: 3} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using System.Linq; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using GameplayIngredients; |
|||
using GameplayIngredients.Actions; |
|||
using NaughtyAttributes; |
|||
|
|||
public class GameLevelLoadAction : ActionBase |
|||
{ |
|||
public enum Target |
|||
{ |
|||
MainMenu, |
|||
First, |
|||
Previous, |
|||
Current, |
|||
Next, |
|||
Last, |
|||
SpecifiedLevel, |
|||
FromGameSave, |
|||
} |
|||
public bool ShowUI = true; |
|||
public Target level = Target.First; |
|||
[NonNullCheck, ShowIf("isSpecified"), Tooltip("Which Level to Load/Unload, when selected 'Specified' level")] |
|||
public GameLevel specifiedLevel; |
|||
|
|||
[ShowIf("isGameSave")] |
|||
public int UserSaveIndex = 0; |
|||
[ShowIf("isGameSave")] |
|||
public string UserSaveName = "Progress"; |
|||
|
|||
[ReorderableList] |
|||
public Callable[] OnComplete; |
|||
|
|||
private bool isSpecified() { return level == Target.SpecifiedLevel; } |
|||
private bool isGameSave() { return level == Target.FromGameSave; } |
|||
|
|||
public override void Execute(GameObject instigator = null) |
|||
{ |
|||
int index = -2; |
|||
var manager = Manager.Get<GameManager>(); |
|||
|
|||
switch (level) |
|||
{ |
|||
case Target.MainMenu: index = -1; break; |
|||
case Target.First: index = 0; break; |
|||
case Target.Last: index = manager.MainGameLevels.Length - 1; break; |
|||
case Target.Current: index = manager.currentLevel; break; |
|||
case Target.Previous: index = Mathf.Max(0, manager.currentLevel-1); break; |
|||
case Target.Next: index = Mathf.Min(manager.MainGameLevels.Length - 1, manager.currentLevel + 1); break; |
|||
case Target.SpecifiedLevel: |
|||
if(specifiedLevel != null && manager.MainGameLevels.Contains(specifiedLevel)) |
|||
{ |
|||
index = manager.MainGameLevels.ToList().IndexOf(specifiedLevel); |
|||
} |
|||
break; |
|||
case Target.FromGameSave: index = manager.currentSaveProgress; break; |
|||
} |
|||
|
|||
manager.SwitchLevel(index, ShowUI, OnComplete); |
|||
|
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 3aabe1ebc59bfa94499c44333106efec |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
using GameplayIngredients; |
|||
using GameplayIngredients.Actions; |
|||
using GameplayIngredients.LevelStreaming; |
|||
using NaughtyAttributes; |
|||
using System.Linq; |
|||
using System.Collections.Generic; |
|||
using UnityEngine; |
|||
using GameplayIngredients.Logic; |
|||
|
|||
[ManagerDefaultPrefab("GameManager")] |
|||
public class GameManager : Manager |
|||
{ |
|||
[Header("Events")] |
|||
[ReorderableList] |
|||
public Callable[] OnGameStart; |
|||
[ReorderableList] |
|||
public Callable[] OnLevelLoaded; |
|||
[ReorderableList] |
|||
public Callable[] OnMainMenuLoaded; |
|||
|
|||
[Header("Levels"),NonNullCheck] |
|||
public GameLevel MainMenuGameLevel; |
|||
[ReorderableList,NonNullCheck] |
|||
public GameLevel[] MainGameLevels; |
|||
|
|||
[Header("Save")] |
|||
public string ProgressSaveName = "Progress"; |
|||
|
|||
[Header("Messages")] |
|||
public string MainMenuStartMessage = "MAINMENU_START"; |
|||
public string GameLevelStartMessage = "GAME_START"; |
|||
|
|||
public int currentLevel { get; private set; } = -2; |
|||
|
|||
public int currentSaveProgress { |
|||
get { Manager.Get<GameSaveManager>().LoadUserSave(0); return Manager.Get<GameSaveManager>().GetInt(ProgressSaveName, GameSaveManager.Location.User); } |
|||
set { Manager.Get<GameSaveManager>().SetInt(ProgressSaveName, GameSaveManager.Location.User, value); Manager.Get<GameSaveManager>().SaveUserSave(0); } |
|||
} |
|||
|
|||
GameObject m_CurrentLevelSwitch; |
|||
|
|||
public void Start() |
|||
{ |
|||
currentLevel = int.MinValue; |
|||
Callable.Call(OnGameStart); |
|||
Manager.Get<GameSaveManager>().LoadUserSave(0); |
|||
} |
|||
|
|||
Callable GetCurrentLevelSwitch(int targetLevel, bool showUI = false, Callable[] onComplete = null) |
|||
{ |
|||
GameObject go = new GameObject(); |
|||
go.name = $"LevelSwtich {currentLevel} -> {targetLevel}"; |
|||
go.transform.parent = this.transform; |
|||
m_CurrentLevelSwitch = go; |
|||
|
|||
var cameraFade = go.AddComponent<FullScreenFadeAction>(); |
|||
var loadLevel = go.AddComponent<StreamingLevelAction>(); |
|||
var sendMessage = go.AddComponent<SendMessageAction>(); |
|||
var destroy = go.AddComponent<DestroyObjectAction>(); |
|||
var next = go.AddComponent<Logic>(); |
|||
|
|||
cameraFade.Fading = FullScreenFadeManager.FadeMode.ToBlack; |
|||
cameraFade.Name = "Fade to Black"; |
|||
cameraFade.Duration = 1.0f; |
|||
cameraFade.OnComplete = new Callable[]{ loadLevel }; |
|||
|
|||
loadLevel.Name = $"Load {(targetLevel < 0? "Main menu" : MainGameLevels[targetLevel].name)}"; |
|||
loadLevel.ShowUI = showUI; |
|||
loadLevel.Action = LevelStreamingManager.StreamingAction.Replace; |
|||
var level = targetLevel < 0 ? MainMenuGameLevel : MainGameLevels[targetLevel]; |
|||
loadLevel.SceneToActivate = level.StartupScenes[0]; |
|||
loadLevel.Scenes = level.StartupScenes; |
|||
loadLevel.OnLoadComplete = new Callable[] { sendMessage, destroy, next }; |
|||
|
|||
string message = targetLevel == -1 ? MainMenuStartMessage : GameLevelStartMessage; |
|||
sendMessage.Name = $"Send {message}"; |
|||
sendMessage.MessageToSend = message; |
|||
|
|||
destroy.ObjectsToDestroy = new GameObject[] { go }; |
|||
|
|||
var nextActions = targetLevel < 0 ? OnMainMenuLoaded : OnLevelLoaded; |
|||
next.Calls = nextActions.Concat(onComplete).ToArray(); |
|||
|
|||
// Return first callable
|
|||
return cameraFade; |
|||
} |
|||
|
|||
public void SwitchLevel(int nextLevel, bool showUI = false, Callable[] onComplete = null) |
|||
{ |
|||
if (m_CurrentLevelSwitch == null) |
|||
{ |
|||
var call = GetCurrentLevelSwitch(nextLevel, showUI, onComplete); |
|||
call.Execute(); |
|||
currentLevel = nextLevel; |
|||
} |
|||
else |
|||
Debug.LogWarning("SwitchLevel : an Operation was still in progress and switching level could not be done. "); |
|||
} |
|||
|
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 9fd2ae503e78cd14da039ced88d8e0b3 |
|||
MonoImporter: |
|||
externalObjects: {} |
|||
serializedVersion: 2 |
|||
defaultReferences: [] |
|||
executionOrder: 0 |
|||
icon: {instanceID: 0} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue