AxibugEmuOnline/AxibugEmuOnline.Client/Assets/Script/ControlSchemes/ControlScheme.cs
2024-11-21 17:18:15 +08:00

66 lines
2.9 KiB
C#

using System.Collections.Generic;
using UnityEngine;
namespace AxibugEmuOnline.Client
{
public abstract class ControlScheme
{
private static ControlScheme m_current;
public static ControlScheme Current
{
get => m_current;
set
{
m_current = value;
Dictionary<KeyCode, EnumCommand> mapper = new Dictionary<KeyCode, EnumCommand>();
m_current.SetUIKeys(mapper);
CommandDispatcher.Instance.SetKeyMapper(mapper);
}
}
public string Name { get; private set; }
public virtual void SetUIKeys(Dictionary<KeyCode, EnumCommand> uiKeyMapper)
{
uiKeyMapper[KeyCode.A] = EnumCommand.SelectItemLeft;
uiKeyMapper[KeyCode.D] = EnumCommand.SelectItemRight;
uiKeyMapper[KeyCode.W] = EnumCommand.SelectItemUp;
uiKeyMapper[KeyCode.S] = EnumCommand.SelectItemDown;
uiKeyMapper[KeyCode.K] = EnumCommand.Enter;
uiKeyMapper[KeyCode.L] = EnumCommand.Back;
uiKeyMapper[KeyCode.I] = EnumCommand.OptionMenu;
uiKeyMapper[KeyCode.LeftArrow] = EnumCommand.SelectItemLeft;
uiKeyMapper[KeyCode.RightArrow] = EnumCommand.SelectItemRight;
uiKeyMapper[KeyCode.UpArrow] = EnumCommand.SelectItemUp;
uiKeyMapper[KeyCode.DownArrow] = EnumCommand.SelectItemDown;
uiKeyMapper[KeyCode.Return] = EnumCommand.Enter;
uiKeyMapper[KeyCode.Escape] = EnumCommand.Back;
uiKeyMapper[KeyCode.RightShift] = EnumCommand.OptionMenu;
uiKeyMapper[KeyCode.LeftShift] = EnumCommand.OptionMenu;
if (Application.platform == RuntimePlatform.PSP2)
{
uiKeyMapper[Common.PSVitaKey.Left] = EnumCommand.SelectItemLeft;
uiKeyMapper[Common.PSVitaKey.Right] = EnumCommand.SelectItemRight;
uiKeyMapper[Common.PSVitaKey.Up] = EnumCommand.SelectItemUp;
uiKeyMapper[Common.PSVitaKey.Down] = EnumCommand.SelectItemDown;
uiKeyMapper[Common.PSVitaKey.Circle] = EnumCommand.Enter;
uiKeyMapper[Common.PSVitaKey.Cross] = EnumCommand.Back;
uiKeyMapper[Common.PSVitaKey.Triangle] = EnumCommand.OptionMenu;
}
//PC XBOX
//uiKeyMapper[Common.PC_XBOXKEY.Left] = EnumCommand.SelectItemLeft;
//uiKeyMapper[Common.PSVitaKey.Right] = EnumCommand.SelectItemRight;
//uiKeyMapper[Common.PSVitaKey.Up] = EnumCommand.SelectItemUp;
//uiKeyMapper[Common.PSVitaKey.Down] = EnumCommand.SelectItemDown;
uiKeyMapper[Common.PC_XBOXKEY.MenuBtn] = EnumCommand.Enter;
uiKeyMapper[Common.PC_XBOXKEY.ViewBtn] = EnumCommand.Back;
uiKeyMapper[Common.PC_XBOXKEY.Y] = EnumCommand.OptionMenu;
}
}
}