Что я сдал
This commit is contained in:
1 parent
24b1157026
commit
a5665f0101
2838 files changed
+129953
-1304
No files matched your search
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad4f1ab999e643ffb712ed4cd51553c7
|
||||
timeCreated: 1777902579
|
||||
@@ -0,0 +1,38 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Audio
|
||||
{
|
||||
public class AudioManager : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private AudioSource musicSource;
|
||||
[SerializeField] private AudioSource playerFXSource;
|
||||
|
||||
[SerializeField] private AudioClip music;
|
||||
[SerializeField] private AudioClip jump;
|
||||
[SerializeField] private AudioClip coin;
|
||||
[SerializeField] private AudioClip powerUp;
|
||||
[SerializeField] private AudioClip gameOver;
|
||||
public static AudioManager Instance { get; private set; }
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
|
||||
musicSource.clip = music;
|
||||
}
|
||||
|
||||
public void PlayJump() => playerFXSource.PlayOneShot(jump);
|
||||
public void PlayCoin() => playerFXSource.PlayOneShot(coin);
|
||||
public void PlayPowerUp() => playerFXSource.PlayOneShot(powerUp);
|
||||
public void PlayGameOver() => musicSource.PlayOneShot(gameOver);
|
||||
|
||||
public void StartMusic()
|
||||
{
|
||||
musicSource.Play();
|
||||
}
|
||||
|
||||
public void StopMusic()
|
||||
{
|
||||
musicSource.Stop();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 75c8b17390584480841466a19553160a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -3
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,64 @@
|
||||
using System.Threading;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.GameplayServices
|
||||
{
|
||||
public class BonusService : MonoBehaviour
|
||||
{
|
||||
public static BonusService Instance { get; private set; }
|
||||
private void Awake()
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
|
||||
public bool CoinBoost { get; private set; }
|
||||
public bool Invincibility { get; private set; }
|
||||
|
||||
|
||||
private CancellationTokenSource _coinBoostCancellationTokenSource;
|
||||
|
||||
public async UniTaskVoid GiveCoinBoost()
|
||||
{
|
||||
if (_coinBoostCancellationTokenSource != null && _coinBoostCancellationTokenSource.Token.CanBeCanceled)
|
||||
_coinBoostCancellationTokenSource.Cancel();
|
||||
|
||||
_coinBoostCancellationTokenSource = new();
|
||||
try
|
||||
{
|
||||
CoinBoost = true;
|
||||
|
||||
await UniTask.WaitForSeconds(5f)
|
||||
.AttachExternalCancellation(_coinBoostCancellationTokenSource.Token);
|
||||
|
||||
CoinBoost = false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
_coinBoostCancellationTokenSource.Dispose();
|
||||
}
|
||||
}
|
||||
private CancellationTokenSource _invincibilityCancellationTokenSource;
|
||||
|
||||
public async UniTaskVoid GiveInvincibility()
|
||||
{
|
||||
if (_invincibilityCancellationTokenSource != null && _invincibilityCancellationTokenSource.Token.CanBeCanceled)
|
||||
_invincibilityCancellationTokenSource.Cancel();
|
||||
|
||||
_invincibilityCancellationTokenSource = new();
|
||||
try
|
||||
{
|
||||
Invincibility = true;
|
||||
|
||||
await UniTask.WaitForSeconds(5f)
|
||||
.AttachExternalCancellation(_invincibilityCancellationTokenSource.Token);
|
||||
|
||||
Invincibility = false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
_invincibilityCancellationTokenSource.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc8b67c863184e58b33bd510cda6493c
|
||||
timeCreated: 1777906697
|
||||
@@ -1,3 +1,8 @@
|
||||
using System.Threading;
|
||||
using Alchemy.Inspector;
|
||||
using Code.Audio;
|
||||
using Code.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.GameplayServices
|
||||
@@ -6,13 +11,21 @@ namespace Code.GameplayServices
|
||||
{
|
||||
public static GameplayManager Instance { get; private set; }
|
||||
|
||||
private bool _onPause;
|
||||
private bool _onPause = true;
|
||||
public bool OnPause => _onPause;
|
||||
|
||||
[TabGroup("Gameplay")]
|
||||
[SerializeField] [Range(0f, 30f)] private float gameSpeed;
|
||||
[TabGroup("Gameplay")]
|
||||
[SerializeField] [Range(0f, 30f)] private float gameSpeedIncrement;
|
||||
|
||||
[TabGroup("UI")]
|
||||
[SerializeField]
|
||||
private RestartPanel restartPanel;
|
||||
|
||||
private float _currentGameSpeed;
|
||||
public float GameSpeed => _currentGameSpeed;
|
||||
private float _incrementedGameSpeed;
|
||||
public float GameSpeed => _currentGameSpeed > 0.1f ? _currentGameSpeed + _incrementedGameSpeed : _currentGameSpeed;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@@ -25,25 +38,51 @@ namespace Code.GameplayServices
|
||||
ResetGame();
|
||||
ResumeGame();
|
||||
}
|
||||
public void PlayerDead()
|
||||
public void PlayerDied()
|
||||
{
|
||||
PauseGame();
|
||||
restartPanel.gameObject.SetActive(true);
|
||||
PlayerScoreService.Instance.ResetScore();
|
||||
AudioManager.Instance.PlayGameOver();
|
||||
}
|
||||
|
||||
public void PauseGame()
|
||||
{
|
||||
_onPause = true;
|
||||
_currentGameSpeed = 0f;
|
||||
AudioManager.Instance.StopMusic();
|
||||
_cycleTokenSource.Cancel();
|
||||
}
|
||||
public void ResumeGame()
|
||||
{
|
||||
_onPause = false;
|
||||
_currentGameSpeed = gameSpeed;
|
||||
AudioManager.Instance.StartMusic();
|
||||
DifficultyCycle().Forget();
|
||||
}
|
||||
|
||||
private void ResetGame()
|
||||
{
|
||||
_incrementedGameSpeed = 0f;
|
||||
PassingObjectsManager.Instance.ResetObjects();
|
||||
PlayerScoreService.Instance.ResetScore();
|
||||
}
|
||||
|
||||
private CancellationTokenSource _cycleTokenSource;
|
||||
private async UniTaskVoid DifficultyCycle()
|
||||
{
|
||||
_cycleTokenSource = new();
|
||||
try
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
await UniTask.WaitForSeconds(10).AttachExternalCancellation(_cycleTokenSource.Token);
|
||||
_incrementedGameSpeed += gameSpeedIncrement;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
_cycleTokenSource.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2cdf72ee53f84d76ab57d0dcd7798e75
|
||||
timeCreated: 1777833499
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -5
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -7,6 +7,39 @@ using Random = UnityEngine.Random;
|
||||
|
||||
namespace Code.GameplayServices
|
||||
{
|
||||
// [OnListViewChanged(
|
||||
// OnItemChanged = nameof(OnPassingObjectsPresetsChanged),
|
||||
// OnItemsAdded = nameof(OnPassingObjectsPresetsAdded),
|
||||
// OnItemsRemoved = nameof(OnPassingObjectsPresetsRemoved),
|
||||
// OnSelectedIndicesChanged = nameof(OnPassingObjectsPresetsIndicesChanged),
|
||||
// OnItemIndexChanged = nameof(OnPassingObjectsPresetsIndexChanged))
|
||||
// ]
|
||||
// public float[] array;
|
||||
//
|
||||
// void OnPassingObjectsPresetsChanged(int index, PassingObjectsPreset item)
|
||||
// {
|
||||
// Debug.Log($"Changed: [{index}] -> {item}");
|
||||
// }
|
||||
//
|
||||
// void OnPassingObjectsPresetsAdded(IEnumerable<int> indices)
|
||||
// {
|
||||
// Debug.Log($"Added: [{string.Join(',', indices)}]");
|
||||
// }
|
||||
//
|
||||
// void OnPassingObjectsPresetsRemoved(IEnumerable<int> indices)
|
||||
// {
|
||||
// Debug.Log($"Removed: [{string.Join(',', indices)}]");
|
||||
// }
|
||||
//
|
||||
// void OnPassingObjectsPresetsIndicesChanged(IEnumerable<int> indices)
|
||||
// {
|
||||
// Debug.Log($"Selected: [{string.Join(',', indices)}]");
|
||||
// }
|
||||
//
|
||||
// void OnPassingObjectsPresetsIndexChanged(int before, int after)
|
||||
// {
|
||||
// Debug.Log($"Index Changed: [{before} -> {after}]");
|
||||
// }
|
||||
public class PassingObjectsManager : MonoBehaviour
|
||||
{
|
||||
[TabGroup("Spawn")] [SerializeField] private List<Transform> spawnPoints;
|
||||
@@ -18,9 +51,43 @@ namespace Code.GameplayServices
|
||||
[TabGroup("Gameplay")] [SerializeField]
|
||||
private float obstacleCooldown;
|
||||
|
||||
[OnListViewChanged(
|
||||
OnItemChanged = nameof(OnPassingObjectsPresetsChanged),
|
||||
OnItemsAdded = nameof(OnPassingObjectsPresetsAdded),
|
||||
OnItemsRemoved = nameof(OnPassingObjectsPresetsRemoved),
|
||||
OnSelectedIndicesChanged = nameof(OnPassingObjectsPresetsIndicesChanged),
|
||||
OnItemIndexChanged = nameof(OnPassingObjectsPresetsIndexChanged))
|
||||
]
|
||||
[TabGroup("Gameplay")] [SerializeField]
|
||||
private List<PassingObjectsPreset> obstaclesPresets;
|
||||
|
||||
|
||||
void OnPassingObjectsPresetsChanged(int index, PassingObjectsPreset item)
|
||||
{
|
||||
float totalChance = 0f;
|
||||
for (var i = 0; i < obstaclesPresets.Count; i++)
|
||||
{
|
||||
if (i == index) continue;
|
||||
totalChance += obstaclesPresets[i].chance;
|
||||
}
|
||||
|
||||
if(item.chance > 1 - totalChance) item.chance = 1 - totalChance;
|
||||
}
|
||||
|
||||
void OnPassingObjectsPresetsAdded(IEnumerable<int> indices)
|
||||
{
|
||||
}
|
||||
|
||||
void OnPassingObjectsPresetsRemoved(IEnumerable<int> indices)
|
||||
{
|
||||
}
|
||||
|
||||
void OnPassingObjectsPresetsIndicesChanged(IEnumerable<int> indices)
|
||||
{
|
||||
}
|
||||
|
||||
void OnPassingObjectsPresetsIndexChanged(int before, int after)
|
||||
{
|
||||
}
|
||||
private List<GameObject> _spawnedObjects = new();
|
||||
public float BehindPlayerThreshold => behindPlayerThreshold;
|
||||
public static PassingObjectsManager Instance { get; private set; }
|
||||
@@ -62,6 +129,7 @@ namespace Code.GameplayServices
|
||||
if (prefabs.Count == 0 && obstaclesPresets.Count > 0) return;
|
||||
|
||||
var presetId = Random.Range(0, obstaclesPresets.Count);
|
||||
var chance = Random.Range(0,1f);
|
||||
|
||||
_spawnedObjects.Add(
|
||||
Instantiate(
|
||||
@@ -87,5 +155,7 @@ namespace Code.GameplayServices
|
||||
public int prefabId1;
|
||||
public int prefabId2;
|
||||
public int prefabId3;
|
||||
[Range(0,1f)]
|
||||
public float chance;
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 95f7cf3ef95244ca9903d804eb9463d7
|
||||
timeCreated: 1777828525
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -10
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,3 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using Code.UI;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
@@ -5,10 +7,21 @@ namespace Code.GameplayServices
|
||||
{
|
||||
public class PlayerScoreService : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Text scoreText;
|
||||
|
||||
private int _score;
|
||||
[SerializeField] private ScoreTable scoreTable;
|
||||
|
||||
public void ShowScoreTable()
|
||||
{
|
||||
scoreTable.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
[SerializeField] private TMP_Text scoreText;
|
||||
[SerializeField] private TMP_Text playerNameText;
|
||||
|
||||
private List<ScoreData> _scores = new();
|
||||
public List<ScoreData> Scores => _scores;
|
||||
private int _score;
|
||||
private string _playerName;
|
||||
|
||||
public static PlayerScoreService Instance { get; private set; }
|
||||
public int Score => _score;
|
||||
|
||||
@@ -19,7 +32,7 @@ namespace Code.GameplayServices
|
||||
|
||||
public void AddScore(int score)
|
||||
{
|
||||
_score += score;
|
||||
_score += BonusService.Instance.CoinBoost ? score * 2 : score;
|
||||
UpdateScoreTextWithScoreValue();
|
||||
}
|
||||
|
||||
@@ -30,8 +43,30 @@ namespace Code.GameplayServices
|
||||
|
||||
public void ResetScore()
|
||||
{
|
||||
_scores.Add(new ScoreData(_playerName, _score));
|
||||
|
||||
_score = 0;
|
||||
// _playerName = string.Empty;
|
||||
|
||||
scoreText.text = _score.ToString();
|
||||
}
|
||||
|
||||
public void SetPlayerName(string playerName)
|
||||
{
|
||||
_playerName = playerName;
|
||||
playerNameText.text = _playerName;
|
||||
}
|
||||
}
|
||||
|
||||
public struct ScoreData
|
||||
{
|
||||
public string name;
|
||||
public int score;
|
||||
|
||||
public ScoreData(string name, int score)
|
||||
{
|
||||
this.name = name;
|
||||
this.score = score;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1e330c677aa54ef6a017e7bab9ebd104
|
||||
timeCreated: 1777831807
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -20
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using Code.Audio;
|
||||
using Code.GameplayServices;
|
||||
using LitMotion;
|
||||
using LitMotion.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.PassingObjects
|
||||
@@ -7,11 +10,32 @@ namespace Code.PassingObjects
|
||||
public class Coin : PassingObject
|
||||
{
|
||||
[SerializeField] private int countOnActivate;
|
||||
private MotionHandle _movementAnim;
|
||||
private MotionHandle _rotationAnim;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
PlayerScoreService.Instance.AddScore(countOnActivate);
|
||||
AudioManager.Instance.PlayCoin();
|
||||
|
||||
PassingObjectsManager.Instance.KillChild(this);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_rotationAnim = LMotion.Create(Quaternion.Euler(0,0,0), Quaternion.Euler(0,180,0), 2)
|
||||
.WithLoops(123)
|
||||
.BindToRotation(transform);
|
||||
|
||||
_movementAnim = LMotion.Create(0.5f, 1.5f, 2)
|
||||
.WithLoops(123, LoopType.Yoyo)
|
||||
.BindToPositionY(transform);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
_rotationAnim.Cancel();
|
||||
_movementAnim.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
using Code.Audio;
|
||||
using Code.GameplayServices;
|
||||
using LitMotion;
|
||||
using LitMotion.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.PassingObjects
|
||||
{
|
||||
public class CoinBooster : PassingObject
|
||||
{
|
||||
private MotionHandle _movementAnim;
|
||||
private MotionHandle _rotationAnim;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
BonusService.Instance.GiveCoinBoost().Forget();
|
||||
AudioManager.Instance.PlayPowerUp();
|
||||
|
||||
PassingObjectsManager.Instance.KillChild(this);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_rotationAnim = LMotion.Create(Quaternion.Euler(0,0,0), Quaternion.Euler(0,180,0), 1)
|
||||
.WithLoops(123)
|
||||
.BindToRotation(transform);
|
||||
|
||||
_movementAnim = LMotion.Create(0.5f, 1.5f, 1)
|
||||
.WithLoops(123, LoopType.Yoyo)
|
||||
.BindToPositionY(transform);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
_rotationAnim.Cancel();
|
||||
_movementAnim.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 633c0357f80e4e53a0fc9410a2a40405
|
||||
timeCreated: 1777906076
|
||||
@@ -0,0 +1,39 @@
|
||||
using Code.Audio;
|
||||
using Code.GameplayServices;
|
||||
using LitMotion;
|
||||
using LitMotion.Extensions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.PassingObjects
|
||||
{
|
||||
public class InvincibilityPowerUp : PassingObject
|
||||
{
|
||||
private MotionHandle _movementAnim;
|
||||
private MotionHandle _rotationAnim;
|
||||
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
BonusService.Instance.GiveInvincibility().Forget();
|
||||
AudioManager.Instance.PlayPowerUp();
|
||||
|
||||
PassingObjectsManager.Instance.KillChild(this);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_rotationAnim = LMotion.Create(Quaternion.Euler(0,0,0), Quaternion.Euler(0,180,0), 1)
|
||||
.WithLoops(123)
|
||||
.BindToRotation(transform);
|
||||
|
||||
_movementAnim = LMotion.Create(0.5f, 1.5f, 1)
|
||||
.WithLoops(123, LoopType.Yoyo)
|
||||
.BindToPositionY(transform);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
_rotationAnim.Cancel();
|
||||
_movementAnim.Cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f29fbb59e114a04a60fb0fd883b70c1
|
||||
timeCreated: 1777907203
|
||||
@@ -5,6 +5,10 @@ namespace Code.PassingObjects
|
||||
{
|
||||
public class Wall : PassingObject
|
||||
{
|
||||
private void OnTriggerEnter(Collider other) => GameplayManager.Instance.PlayerDead();
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
if (!BonusService.Instance.Invincibility) GameplayManager.Instance.PlayerDied();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,9 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using Alchemy.Inspector;
|
||||
using Code.Audio;
|
||||
using LitMotion;
|
||||
using LitMotion.Extensions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
@@ -5,12 +11,26 @@ namespace Code.Player
|
||||
{
|
||||
public class Player : MonoBehaviour
|
||||
{
|
||||
private static readonly int OnGround = Animator.StringToHash("OnGround");
|
||||
|
||||
[TabGroup("Movement")]
|
||||
[SerializeField] private Transform[] runPositions = new Transform[3];
|
||||
|
||||
[TabGroup("Movement")]
|
||||
[SerializeField] private float jumpStrength;
|
||||
|
||||
[TabGroup("Movement")]
|
||||
[SerializeField] private float sideSpeed;
|
||||
|
||||
[TabGroup("Movement")]
|
||||
[SerializeField] private LayerMask groundMask;
|
||||
|
||||
private Animator _animator;
|
||||
private Rigidbody _rigidbody;
|
||||
private void Awake()
|
||||
{
|
||||
_rigidbody = GetComponent<Rigidbody>();
|
||||
_animator = GetComponentInChildren<Animator>();
|
||||
|
||||
InputSystem.actions.actionMaps[0].actions[0].performed += Jump;
|
||||
InputSystem.actions.actionMaps[0].actions[1].performed += MoveRight;
|
||||
@@ -26,7 +46,10 @@ namespace Code.Player
|
||||
|
||||
private void Jump(InputAction.CallbackContext context)
|
||||
{
|
||||
if(!_onGround) return;
|
||||
|
||||
_rigidbody.AddForce(new(0,jumpStrength,0), ForceMode.Impulse);
|
||||
AudioManager.Instance.PlayJump();
|
||||
}
|
||||
|
||||
private int _currentTarget = 1;
|
||||
@@ -41,9 +64,28 @@ namespace Code.Player
|
||||
ChangePosition();
|
||||
}
|
||||
|
||||
private MotionHandle _sideMotion;
|
||||
private bool _onGround;
|
||||
private Collider[] _overlapResults = new Collider[1];
|
||||
|
||||
private void ChangePosition()
|
||||
{
|
||||
transform.position = runPositions[_currentTarget].position;
|
||||
if(_sideMotion.IsActive()) _sideMotion.Cancel();
|
||||
|
||||
_sideMotion = LMotion
|
||||
.Create(transform.position.x, runPositions[_currentTarget].position.x, sideSpeed)
|
||||
.WithEase(Ease.Linear)
|
||||
.BindToPositionX(transform);
|
||||
// transform.position = runPositions[_currentTarget].position;
|
||||
}
|
||||
|
||||
|
||||
private void FixedUpdate()
|
||||
{
|
||||
var groundedCheck = Physics.OverlapSphereNonAlloc(transform.position, 1f, _overlapResults, groundMask);
|
||||
|
||||
_onGround = groundedCheck > 0;
|
||||
_animator.SetBool(OnGround, _onGround);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
using System;
|
||||
using Code.GameplayServices;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.UI
|
||||
{
|
||||
public class PlayerNameSetter : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_InputField playerNameInput;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
playerNameInput.onSubmit.AddListener(PlayerScoreService.Instance.SetPlayerName);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
playerNameInput.onSubmit.RemoveListener(PlayerScoreService.Instance.SetPlayerName);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1f4db2b26d88412b866130c8c56de6a3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 500
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,4 +1,3 @@
|
||||
using System;
|
||||
using Code.GameplayServices;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
@@ -9,16 +8,22 @@ namespace Code.UI
|
||||
public class RestartPanel : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button restartButton;
|
||||
[SerializeField] private Button showScoresPanel;
|
||||
[SerializeField] private ScoreTable scoreTable;
|
||||
[SerializeField] private TMP_Text scoreText;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
restartButton.onClick.AddListener(RestartGame);
|
||||
showScoresPanel.onClick.AddListener(PlayerScoreService.Instance.ShowScoreTable);
|
||||
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
restartButton.onClick.RemoveListener(RestartGame);
|
||||
showScoresPanel.onClick.RemoveListener(PlayerScoreService.Instance.ShowScoreTable);
|
||||
}
|
||||
|
||||
private void OnEnable()
|
||||
@@ -31,6 +36,10 @@ namespace Code.UI
|
||||
scoreText.text = PlayerScoreService.Instance.Score.ToString();
|
||||
}
|
||||
|
||||
private void RestartGame() => GameplayManager.Instance.RestartGame();
|
||||
private void RestartGame()
|
||||
{
|
||||
GameplayManager.Instance.RestartGame();
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
using Code.GameplayServices;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.UI
|
||||
{
|
||||
public class ScoreDataView : MonoBehaviour
|
||||
{
|
||||
private ScoreData _scoreData;
|
||||
[SerializeField] private TMP_Text playerName;
|
||||
[SerializeField] private TMP_Text score;
|
||||
|
||||
public void SetScoreData(ScoreData scoreData)
|
||||
{
|
||||
_scoreData = scoreData;
|
||||
score.text = _scoreData.score.ToString();
|
||||
playerName.text = _scoreData.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4062cee3c2574cf5a585fe6a1ad09955
|
||||
timeCreated: 1777911875
|
||||
@@ -0,0 +1,46 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Code.GameplayServices;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Code.UI
|
||||
{
|
||||
public class ScoreTable : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Transform scoreDataBox;
|
||||
[SerializeField] private ScoreDataView scoreDataPrefab;
|
||||
[SerializeField] private Button exitButton;
|
||||
private List<ScoreDataView> _scoreDataViews = new();
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
exitButton.onClick.AddListener(HideTable);
|
||||
HideTable();
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
exitButton.onClick.RemoveListener(HideTable);
|
||||
}
|
||||
|
||||
private void HideTable() => gameObject.SetActive(false);
|
||||
private void OnEnable()
|
||||
{
|
||||
foreach (var score in PlayerScoreService.Instance.Scores)
|
||||
{
|
||||
var scoreData = Instantiate(scoreDataPrefab, scoreDataBox);
|
||||
scoreData.SetScoreData(score);
|
||||
_scoreDataViews.Add(scoreData);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
foreach (var scoreDataView in _scoreDataViews)
|
||||
{
|
||||
Destroy(scoreDataView.gameObject);
|
||||
}
|
||||
_scoreDataViews.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 070b229c264246378695676272843220
|
||||
timeCreated: 1777911495
|
||||
@@ -0,0 +1,27 @@
|
||||
using Code.GameplayServices;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Code.UI
|
||||
{
|
||||
public class StartGamePanel : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button startGameButton;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
startGameButton.onClick.AddListener(RestartGame);
|
||||
}
|
||||
|
||||
private void RestartGame()
|
||||
{
|
||||
GameplayManager.Instance.RestartGame();
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
startGameButton.onClick.RemoveListener(RestartGame);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 28b1b2220c4e4b2bbd9066886e8c0765
|
||||
timeCreated: 1777891400
|
||||
Reference in new issue
Block a user