master
sangta 2024-04-26 13:57:30 +07:00
parent 5867753b75
commit 9a63ea394c
16 changed files with 840 additions and 88 deletions

View File

@ -2057,8 +2057,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: -472} m_AnchoredPosition: {x: -0.0059528, y: -337}
m_SizeDelta: {x: 826.54, y: 132} m_SizeDelta: {x: 965.41, y: 149}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &636098796 --- !u!114 &636098796
MonoBehaviour: MonoBehaviour:
@ -2109,17 +2109,17 @@ MonoBehaviour:
m_OnCullStateChanged: m_OnCullStateChanged:
m_PersistentCalls: m_PersistentCalls:
m_Calls: [] m_Calls: []
m_text: <bounce>Wait For Gift...</bounce> m_text: <bounce>Please wait while the system selects your reward</bounce>
m_isRightToLeft: 0 m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_fontAsset: {fileID: 11400000, guid: 2e498d1c8094910479dc3e1b768306a4, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2} m_sharedMaterial: {fileID: 2180264, guid: 2e498d1c8094910479dc3e1b768306a4, type: 2}
m_fontSharedMaterials: [] m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0} m_fontMaterial: {fileID: 0}
m_fontMaterials: [] m_fontMaterials: []
m_fontColor32: m_fontColor32:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4278232063
m_fontColor: {r: 1, g: 1, b: 1, a: 1} m_fontColor: {r: 1, g: 0.6392157, b: 0, a: 1}
m_enableVertexGradient: 0 m_enableVertexGradient: 0
m_colorMode: 3 m_colorMode: 3
m_fontColorGradient: m_fontColorGradient:
@ -2131,18 +2131,18 @@ MonoBehaviour:
m_spriteAsset: {fileID: 0} m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0 m_tintAllSprites: 0
m_StyleSheet: {fileID: 0} m_StyleSheet: {fileID: 0}
m_TextStyleHashCode: 2426 m_TextStyleHashCode: -1183493901
m_overrideHtmlColors: 0 m_overrideHtmlColors: 0
m_faceColor: m_faceColor:
serializedVersion: 2 serializedVersion: 2
rgba: 4294967295 rgba: 4294967295
m_fontSize: 50 m_fontSize: 80
m_fontSizeBase: 50 m_fontSizeBase: 80
m_fontWeight: 400 m_fontWeight: 400
m_enableAutoSizing: 0 m_enableAutoSizing: 0
m_fontSizeMin: 18 m_fontSizeMin: 18
m_fontSizeMax: 72 m_fontSizeMax: 72
m_fontStyle: 0 m_fontStyle: 1
m_HorizontalAlignment: 2 m_HorizontalAlignment: 2
m_VerticalAlignment: 512 m_VerticalAlignment: 512
m_textAlignment: 65535 m_textAlignment: 65535
@ -4137,8 +4137,8 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 1} m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 1, y: 1} m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 0, y: -63} m_AnchoredPosition: {x: 96.66998, y: -63}
m_SizeDelta: {x: 330.89, y: 50} m_SizeDelta: {x: 137.56, y: 50}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1324683899 --- !u!114 &1324683899
MonoBehaviour: MonoBehaviour:
@ -4194,7 +4194,7 @@ MonoBehaviour:
m_fontSizeMin: 18 m_fontSizeMin: 18
m_fontSizeMax: 72 m_fontSizeMax: 72
m_fontStyle: 1 m_fontStyle: 1
m_HorizontalAlignment: 2 m_HorizontalAlignment: 1
m_VerticalAlignment: 512 m_VerticalAlignment: 512
m_textAlignment: 65535 m_textAlignment: 65535
m_characterSpacing: 0 m_characterSpacing: 0
@ -4223,7 +4223,7 @@ MonoBehaviour:
m_VertexBufferAutoSizeReduction: 0 m_VertexBufferAutoSizeReduction: 0
m_useMaxVisibleDescender: 1 m_useMaxVisibleDescender: 1
m_pageToDisplay: 1 m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0} m_margin: {x: 13.93866, y: 0, z: 0, w: 0}
m_isUsingLegacyAnimationComponent: 0 m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0 m_isVolumetricText: 0
m_hasFontAssetChanged: 0 m_hasFontAssetChanged: 0
@ -4908,7 +4908,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 1, y: 0.5} m_AnchorMin: {x: 1, y: 0.5}
m_AnchorMax: {x: 1, y: 0.5} m_AnchorMax: {x: 1, y: 0.5}
m_AnchoredPosition: {x: -300, y: 0} m_AnchoredPosition: {x: -341, y: 0}
m_SizeDelta: {x: 120, y: 100} m_SizeDelta: {x: 120, y: 100}
m_Pivot: {x: 0, y: 0.5} m_Pivot: {x: 0, y: 0.5}
--- !u!114 &1461246854 --- !u!114 &1461246854
@ -6310,7 +6310,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 1 m_IsActive: 0
--- !u!4 &1805668787 --- !u!4 &1805668787
Transform: Transform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
@ -6490,14 +6490,14 @@ RectTransform:
m_GameObject: {fileID: 1827213707} m_GameObject: {fileID: 1827213707}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.9, y: 0.9, z: 0.9} m_LocalScale: {x: 0.6, y: 0.6, z: 0.6}
m_ConstrainProportionsScale: 1 m_ConstrainProportionsScale: 1
m_Children: [] m_Children: []
m_Father: {fileID: 1691484230} m_Father: {fileID: 1691484230}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: 0, y: 0} m_AnchoredPosition: {x: 0, y: 135}
m_SizeDelta: {x: 1000, y: 1000} m_SizeDelta: {x: 1000, y: 1000}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &1827213709 --- !u!114 &1827213709
@ -7155,7 +7155,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 1} m_AnchorMin: {x: 0.5, y: 1}
m_AnchorMax: {x: 0.5, y: 1} m_AnchorMax: {x: 0.5, y: 1}
m_AnchoredPosition: {x: 0, y: -337} m_AnchoredPosition: {x: 0, y: -278}
m_SizeDelta: {x: 1080, y: 50} m_SizeDelta: {x: 1080, y: 50}
m_Pivot: {x: 0.5, y: 0.5} m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &2012096806 --- !u!114 &2012096806
@ -7187,8 +7187,8 @@ MonoBehaviour:
m_fontMaterials: [] m_fontMaterials: []
m_fontColor32: m_fontColor32:
serializedVersion: 2 serializedVersion: 2
rgba: 4278232063 rgba: 4294967295
m_fontColor: {r: 1, g: 0.6388892, b: 0, a: 1} m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0 m_enableVertexGradient: 0
m_colorMode: 3 m_colorMode: 3
m_fontColorGradient: m_fontColorGradient:
@ -7853,7 +7853,7 @@ MonoBehaviour:
- GadGame.State.GameState.ResumeGameState - GadGame.State.GameState.ResumeGameState
- GadGame.State.GameState.PlayingGameState - GadGame.State.GameState.PlayingGameState
- GadGame.State.GameState.EndGameState - GadGame.State.GameState.EndGameState
GameTime: 30 GameTime: 20
_basket: {fileID: 1254852293} _basket: {fileID: 1254852293}
_lerp: 10 _lerp: 10
_spawnTime: 0.2 _spawnTime: 0.2

