mirror of
https://github.com/0x7c13/Pal3.Unity.git
synced 2026-11-26 17:38:10 +08:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
be861dc536 | ||
|
|
6dfff9ff57 | ||
|
|
cbe4f82489 | ||
|
|
01a41fa834 | ||
|
|
cb821a0901 | ||
|
|
4b36a38b21 | ||
|
|
17ebee5b28 | ||
|
|
f0e1b2db98 | ||
|
|
23673aae2a | ||
|
|
ca3b28a089 | ||
|
|
45b5971ede | ||
|
|
ad97b6a817 |
No files matched your search
@@ -32,7 +32,7 @@ namespace Core.DataLoader
|
||||
|
||||
DxtHeader header = DxtHeader.ReadHeader(reader);
|
||||
var format = header.DxtPixelFormat.Format;
|
||||
hasAlphaChannel = format == "DXT1";
|
||||
hasAlphaChannel = true;
|
||||
|
||||
_width = header.Width;
|
||||
_height = header.Height;
|
||||
|
||||
@@ -42,7 +42,7 @@ namespace Core.DataReader.Pol
|
||||
nodeInfos[i] = new PolGeometryNode
|
||||
{
|
||||
Name = reader.ReadString(32, codepage),
|
||||
Position = reader.ReadVector3(),
|
||||
Position = GameBoxInterpreter.ToUnityPosition(reader.ReadVector3()),
|
||||
Radius = reader.ReadSingle(),
|
||||
Offset = reader.ReadInt32()
|
||||
};
|
||||
|
||||
@@ -58,8 +58,8 @@ namespace Core.GameBox
|
||||
|
||||
public static class GameBoxVertexType
|
||||
{
|
||||
public const int MaxUvSet = 4;
|
||||
public const int Null = 0;
|
||||
public const int MaxUvSet = 4;
|
||||
public const int XYZ = (1 << 0);
|
||||
public const int Normal = (1 << 1);
|
||||
public const int Diffuse = (1 << 2);
|
||||
|
||||
@@ -74,7 +74,7 @@ namespace Core.Utils
|
||||
RuntimePlatform.IPhonePlayer => iOSSupportedVideoFormats,
|
||||
RuntimePlatform.Android => AndroidSupportedVideoFormats,
|
||||
|
||||
_ => new () {".mp4" }
|
||||
_ => new HashSet<string> {".mp4" }
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace Editor
|
||||
{
|
||||
allDefines.Add(symbolToAdd);
|
||||
}
|
||||
|
||||
allDefines.Sort();
|
||||
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup,
|
||||
string.Join(";", allDefines.ToArray()));
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ namespace Pal3.Actor
|
||||
switch (actor.Info.Id)
|
||||
{
|
||||
case (byte)PlayerActorId.HuaYing:
|
||||
actorGameObject.AddComponent<HuaYingController>().Init(actorController, actionController);
|
||||
actorGameObject.AddComponent<HuaYingController>().Init(actor, actorController, actionController);
|
||||
break;
|
||||
case (byte)PlayerActorId.LongKui:
|
||||
actorGameObject.AddComponent<LongKuiController>().Init(actor, actionController);
|
||||
@@ -56,7 +56,7 @@ namespace Pal3.Actor
|
||||
switch (actor.Info.Id)
|
||||
{
|
||||
case (byte)PlayerActorId.TaoZi:
|
||||
actorGameObject.AddComponent<FlyingActorController>().Init(actionController);
|
||||
actorGameObject.AddComponent<FlyingActorController>().Init(actor, actionController);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -404,6 +404,7 @@ namespace Pal3.Actor
|
||||
private void ReachingToEndOfPath()
|
||||
{
|
||||
_movementWaiter?.CancelWait();
|
||||
|
||||
switch (_currentPath.EndOfPathAction)
|
||||
{
|
||||
case EndOfPathActionType.DisposeSelf:
|
||||
@@ -539,7 +540,7 @@ namespace Pal3.Actor
|
||||
}
|
||||
}
|
||||
|
||||
transform.position = _tilemap.GetWorldPosition(tilePosition, _currentLayerIndex);
|
||||
transform.position = _tilemap.GetWorldPosition(tilePosition, _currentLayerIndex);
|
||||
}
|
||||
|
||||
public void Execute(ActorPathToCommand command)
|
||||
|
||||
@@ -10,7 +10,6 @@ namespace Pal3.Actor
|
||||
using Command.InternalCommands;
|
||||
using Command.SceCommands;
|
||||
using Core.GameBox;
|
||||
using MetaData;
|
||||
using Player;
|
||||
using Script.Waiter;
|
||||
using UnityEngine;
|
||||
@@ -19,11 +18,14 @@ namespace Pal3.Actor
|
||||
ICommandExecutor<FlyingActorFlyToCommand>
|
||||
{
|
||||
private const float FLY_SPEED = 144f / GameBoxInterpreter.GameBoxUnitToUnityUnit;
|
||||
private const float FLYING_MOVEMENT_MODE_SWITCH_DISTANCE = 5f;
|
||||
|
||||
private Actor _actor;
|
||||
private ActorActionController _actionController;
|
||||
|
||||
public void Init(ActorActionController actionController)
|
||||
public void Init(Actor actor, ActorActionController actionController)
|
||||
{
|
||||
_actor = actor;
|
||||
_actionController = actionController;
|
||||
}
|
||||
|
||||
@@ -44,6 +46,7 @@ namespace Pal3.Actor
|
||||
if (Vector3.Distance(transform.position, PlayerActorNpcInfo.InitPosition) < float.Epsilon)
|
||||
{
|
||||
transform.position = targetPosition;
|
||||
_actionController.PerformAction(_actor.GetIdleAction());
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -53,7 +56,10 @@ namespace Pal3.Actor
|
||||
var distance = (targetPosition - transform.position).magnitude;
|
||||
var duration = distance / FLY_SPEED;
|
||||
|
||||
_actionController.PerformAction(ActorActionType.Run);
|
||||
_actionController.PerformAction(distance < FLYING_MOVEMENT_MODE_SWITCH_DISTANCE
|
||||
? _actor.GetMovementAction(0)
|
||||
: _actor.GetMovementAction(1));
|
||||
|
||||
StartCoroutine(Fly(targetPosition, duration, waiter));
|
||||
}
|
||||
|
||||
@@ -62,9 +68,8 @@ namespace Pal3.Actor
|
||||
Vector3 oldPosition = transform.position;
|
||||
|
||||
// Facing towards target position, ignoring y
|
||||
transform.forward = (new Vector3(targetPosition.x, 0f, targetPosition.z)
|
||||
- new Vector3(oldPosition.x, 0f, oldPosition.z)).normalized;
|
||||
|
||||
transform.LookAt(new Vector3(targetPosition.x, oldPosition.y, targetPosition.z));
|
||||
|
||||
var timePast = 0f;
|
||||
while (timePast < duration)
|
||||
{
|
||||
@@ -78,6 +83,7 @@ namespace Pal3.Actor
|
||||
}
|
||||
|
||||
transform.position = targetPosition;
|
||||
_actionController.PerformAction(_actor.GetIdleAction());
|
||||
waiter?.CancelWait();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,15 +19,19 @@ namespace Pal3.Actor
|
||||
ICommandExecutor<HuaYingSwitchBehaviourModeCommand>
|
||||
{
|
||||
private const float FLY_SPEED = 144f / GameBoxInterpreter.GameBoxUnitToUnityUnit;
|
||||
private const float ROTATION_SPEED = 10f;
|
||||
private const float ROTATION_SYNCING_DISTANCE = 2f;
|
||||
private const float FOLLOW_TARGET_MIN_DISTANCE = 1f;
|
||||
private const float FOLLOW_TARGET_MAX_DISTANCE = 6f;
|
||||
private const float FOLLOW_TARGET_X_OFFSET = -0.8f;
|
||||
private const float FOLLOW_TARGET_Y_OFFSET = -0.8f;
|
||||
|
||||
private readonly PlayerActorId _followActorId = PlayerActorId.XueJian;
|
||||
private const PlayerActorId FOLLOW_ACTOR_ID = PlayerActorId.XueJian;
|
||||
|
||||
private SceneManager _sceneManager;
|
||||
private Actor _actor;
|
||||
private ActorController _actorController;
|
||||
private ActorActionController _actorActionController;
|
||||
|
||||
private bool _isTargetRegistered;
|
||||
private GameObject _target;
|
||||
@@ -35,15 +39,24 @@ namespace Pal3.Actor
|
||||
private ActorActionController _targetActorActionController;
|
||||
private float _targetHeight;
|
||||
private bool _followTarget = true;
|
||||
private int _currentMode = 1; // defaults to follow target actor
|
||||
|
||||
public void Init(ActorController actorController,
|
||||
public void Init(Actor actor,
|
||||
ActorController actorController,
|
||||
ActorActionController actionController)
|
||||
{
|
||||
base.Init(actionController);
|
||||
base.Init(actor, actionController);
|
||||
_actor = actor;
|
||||
_actorController = actorController;
|
||||
_actorActionController = actionController;
|
||||
_sceneManager = ServiceLocator.Instance.Get<SceneManager>();
|
||||
}
|
||||
|
||||
public int GetCurrentMode()
|
||||
{
|
||||
return _currentMode;
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
CommandExecutorRegistry<ICommand>.Instance.Register(this);
|
||||
@@ -96,27 +109,42 @@ namespace Pal3.Actor
|
||||
}
|
||||
|
||||
Vector3 myNewPosition = GetTargetStayPosition();
|
||||
var distanceToNewPosition = Vector3.Distance(myNewPosition, transform.position);
|
||||
|
||||
if (Vector3.Distance(myNewPosition, transform.position) > FOLLOW_TARGET_MAX_DISTANCE)
|
||||
if (distanceToNewPosition < float.Epsilon)
|
||||
{
|
||||
transform.position = myNewPosition;
|
||||
_actorActionController.PerformAction(_actor.GetIdleAction());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Vector3.Distance(myNewPosition, transform.position) < FOLLOW_TARGET_MAX_DISTANCE)
|
||||
{
|
||||
_actorActionController.PerformAction(_actor.GetMovementAction(0));
|
||||
}
|
||||
else
|
||||
{
|
||||
transform.position = (transform.position - myNewPosition).normalized * FOLLOW_TARGET_MAX_DISTANCE +
|
||||
myNewPosition;
|
||||
_actorActionController.PerformAction(_actor.GetMovementAction(1));
|
||||
}
|
||||
|
||||
transform.position = Vector3.MoveTowards(transform.position,
|
||||
myNewPosition,
|
||||
Time.deltaTime * FLY_SPEED);
|
||||
transform.LookAt(new Vector3(myNewPosition.x, transform.position.y, myNewPosition.z));
|
||||
}
|
||||
|
||||
if (_isTargetRegistered)
|
||||
if (distanceToNewPosition < ROTATION_SYNCING_DISTANCE)
|
||||
{
|
||||
transform.rotation = _target.transform.rotation;
|
||||
Vector3 newRotation= Vector3.RotateTowards(transform.forward,
|
||||
_target.transform.forward, ROTATION_SPEED * Time.deltaTime, 0.0f);
|
||||
transform.rotation = Quaternion.LookRotation(newRotation);
|
||||
}
|
||||
}
|
||||
|
||||
private void FindAndSetTarget()
|
||||
{
|
||||
_target = _sceneManager.GetCurrentScene().GetActorGameObject((byte) _followActorId);
|
||||
_target = _sceneManager.GetCurrentScene().GetActorGameObject((byte) FOLLOW_ACTOR_ID);
|
||||
_targetActorController = _target.GetComponent<ActorController>();
|
||||
_targetActorActionController = _target.GetComponent<ActorActionController>();
|
||||
_isTargetRegistered = true;
|
||||
@@ -139,6 +167,8 @@ namespace Pal3.Actor
|
||||
_followTarget = false;
|
||||
break;
|
||||
}
|
||||
|
||||
_currentMode = command.Mode;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -238,6 +238,11 @@ namespace Pal3.Audio
|
||||
new CancellationToken(false))); // Should not stop music during scene switch
|
||||
}
|
||||
|
||||
public string GetCurrentScriptMusic()
|
||||
{
|
||||
return _currentScriptMusic;
|
||||
}
|
||||
|
||||
private void DestroyAllSfxAudioSource()
|
||||
{
|
||||
// Destroy current playing sfx
|
||||
|
||||
@@ -34,6 +34,5 @@ namespace Pal3.Command.InternalCommands
|
||||
public float Volume { get; }
|
||||
public float StartDelayInSeconds { get; }
|
||||
public float Interval { get; }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
|
||||
// See LICENSE file in the project root for license information.
|
||||
// ---------------------------------------------------------------------------------------------
|
||||
|
||||
namespace Pal3.Command.InternalCommands
|
||||
{
|
||||
public class SceneBeforeLoadingNotification : ICommand
|
||||
{
|
||||
public SceneBeforeLoadingNotification() { }
|
||||
}
|
||||
}
|
||||
@@ -1,3 +0,0 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6affef692c664172a6cc441fecd714cd
|
||||
timeCreated: 1663649030
|
||||
@@ -15,6 +15,7 @@ namespace Pal3.Dev
|
||||
// Should be (1, 1) but these are (1, -1)
|
||||
public static readonly HashSet<string> KnownTextureFiles = new HashSet<string>
|
||||
{
|
||||
"basedata.cpk\\role\\607\\607.tga",
|
||||
"basedata.cpk\\role\\611\\611.tga",
|
||||
"basedata.cpk\\role\\613\\613.tga",
|
||||
"basedata.cpk\\role\\b03\\b03.tga",
|
||||
|
||||
@@ -27,7 +27,10 @@ namespace Pal3.Dev
|
||||
|
||||
public sealed class StorySelector : MonoBehaviour,
|
||||
ICommandExecutor<ToggleStorySelectorRequest>,
|
||||
ICommandExecutor<GameSwitchToMainMenuCommand>
|
||||
ICommandExecutor<GameSwitchToMainMenuCommand>,
|
||||
ICommandExecutor<ScriptFinishedRunningNotification>,
|
||||
ICommandExecutor<GameStateChangedNotification>,
|
||||
ICommandExecutor<ResetGameStateCommand>
|
||||
{
|
||||
private InputManager _inputManager;
|
||||
private EventSystem _eventSystem;
|
||||
@@ -39,6 +42,8 @@ namespace Pal3.Dev
|
||||
private CanvasGroup _storySelectorCanvas;
|
||||
private GameObject _storySelectorButtonPrefab;
|
||||
|
||||
private readonly List<string> _deferredExecutionCommands = new();
|
||||
|
||||
private readonly List<GameObject> _selectionButtons = new();
|
||||
|
||||
private readonly Dictionary<string, string> _storySelections = new()
|
||||
@@ -1966,15 +1971,19 @@ namespace Pal3.Dev
|
||||
}
|
||||
|
||||
var firstButton = _selectionButtons.First().GetComponent<Button>();
|
||||
_eventSystem.firstSelectedGameObject = firstButton.gameObject;
|
||||
|
||||
InputDevice lastActiveInputDevice = _inputManager.GetLastActiveInputDevice();
|
||||
if (lastActiveInputDevice == Keyboard.current ||
|
||||
lastActiveInputDevice == Gamepad.current ||
|
||||
lastActiveInputDevice == DualShockGamepad.current)
|
||||
{
|
||||
_eventSystem.firstSelectedGameObject = firstButton.gameObject;
|
||||
firstButton.Select();
|
||||
}
|
||||
else
|
||||
{
|
||||
_eventSystem.firstSelectedGameObject = null;
|
||||
}
|
||||
|
||||
_storySelectorCanvas.alpha = 1f;
|
||||
_storySelectorCanvas.interactable = true;
|
||||
@@ -2011,7 +2020,7 @@ namespace Pal3.Dev
|
||||
}
|
||||
else
|
||||
{
|
||||
ExecuteCommands(commands);
|
||||
ExecuteCommandsFromSaveFile(commands);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -2051,6 +2060,32 @@ namespace Pal3.Dev
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void ExecuteCommandsFromSaveFile(string commands)
|
||||
{
|
||||
foreach (var command in commands.Split('\n'))
|
||||
{
|
||||
if (string.IsNullOrEmpty(command)) continue;
|
||||
|
||||
var arguments = new List<string>();
|
||||
|
||||
DebugLogConsole.FetchArgumentsFromCommand(command, arguments);
|
||||
|
||||
if (arguments[0] == nameof(ActorActivateCommand).Replace("Command", string.Empty) &&
|
||||
!Enum.GetValues(typeof(PlayerActorId)).Cast<int>().Contains(int.Parse(arguments[1])))
|
||||
{
|
||||
_deferredExecutionCommands.Add(command);
|
||||
}
|
||||
else if (arguments[0] == nameof(SceneActivateObjectCommand).Replace("Command", string.Empty))
|
||||
{
|
||||
_deferredExecutionCommands.Add(command);
|
||||
}
|
||||
else
|
||||
{
|
||||
DebugLogConsole.ExecuteCommand(command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
@@ -2074,5 +2109,32 @@ namespace Pal3.Dev
|
||||
{
|
||||
if (!_storySelectorCanvas.interactable) Show();
|
||||
}
|
||||
|
||||
public void Execute(ScriptFinishedRunningNotification command)
|
||||
{
|
||||
if (command.ScriptType == PalScriptType.Scene &&
|
||||
_deferredExecutionCommands.Count > 0)
|
||||
{
|
||||
ExecuteCommands(string.Join('\n', _deferredExecutionCommands));
|
||||
_deferredExecutionCommands.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(GameStateChangedNotification command)
|
||||
{
|
||||
// Not every scene has init scene script to run,
|
||||
// so we need to check if there are pending deferred commands to run.
|
||||
if (command.NewState == GameState.Gameplay &&
|
||||
_deferredExecutionCommands.Count > 0)
|
||||
{
|
||||
ExecuteCommands(string.Join('\n', _deferredExecutionCommands));
|
||||
_deferredExecutionCommands.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(ResetGameStateCommand command)
|
||||
{
|
||||
_deferredExecutionCommands.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -289,6 +289,7 @@ namespace Pal3
|
||||
_scriptManager,
|
||||
_favorManager,
|
||||
_cameraManager,
|
||||
_audioManager,
|
||||
_postProcessManager);
|
||||
ServiceLocator.Instance.Register(_saveManager);
|
||||
|
||||
|
||||
@@ -35,7 +35,7 @@ namespace Pal3.Player
|
||||
#if PAL3
|
||||
ICommandExecutor<LongKuiSwitchModeCommand>,
|
||||
#endif
|
||||
ICommandExecutor<SceneBeforeLoadingNotification>,
|
||||
ICommandExecutor<SceneLoadCommand>,
|
||||
ICommandExecutor<ScenePostLoadingNotification>,
|
||||
ICommandExecutor<ResetGameStateCommand>
|
||||
{
|
||||
@@ -58,8 +58,7 @@ namespace Pal3.Player
|
||||
#if PAL3
|
||||
private int _longKuiLastKnownMode = 0;
|
||||
#endif
|
||||
|
||||
private bool _isDuringSceneTransition = true;
|
||||
|
||||
private GameObject _playerActor;
|
||||
private ActorController _playerActorController;
|
||||
private ActorActionController _playerActorActionController;
|
||||
@@ -109,7 +108,6 @@ namespace Pal3.Player
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_isDuringSceneTransition) return;
|
||||
if (_playerActor == null) return;
|
||||
|
||||
var isPlayerInControl = false;
|
||||
@@ -354,7 +352,7 @@ namespace Pal3.Player
|
||||
var nearestInteractableDistance = float.MaxValue;
|
||||
Action interactionAction = null;
|
||||
|
||||
foreach (var actorInfo in _sceneManager.GetCurrentScene().GetAllActors())
|
||||
foreach (var actorInfo in _sceneManager.GetCurrentScene().GetAllActorGameObjects())
|
||||
{
|
||||
var actorController = actorInfo.Value.GetComponent<ActorController>();
|
||||
var actorMovementController = actorInfo.Value.GetComponent<ActorMovementController>();
|
||||
@@ -705,12 +703,19 @@ namespace Pal3.Player
|
||||
if (command.ActorId == ActorConstants.PlayerActorVirtualID)
|
||||
{
|
||||
Scene currentScene = _sceneManager.GetCurrentScene();
|
||||
|
||||
var currentLayerIndex = currentScene
|
||||
.GetActorGameObject((byte) _playerManager.GetPlayerActor())
|
||||
.GetComponent<ActorMovementController>()
|
||||
.GetCurrentLayerIndex();
|
||||
|
||||
_lastKnownPosition = currentScene.GetTilemap().GetWorldPosition(
|
||||
new Vector2Int(command.TileXPosition,command.TileZPosition), currentLayerIndex);
|
||||
|
||||
if (!_playerActorController.IsActive)
|
||||
{
|
||||
_playerActorController.IsActive = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -725,10 +730,8 @@ namespace Pal3.Player
|
||||
#endif
|
||||
}
|
||||
|
||||
public void Execute(SceneBeforeLoadingNotification command)
|
||||
public void Execute(SceneLoadCommand command)
|
||||
{
|
||||
_isDuringSceneTransition = true;
|
||||
|
||||
if (_sceneManager.GetCurrentScene() is not { } currentScene) return;
|
||||
|
||||
// Stop current player actor movement sfx
|
||||
@@ -791,13 +794,28 @@ namespace Pal3.Player
|
||||
#if PAL3
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new LongKuiSwitchModeCommand(_longKuiLastKnownMode));
|
||||
#endif
|
||||
|
||||
_isDuringSceneTransition = false;
|
||||
}
|
||||
|
||||
public void Execute(ResetGameStateCommand command)
|
||||
{
|
||||
_playerActorLastKnownPositionInfo.Clear();
|
||||
|
||||
_currentMovementSfxAudioName = string.Empty;
|
||||
|
||||
_lastInputTapPosition = default;
|
||||
_lastKnownPosition = default;
|
||||
_lastKnownTilePosition = default;
|
||||
_lastKnownLayerIndex = 0;
|
||||
_lastKnownPlayerActorAction = string.Empty;
|
||||
|
||||
#if PAL3
|
||||
_longKuiLastKnownMode = 0;
|
||||
#endif
|
||||
|
||||
_playerActor = null;
|
||||
_playerActorController = null;
|
||||
_playerActorActionController = null;
|
||||
_playerActorMovementController = null;
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
|
||||
@@ -48,10 +48,11 @@ namespace Pal3.Player
|
||||
#endif
|
||||
ICommandExecutor<PlayerEnableInputCommand>,
|
||||
ICommandExecutor<CameraFocusOnActorCommand>,
|
||||
ICommandExecutor<EffectAttachToActorCommand>
|
||||
ICommandExecutor<EffectAttachToActorCommand>,
|
||||
ICommandExecutor<ResetGameStateCommand>
|
||||
{
|
||||
private PlayerActorId _playerActor = 0;
|
||||
private bool _playerActorControlEnabled;
|
||||
private bool _playerActorControlEnabled = true;
|
||||
private bool _playerInputEnabled;
|
||||
|
||||
public PlayerManager()
|
||||
@@ -369,5 +370,12 @@ namespace Pal3.Player
|
||||
new EffectAttachToActorCommand((int)_playerActor));
|
||||
}
|
||||
}
|
||||
|
||||
public void Execute(ResetGameStateCommand command)
|
||||
{
|
||||
_playerActor = 0;
|
||||
_playerActorControlEnabled = true;
|
||||
_playerInputEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -128,7 +128,7 @@ namespace Pal3.Player
|
||||
|
||||
var playerActorIds = Enum.GetValues(typeof(PlayerActorId)).Cast<int>();
|
||||
var activePlayerActors = _sceneManager.GetCurrentScene()
|
||||
.GetAllActors()
|
||||
.GetAllActorGameObjects()
|
||||
.Where(actor => playerActorIds.Contains(actor.Key) &&
|
||||
actor.Value.GetComponent<ActorController>().IsActive);
|
||||
|
||||
|
||||
@@ -25,6 +25,8 @@ namespace Pal3.Renderer
|
||||
{
|
||||
public event EventHandler<int> AnimationLoopPointReached;
|
||||
|
||||
private const int TRANSPARENT_RENDER_QUEUE_INDEX = 3000;
|
||||
|
||||
private const string MV3_ANIMATION_HOLD_EVENT_NAME = "hold";
|
||||
private const string MV3_MODEL_DEFAULT_TEXTURE_EXTENSION = ".tga";
|
||||
private const float TIME_TO_TICK_SCALE = 5000f;
|
||||
@@ -32,6 +34,7 @@ namespace Pal3.Renderer
|
||||
private readonly int _mainTexturePropertyId = Shader.PropertyToID("_MainTex");
|
||||
private readonly int _cutoffPropertyId = Shader.PropertyToID("_Cutoff");
|
||||
private readonly int _tintColorPropertyId = Shader.PropertyToID("_TintColor");
|
||||
private readonly int _isOpaquePropertyId = Shader.PropertyToID("_IsOpaque");
|
||||
private Shader _standardNoShadowShader;
|
||||
|
||||
private ITextureResourceProvider _textureProvider;
|
||||
@@ -153,10 +156,12 @@ namespace Pal3.Renderer
|
||||
_materials[index] = new Material(_standardNoShadowShader);
|
||||
_materials[index].SetTexture(_mainTexturePropertyId, _textures[index]);
|
||||
|
||||
var cutoff = _textureHasAlphaChannel[index] ? 0.3f : 0f;
|
||||
var cutoff = _textureHasAlphaChannel[index] ? 0.01f : 0f;
|
||||
if (cutoff > Mathf.Epsilon)
|
||||
{
|
||||
_materials[index].SetFloat(_cutoffPropertyId, cutoff);
|
||||
_materials[index].renderQueue = TRANSPARENT_RENDER_QUEUE_INDEX - 100; // TODO: Find a better way to set render queue
|
||||
_materials[index].SetFloat(_isOpaquePropertyId, .0f);
|
||||
}
|
||||
|
||||
_materials[index].SetColor(_tintColorPropertyId, _tintColor);
|
||||
|
||||
@@ -39,18 +39,16 @@ namespace Pal3.Renderer
|
||||
private readonly int _shadowTexturePropertyId = Shader.PropertyToID("_ShadowTex");
|
||||
private readonly int _cutoffPropertyId = Shader.PropertyToID("_Cutoff");
|
||||
private readonly int _tintColorPropertyId = Shader.PropertyToID("_TintColor");
|
||||
private readonly int _transparencyPropertyId = Shader.PropertyToID("_Transparency");
|
||||
private readonly int _isOpaquePropertyId = Shader.PropertyToID("_IsOpaque");
|
||||
private Shader _standardShader;
|
||||
private Shader _standardNoShadowShader;
|
||||
private readonly Dictionary<string, Material> _materials = new ();
|
||||
private bool _disableTransparency;
|
||||
|
||||
public void Render(PolFile polFile, ITextureResourceProvider textureProvider, Color tintColor, bool disableTransparency = false)
|
||||
public void Render(PolFile polFile, ITextureResourceProvider textureProvider, Color tintColor)
|
||||
{
|
||||
_textureProvider = textureProvider;
|
||||
_tintColor = tintColor;
|
||||
_textureCache = BuildTextureCache(polFile, textureProvider);
|
||||
_disableTransparency = disableTransparency;
|
||||
|
||||
_standardShader = Shader.Find("Pal3/Standard");
|
||||
_standardNoShadowShader = Shader.Find("Pal3/StandardNoShadow");
|
||||
@@ -58,7 +56,7 @@ namespace Pal3.Renderer
|
||||
for (var i = 0; i < polFile.Meshes.Length; i++)
|
||||
{
|
||||
RenderMeshInternal(
|
||||
polFile.NodeDescriptions[i].Name,
|
||||
polFile.NodeDescriptions[i],
|
||||
polFile.Meshes[i]);
|
||||
}
|
||||
}
|
||||
@@ -95,7 +93,7 @@ namespace Pal3.Renderer
|
||||
return textureCache;
|
||||
}
|
||||
|
||||
private void RenderMeshInternal(string meshName, PolMesh mesh)
|
||||
private void RenderMeshInternal(PolGeometryNode meshNode, PolMesh mesh)
|
||||
{
|
||||
for (var i = 0; i < mesh.Textures.Length; i++)
|
||||
{
|
||||
@@ -112,11 +110,11 @@ namespace Pal3.Renderer
|
||||
|
||||
if (textures.Count == 0)
|
||||
{
|
||||
Debug.LogWarning($"0 texture found for {meshName}");
|
||||
Debug.LogWarning($"0 texture found for {meshNode.Name}");
|
||||
return;
|
||||
}
|
||||
|
||||
var meshObject = new GameObject(meshName);
|
||||
var meshObject = new GameObject(meshNode.Name);
|
||||
|
||||
// Attach BlendFlag and GameBoxMaterial to the GameObject for better debuggability
|
||||
#if UNITY_EDITOR
|
||||
@@ -126,17 +124,13 @@ namespace Pal3.Renderer
|
||||
#endif
|
||||
|
||||
var meshRenderer = meshObject.AddComponent<StaticMeshRenderer>();
|
||||
GameBoxMaterial gbMaterial = mesh.Textures[i].Material;
|
||||
var blendFlag = mesh.Textures[i].BlendFlag;
|
||||
|
||||
if (textures.Count == 1)
|
||||
{
|
||||
var materialHashKey = _standardNoShadowShader.name +
|
||||
textures[0].name +
|
||||
blendFlag +
|
||||
gbMaterial.Emissive.r +
|
||||
gbMaterial.Emissive.g +
|
||||
gbMaterial.Emissive.b;
|
||||
blendFlag;
|
||||
|
||||
var isWaterSurface = textures[0].name
|
||||
.StartsWith(ANIMATED_WATER_TEXTURE_DEFAULT_NAME, StringComparison.OrdinalIgnoreCase);
|
||||
@@ -157,18 +151,10 @@ namespace Pal3.Renderer
|
||||
material.SetFloat(_cutoffPropertyId, cutoff);
|
||||
}
|
||||
|
||||
if (!_disableTransparency &&
|
||||
(gbMaterial.Emissive.r is > 0 and < 255 ||
|
||||
gbMaterial.Emissive.g is > 0 and < 255 ||
|
||||
gbMaterial.Emissive.b is > 0 and < 255 ||
|
||||
isWaterSurface))
|
||||
if (blendFlag is 1 or 2)
|
||||
{
|
||||
var transparency = blendFlag is 1 or 2 ? 0.5f : 0f;
|
||||
if (transparency > Mathf.Epsilon)
|
||||
{
|
||||
material.renderQueue = TRANSPARENT_RENDER_QUEUE_INDEX;
|
||||
material.SetFloat(_transparencyPropertyId, transparency);
|
||||
}
|
||||
material.renderQueue = TRANSPARENT_RENDER_QUEUE_INDEX;
|
||||
material.SetFloat(_isOpaquePropertyId, .0f);
|
||||
}
|
||||
material.SetColor(_tintColorPropertyId, _tintColor);
|
||||
_materials[materialHashKey] = material;
|
||||
@@ -191,10 +177,7 @@ namespace Pal3.Renderer
|
||||
var materialHashKey = _standardShader.name +
|
||||
textures[0].name +
|
||||
textures[1].name +
|
||||
blendFlag +
|
||||
gbMaterial.Emissive.r +
|
||||
gbMaterial.Emissive.g +
|
||||
gbMaterial.Emissive.b;
|
||||
blendFlag;
|
||||
|
||||
var isWaterSurface = textures[1].name
|
||||
.StartsWith(ANIMATED_WATER_TEXTURE_DEFAULT_NAME, StringComparison.OrdinalIgnoreCase);
|
||||
@@ -216,18 +199,10 @@ namespace Pal3.Renderer
|
||||
material.SetFloat(_cutoffPropertyId, cutoff);
|
||||
}
|
||||
|
||||
if (!_disableTransparency &&
|
||||
(gbMaterial.Emissive.r is > 0 and < 255 ||
|
||||
gbMaterial.Emissive.g is > 0 and < 255 ||
|
||||
gbMaterial.Emissive.b is > 0 and < 255 ||
|
||||
isWaterSurface))
|
||||
if (blendFlag is 1 or 2)
|
||||
{
|
||||
var transparency = blendFlag is 1 or 2 ? 0.5f : 0f;
|
||||
if (transparency > Mathf.Epsilon)
|
||||
{
|
||||
material.renderQueue = TRANSPARENT_RENDER_QUEUE_INDEX;
|
||||
material.SetFloat(_transparencyPropertyId, transparency);
|
||||
}
|
||||
material.renderQueue = TRANSPARENT_RENDER_QUEUE_INDEX;
|
||||
material.SetFloat(_isOpaquePropertyId, .0f);
|
||||
}
|
||||
material.SetColor(_tintColorPropertyId, _tintColor);
|
||||
_materials[materialHashKey] = material;
|
||||
|
||||
@@ -172,12 +172,17 @@ namespace Pal3.Scene
|
||||
return Actors.ContainsKey(id) ? Actors[id] : null;
|
||||
}
|
||||
|
||||
public Dictionary<byte, Actor> GetAllActors()
|
||||
{
|
||||
return Actors;
|
||||
}
|
||||
|
||||
public GameObject GetActorGameObject(byte id)
|
||||
{
|
||||
return _actorObjects.ContainsKey(id) ? _actorObjects[id] : null;
|
||||
}
|
||||
|
||||
public Dictionary<byte, GameObject> GetAllActors()
|
||||
public Dictionary<byte, GameObject> GetAllActorGameObjects()
|
||||
{
|
||||
return _actorObjects;
|
||||
}
|
||||
@@ -330,7 +335,7 @@ namespace Pal3.Scene
|
||||
/// </summary>
|
||||
private HashSet<Vector2Int> GetAllActiveActorBlockingTilePositions(int layerIndex, byte[] excludeActorIds)
|
||||
{
|
||||
var allActors = GetAllActors();
|
||||
var allActors = GetAllActorGameObjects();
|
||||
|
||||
var actorTiles = new HashSet<Vector2Int>();
|
||||
foreach ((var id, GameObject actor) in allActors)
|
||||
|
||||
@@ -51,8 +51,6 @@ namespace Pal3.Scene
|
||||
|
||||
public void LoadScene(string sceneFileName, string sceneName)
|
||||
{
|
||||
CommandDispatcher<ICommand>.Instance.Dispatch(new SceneBeforeLoadingNotification());
|
||||
|
||||
var timer = new Stopwatch();
|
||||
timer.Start();
|
||||
DisposeCurrentScene();
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace Pal3.Scene.SceneObjects
|
||||
{
|
||||
(PolFile PolFile, ITextureResourceProvider TextureProvider) poly = resourceProvider.GetPol(_modelFilePath);
|
||||
var sceneObjectRenderer = sceneGameObject.AddComponent<PolyModelRenderer>();
|
||||
sceneObjectRenderer.Render(poly.PolFile, poly.TextureProvider, tintColor, disableTransparency: true);
|
||||
sceneObjectRenderer.Render(poly.PolFile, poly.TextureProvider, tintColor);
|
||||
}
|
||||
else if (_modelFilePath.ToLower().EndsWith(".cvd"))
|
||||
{
|
||||
|
||||
@@ -21,19 +21,22 @@ namespace Pal3.Settings
|
||||
|
||||
public void ApplyDefaultRenderingSettings()
|
||||
{
|
||||
//var vSyncCount = Utility.IsDesktopDevice() ? 0 : 1;
|
||||
//QualitySettings.vSyncCount = vSyncCount;
|
||||
var vSyncCount = Utility.IsDesktopDevice() ? 0 : 1;
|
||||
QualitySettings.vSyncCount = vSyncCount;
|
||||
|
||||
var monitorRefreshRate = Screen.currentResolution.refreshRate;
|
||||
|
||||
Application.targetFrameRate = Application.platform switch
|
||||
{
|
||||
RuntimePlatform.WindowsEditor => 120,
|
||||
RuntimePlatform.WindowsPlayer => 120,
|
||||
RuntimePlatform.OSXEditor => 120,
|
||||
RuntimePlatform.OSXPlayer => 120,
|
||||
RuntimePlatform.LinuxEditor => 120,
|
||||
RuntimePlatform.LinuxPlayer => 120,
|
||||
RuntimePlatform.WindowsEditor => monitorRefreshRate,
|
||||
RuntimePlatform.WindowsPlayer => monitorRefreshRate,
|
||||
RuntimePlatform.OSXEditor => monitorRefreshRate,
|
||||
RuntimePlatform.OSXPlayer => monitorRefreshRate,
|
||||
RuntimePlatform.LinuxEditor => monitorRefreshRate,
|
||||
RuntimePlatform.LinuxPlayer => monitorRefreshRate,
|
||||
RuntimePlatform.IPhonePlayer => 120,
|
||||
RuntimePlatform.Android => 120,
|
||||
RuntimePlatform.Switch => 60,
|
||||
_ => -1,
|
||||
};
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@ namespace Pal3.State
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Actor;
|
||||
using Audio;
|
||||
using Camera;
|
||||
using Command;
|
||||
using Command.InternalCommands;
|
||||
@@ -40,6 +41,7 @@ namespace Pal3.State
|
||||
private readonly ScriptManager _scriptManager;
|
||||
private readonly FavorManager _favorManager;
|
||||
private readonly CameraManager _cameraManager;
|
||||
private readonly AudioManager _audioManager;
|
||||
private readonly PostProcessManager _postProcessManager;
|
||||
|
||||
private const string SAVE_FILE_NAME = "save.txt";
|
||||
@@ -51,6 +53,7 @@ namespace Pal3.State
|
||||
ScriptManager scriptManager,
|
||||
FavorManager favorManager,
|
||||
CameraManager cameraManager,
|
||||
AudioManager audioManager,
|
||||
PostProcessManager postProcessManager)
|
||||
{
|
||||
_sceneManager = sceneManager ?? throw new ArgumentNullException(nameof(sceneManager));
|
||||
@@ -60,6 +63,7 @@ namespace Pal3.State
|
||||
_scriptManager = scriptManager ?? throw new ArgumentNullException(nameof(scriptManager));
|
||||
_favorManager = favorManager ?? throw new ArgumentNullException(nameof(favorManager));
|
||||
_cameraManager = cameraManager != null ? cameraManager : throw new ArgumentNullException(nameof(cameraManager));
|
||||
_audioManager = audioManager != null ? audioManager : throw new ArgumentNullException(nameof(audioManager));
|
||||
_postProcessManager = postProcessManager != null ? postProcessManager : throw new ArgumentNullException(nameof(postProcessManager));
|
||||
}
|
||||
|
||||
@@ -117,49 +121,76 @@ namespace Pal3.State
|
||||
|
||||
var commands = new List<ICommand>
|
||||
{
|
||||
new ResetGameStateCommand(),
|
||||
new ResetGameStateCommand(), // Reset game state at first
|
||||
};
|
||||
|
||||
// Save global variable(s)
|
||||
commands.AddRange(varsToSave.Select(var =>
|
||||
new ScriptVarSetValueCommand(var.Key, var.Value)));
|
||||
|
||||
var currentPlayerActorId = (int)_playerManager.GetPlayerActor();
|
||||
|
||||
// Save current playing script music (if any)
|
||||
var currentScriptMusic = _audioManager.GetCurrentScriptMusic();
|
||||
if (!string.IsNullOrEmpty(currentScriptMusic))
|
||||
{
|
||||
commands.Add(new PlayMusicCommand(currentScriptMusic, 0));
|
||||
}
|
||||
|
||||
// Save current scene info and player actor state
|
||||
commands.AddRange(new List<ICommand>()
|
||||
{
|
||||
new SceneLoadCommand(currentSceneInfo.CityName, currentSceneInfo.Name),
|
||||
new ActorActivateCommand(ActorConstants.PlayerActorVirtualID, 1),
|
||||
new ActorEnablePlayerControlCommand(ActorConstants.PlayerActorVirtualID),
|
||||
new ActorActivateCommand(currentPlayerActorId, 1),
|
||||
new ActorEnablePlayerControlCommand(currentPlayerActorId),
|
||||
new PlayerEnableInputCommand(1),
|
||||
new ActorSetNavLayerCommand(ActorConstants.PlayerActorVirtualID,
|
||||
new ActorSetNavLayerCommand(currentPlayerActorId,
|
||||
playerActorMovementController.GetCurrentLayerIndex()),
|
||||
new ActorSetTilePositionCommand(ActorConstants.PlayerActorVirtualID,
|
||||
playerActorTilePosition.x, playerActorTilePosition.y)
|
||||
new ActorSetTilePositionCommand(currentPlayerActorId,
|
||||
playerActorTilePosition.x, playerActorTilePosition.y),
|
||||
new ActorRotateFacingCommand(currentPlayerActorId,
|
||||
-(int)playerActorMovementController.gameObject.transform.rotation.eulerAngles.y)
|
||||
});
|
||||
|
||||
// Save team state
|
||||
commands.AddRange(_teamManager.GetActorsInTeam()
|
||||
.Select(actorId => new TeamAddOrRemoveActorCommand((int) actorId, 1)));
|
||||
|
||||
if (saveLevel == SaveLevel.Full)
|
||||
{
|
||||
// Save favor info
|
||||
commands.AddRange(_favorManager.GetAllActorFavorInfo()
|
||||
.Select(favorInfo => new FavorAddCommand(favorInfo.Key, favorInfo.Value)));
|
||||
|
||||
var allSceneObjectIds = currentScene.GetAllSceneObjects().Keys.ToArray();
|
||||
var allActivatedSceneObjectIds = currentScene.GetAllActivatedSceneObjects().Keys.ToArray();
|
||||
// Save scene object activation state changed by the script
|
||||
var allSceneObjects = currentScene.GetAllSceneObjects();
|
||||
var allActivatedSceneObjects = currentScene.GetAllActivatedSceneObjects();
|
||||
commands.AddRange(allActivatedSceneObjects
|
||||
.Where(_ => allSceneObjects[_.Key].Info.Active == 0)
|
||||
.Select(_ => new SceneActivateObjectCommand(_.Key, 1)));
|
||||
commands.AddRange(allSceneObjects
|
||||
.Where(_ => allSceneObjects[_.Key].Info.Active == 1)
|
||||
.Where(_ => !allActivatedSceneObjects.Keys.Contains(_.Key))
|
||||
.Select(_ => new SceneActivateObjectCommand(_.Key, 0)));
|
||||
|
||||
commands.AddRange(allActivatedSceneObjectIds
|
||||
.Select(activeSceneObjectId => new SceneActivateObjectCommand(activeSceneObjectId, 1)));
|
||||
|
||||
commands.AddRange(allSceneObjectIds
|
||||
.Where(_ => !allActivatedSceneObjectIds.Contains(_))
|
||||
.Select(inactiveSceneObjectId => new SceneActivateObjectCommand(inactiveSceneObjectId, 0)));
|
||||
|
||||
commands.AddRange(currentScene.GetAllActors()
|
||||
.Select(actorInfo => actorInfo.Value.GetComponent<ActorController>().IsActive
|
||||
? new ActorActivateCommand(actorInfo.Key, 1)
|
||||
: new ActorActivateCommand(actorInfo.Key, 0)));
|
||||
// Save actor activation state changed by the script
|
||||
var playerActorIds = Enum.GetValues(typeof(PlayerActorId)).Cast<int>().ToList();
|
||||
var allActors = currentScene.GetAllActors().Where(_ => !playerActorIds.Contains(_.Key)).ToArray();
|
||||
var allActorGameObjects = currentScene.GetAllActorGameObjects();
|
||||
commands.AddRange(allActors
|
||||
.Where(_ => _.Value.Info.InitActive == 0)
|
||||
.Where(_ => allActorGameObjects.ContainsKey(_.Key) &&
|
||||
allActorGameObjects[_.Key].GetComponent<ActorController>().IsActive)
|
||||
.Select(_ => new ActorActivateCommand(_.Key, 1)));
|
||||
commands.AddRange(allActors
|
||||
.Where(_ => _.Value.Info.InitActive == 1)
|
||||
.Where(_ => allActorGameObjects.ContainsKey(_.Key) &&
|
||||
!allActorGameObjects[_.Key].GetComponent<ActorController>().IsActive)
|
||||
.Select(_ => new ActorActivateCommand(_.Key, 0)));
|
||||
}
|
||||
|
||||
#if PAL3
|
||||
// Save LongKui state
|
||||
var longKuiCurrentMode = currentScene.GetActorGameObject((byte) PlayerActorId.LongKui)
|
||||
.GetComponent<LongKuiController>()
|
||||
.GetCurrentMode();
|
||||
@@ -167,25 +198,49 @@ namespace Pal3.State
|
||||
{
|
||||
commands.Add(new LongKuiSwitchModeCommand(longKuiCurrentMode));
|
||||
}
|
||||
|
||||
// Save HuaYing state
|
||||
var huaYingGameObject = currentScene.GetActorGameObject((byte) PlayerActorId.HuaYing);
|
||||
var huaYingCurrentMode = huaYingGameObject.GetComponent<HuaYingController>().GetCurrentMode();
|
||||
if (huaYingCurrentMode != 1)
|
||||
{
|
||||
commands.Add(new HuaYingSwitchBehaviourModeCommand(huaYingCurrentMode));
|
||||
}
|
||||
if (huaYingCurrentMode == 2 && huaYingGameObject.GetComponent<ActorController>().IsActive)
|
||||
{
|
||||
commands.Add(new ActorActivateCommand((int) PlayerActorId.HuaYing, 1));
|
||||
var huaYingMovementController = huaYingGameObject.GetComponent<ActorMovementController>();
|
||||
commands.Add(new ActorSetNavLayerCommand((int)PlayerActorId.HuaYing,
|
||||
huaYingMovementController.GetCurrentLayerIndex()));
|
||||
Vector2Int tilePosition = huaYingMovementController.GetTilePosition();
|
||||
commands.Add(new ActorSetTilePositionCommand((int)PlayerActorId.HuaYing,
|
||||
tilePosition.x,
|
||||
tilePosition.y));
|
||||
var rotationInDegrees = (int)huaYingGameObject.transform.rotation.eulerAngles.y;
|
||||
commands.Add(new ActorRotateFacingCommand((int)PlayerActorId.HuaYing, -rotationInDegrees));
|
||||
}
|
||||
#endif
|
||||
|
||||
// Save big map region activation state
|
||||
commands.AddRange(_bigMapManager.GetRegionEnablementInfo()
|
||||
.Select(regionEnablement => new BigMapEnableRegionCommand(regionEnablement.Key, regionEnablement.Value)));
|
||||
|
||||
// Save current applied screen effect state
|
||||
var currentEffectMode = _postProcessManager.GetCurrentAppliedEffectMode();
|
||||
if (currentEffectMode != -1)
|
||||
{
|
||||
commands.Add(new EffectSetScreenEffectCommand(currentEffectMode));
|
||||
}
|
||||
|
||||
// Save current applied camera settings
|
||||
var defaultCameraTransformOption = _cameraManager.GetCurrentAppliedDefaultTransformOption();
|
||||
if (defaultCameraTransformOption != 0)
|
||||
{
|
||||
commands.Add(new CameraSetDefaultTransformCommand(defaultCameraTransformOption));
|
||||
}
|
||||
|
||||
// Good to have
|
||||
commands.Add(new CameraFadeInCommand());
|
||||
|
||||
return commands;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ namespace Pal3.UI
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
using UnityEngine.InputSystem;
|
||||
using UnityEngine.InputSystem.DualShock;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public sealed class BigMapManager : MonoBehaviour,
|
||||
@@ -164,14 +165,19 @@ namespace Pal3.UI
|
||||
}
|
||||
|
||||
var firstButton = _selectionButtons.First().GetComponent<Button>();
|
||||
_eventSystem.firstSelectedGameObject = firstButton.gameObject;
|
||||
|
||||
InputDevice lastActiveInputDevice = _inputManager.GetLastActiveInputDevice();
|
||||
if (lastActiveInputDevice == Keyboard.current ||
|
||||
lastActiveInputDevice == Gamepad.current)
|
||||
lastActiveInputDevice == Gamepad.current ||
|
||||
lastActiveInputDevice == DualShockGamepad.current)
|
||||
{
|
||||
_eventSystem.firstSelectedGameObject = firstButton.gameObject;
|
||||
firstButton.Select();
|
||||
}
|
||||
else
|
||||
{
|
||||
_eventSystem.firstSelectedGameObject = null;
|
||||
}
|
||||
|
||||
if (_selectionButtons.Count > 0)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@ namespace Pal3.UI
|
||||
ICommandExecutor<ActiveInputDeviceChangedNotification>
|
||||
{
|
||||
private Texture2D _cursorTextureNormal;
|
||||
|
||||
public void Init(GameResourceProvider gameResourceProvider)
|
||||
{
|
||||
gameResourceProvider = gameResourceProvider ?? throw new ArgumentNullException(nameof(gameResourceProvider));
|
||||
|
||||
@@ -504,15 +504,19 @@ namespace Pal3.UI
|
||||
}
|
||||
|
||||
var firstButton = _selectionButtons.First().GetComponentInChildren<Button>();
|
||||
_eventSystem.firstSelectedGameObject = firstButton.gameObject;
|
||||
|
||||
InputDevice lastActiveInputDevice = _inputManager.GetLastActiveInputDevice();
|
||||
if (lastActiveInputDevice == Keyboard.current ||
|
||||
lastActiveInputDevice == Gamepad.current ||
|
||||
lastActiveInputDevice == DualShockGamepad.current)
|
||||
{
|
||||
_eventSystem.firstSelectedGameObject = firstButton.gameObject;
|
||||
firstButton.Select();
|
||||
}
|
||||
else
|
||||
{
|
||||
_eventSystem.firstSelectedGameObject = null;
|
||||
}
|
||||
|
||||
_dialogueCanvas.enabled = true;
|
||||
_dialogueSelectionButtonsCanvas.enabled = true;
|
||||
|
||||
@@ -11,7 +11,7 @@ Shader "Pal3/Standard"
|
||||
_ShadowTex ("Shadow map (RGB)", 2D) = "white" {}
|
||||
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.0
|
||||
_Exposure("Exposure Amount", Range(0.1,1.0)) = 0.4
|
||||
_Transparency("Transparency Amount", Range(0.1,1.0)) = 1.0
|
||||
_IsOpaque("Is Material Opaque", Range(0,1)) = 1.0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
@@ -54,7 +54,7 @@ Shader "Pal3/Standard"
|
||||
float4 _ShadowTex_ST;
|
||||
fixed _Cutoff;
|
||||
float _Exposure;
|
||||
float _Transparency;
|
||||
float _IsOpaque;
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
@@ -71,13 +71,23 @@ Shader "Pal3/Standard"
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
half4 color = tex2D(_MainTex, i.texcoord);
|
||||
|
||||
const half alpha = color.a;
|
||||
|
||||
// Cutout
|
||||
clip(color.a - _Cutoff);
|
||||
|
||||
// Shadow
|
||||
color *= tex2D(_ShadowTex, i.shadowcoord) / (1 - _Exposure);
|
||||
// Transparency
|
||||
color.a = _Transparency;
|
||||
|
||||
// Preserve alpha or not
|
||||
if (_IsOpaque == 1.0)
|
||||
{
|
||||
color.a = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
color.a = alpha;
|
||||
}
|
||||
|
||||
UNITY_APPLY_FOG(i.fogCoord, color);
|
||||
return color;
|
||||
|
||||
@@ -10,7 +10,7 @@ Shader "Pal3/StandardNoShadow"
|
||||
_MainTex ("Base (RGB) Trans (A)", 2D) = "white" {}
|
||||
_Cutoff ("Alpha cutoff", Range(0,1)) = 0.0
|
||||
_TintColor ("Tint color", Color) = (1.0, 1.0, 1.0, 1.0)
|
||||
_Transparency("Transparency Amount", Range(0.1,1.0)) = 1.0
|
||||
_IsOpaque("Is Material Opaque", Range(0,1)) = 1.0
|
||||
}
|
||||
SubShader
|
||||
{
|
||||
@@ -49,7 +49,7 @@ Shader "Pal3/StandardNoShadow"
|
||||
float4 _MainTex_ST;
|
||||
fixed _Cutoff;
|
||||
half4 _TintColor;
|
||||
float _Transparency;
|
||||
float _IsOpaque;
|
||||
|
||||
v2f vert(appdata_t v)
|
||||
{
|
||||
@@ -65,13 +65,23 @@ Shader "Pal3/StandardNoShadow"
|
||||
half4 frag(v2f i) : SV_Target
|
||||
{
|
||||
half4 color = tex2D(_MainTex, i.texcoord);
|
||||
|
||||
const half alpha = color.a;
|
||||
|
||||
// Cutout
|
||||
clip(color.a - _Cutoff);
|
||||
|
||||
// Tint color
|
||||
color *= _TintColor;
|
||||
// Transparency
|
||||
color.a = _Transparency;
|
||||
|
||||
// Preserve alpha or not
|
||||
if (_IsOpaque == 1.0)
|
||||
{
|
||||
color.a = 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
color.a = alpha;
|
||||
}
|
||||
|
||||
UNITY_APPLY_FOG(i.fogCoord, color);
|
||||
return color;
|
||||
|
||||
@@ -134,7 +134,7 @@ PlayerSettings:
|
||||
16:10: 1
|
||||
16:9: 1
|
||||
Others: 1
|
||||
bundleVersion: 0.26
|
||||
bundleVersion: 0.27
|
||||
preloadedAssets: []
|
||||
metroInputSource: 0
|
||||
wsaTransparentSwapchain: 0
|
||||
@@ -590,13 +590,13 @@ PlayerSettings:
|
||||
m_Automatic: 1
|
||||
- m_BuildTarget: MacStandaloneSupport
|
||||
m_APIs: 10000000
|
||||
m_Automatic: 1
|
||||
m_Automatic: 0
|
||||
- m_BuildTarget: LinuxStandaloneSupport
|
||||
m_APIs: 1100000015000000
|
||||
m_Automatic: 1
|
||||
m_APIs: 1500000011000000
|
||||
m_Automatic: 0
|
||||
- m_BuildTarget: WindowsStandaloneSupport
|
||||
m_APIs: 02000000
|
||||
m_Automatic: 1
|
||||
m_APIs: 0200000015000000
|
||||
m_Automatic: 0
|
||||
m_BuildTargetVRSettings:
|
||||
- m_BuildTarget: Standalone
|
||||
m_Enabled: 0
|
||||
@@ -877,7 +877,7 @@ PlayerSettings:
|
||||
webGLThreadsSupport: 0
|
||||
webGLDecompressionFallback: 0
|
||||
scriptingDefineSymbols:
|
||||
Android: UNITY_POST_PROCESSING_STACK_V2;PAL3
|
||||
Android: PAL3;UNITY_POST_PROCESSING_STACK_V2
|
||||
CloudRendering: UNITY_POST_PROCESSING_STACK_V2
|
||||
EmbeddedLinux: UNITY_POST_PROCESSING_STACK_V2
|
||||
GameCoreXboxOne: UNITY_POST_PROCESSING_STACK_V2
|
||||
@@ -886,7 +886,7 @@ PlayerSettings:
|
||||
PS4: UNITY_POST_PROCESSING_STACK_V2
|
||||
PS5: UNITY_POST_PROCESSING_STACK_V2
|
||||
Stadia: UNITY_POST_PROCESSING_STACK_V2
|
||||
Standalone: UNITY_POST_PROCESSING_STACK_V2;PAL3
|
||||
Standalone: PAL3;UNITY_POST_PROCESSING_STACK_V2
|
||||
WebGL: UNITY_POST_PROCESSING_STACK_V2
|
||||
Windows Store Apps: UNITY_POST_PROCESSING_STACK_V2
|
||||
XboxOne: UNITY_POST_PROCESSING_STACK_V2
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
因为项目本身不含有仙剑奇侠传三或仙剑奇侠传三外传的游戏数据,所以你需要持有一份仙剑三或外传的游戏原始文件(Steam或者方块游戏获得皆可,注意:暂时仅支持简体版游戏)。
|
||||
- 第一次打开Unity项目之后,先双击选择Scenes\Game作为当前场景,然后点播放键即可。如果选择Scenes\ResourceViewer,则会打开游戏资源查看器。
|
||||
- 第一次打开的时候会自动弹出文件夹选择窗口,请选择当前电脑上仙剑奇侠传三(或者外传)的安装文件夹即可。
|
||||
- 因为原始游戏的过场动画为Bink格式,Unity并不原生支持,所以请自行转码视频为Unity所支持的格式放在游戏根目录下的movie文件夹即可(大部分设备和系统支持.mp4等主流格式视频,Linux下仅支持.webm格式视频)。
|
||||
* Linux用户可以使用FFmpeg转码视频为.webm格式封装(vp8 + vorbis):ffmpeg -i input.mp4 -c:v libvpx -b:v 3M -c:a libvorbis output.webm
|
||||
|
||||
## 如何在手持设备上运行
|
||||
- 在打包后的运行时,所有平台都默认使用Application.persistentDataPath目录读取仙剑三文件,具体这个目录在哪里,根据平台决定,请阅读Unity文档:[Application.persistentDataPath](https://docs.unity3d.com/ScriptReference/Application-persistentDataPath.html)
|
||||
@@ -62,9 +64,8 @@ https://www.bilibili.com/video/BV1Fu411R7jM
|
||||
|
||||
## 如何贡献?
|
||||
因为项目还处于早期实现过程中,很多系统还没有实现,暂时不接受比较大的Pull request,特别是feature类型,如果您有好的想法,意见或者发现了Bug请欢迎提交issue或者加入交流群与我讨论。
|
||||
|
||||
另外您还可以参考这个项目解析视频:https://www.bilibili.com/video/BV1Pr4y167sF
|
||||
|
||||
## 技术交流以及测试
|
||||
## 社区
|
||||
仙剑三(及外传)复刻版讨论群:252315306
|
||||
|
||||
仙剑三(及外传)复刻版开发群:330680869
|
||||
Reference in new issue
Block a user