Compare commits

...
5 Commits
Author SHA1 Message Date
Jackie Liu be5aebde3b Bug fixes 2023-04-03 02:32:37 -07:00
Jackie Liu 142593a9f2 v0.63 2023-04-03 01:41:11 -07:00
Jackie Liu 63e8bf3291 Implement auto-save and save/load menus 2023-04-03 01:09:40 -07:00
Jackie Liu 0268e131f1 Bug fixes 2023-04-02 21:53:17 -07:00
Jackie Liu a3277187cf Code refactoring 2023-04-02 20:37:09 -07:00
48 changed files with 1828 additions and 1670 deletions

No files matched your search

@@ -20,7 +20,7 @@ namespace Pal3.Actor
using Core.Services;
using Data;
using MetaData;
using Player;
using GamePlay;
using Renderer;
using Script.Waiter;
using State;
+1 -1
View File
@@ -16,7 +16,7 @@ namespace Pal3.Actor
using Core.Services;
using Input;
using MetaData;
using Player;
using GamePlay;
using Script.Waiter;
using UnityEngine;
@@ -5,7 +5,7 @@
#if PAL3A
namespace Pal3.Player
namespace Pal3.Actor
{
using System;
using System.Collections.Generic;
@@ -10,7 +10,7 @@ namespace Pal3.Actor
using Command.InternalCommands;
using Command.SceCommands;
using Core.GameBox;
using Player;
using GamePlay;
using Script.Waiter;
using UnityEngine;
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Player
namespace Pal3.Actor
{
using System;
using System.Collections.Generic;
+1 -1
View File
@@ -17,9 +17,9 @@ namespace Pal3.Camera
using Core.DataReader.Scn;
using Core.GameBox;
using Core.Utils;
using GamePlay;
using Input;
using MetaData;
using Player;
using Scene;
using Script.Waiter;
using State;
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,3 @@
fileFormatVersion: 2
guid: 515d83a628644044955b51117dde338d
timeCreated: 1680489008
File diff suppressed because it is too large. Load diff
+2 -5
View File
@@ -17,10 +17,6 @@ namespace Pal3.Dev
using MetaData;
using Scene;
using Script;
using State;
using UI;
using UnityEngine;
using UnityEngine.UI;
public sealed class MazeSkipper
{
@@ -660,7 +656,8 @@ namespace Pal3.Dev
{ "m11_4_1", new List<ICommand>()
{
new ActorSetNavLayerCommand(-1, 1),
new ActorSetTilePositionCommand(-1, 118, 236)
new ActorSetTilePositionCommand(-1, 118, 236),
new PlayerInteractWithObjectCommand(10)
}},
{ "m12_1_0", new List<ICommand>()
{
File renamed without changes.
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Player
namespace Pal3.GamePlay
{
using System;
using System.Collections;
@@ -20,6 +20,7 @@ namespace Pal3.Player
using Core.Renderer;
using Core.Utils;
using Data;
using GameSystem;
using Input;
using MetaData;
using Scene;
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Player
namespace Pal3.GamePlay
{
using System;
using Command;
File renamed without changes.
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.UI
namespace Pal3.GameSystem
{
using System;
using System.Collections.Generic;
@@ -19,6 +19,7 @@ namespace Pal3.UI
using Scene;
using State;
using TMPro;
using UI;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Feature
namespace Pal3.GameSystem
{
using System;
using System.Collections;
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.UI
namespace Pal3.GameSystem
{
using System;
using System.Collections;
@@ -22,6 +22,7 @@ namespace Pal3.UI
using Script.Waiter;
using State;
using TMPro;
using UI;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.InputSystem;
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Feature
namespace Pal3.GameSystem
{
using System;
using System.Collections.Generic;
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Feature
namespace Pal3.GameSystem
{
using System;
using Command;
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.UI
namespace Pal3.GameSystem
{
using System;
using System.Collections;
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Player
namespace Pal3.GameSystem
{
using System;
using System.Collections.Generic;
@@ -3,7 +3,7 @@
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Player
namespace Pal3.GameSystem
{
using System;
using System.Collections.Generic;
@@ -15,6 +15,7 @@ namespace Pal3.Player
using Core.DataReader.Scn;
using Core.Utils;
using MetaData;
using GamePlay;
using Scene;
using UnityEngine;
+3 -2
View File
@@ -19,10 +19,10 @@ namespace Pal3
using Data;
using Dev;
using Effect;
using Feature;
using GamePlay;
using GameSystem;
using Input;
using IngameDebugConsole;
using Player;
using Scene;
using Script;
using Settings;
@@ -364,6 +364,7 @@ namespace Pal3
_sceneManager.Dispose();
_touchControlUIManager.Dispose();
_favorManager.Dispose();
_saveManager.Dispose();
#if PAL3
_appraisalsMiniGame.Dispose();
@@ -60,16 +60,16 @@ namespace Pal3.Renderer
public void Init(Mv3File mv3File,
IMaterialFactory materialFactory,
ITextureResourceProvider textureProvider,
Color tintColor,
Color? tintColor = default,
PolFile tagNodePolFile = default,
ITextureResourceProvider tagNodeTextureProvider = default,
Color tagNodeTintColor = default)
Color? tagNodeTintColor = default)
{
DisposeAnimation();
_materialFactory = materialFactory;
_textureProvider = textureProvider;
_tintColor = tintColor;
_tintColor = tintColor ?? Color.white;
_events = mv3File.AnimationEvents;
_duration = mv3File.Duration;
+1 -1
View File
@@ -16,7 +16,7 @@ namespace Pal3.Scene
using Core.DataReader.Pol;
using Core.DataReader.Scn;
using Data;
using Player;
using GamePlay;
using SceneObjects;
using State;
using UnityEngine;
@@ -15,8 +15,8 @@ namespace Pal3.Scene.SceneObjects
using Core.GameBox;
using Core.Services;
using Data;
using GamePlay;
using MetaData;
using Player;
using Renderer;
using UnityEngine;
@@ -8,7 +8,7 @@ namespace Pal3.Scene.SceneObjects.Common
using System;
using Actor;
using Core.Services;
using Player;
using GamePlay;
using UnityEngine;
public class BoundsTriggerController : MonoBehaviour
@@ -8,7 +8,7 @@ namespace Pal3.Scene.SceneObjects.Common
using System;
using Actor;
using Core.Services;
using Player;
using GamePlay;
using UnityEngine;
public class StandingPlatformController : MonoBehaviour
@@ -16,7 +16,7 @@ namespace Pal3.Scene.SceneObjects
using Core.DataReader.Scn;
using Core.Services;
using Data;
using Player;
using GameSystem;
using UnityEngine;
[ScnSceneObject(ScnSceneObjectType.GravitySwitch)]
@@ -9,7 +9,7 @@ namespace Pal3.Scene.SceneObjects
using Core.DataReader.Scn;
using Core.Services;
using Data;
using Player;
using GamePlay;
using UnityEngine;
[ScnSceneObject(ScnSceneObjectType.JumpableArea)]
@@ -15,8 +15,8 @@ namespace Pal3.Scene.SceneObjects
using Common;
using Core.DataReader.Scn;
using Core.Services;
using GameSystem;
using MetaData;
using Player;
using UnityEngine;
[ScnSceneObject(ScnSceneObjectType.PaperweightDesk)]
@@ -14,13 +14,13 @@ namespace Pal3.Script
using Core.DataReader.Sce;
using Core.Services;
using Dev;
using GamePlay;
using GameSystem;
using MetaData;
#if PAL3
using MiniGame;
#endif
using Player;
using UI;
using Feature;
using Scene;
using State;
using UnityEngine;
+88 -17
View File
@@ -18,14 +18,12 @@ namespace Pal3.State
using Core.DataReader.Scn;
using Core.GameBox;
using Core.Utils;
using Effect;
using Effect.PostProcessing;
using Feature;
using GamePlay;
using GameSystem;
using MetaData;
using Player;
using Scene;
using Script;
using UI;
using UnityEngine;
using Path = System.IO.Path;
@@ -35,9 +33,17 @@ namespace Pal3.State
Full
}
public class SaveManager
public class SaveManager : IDisposable,
ICommandExecutor<GameStateChangedNotification>,
ICommandExecutor<GameSwitchToMainMenuCommand>
{
private const string SAVE_FILE_NAME = "save.txt";
public const int AutoSaveSlotIndex = 0;
public bool IsAutoSaveEnabled { get; set; } = false;
private const string LEGACY_SAVE_FILE_NAME = "save.txt";
private const string SAVE_FILE_FORMAT = "slot_{0}.txt";
private const string SAVE_FOLDER_NAME = "Saves";
private const float AUTO_SAVE_MIN_DURATION = 180f; // 3 minutes
private readonly SceneManager _sceneManager;
private readonly PlayerManager _playerManager;
@@ -51,6 +57,8 @@ namespace Pal3.State
private readonly AudioManager _audioManager;
private readonly PostProcessManager _postProcessManager;
private double _lastAutoSaveTime = -AUTO_SAVE_MIN_DURATION;
public SaveManager(SceneManager sceneManager,
PlayerManager playerManager,
TeamManager teamManager,
@@ -74,26 +82,59 @@ namespace Pal3.State
_cameraManager = Requires.IsNotNull(cameraManager, nameof(cameraManager));
_audioManager = Requires.IsNotNull(audioManager, nameof(audioManager));
_postProcessManager = Requires.IsNotNull(postProcessManager, nameof(postProcessManager));
string saveFolder = GetSaveFolderPath();
if (!Directory.Exists(saveFolder))
{
Directory.CreateDirectory(saveFolder);
}
// Migrate old save file if exists
// TODO: Remove this after a few versions
{
string legacySaveFilePath = Application.persistentDataPath +
Path.DirectorySeparatorChar + LEGACY_SAVE_FILE_NAME;
if (File.Exists(legacySaveFilePath))
{
// Migrate old save file to slot 1
File.Move(legacySaveFilePath, GetSaveFilePath(1));
}
}
CommandExecutorRegistry<ICommand>.Instance.Register(this);
}
private string GetSaveFilePath()
public void Dispose()
{
return Application.persistentDataPath +
Path.DirectorySeparatorChar + SAVE_FILE_NAME;
CommandExecutorRegistry<ICommand>.Instance.UnRegister(this);
}
public bool SaveFileExists()
private string GetSaveFolderPath()
{
return File.Exists(GetSaveFilePath());
return Application.persistentDataPath + Path.DirectorySeparatorChar + SAVE_FOLDER_NAME;
}
public bool SaveGameStateToFile()
private string GetSaveFilePath(int slotIndex)
{
string saveFilePath = GetSaveFilePath();
return GetSaveFolderPath() + Path.DirectorySeparatorChar + string.Format(SAVE_FILE_FORMAT, slotIndex);
}
public bool SaveSlotExists(int slotIndex)
{
return File.Exists(GetSaveFilePath(slotIndex));
}
public DateTime GetSaveSlotLastWriteTime(int slotIndex)
{
return File.GetLastWriteTime(GetSaveFilePath(slotIndex));
}
public bool SaveGameStateToSlot(int slotIndex, IList<ICommand> stateCommands)
{
string saveFilePath = GetSaveFilePath(slotIndex);
try
{
var commands = ConvertCurrentGameStateToCommands(SaveLevel.Full);
File.WriteAllText(saveFilePath, string.Join('\n', commands.Select(CommandExtensions.ToString).ToList()));
File.WriteAllText(saveFilePath, string.Join('\n', stateCommands.Select(CommandExtensions.ToString).ToList()));
Debug.Log($"Game state saved to: {saveFilePath}");
return true;
}
@@ -104,9 +145,9 @@ namespace Pal3.State
}
}
public string LoadFromSaveFile()
public string LoadFromSaveSlot(int slotIndex)
{
return SaveFileExists() ? File.ReadAllText(GetSaveFilePath()) : null;
return SaveSlotExists(slotIndex) ? File.ReadAllText(GetSaveFilePath(slotIndex)) : null;
}
public List<ICommand> ConvertCurrentGameStateToCommands(SaveLevel saveLevel)
@@ -306,7 +347,37 @@ namespace Pal3.State
// Good to have
commands.Add(new CameraFadeInCommand());
return commands;
}
public void Execute(GameStateChangedNotification command)
{
if (!IsAutoSaveEnabled) return;
// Auto save game state in auto-save slot when entering gameplay state
// and no script is running
if (command.NewState == GameState.Gameplay &&
_scriptManager.GetNumberOfRunningScripts() == 0 &&
_playerManager.IsPlayerInputEnabled() &&
_playerManager.IsPlayerActorControlEnabled() &&
Time.realtimeSinceStartupAsDouble - _lastAutoSaveTime > AUTO_SAVE_MIN_DURATION)
{
IList<ICommand> gameStateCommands = ConvertCurrentGameStateToCommands(SaveLevel.Full);
bool success = SaveGameStateToSlot(AutoSaveSlotIndex, gameStateCommands);
if (success)
{
_lastAutoSaveTime = Time.realtimeSinceStartupAsDouble;
}
Debug.LogWarning($"Game state auto-saved to slot {AutoSaveSlotIndex}.");
}
}
public void Execute(GameSwitchToMainMenuCommand command)
{
IsAutoSaveEnabled = false;
}
}
}
+15 -49
View File
@@ -8,62 +8,28 @@ namespace Pal3.UI
using UnityEngine;
using UnityEngine.UI;
public enum ButtonType
{
Normal,
Highlighted,
}
public static class UITheme
{
public static ColorBlock GetButtonColors(ButtonType buttonType = ButtonType.Normal)
public static ColorBlock GetButtonColors()
{
#if PAL3
if (buttonType == ButtonType.Normal)
return new ColorBlock()
{
return new ColorBlock()
{
colorMultiplier = 1f,
normalColor = new Color(100f / 255f, 80f / 255f, 40f / 255f, 190f / 255f),
highlightedColor = new Color(30f / 255f, 75f / 255f, 140f / 255f, 200f / 255f),
pressedColor = new Color(20f / 255f, 50f / 255f, 100f / 255f, 200f / 255f),
selectedColor = new Color(30f / 255f, 75f / 255f, 140f / 255f, 200f / 255f),
};
}
else
{
return new ColorBlock()
{
colorMultiplier = 1f,
normalColor = new Color(100f / 255f, 80f / 255f, 40f / 255f, 190f / 255f),
highlightedColor = new Color(30f / 255f, 75f / 255f, 140f / 255f, 200f / 255f),
pressedColor = new Color(20f / 255f, 50f / 255f, 100f / 255f, 200f / 255f),
selectedColor = new Color(30f / 255f, 75f / 255f, 140f / 255f, 200f / 255f),
};
}
colorMultiplier = 1f,
normalColor = new Color(100f / 255f, 80f / 255f, 40f / 255f, 190f / 255f),
highlightedColor = new Color(30f / 255f, 75f / 255f, 140f / 255f, 200f / 255f),
pressedColor = new Color(20f / 255f, 50f / 255f, 100f / 255f, 200f / 255f),
selectedColor = new Color(30f / 255f, 75f / 255f, 140f / 255f, 200f / 255f),
};
#elif PAL3A
if (buttonType == ButtonType.Normal)
return new ColorBlock()
{
return new ColorBlock()
{
colorMultiplier = 1f,
normalColor = new Color(100f / 255f, 80f / 255f, 40f / 255f, 190f / 255f),
highlightedColor = new Color(160f / 255f, 40f / 255f, 110f / 255f, 200f / 255f),
pressedColor = new Color(110f / 255f, 25f / 255f, 75f / 255f, 200f / 255f),
selectedColor = new Color(160f / 255f, 40f / 255f, 110f / 255f, 200f / 255f),
};
}
else
{
return new ColorBlock()
{
colorMultiplier = 1f,
normalColor = new Color(100f / 255f, 80f / 255f, 40f / 255f, 190f / 255f),
highlightedColor = new Color(160f / 255f, 40f / 255f, 110f / 255f, 200f / 255f),
pressedColor = new Color(110f / 255f, 25f / 255f, 75f / 255f, 200f / 255f),
selectedColor = new Color(160f / 255f, 40f / 255f, 110f / 255f, 200f / 255f),
};
}
colorMultiplier = 1f,
normalColor = new Color(100f / 255f, 80f / 255f, 40f / 255f, 190f / 255f),
highlightedColor = new Color(160f / 255f, 40f / 255f, 110f / 255f, 200f / 255f),
pressedColor = new Color(110f / 255f, 25f / 255f, 75f / 255f, 200f / 255f),
selectedColor = new Color(160f / 255f, 40f / 255f, 110f / 255f, 200f / 255f),
};
#endif
}
}
@@ -342,8 +342,7 @@ namespace ResourceViewer
{
mv3AnimationRenderer.Init(mv3File,
_resourceProvider.GetMaterialFactory(),
textureProvider,
Color.white);
textureProvider);
}
mv3AnimationRenderer.StartAnimation();
+1 -1
View File
@@ -133,7 +133,7 @@ PlayerSettings:
vulkanEnableLateAcquireNextImage: 0
vulkanEnableCommandBufferRecycling: 1
loadStoreDebugModeEnabled: 0
bundleVersion: 0.62
bundleVersion: 0.63
preloadedAssets: []
metroInputSource: 0
wsaTransparentSwapchain: 0