Escape button with hard/soft escapes based on game state
This commit is contained in:
parent
59744c3eb7
commit
3679c11e41
|
@ -11161,6 +11161,7 @@ RectTransform:
|
|||
m_Children:
|
||||
- {fileID: 1736330635485585599}
|
||||
- {fileID: 2013137394}
|
||||
- {fileID: 1036663867988040668}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
@ -13002,6 +13003,7 @@ MonoBehaviour:
|
|||
m_Script: {fileID: 11500000, guid: 31f8c272002349f4fa1738a050947564, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
EscapeButton: {fileID: 7885933422612942150}
|
||||
_state: 0
|
||||
inMultiplayer: 0
|
||||
lerpSpeed: 4
|
||||
|
@ -14504,6 +14506,123 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
key: CONTINUE_LEAVEMENU
|
||||
--- !u!1 &6112890191110898842
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1036663867988040668}
|
||||
- component: {fileID: 6668250006254791506}
|
||||
- component: {fileID: 1831042773411378553}
|
||||
- component: {fileID: 7885933422612942150}
|
||||
m_Layer: 5
|
||||
m_Name: Escape Button
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1036663867988040668
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6112890191110898842}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1736330635070797289}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||
m_AnchoredPosition: {x: -532, y: -274.6}
|
||||
m_SizeDelta: {x: 82.29, y: 82.29}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!222 &6668250006254791506
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6112890191110898842}
|
||||
m_CullTransparentMesh: 0
|
||||
--- !u!114 &1831042773411378553
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6112890191110898842}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 21300000, guid: 208994dd972b5124bb8d92b4be9e6fa8, type: 3}
|
||||
m_Type: 0
|
||||
m_PreserveAspect: 1
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!114 &7885933422612942150
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 6112890191110898842}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 1831042773411378553}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!1 &6603978597822967378
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
|
|
@ -4,11 +4,45 @@ using UnityEngine;
|
|||
using UnityEngine.EventSystems;
|
||||
using System.Linq;
|
||||
|
||||
public enum GameState { Menu, SinglePlayer, Multiplayer, Lobby, SelectingRegion, ConnectionInProgress, InGame, Continue, Credits }
|
||||
public enum GameState { Menu, SinglePlayer, Multiplayer, Lobby, SelectingRegion, ConnectionInProgress, InGame, Continue, Credits, Help }
|
||||
|
||||
public class GameTransition : MonoBehaviour {
|
||||
|
||||
public static GameTransition Instance { get; private set; }
|
||||
#region Escape
|
||||
public static void Escape() {
|
||||
// Menu, SinglePlayer, Multiplayer, Lobby, SelectingRegion, ConnectionInProgress, InGame, Continue, Credits
|
||||
switch (Instance.state){
|
||||
case GameState.SinglePlayer:
|
||||
case GameState.Multiplayer:
|
||||
case GameState.SelectingRegion:
|
||||
case GameState.Continue:
|
||||
case GameState.InGame:
|
||||
case GameState.Help:
|
||||
// Hard reset states
|
||||
// Blah blah deprecated still works
|
||||
Application.LoadLevel(0);
|
||||
break;
|
||||
|
||||
default:
|
||||
Instance.state = GameState.Menu;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public static bool ShowEscape() {
|
||||
switch(Instance.state) {
|
||||
case GameState.Menu:
|
||||
case GameState.Lobby:
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public UnityEngine.UI.Button EscapeButton;
|
||||
#endregion
|
||||
|
||||
public static GameTransition Instance { get; private set; }
|
||||
|
||||
[SerializeField]
|
||||
private GameState _state;
|
||||
|
@ -87,6 +121,8 @@ public class GameTransition : MonoBehaviour {
|
|||
}
|
||||
|
||||
private void Start() {
|
||||
if (EscapeButton) EscapeButton.onClick.AddListener(Escape);
|
||||
|
||||
baseCamera = Camera.main;
|
||||
baseCameraOrthoSize = baseCamera.orthographicSize;
|
||||
|
||||
|
@ -98,6 +134,15 @@ public class GameTransition : MonoBehaviour {
|
|||
}
|
||||
|
||||
private void Update() {
|
||||
// Escape handling
|
||||
if (state != GameState.Menu) {
|
||||
if (Input.GetKey(KeyCode.Escape)) {
|
||||
Escape();
|
||||
}
|
||||
}
|
||||
|
||||
if (EscapeButton)
|
||||
EscapeButton.gameObject.SetActive(ShowEscape());
|
||||
|
||||
if (inMultiplayer){
|
||||
switch(NetworkManager.net.State){
|
||||
|
|
Loading…
Reference in New Issue