View File

@ -5,9 +5,10 @@ using UnityEngine.UI;
namespace GadGame.Manager namespace GadGame.Manager
{ {
public class GameManager : Singleton.Singleton<GameManager> public class GameManager : Singleton.Singleton<GameManager>
{ {
public bool Playing {get; private set;}
private int _score; private int _score;
public int Score => _score; public int Score => _score;
public event Action OnEnd; public event Action OnEnd;
@ -22,6 +23,15 @@ namespace GadGame.Manager
OnScoreUpdate?.Invoke(_score); OnScoreUpdate?.Invoke(_score);
} }
public void StartPlay()
{
Playing = true;
}
public void EndPlay()
{
Playing = false;
}
public void EndGame() public void EndGame()
{ {
OnEnd?.Invoke(); OnEnd?.Invoke();

View File

@ -105,11 +105,12 @@ namespace GadGame.MiniGame
// var inputNormalize = new Vector2(inputData.x/ 200, inputData.y / 480); // var inputNormalize = new Vector2(inputData.x/ 200, inputData.y / 480);
receivedData = UdpSocket.Instance.DataReceived.PosPoints; receivedData = UdpSocket.Instance.DataReceived.PosPoints;
Debug.Log(receivedData); // Debug.Log(receivedData);
for (int i = 0; i < Objects.Length; ++i) for (int i = 0; i < Objects.Length; ++i)
{ {
var inputNormalize = new Vector2((receivedData[i].x - 213.33f)/ 213.33f, receivedData[i].y / 480); var inputNormalize = new Vector2((receivedData[i].x - 213.33f)/ 213.33f, receivedData[i].y / 480);
// Debug.Log(inputNormalize);
if (i == 0) if (i == 0)
{ {
var input = new Vector2 var input = new Vector2

View File

@ -30,7 +30,7 @@ namespace GadGame
_duration -= 100; _duration -= 100;
if (_duration <= 0) if (_duration <= 0)
{ {
Hide(); Hide(true);
} }
} }
_onRun?.Invoke(_duration); _onRun?.Invoke(_duration);
@ -58,7 +58,7 @@ namespace GadGame
PopupUpdate(); PopupUpdate();
} }
public async void Hide() public async void Hide(bool runComplete = false)
{ {
_active = false; _active = false;
_duration = 0; _duration = 0;
@ -67,7 +67,7 @@ namespace GadGame
_canvasGroup.DOComplete(); _canvasGroup.DOComplete();
await _content.DOScale(Vector3.zero, 0.3f).SetUpdate(true); await _content.DOScale(Vector3.zero, 0.3f).SetUpdate(true);
await _canvasGroup.DOFade(0, 0.3f).SetUpdate(true); await _canvasGroup.DOFade(0, 0.3f).SetUpdate(true);
_onComplete?.Invoke(); if(runComplete) _onComplete?.Invoke();
_onComplete = null; _onComplete = null;
_onRun = null; _onRun = null;
} }

View File

@ -10,12 +10,9 @@ namespace GadGame.State.GameState
{ {
public override async void Enter() public override async void Enter()
{ {
// Debug.Log("End Game");
Runner.SetActive(false); Runner.SetActive(false);
await UniTask.Delay(1000); await UniTask.Delay(1000);
Runner.ShowResult(); Runner.ShowResult();
// await UniTask.Delay(5000);
// GameManager.Instance.EndGame();
} }
public override void Update(float time) public override void Update(float time)

View File

@ -1,3 +1,4 @@
using GadGame.Manager;
using GadGame.MiniGame; using GadGame.MiniGame;
using UnityEngine; using UnityEngine;

View File

@ -1,5 +1,6 @@
using UnityEngine; using UnityEngine;
using GadGame.MiniGame; using GadGame.MiniGame;
using GadGame.Manager;
namespace GadGame.State.GameState namespace GadGame.State.GameState
{ {
@ -9,6 +10,7 @@ namespace GadGame.State.GameState
public override void Enter() public override void Enter()
{ {
GameManager.Instance.StartPlay();
Runner.SetActive(true); Runner.SetActive(true);
} }
@ -28,7 +30,7 @@ namespace GadGame.State.GameState
public override void Exit() public override void Exit()
{ {
GameManager.Instance.EndPlay();
} }
} }
} }

View File

@ -1,3 +1,4 @@
using GadGame.Manager;
using GadGame.MiniGame; using GadGame.MiniGame;
using UnityEngine; using UnityEngine;
@ -9,12 +10,11 @@ namespace GadGame.State.GameState
{ {
Debug.Log("Resume Game"); Debug.Log("Resume Game");
Time.timeScale = 1; Time.timeScale = 1;
Runner.SetState<PlayingGameState>();
} }
public override void Update(float time) public override void Update(float time)
{ {
Runner.SetState<PlayingGameState>();
} }
public override void Exit() public override void Exit()

View File

@ -1,4 +1,5 @@
using GadGame.MiniGame; using GadGame.Manager;
using GadGame.MiniGame;
namespace GadGame.State.GameState namespace GadGame.State.GameState
{ {
@ -18,6 +19,10 @@ namespace GadGame.State.GameState
{ {
Runner.PlayerControl(); Runner.PlayerControl();
} }
if(time >= 60) {
GameManager.Instance.EndGame();
}
} }
public override void Exit() public override void Exit()

View File

@ -16,14 +16,12 @@ namespace GadGame.State.MainFlowState
} }
} }
public override void Update(float time) public async override void Update(float time)
{ {
if (time >= 10) if (time >= 10)
{ {
LoadSceneManager.Instance.LoadSceneWithTransition(Runner.SceneFlowConfig.PassByScene.ScenePath);
Runner.SetState<IdleState>(); Runner.SetState<IdleState>();
await LoadSceneManager.Instance.LoadSceneWithTransitionAsync(Runner.SceneFlowConfig.PassByScene.ScenePath);
} }
} }

