add change trains
This commit is contained in:
@@ -3,7 +3,6 @@ using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class InputHandler : MonoBehaviour, IGameComponent
|
||||
{
|
||||
@@ -15,7 +14,6 @@ public class InputHandler : MonoBehaviour, IGameComponent
|
||||
w
|
||||
}
|
||||
|
||||
private Controls inputSystem;
|
||||
private Transform cameraTransform;
|
||||
|
||||
private float X0;
|
||||
@@ -42,34 +40,18 @@ public class InputHandler : MonoBehaviour, IGameComponent
|
||||
|
||||
void Awake()
|
||||
{
|
||||
inputSystem = new Controls();
|
||||
cameraTransform = transform;
|
||||
}
|
||||
|
||||
void Start()
|
||||
{
|
||||
GameSystem.Instance.AddGameComponent(this);
|
||||
}
|
||||
|
||||
void OnEnable()
|
||||
{
|
||||
inputSystem.Enable();
|
||||
InputSystem.EnableDevice(UnityEngine.InputSystem.AttitudeSensor.current);
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
InputSystem.DisableDevice(UnityEngine.InputSystem.AttitudeSensor.current);
|
||||
inputSystem.Disable();
|
||||
Input.gyro.enabled = true;
|
||||
}
|
||||
|
||||
public void OnUpdate()
|
||||
{
|
||||
var phoneRotation = inputSystem
|
||||
.Rotation
|
||||
.Gyroscope
|
||||
.ReadValue<Quaternion>();
|
||||
|
||||
var phoneRotation = Input.gyro.attitude;
|
||||
cameraTransform.rotation = phoneRotation;
|
||||
|
||||
cameraTransform.Rotate(0, 0, 180, Space.Self);
|
||||
|
||||
@@ -22,7 +22,6 @@ public class LocomotionHandler : MonoBehaviour
|
||||
public float pullUpPositionBefore;
|
||||
public float pullUpPositionAfter;
|
||||
|
||||
public readonly float pullUpPosition = -12;
|
||||
private Coroutine c_effect;
|
||||
|
||||
void Update()
|
||||
|
||||
@@ -33,16 +33,18 @@ public class QRCodeReader : MonoBehaviour
|
||||
{
|
||||
for(int i = 0; i < devices.Length; i++)
|
||||
{
|
||||
if(Application.platform == RuntimePlatform.Android && !devices[i].isFrontFacing)
|
||||
{
|
||||
backCameraEnabled = true;
|
||||
backCameraIDs.Add(i);
|
||||
}
|
||||
else
|
||||
if(Application.platform == RuntimePlatform.WindowsEditor)
|
||||
{
|
||||
backCameraEnabled = true;
|
||||
backCameraId = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(devices[i].isFrontFacing) continue;
|
||||
|
||||
backCameraEnabled = true;
|
||||
backCameraIDs.Add(i);
|
||||
}
|
||||
}
|
||||
|
||||
if(backCameraIDs.Count != 0)
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
||||
public class SceneHandler : MonoBehaviour
|
||||
{
|
||||
@@ -12,6 +13,8 @@ public class SceneHandler : MonoBehaviour
|
||||
[SerializeField] float endPositionValue;
|
||||
[Space]
|
||||
[SerializeField] GameObject[] disableOnStart;
|
||||
[Space]
|
||||
[SerializeField] UnityEvent OnSceneLoaded;
|
||||
|
||||
async Task Start()
|
||||
{
|
||||
@@ -56,5 +59,7 @@ public class SceneHandler : MonoBehaviour
|
||||
|
||||
foreach(var item in disableOnStart)
|
||||
item.SetActive(true);
|
||||
|
||||
OnSceneLoaded?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ public class Train : MonoBehaviour
|
||||
transform.localPosition.y,
|
||||
startPosition);
|
||||
|
||||
transform.DOLocalMoveZ(0, speed)
|
||||
transform.DOLocalMoveZ(-4, speed)
|
||||
.SetEase(Ease.OutSine);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(CanvasGroup))]
|
||||
public class UICanvas : MonoBehaviour
|
||||
{
|
||||
CanvasGroup canvasGroup;
|
||||
|
||||
void Start()
|
||||
{
|
||||
canvasGroup = GetComponent<CanvasGroup>();
|
||||
}
|
||||
|
||||
public void Show()
|
||||
{
|
||||
canvasGroup.DOFade(1, .2f);
|
||||
}
|
||||
|
||||
public void Hide()
|
||||
{
|
||||
canvasGroup.DOFade(0, .2f);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 61721c236a4d3b543b400668e74b0e01
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(CanvasGroup))]
|
||||
public class UIHelp : MonoBehaviour
|
||||
{
|
||||
private CanvasGroup canvasGroup;
|
||||
|
||||
void Start()
|
||||
{
|
||||
canvasGroup = GetComponent<CanvasGroup>();
|
||||
}
|
||||
|
||||
public void OK()
|
||||
{
|
||||
canvasGroup.DOFade(0, .4f)
|
||||
.OnComplete(() => gameObject.SetActive(false));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3916a130b9d6de34693655c7f23d3095
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
||||
using DG.Tweening;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
[RequireComponent(typeof(Image))]
|
||||
public class UITrainButton : MonoBehaviour, IPointerClickHandler
|
||||
{
|
||||
public TrainType trainType;
|
||||
[SerializeField] private Color selectedColor;
|
||||
private Image buttonBase;
|
||||
public bool isSelected { get; private set; }
|
||||
|
||||
LocomotionHandler locomotionHandler;
|
||||
|
||||
void Start()
|
||||
{
|
||||
buttonBase = GetComponent<Image>();
|
||||
locomotionHandler = FindObjectOfType<LocomotionHandler>();
|
||||
}
|
||||
|
||||
public void Select()
|
||||
{
|
||||
if(isSelected) return;
|
||||
|
||||
var buttons = FindObjectsOfType<UITrainButton>();
|
||||
foreach(var item in buttons)
|
||||
{
|
||||
if(item.isSelected)
|
||||
item.Unselect();
|
||||
}
|
||||
|
||||
locomotionHandler.ShowTrain(trainType);
|
||||
buttonBase.DOColor(selectedColor, .2f);
|
||||
isSelected = true;
|
||||
}
|
||||
|
||||
public void Unselect()
|
||||
{
|
||||
buttonBase.DOColor(Color.white, .2f);
|
||||
isSelected = false;
|
||||
}
|
||||
|
||||
public void OnPointerClick(PointerEventData eventData)
|
||||
{
|
||||
Select();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 25f2335cf2ab55a4aa304e715e838bde
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user