View File

@ -7,7 +7,6 @@ namespace GadGame.State.MainFlowState
{ {
public class IdleState : State<MainFlow> public class IdleState : State<MainFlow>
{ {
public override void Enter() public override void Enter()
{ {
PassByAnimation.Instance.Play(false); PassByAnimation.Instance.Play(false);
@ -16,7 +15,7 @@ namespace GadGame.State.MainFlowState
public override void Update(float time) public override void Update(float time)
{ {
// if(time < 2) return; if(time < 2) return;
if (UdpSocket.Instance.DataReceived.PassBy) if (UdpSocket.Instance.DataReceived.PassBy)
{ {

View File

@ -15,7 +15,7 @@ namespace GadGame.State.MainFlowState
public override void Update(float time) public override void Update(float time)
{ {
// if(time < 2) return; if(time < 2) return;
if (!UdpSocket.Instance.DataReceived.PassBy) if (!UdpSocket.Instance.DataReceived.PassBy)
{ {
Runner.SetState<IdleState>(); Runner.SetState<IdleState>();

View File

@ -1,3 +1,4 @@
using Cysharp.Threading.Tasks;
using GadGame.Manager; using GadGame.Manager;
using GadGame.Network; using GadGame.Network;
using UnityEngine; using UnityEngine;
@ -21,26 +22,29 @@ namespace GadGame.State.MainFlowState
public override void Update(float time) public override void Update(float time)
{ {
UdpSocket.Instance.SendDataToPython("1"); UdpSocket.Instance.SendDataToPython("1");
// Debug.Log("Playing Game"); if(!GameManager.Instance.Playing) return;
switch (_warned)
{ if(!_warned && !UdpSocket.Instance.DataReceived.Engage) {
case false when !UdpSocket.Instance.DataReceived.Engage: _leaveTimer += Time.deltaTime;
if ( _leaveTimer >= 5)
{ {
_leaveTimer += Time.deltaTime; _warned = true;
if ( _leaveTimer >= 5) _leaveTimer = 0;
{ _gameManager.Pause();
_warned = true; PopupManager.Instance.Show("Where Are You?", 10).OnComplete(OnWaringComplete);
_leaveTimer = 0; CheckPlayBack();
_gameManager.Pause();
PopupManager.Instance.Show("Where Are You?", 10).OnComplete(OnWaringComplete);
}
return;
} }
case true when UdpSocket.Instance.DataReceived.Engage: }
}
public async void CheckPlayBack () {
while(_warned) {
if(UdpSocket.Instance.DataReceived.Engage) {
_warned = false; _warned = false;
_gameManager.Resume(); _gameManager.Resume();
PopupManager.Instance.Hide(); PopupManager.Instance.Hide();
return; }
await UniTask.Yield();
} }
} }
@ -55,20 +59,22 @@ namespace GadGame.State.MainFlowState
Runner.SetState<CTAState>(); Runner.SetState<CTAState>();
} }
private void OnWaringComplete() private async void OnWaringComplete()
{ {
_gameManager.Resume(); _gameManager.Resume();
if(!UdpSocket.Instance.DataReceived.PassBy) await LoadSceneManager.Instance.LoadSceneWithTransitionAsync(Runner.SceneFlowConfig.PassByScene.ScenePath);
{ Runner.SetState<IdleState>();
Runner.SetState<PassByState>(); // if(!UdpSocket.Instance.DataReceived.PassBy)
return; // {
} // Runner.SetState<PassByState>();
// return;
// }
if(!UdpSocket.Instance.DataReceived.Engage) // if(!UdpSocket.Instance.DataReceived.Engage)
{ // {
Runner.SetState<ViewedState>(); // Runner.SetState<ViewedState>();
return; // return;
} // }
// Runner.SetState<EngageState>(); // Runner.SetState<EngageState>();
} }
} }

View File

@ -17,7 +17,7 @@ namespace GadGame.State
#endif #endif
[SerializeField] [SerializeField]
private List<string> _availableStates; private List<string> _availableStates;
private List<State<T>> _states; private List<State<T>> _states = new();
private float _timer; private float _timer;
#if UNITY_EDITOR #if UNITY_EDITOR
@ -36,8 +36,6 @@ namespace GadGame.State
protected virtual void Awake() protected virtual void Awake()
{ {
_states = new List<State<T>>();
foreach (var stateName in _availableStates) foreach (var stateName in _availableStates)
{ {
var stateType = Assembly.GetExecutingAssembly().GetType(stateName); var stateType = Assembly.GetExecutingAssembly().GetType(stateName);

Binary file not shown.

File diff suppressed because one or more lines are too long