ИИ гонщиков, запуск, перезапуск игры и пр
This commit is contained in:
1 parent
f557c58c9d
commit
efcfaae647
48 files changed
+1486
-212
No files matched your search
@@ -1,8 +1,10 @@
|
||||
using System.Collections.Generic;
|
||||
using Code.Infrastructure.App;
|
||||
using Code.Infrastructure.SceneLoader;
|
||||
using Reflex.Attributes;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Code.Debug
|
||||
{
|
||||
@@ -12,7 +14,7 @@ namespace Code.Debug
|
||||
[Inject] private AppStateMachine _stateMachine;
|
||||
public void ChooseScene(int id)
|
||||
{
|
||||
_sceneLoader.LoadSceneAsync((SceneId)id, LoadSceneMode.Single).Forget();
|
||||
_sceneLoader.LoadSceneAsync((SceneId)id, LoadSceneMode.Additive).Forget();
|
||||
}
|
||||
|
||||
public void ChooseState(int id)
|
||||
@@ -24,5 +26,12 @@ namespace Code.Debug
|
||||
{
|
||||
_stateMachine.SwitchState(AppStates.Gameplay).AllowStateTransition(AppStates.MainMenu);
|
||||
}
|
||||
|
||||
[SerializeField] private List<Button> buttons;
|
||||
|
||||
public void EnableButtons()
|
||||
{
|
||||
foreach (var button in buttons) button.interactable = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,10 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Code.Example.Race.Racer;
|
||||
using Code.Example.Race.Track;
|
||||
using Code.Infrastructure.EventBus;
|
||||
using Code.Infrastructure.Loadings;
|
||||
using Reflex.Attributes;
|
||||
using Code.Infrastructure.Loadings;
|
||||
|
||||
namespace Code.Example.Race
|
||||
{
|
||||
@@ -52,7 +52,7 @@ namespace Code.Example.Race
|
||||
}
|
||||
|
||||
private void RacersLoadCompleted() =>
|
||||
_eventBus.RaiseEvent<IRaceGameInitializedHandle>(x => x.RaceGameReady());
|
||||
_eventBus.RaiseEvent<IRaceGameHandle>(x => x.RaceGameReady());
|
||||
|
||||
public List<Racer.Racer> PlacedRacers { get; } = new();
|
||||
|
||||
@@ -70,7 +70,7 @@ namespace Code.Example.Race
|
||||
|
||||
foreach (var racer in PlacedRacers)
|
||||
{
|
||||
racer.Initialize(_raceTrackData.trackData.Checkpoints);
|
||||
racer.Initialize(_raceTrackData.trackData.Checkpoints.Select(x=> x.transform).ToList());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,23 +84,20 @@ namespace Code.Example.Race
|
||||
|
||||
_raceGameLoading.DoProgress();
|
||||
}
|
||||
|
||||
// private Dictionary<RacerType, Racer.AI.Racer> _spawnedRacers = new();
|
||||
public void RacerCreated(RacerType type, Racer.Racer racer)
|
||||
{
|
||||
// _spawnedRacers.Add(type, racer);
|
||||
// _raceGameLoading.DoProgress();
|
||||
}
|
||||
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
foreach (var racer in PlacedRacers) _scores.UnsubscribeRacer(racer);
|
||||
|
||||
_eventBus.Unsubscribe(this);
|
||||
_racerPrefabs.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
public interface IRaceGameInitializedHandle : IGlobalSubscriber
|
||||
public interface IRaceGameHandle : IGlobalSubscriber
|
||||
{
|
||||
void RaceGameReady();
|
||||
void RaceGameEnded(RaceScores scores);
|
||||
}
|
||||
}
|
||||
@@ -1,14 +1,16 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Code.Example.Race.Racer.Player;
|
||||
using Code.Example.Race.Track;
|
||||
using Code.Infrastructure.EventBus;
|
||||
using Reflex.Attributes;
|
||||
|
||||
namespace Code.Example.Race
|
||||
{
|
||||
public class RaceScores : IRacerPassedCheckpointHandler, IDisposable
|
||||
public class RaceScores : IRacerPassedCheckpointHandler, IDisposable, IPlayerPassedCheckpointHandler
|
||||
{
|
||||
private Dictionary<Racer.Racer, int> _scores = new();
|
||||
private Dictionary<Racer.Racer, ScoreData> _scores = new();
|
||||
private EventBus _eventBus;
|
||||
|
||||
public RaceScores(EventBus eventBus)
|
||||
@@ -16,25 +18,34 @@ namespace Code.Example.Race
|
||||
_eventBus = eventBus;
|
||||
_eventBus.Subscribe(this);
|
||||
}
|
||||
|
||||
public void SubscribeRacer(Racer.Racer racer)
|
||||
{
|
||||
_scores.Add(racer, 0);
|
||||
_scores.Add(racer, new ScoreData());
|
||||
}
|
||||
|
||||
public void ChangeScore(Racer.Racer racer, int additionalScore)
|
||||
{
|
||||
_scores[racer] += additionalScore;
|
||||
_eventBus.RaiseEvent<IScoreChangedHandle>(x=> x.ScoreChanged(racer,additionalScore, GetScores()));
|
||||
_scores[racer].checkpointsPassed += additionalScore;
|
||||
_eventBus.RaiseEvent<IScoreChangedHandle>(x=> x.ScoreChanged(racer,_scores[racer], GetScores()));
|
||||
}
|
||||
|
||||
|
||||
public void LapPassed(Racer.Racer racer)
|
||||
{
|
||||
_scores[racer].lapsPassed++;
|
||||
_eventBus.RaiseEvent<IScoreChangedHandle>(x=> x.ScoreChanged(racer,_scores[racer], GetScores()));
|
||||
if (_scores[racer].lapsPassed >= _raceTrackData.trackData.LapCount)
|
||||
_eventBus.RaiseEvent<IRaceGameHandle>(x=> x.RaceGameEnded(this));
|
||||
}
|
||||
|
||||
public void UnsubscribeRacer(Racer.Racer racer)
|
||||
{
|
||||
_scores.Remove(racer);
|
||||
}
|
||||
|
||||
public List<KeyValuePair<Racer.Racer, int>> GetScores()
|
||||
public List<KeyValuePair<Racer.Racer, ScoreData>> GetScores()
|
||||
{
|
||||
return _scores.OrderByDescending(x => x.Value).ToList();
|
||||
return _scores.OrderByDescending(x => x.Value.checkpointsPassed).ToList();
|
||||
}
|
||||
|
||||
public void OnRacerPassedCheckpoint(Racer.Racer racer) => ChangeScore(racer,1);
|
||||
@@ -43,10 +54,27 @@ namespace Code.Example.Race
|
||||
{
|
||||
_eventBus.Unsubscribe(this);
|
||||
}
|
||||
|
||||
[Inject] private RaceTrackData _raceTrackData;
|
||||
|
||||
public void OnPlayerPassedCheckpoint(Racer.Racer racer)
|
||||
{
|
||||
var player = (PlayerRacer)racer;
|
||||
_raceTrackData.trackData.Checkpoints[player.CurrentWaypointIndex].Show();
|
||||
}
|
||||
|
||||
public void OnPlayerLapPassed(Racer.Racer racer)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
public class ScoreData
|
||||
{
|
||||
public int checkpointsPassed;
|
||||
public int lapsPassed;
|
||||
}
|
||||
public interface IScoreChangedHandle : IGlobalSubscriber
|
||||
{
|
||||
void ScoreChanged(Racer.Racer racer, int additionalScore, List<KeyValuePair<Racer.Racer, int>> scores);
|
||||
void ScoreChanged(Racer.Racer racer, ScoreData score, List<KeyValuePair<Racer.Racer, ScoreData>> scores);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Example.Race.Racer.AI
|
||||
{
|
||||
public class AICarDriver : CarControllerRB
|
||||
{
|
||||
public override void SetSteering(Vector2 steeringLinear)
|
||||
{
|
||||
SteeringInput = steeringLinear;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c82b0db1441e417098bccb9ca1575e3e
|
||||
timeCreated: 1770639201
|
||||
@@ -1,11 +1,16 @@
|
||||
using System.Collections.Generic;
|
||||
using Code.Example.Race.Racer.AI.ID;
|
||||
using Code.Example.Race.Track;
|
||||
using Code.Infrastructure.EventBus;
|
||||
using Reflex.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Example.Race.Racer.AI
|
||||
{
|
||||
public class AIRacerID : Racer
|
||||
{
|
||||
[Inject] private EventBus _eventBus;
|
||||
[SerializeField] private CarControllerRB carController;
|
||||
public override void SetData(RacerData data)
|
||||
{
|
||||
Data = data;
|
||||
@@ -21,9 +26,10 @@ namespace Code.Example.Race.Racer.AI
|
||||
|
||||
public override void NextWaypoint()
|
||||
{
|
||||
if(CurrentWaypointIndex >= Waypoints.Count) CurrentWaypointIndex = 0;
|
||||
if (++CurrentWaypointIndex < Waypoints.Count) return;
|
||||
|
||||
CurrentWaypointIndex++;
|
||||
CurrentWaypointIndex = 0;
|
||||
_eventBus.RaiseEvent<IRacerPassedCheckpointHandler>(x=> x.LapPassed(this));
|
||||
}
|
||||
|
||||
public override void StartRacer()
|
||||
@@ -66,33 +72,38 @@ namespace Code.Example.Race.Racer.AI
|
||||
{
|
||||
if (!_running) return;
|
||||
|
||||
var displacement = _velocity * Time.deltaTime;
|
||||
_orientation += _rotation * Time.deltaTime;
|
||||
_orientation = NormalizeAngle(_orientation);
|
||||
var steering =
|
||||
transform.InverseTransformDirection(
|
||||
agent.GetSteering(Waypoints[CurrentWaypointIndex]).linear);
|
||||
|
||||
transform.Translate(displacement, Space.World);
|
||||
transform.Rotate(Vector3.up, _orientation);
|
||||
carController.SetSteering(new Vector2(steering.x, steering.z));
|
||||
// var displacement = _velocity * Time.deltaTime;
|
||||
// _orientation += _rotation * Time.deltaTime;
|
||||
// _orientation = NormalizeAngle(_orientation);
|
||||
//
|
||||
// transform.Translate(displacement, Space.World);
|
||||
// transform.Rotate(Vector3.up, _orientation);
|
||||
}
|
||||
public virtual void LateUpdate()
|
||||
{
|
||||
if (!_running) return;
|
||||
|
||||
_steering = agent.GetSteering(Waypoints[CurrentWaypointIndex]);
|
||||
|
||||
_velocity += _steering.linear * Time.deltaTime;
|
||||
_rotation += _steering.angular * Time.deltaTime;
|
||||
if (_velocity.magnitude > Data.speed)
|
||||
{
|
||||
_velocity = _velocity.normalized * Data.speed;
|
||||
}
|
||||
if (_steering.angular == 0.0f)
|
||||
{
|
||||
_rotation = 0.0f;
|
||||
}
|
||||
if (_steering.linear.sqrMagnitude == 0.0f)
|
||||
{
|
||||
_velocity = Vector3.zero;
|
||||
}
|
||||
//
|
||||
// _steering = agent.GetSteering(Waypoints[CurrentWaypointIndex]);
|
||||
//
|
||||
// _velocity += _steering.linear * Time.deltaTime;
|
||||
// _rotation += _steering.angular * Time.deltaTime;
|
||||
// if (_velocity.magnitude > Data.speed)
|
||||
// {
|
||||
// _velocity = _velocity.normalized * Data.speed;
|
||||
// }
|
||||
// if (_steering.angular == 0.0f)
|
||||
// {
|
||||
// _rotation = 0.0f;
|
||||
// }
|
||||
// if (_steering.linear.sqrMagnitude == 0.0f)
|
||||
// {
|
||||
// _velocity = Vector3.zero;
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -16,11 +16,6 @@ namespace Code.Example.Race.Racer.AI.ID
|
||||
velocity = Vector3.zero;
|
||||
steering = new Steering();
|
||||
}
|
||||
|
||||
public void SetSteering(Steering steering)
|
||||
{
|
||||
this.steering = steering;
|
||||
}
|
||||
public virtual void Update ()
|
||||
{
|
||||
Vector3 displacement = velocity * Time.deltaTime;
|
||||
|
||||
@@ -9,8 +9,10 @@ namespace Code.Example.Race.Racer.AI.ID.Behaviours
|
||||
Steering steering = new Steering();
|
||||
|
||||
steering.linear = target.position - transform.position;
|
||||
UnityEngine.Debug.DrawRay(transform.position, steering.linear, Color.yellow, 5f);
|
||||
// steering.linear *= agent.Data.maxAcceleration;
|
||||
steering.linear.Normalize();
|
||||
steering.linear *= agent.Data.maxAcceleration;
|
||||
UnityEngine.Debug.Log(steering.linear);
|
||||
return steering;
|
||||
}
|
||||
}
|
||||
|
||||
+46
-43
@@ -1,11 +1,10 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Code.Example.Race.Racer.AI;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Example.Race.Racer.Player
|
||||
namespace Code.Example.Race.Racer
|
||||
{
|
||||
public class PlayerCarControllerRB : MonoBehaviour
|
||||
public abstract class CarControllerRB : MonoBehaviour
|
||||
{
|
||||
public enum ControlMode
|
||||
{
|
||||
@@ -35,30 +34,31 @@ namespace Code.Example.Race.Racer.Player
|
||||
|
||||
public List<Wheel> wheels;
|
||||
|
||||
private Rigidbody carRb;
|
||||
|
||||
[SerializeField] private PlayerCarInput _playerCarInput;
|
||||
[SerializeField] private PlayerRacer _playerRacer;
|
||||
|
||||
protected Rigidbody CarRb;
|
||||
|
||||
protected Vector2 SteeringInput = Vector2.zero;
|
||||
public abstract void SetSteering(Vector2 steeringLinear);
|
||||
|
||||
[SerializeField] protected Racer racer;
|
||||
|
||||
// private CarLights carLights;
|
||||
|
||||
void Start()
|
||||
private void Start()
|
||||
{
|
||||
carRb = GetComponent<Rigidbody>();
|
||||
carRb.centerOfMass = _centerOfMass;
|
||||
CarRb = GetComponent<Rigidbody>();
|
||||
CarRb.centerOfMass = _centerOfMass;
|
||||
|
||||
// carLights = GetComponent<CarLights>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
protected virtual void Update()
|
||||
{
|
||||
// GetInputs();
|
||||
AnimateWheels();
|
||||
// WheelEffects();
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
private void FixedUpdate()
|
||||
{
|
||||
Move();
|
||||
Steer();
|
||||
@@ -84,51 +84,54 @@ namespace Code.Example.Race.Racer.Player
|
||||
// }
|
||||
}
|
||||
|
||||
void Move()
|
||||
private void Move()
|
||||
{
|
||||
foreach (var wheel in wheels)
|
||||
{
|
||||
wheel.wheelCollider.motorTorque = _playerCarInput.MovementInput.y * 600 * _playerRacer.Data.maxAcceleration * Time.fixedDeltaTime;
|
||||
wheel.wheelCollider.motorTorque = SteeringInput.y * 600 * racer.Data.maxAcceleration * Time.fixedDeltaTime;
|
||||
// wheel.wheelCollider.motorTorque = _playerCarInput.MovementInput.y * 600 * _playerRacer.Data.maxAcceleration * Time.fixedDeltaTime;
|
||||
}
|
||||
}
|
||||
|
||||
void Steer()
|
||||
private void Steer()
|
||||
{
|
||||
foreach (var wheel in wheels)
|
||||
{
|
||||
if (wheel.axel != Axel.Front) continue;
|
||||
|
||||
var _steerAngle = _playerCarInput.MovementInput.x * _playerRacer.Data.turnSensitivity * _playerRacer.Data.maxSteerAngle;
|
||||
wheel.wheelCollider.steerAngle = _steerAngle;
|
||||
var steerAngle = SteeringInput.x * racer.Data.turnSensitivity * racer.Data.maxSteerAngle;
|
||||
// var _steerAngle = _playerCarInput.MovementInput.x * _playerRacer.Data.turnSensitivity * _playerRacer.Data.maxSteerAngle;
|
||||
wheel.wheelCollider.steerAngle = steerAngle;
|
||||
// wheel.wheelCollider.steerAngle = Mathf.Lerp(wheel.wheelCollider.steerAngle, _steerAngle, 0.6f);
|
||||
}
|
||||
}
|
||||
|
||||
void Brake()
|
||||
protected virtual void Brake()
|
||||
{
|
||||
if (_playerCarInput.Brake || _playerCarInput.MovementInput.y == 0)
|
||||
{
|
||||
foreach (var wheel in wheels)
|
||||
{
|
||||
wheel.wheelCollider.brakeTorque = 300 * _playerRacer.Data.brakeAcceleration * Time.fixedDeltaTime;
|
||||
}
|
||||
|
||||
// carLights.isBackLightOn = true;
|
||||
// carLights.OperateBackLights();
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var wheel in wheels)
|
||||
{
|
||||
wheel.wheelCollider.brakeTorque = 0;
|
||||
}
|
||||
|
||||
// carLights.isBackLightOn = false;
|
||||
// carLights.OperateBackLights();
|
||||
}
|
||||
//|| _playerCarInput.MovementInput.y == 0
|
||||
// if (_playerCarInput.Brake )
|
||||
// {
|
||||
// foreach (var wheel in wheels)
|
||||
// {
|
||||
// wheel.wheelCollider.brakeTorque = 300 * _racer.Data.brakeAcceleration * Time.fixedDeltaTime;
|
||||
// }
|
||||
//
|
||||
// // carLights.isBackLightOn = true;
|
||||
// // carLights.OperateBackLights();
|
||||
// }
|
||||
// else
|
||||
// {
|
||||
// foreach (var wheel in wheels)
|
||||
// {
|
||||
// wheel.wheelCollider.brakeTorque = 0;
|
||||
// }
|
||||
//
|
||||
// // carLights.isBackLightOn = false;
|
||||
// // carLights.OperateBackLights();
|
||||
// }
|
||||
}
|
||||
|
||||
void AnimateWheels()
|
||||
private void AnimateWheels()
|
||||
{
|
||||
foreach (var wheel in wheels)
|
||||
{
|
||||
@@ -140,14 +143,14 @@ namespace Code.Example.Race.Racer.Player
|
||||
}
|
||||
}
|
||||
|
||||
void WheelEffects()
|
||||
private void WheelEffects()
|
||||
{
|
||||
foreach (var wheel in wheels)
|
||||
{
|
||||
//var dirtParticleMainSettings = wheel.smokeParticle.main;
|
||||
|
||||
if (wheel.axel == Axel.Rear && wheel.wheelCollider.isGrounded &&
|
||||
carRb.linearVelocity.magnitude >= 10.0f)
|
||||
CarRb.linearVelocity.magnitude >= 10.0f)
|
||||
{
|
||||
// wheel.wheelEffectObj.GetComponentInChildren<TrailRenderer>().emitting = true;
|
||||
// wheel.smokeParticle.Emit(1);
|
||||
File renamed without changes.
@@ -0,0 +1,44 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Example.Race.Racer.Player
|
||||
{
|
||||
public class PlayerRBCarController : CarControllerRB
|
||||
{
|
||||
[SerializeField] private PlayerCarInput playerCarInput;
|
||||
|
||||
public override void SetSteering(Vector2 steeringLinear)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
protected override void Update()
|
||||
{
|
||||
SteeringInput = playerCarInput.MovementInput;
|
||||
base.Update();
|
||||
}
|
||||
|
||||
protected override void Brake()
|
||||
{
|
||||
if (playerCarInput.Brake )
|
||||
{
|
||||
foreach (var wheel in wheels)
|
||||
{
|
||||
wheel.wheelCollider.brakeTorque = 300 * racer.Data.brakeAcceleration * Time.fixedDeltaTime;
|
||||
}
|
||||
|
||||
// carLights.isBackLightOn = true;
|
||||
// carLights.OperateBackLights();
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var wheel in wheels)
|
||||
{
|
||||
wheel.wheelCollider.brakeTorque = 0;
|
||||
}
|
||||
|
||||
// carLights.isBackLightOn = false;
|
||||
// carLights.OperateBackLights();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bad2326aa0f24acb9bdfeb5fb7d3d208
|
||||
timeCreated: 1770640123
|
||||
@@ -1,10 +1,15 @@
|
||||
using System.Collections.Generic;
|
||||
using Code.Example.Race.Track;
|
||||
using Code.Infrastructure.EventBus;
|
||||
using Reflex.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Example.Race.Racer.Player
|
||||
{
|
||||
public class PlayerRacer : Racer
|
||||
{
|
||||
[Inject] private EventBus _eventBus;
|
||||
|
||||
public Transform CameraPosition;
|
||||
public override void SetData(RacerData data)
|
||||
{
|
||||
@@ -13,21 +18,26 @@ namespace Code.Example.Race.Racer.Player
|
||||
|
||||
public override void Initialize(List<Transform> waypoints)
|
||||
{
|
||||
|
||||
Waypoints = waypoints;
|
||||
}
|
||||
|
||||
public override void NextWaypoint()
|
||||
{
|
||||
if (++CurrentWaypointIndex < Waypoints.Count) return;
|
||||
|
||||
CurrentWaypointIndex = 0;
|
||||
_eventBus.RaiseEvent<IPlayerPassedCheckpointHandler>(x=> x.OnPlayerLapPassed(this));
|
||||
_eventBus.RaiseEvent<IRacerPassedCheckpointHandler>(x=> x.LapPassed(this));
|
||||
}
|
||||
|
||||
public bool RaceStarted { get; set; }
|
||||
public override void StartRacer()
|
||||
{
|
||||
|
||||
RaceStarted = true;
|
||||
}
|
||||
|
||||
public override void StopRacer()
|
||||
{
|
||||
RaceStarted = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,8 @@ namespace Code.Example.Race.Racer
|
||||
public abstract class Racer : MonoBehaviour
|
||||
{
|
||||
protected List<Transform> Waypoints;
|
||||
protected int CurrentWaypointIndex;
|
||||
|
||||
public int CurrentWaypointIndex { get; protected set; }
|
||||
public RacerData Data { get; protected set; }
|
||||
public int Id { get; set; }
|
||||
public abstract void SetData(RacerData data);
|
||||
|
||||
@@ -56,8 +56,8 @@ namespace Code.Example.Race.Racer
|
||||
_eventBus.RaiseEvent<IRacerLoadedHandle>(x => x.RacerLoaded(racerType, null));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
UnityEngine.Debug.LogWarning($"Racer loaded {racerType}");
|
||||
_racerPrefabsHandle.Add(racerType,
|
||||
Addressables.LoadAssetAsync<GameObject>(_racerConfigs[racerType].prefabReference));
|
||||
|
||||
@@ -76,8 +76,10 @@ namespace Code.Example.Race.Racer
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
UnityEngine.Debug.LogWarning($"Racers released");
|
||||
foreach (var prefab in _racerPrefabsHandle)
|
||||
prefab.Value.Release();
|
||||
_racerPrefabsHandle.Clear();
|
||||
|
||||
_racerConfigsHandle.Release();
|
||||
}
|
||||
@@ -90,7 +92,6 @@ namespace Code.Example.Race.Racer
|
||||
|
||||
public interface IRacerLoadedHandle : IGlobalSubscriber
|
||||
{
|
||||
public void RacerLoaded(RacerType type, Racer racer);
|
||||
public void RacerCreated(RacerType type, Racer racer);
|
||||
public void RacerLoaded(RacerType type, Racer racer);
|
||||
}
|
||||
}
|
||||
@@ -1,24 +1,44 @@
|
||||
using Code.Example.Race.Racer.AI;
|
||||
using Code.Example.Race.Racer;
|
||||
using Code.Infrastructure.EventBus;
|
||||
using Reflex.Attributes;
|
||||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Example.Race.Track
|
||||
{
|
||||
public class CheckPoint : MonoBehaviour
|
||||
{
|
||||
[Inject] private EventBus _eventBus;
|
||||
[SerializeField] private GameObject _checkPointMesh;
|
||||
[SerializeField] private int _id; // Костыль инвалид лестница
|
||||
private void OnTriggerEnter(Collider other)
|
||||
{
|
||||
var racer = other.GetComponent<Racer.Racer>();
|
||||
|
||||
if (racer.CurrentWaypointIndex != _id) return;
|
||||
|
||||
racer.NextWaypoint();
|
||||
|
||||
if (racer.Data.type == RacerType.Player)
|
||||
{
|
||||
Hide();
|
||||
_eventBus.RaiseEvent<IPlayerPassedCheckpointHandler>(h => h.OnPlayerPassedCheckpoint(racer));
|
||||
}
|
||||
|
||||
_eventBus.RaiseEvent<IRacerPassedCheckpointHandler>(h => h.OnRacerPassedCheckpoint(racer));
|
||||
}
|
||||
|
||||
public void Hide() => _checkPointMesh.SetActive(false);
|
||||
public void Show() => _checkPointMesh.SetActive(true);
|
||||
}
|
||||
|
||||
public interface IRacerPassedCheckpointHandler : IGlobalSubscriber
|
||||
{
|
||||
void OnRacerPassedCheckpoint(Racer.Racer racer);
|
||||
void LapPassed(Racer.Racer racer);
|
||||
}
|
||||
public interface IPlayerPassedCheckpointHandler : IGlobalSubscriber
|
||||
{
|
||||
void OnPlayerPassedCheckpoint(Racer.Racer racer);
|
||||
void OnPlayerLapPassed(Racer.Racer racer);
|
||||
}
|
||||
}
|
||||
@@ -13,6 +13,7 @@ namespace Code.Example.Race.Track
|
||||
public struct TrackData
|
||||
{
|
||||
public List<Transform> RacerPoints;
|
||||
public List<Transform> Checkpoints;
|
||||
public List<CheckPoint> Checkpoints;
|
||||
public int LapCount;
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Code.Example.Race.Racer;
|
||||
using Code.Example.Race.Track;
|
||||
using Code.Infrastructure.EventBus;
|
||||
using Code.Infrastructure.UI;
|
||||
using Reflex.Attributes;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Rendering;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Example.Race.UI
|
||||
{
|
||||
@@ -25,24 +22,22 @@ namespace Code.Example.Race.UI
|
||||
public override void Open(Action callback = null)
|
||||
{
|
||||
playerScore.gameObject.SetActive(true);
|
||||
callback?.Invoke();
|
||||
// image.DOColor(shownColor, 1f).onComplete = () => callback?.Invoke();
|
||||
}
|
||||
|
||||
public override void Close(Action callback = null)
|
||||
{
|
||||
playerScore.gameObject.SetActive(true);
|
||||
playerScore.gameObject.SetActive(false);
|
||||
callback?.Invoke();
|
||||
// image.DOColor(hiddenColor, 1f).onComplete += () => callback?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
public void OnRacerPassedCheckpoint(Racer.Racer racer)
|
||||
{
|
||||
}
|
||||
|
||||
public void ScoreChanged(Racer.Racer racer, int additionalScore, List<KeyValuePair<Racer.Racer,int>> scores)
|
||||
public void ScoreChanged(Racer.Racer racer, ScoreData additionalScore, List<KeyValuePair<Racer.Racer,ScoreData>> scores)
|
||||
{
|
||||
// if (racer.Data.type == RacerType.Player)
|
||||
string output = "";
|
||||
foreach (var score in scores) output += $@"{score.Key.Data.name}: {score.Value}\n";
|
||||
foreach (var score in scores) output += $@"{score.Key.Data.name}: {score.Value.lapsPassed} \t {score.Value.checkpointsPassed}\n";
|
||||
playerScore.text = output;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
using System;
|
||||
using Code.Infrastructure.UI;
|
||||
using DG.Tweening;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace Code.Example.Race.UI
|
||||
{
|
||||
public class WinScreen : UIPanel
|
||||
{
|
||||
[SerializeField] private Image image;
|
||||
[SerializeField] private TMP_Text winText;
|
||||
[SerializeField] private Color shownColor;
|
||||
[SerializeField] private Color hiddenColor;
|
||||
|
||||
public void SetText(string text) => winText.text = text;
|
||||
public override void Open(Action callback = null)
|
||||
{
|
||||
image.DOColor(shownColor, 1f).onComplete = () => callback?.Invoke();
|
||||
winText.DOColor(shownColor, 1f).onComplete = () => callback?.Invoke();
|
||||
}
|
||||
|
||||
public override void Close(Action callback = null)
|
||||
{
|
||||
image.DOColor(hiddenColor, 1f).onComplete = () => callback?.Invoke();
|
||||
winText.DOColor(hiddenColor, 1f).onComplete = () => callback?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9093110373134c91b06be09705639ddd
|
||||
timeCreated: 1770455340
|
||||
@@ -22,6 +22,7 @@ namespace Code.Infrastructure.App
|
||||
[Inject] public IAudioFactory AudioFactory { get; set; }
|
||||
[Inject] public IAudioService AudioService { get; set; }
|
||||
[Inject] public IInputService InputService { get; set; }
|
||||
public AppStateMachine StateMachine { get; set; }
|
||||
}
|
||||
|
||||
[Generators.StateMachine(typeof(AppStateMachineContext),typeof(AppStates))]
|
||||
|
||||
@@ -110,6 +110,7 @@ namespace Code.Infrastructure.App
|
||||
container.Resolve<EventBus.EventBus>().Unsubscribe(this);
|
||||
container.Resolve<AppStateMachine>().SwitchState(AppStates.Bootstrap)
|
||||
.AllowStateTransition(AppStates.Gameplay);
|
||||
container.Resolve<AppStateMachineContext>().StateMachine = container.Resolve<AppStateMachine>();
|
||||
}
|
||||
|
||||
public void SceneConfigsLoaded()
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using Code.Debug;
|
||||
using Code.Example.Race;
|
||||
using Code.Example.Race.Racer;
|
||||
using Code.Example.Race.Track;
|
||||
@@ -6,21 +5,24 @@ using Code.Infrastructure.SceneLoader;
|
||||
using Reflex.Core;
|
||||
using Reflex.Enums;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
using Resolution = Reflex.Enums.Resolution;
|
||||
|
||||
namespace Code.Infrastructure.App.SceneInstallers
|
||||
{
|
||||
public class GameplaySceneInstaller : MonoBehaviour, IInstaller
|
||||
{
|
||||
[SerializeField] private RaceTrackData _raceTrackData;
|
||||
[SerializeField] private RaceTrackData raceTrackData;
|
||||
|
||||
public void InstallBindings(ContainerBuilder containerBuilder)
|
||||
{
|
||||
containerBuilder.RegisterType(typeof(RacerFactory), new[] { typeof(IRacerFactory) }, Lifetime.Scoped,
|
||||
Resolution.Lazy);
|
||||
containerBuilder.RegisterType(typeof(RaceScores), Lifetime.Scoped,
|
||||
Resolution.Eager);
|
||||
containerBuilder.RegisterValue(raceTrackData);
|
||||
containerBuilder.RegisterType(typeof(RaceGame), Lifetime.Scoped,
|
||||
Resolution.Lazy);
|
||||
containerBuilder.RegisterValue(_raceTrackData);
|
||||
|
||||
containerBuilder.OnContainerBuilt += PostInstall;
|
||||
}
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Threading;
|
||||
using System.Threading;
|
||||
using Code.Debug;
|
||||
using Code.Infrastructure.Audio;
|
||||
using Code.Infrastructure.Generators;
|
||||
using Code.Infrastructure.UI;
|
||||
@@ -37,7 +38,7 @@ namespace Code.Infrastructure.App.States
|
||||
{
|
||||
if (uiPanelType != UIPanelType.DebugSceneChooser) return;
|
||||
|
||||
Context.UIService.OpenPanel(uiPanelType);
|
||||
Context.UIService.OpenPanel(uiPanelType);
|
||||
}
|
||||
public void OnReadyToPlay(AudioNames groupName)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using System.Linq;
|
||||
using Code.Example.Race;
|
||||
using Code.Example.Race.Racer;
|
||||
using Code.Example.Race.Racer.AI;
|
||||
using Code.Example.Race.Racer.Player;
|
||||
using Code.Example.Race.Track;
|
||||
using Code.Example.Race.UI;
|
||||
using Code.Infrastructure.Audio;
|
||||
using Code.Infrastructure.Camera;
|
||||
using Code.Infrastructure.Camera.CameraStates;
|
||||
@@ -11,6 +13,7 @@ using Code.Infrastructure.Input;
|
||||
using Code.Infrastructure.Loadings;
|
||||
using Code.Infrastructure.SceneLoader;
|
||||
using Code.Infrastructure.UI;
|
||||
using Cysharp.Threading.Tasks;
|
||||
using Reflex.Core;
|
||||
using Reflex.Injectors;
|
||||
using Unity.Cinemachine;
|
||||
@@ -22,7 +25,7 @@ namespace Code.Infrastructure.App.States
|
||||
[StateRaisingEvent]
|
||||
public partial class GameplayState :
|
||||
IOnGameplaySceneLoadedHandler,
|
||||
IRaceGameInitializedHandle,
|
||||
IRaceGameHandle,
|
||||
IRacerFactoryInitializedHandle,
|
||||
IUIPanelLoaded,
|
||||
ICinematicMachineHandle
|
||||
@@ -44,10 +47,12 @@ namespace Code.Infrastructure.App.States
|
||||
// RaceGame
|
||||
// Factory
|
||||
// PlayerCounter
|
||||
// WinScreen
|
||||
// CinemachineCamera
|
||||
_gameplayLoading = new Loading(5, GameplayLoadingCompleted);
|
||||
_gameplayLoading = new Loading(6, GameplayLoadingCompleted);
|
||||
|
||||
Context.UIService.TryLoadPanel(UIPanelType.PlayerScoreCounter);
|
||||
Context.UIService.TryLoadPanel(UIPanelType.WinScreen);
|
||||
Context.SceneLoader.LoadSceneAsync(SceneId.Gameplay, LoadSceneMode.Single).Forget();
|
||||
Context.InputService.EnableMap(ActionMappings.Gameplay);
|
||||
Context.CameraFactory.LoadCinemachineCamera(CameraMode.ThirdPerson).Forget();
|
||||
@@ -75,7 +80,12 @@ namespace Code.Infrastructure.App.States
|
||||
{
|
||||
Context.InputService.DisableMap(ActionMappings.Gameplay);
|
||||
Context.UIService.TryRemovePanel(UIPanelType.PlayerScoreCounter);
|
||||
Context.UIService.TryRemovePanel(UIPanelType.WinScreen);
|
||||
Context.CameraFactory.ReleaseCinemachineCamera(CameraMode.ThirdPerson);
|
||||
Context.InputService.DisableMap(ActionMappings.Gameplay);
|
||||
|
||||
_raceGame = null;
|
||||
|
||||
EventBus.Unsubscribe(this);
|
||||
}
|
||||
|
||||
@@ -105,17 +115,50 @@ namespace Code.Infrastructure.App.States
|
||||
_gameplayLoading.DoProgress();
|
||||
}
|
||||
|
||||
public void RaceGameEnded(RaceScores scores)
|
||||
{
|
||||
var winScreen = (WinScreen)Context.UIService.TryGetPanel(UIPanelType.WinScreen);
|
||||
|
||||
var id = 0;
|
||||
var cachedScores = scores.GetScores();
|
||||
|
||||
for (var i = 0; i < cachedScores.Count; i++)
|
||||
if (cachedScores[i].Key.Data.type == RacerType.Player) id = i + 1;
|
||||
|
||||
var winText = $@"{id} МЕСТО\n";
|
||||
winScreen.SetText(winText);
|
||||
|
||||
Context.UIService.ClosePanel(UIPanelType.PlayerScoreCounter);
|
||||
Context.UIService.OpenPanel(UIPanelType.WinScreen);
|
||||
|
||||
EndTheGame().Forget();
|
||||
}
|
||||
|
||||
private async UniTaskVoid EndTheGame()
|
||||
{
|
||||
await UniTask.WaitForSeconds(3f);
|
||||
|
||||
Context.UIService.OpenPanel(UIPanelType.Loading);
|
||||
Context.StateMachine.SwitchState(AppStates.MainMenu).AllowStateTransition(AppStates.Gameplay);
|
||||
}
|
||||
|
||||
public void RacerFactoryInitialized()
|
||||
{
|
||||
_raceGame = (RaceGame)ConstructorInjector.Construct(typeof(RaceGame), UNTILTHEYFIXCONTAINERS);
|
||||
_raceGame = UNTILTHEYFIXCONTAINERS.Resolve<RaceGame>();
|
||||
|
||||
_gameplayLoading.DoProgress();
|
||||
}
|
||||
|
||||
public void UILoaded(UIPanelType uiPanelType)
|
||||
{
|
||||
if(uiPanelType == UIPanelType.WinScreen)
|
||||
{
|
||||
_gameplayLoading.DoProgress();
|
||||
return;
|
||||
}
|
||||
|
||||
if (uiPanelType != UIPanelType.PlayerScoreCounter) return;
|
||||
|
||||
|
||||
Context.UIService.OpenPanel(UIPanelType.PlayerScoreCounter);
|
||||
_gameplayLoading.DoProgress();
|
||||
}
|
||||
|
||||
@@ -1,22 +1,74 @@
|
||||
using Code.Debug;
|
||||
using Code.Infrastructure.Audio;
|
||||
using Code.Infrastructure.Generators;
|
||||
using Code.Infrastructure.Loadings;
|
||||
using Code.Infrastructure.SceneLoader;
|
||||
using Code.Infrastructure.UI;
|
||||
using Code.Infrastructure.UI.Panels;
|
||||
using Reflex.Core;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
namespace Code.Infrastructure.App.States
|
||||
{
|
||||
[State(typeof(AppStates),typeof(AppStateMachineContext))]
|
||||
[StateRaisingEvent]
|
||||
public partial class MainMenuState
|
||||
public partial class MainMenuState : IUIPanelLoaded, IReadyToPlayHandle, IOnMainMenuSceneLoadedHandler
|
||||
{
|
||||
private EventBus.EventBus _eventBus;
|
||||
public MainMenuState(AppStateMachineContext context, EventBus.EventBus eventBus) : base(context,eventBus)
|
||||
{
|
||||
_eventBus = eventBus;
|
||||
}
|
||||
|
||||
public override AppStates myState => AppStates.MainMenu;
|
||||
private Loading _loading;
|
||||
protected override void OnEnterState()
|
||||
{
|
||||
_eventBus.Subscribe(this);
|
||||
|
||||
_loading = new Loading(2, LoadComplete);
|
||||
|
||||
Context.UIService.TryLoadPanel(UIPanelType.DebugSceneChooser);
|
||||
// Context.AudioFactory.LoadAudioClips(AudioNames.UISounds);
|
||||
Context.SceneLoader.LoadSceneAsync(SceneId.MainMenu, LoadSceneMode.Single).Forget();
|
||||
Context.AudioService.PlayRepeatedly(AudioNames.UISounds,0);
|
||||
}
|
||||
|
||||
|
||||
protected override void OnExitState()
|
||||
{
|
||||
// Context.AudioFactory.ReleaseAudios(AudioNames.UISounds);
|
||||
Context.UIService.TryRemovePanel(UIPanelType.DebugSceneChooser);
|
||||
_eventBus.Unsubscribe(this);
|
||||
}
|
||||
|
||||
public void UILoaded(UIPanelType uiPanelType)
|
||||
{
|
||||
if (uiPanelType != UIPanelType.DebugSceneChooser) return;
|
||||
|
||||
Context.UIService.OpenPanel(uiPanelType);
|
||||
_loading.DoProgress();
|
||||
}
|
||||
|
||||
private void LoadComplete()
|
||||
{
|
||||
Context.UIService.OpenPanel(UIPanelType.DebugSceneChooser);
|
||||
Context.UIService.ClosePanel(UIPanelType.Loading);
|
||||
}
|
||||
|
||||
public void OnReadyToPlay(AudioNames groupName)
|
||||
{
|
||||
_loading.DoProgress();
|
||||
Context.AudioService.PlayRepeatedly(AudioNames.UISounds,0);
|
||||
}
|
||||
|
||||
public void OnMainMenuSceneLoaded()
|
||||
{
|
||||
_loading.DoProgress();
|
||||
}
|
||||
|
||||
public void OnMainMenuSceneInitialized(Container container)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -54,6 +54,8 @@ namespace Code.Infrastructure.Audio
|
||||
|
||||
public async UniTaskVoid LoadAudioClips(AudioNames groupName)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning($"Audios loaded {groupName}");
|
||||
|
||||
foreach (var audioInfo in _audioInfos[groupName])
|
||||
if (!_clipsHandles[groupName].ContainsKey(audioInfo.Key))
|
||||
_clipsHandles[groupName].Add(audioInfo.Key, Addressables.LoadAssetAsync<AudioClip>(audioInfo.Value));
|
||||
@@ -71,6 +73,7 @@ namespace Code.Infrastructure.Audio
|
||||
|
||||
public void ReleaseAudios(AudioNames groupName)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning($"Audios unloaded {groupName}");
|
||||
_eventBus.RaiseEvent<IAudioClipsEventHandle>(x=> x.AudioClipsUnLoaded(groupName));
|
||||
|
||||
foreach (var handle in _clipsHandles)
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Code.Infrastructure.Configs;
|
||||
using Code.Infrastructure.EventBus;
|
||||
using Code.Infrastructure.Generators;
|
||||
@@ -36,7 +37,11 @@ namespace Code.Infrastructure.SceneLoader
|
||||
|
||||
// TODO типилище
|
||||
public async UniTaskVoid LoadSceneAsync(SceneId id, LoadSceneMode loadMode)
|
||||
{
|
||||
{
|
||||
if (loadMode == LoadSceneMode.Single)
|
||||
for (var i = 0; i < _loadedScenes.Count; i++)
|
||||
UnloadSceneAsync(_loadedScenes.Keys.ToList()[i]).Forget();
|
||||
|
||||
_loadedScenes.Add(id,Addressables.LoadSceneAsync(_sceneInfos[id].SceneAsset, loadMode));
|
||||
|
||||
await _loadedScenes[id];
|
||||
|
||||
@@ -6,12 +6,12 @@ namespace Code.Infrastructure.UI.Panels
|
||||
{
|
||||
public override void Open(Action callback = null)
|
||||
{
|
||||
|
||||
callback?.Invoke();
|
||||
}
|
||||
|
||||
public override void Close(Action callback = null)
|
||||
{
|
||||
|
||||
callback?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,18 +1,22 @@
|
||||
using System;
|
||||
using Code.Debug;
|
||||
using Code.Infrastructure.Audio;
|
||||
using Reflex.Attributes;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Code.Infrastructure.UI.Panels
|
||||
{
|
||||
public class MenuChoosePanel : UIPanel
|
||||
{
|
||||
[Inject] IAudioService _audioService;
|
||||
[SerializeField] private SceneChooser sceneChooser;
|
||||
public void PlaySelectSound() => _audioService.PlayOneShot(AudioNames.UISounds, 7);
|
||||
public void PlayDeselectSound() => _audioService.PlayOneShot(AudioNames.UISounds, 8);
|
||||
public void PlayClickSound() => _audioService.PlayOneShot(AudioNames.UISounds, 1);
|
||||
public override void Open(Action callback = null)
|
||||
{
|
||||
|
||||
sceneChooser.EnableButtons();
|
||||
callback?.Invoke();
|
||||
}
|
||||
|
||||
public override void Close(Action callback = null)
|
||||
|
||||
@@ -43,13 +43,16 @@ namespace Code.Infrastructure.UI
|
||||
|
||||
public async UniTaskVoid LoadPanel(UIPanelType panelType)
|
||||
{
|
||||
var panel = (await Addressables.InstantiateAsync(_configs[panelType].Prefab, _canvas.transform).ToUniTask()).GetComponent<UIPanel>();
|
||||
var panel = (await Addressables.InstantiateAsync(_configs[panelType].Prefab, _canvas.transform).ToUniTask())
|
||||
.GetComponent<UIPanel>();
|
||||
|
||||
UnityEngine.Debug.LogWarning($"Panel loaded {panelType}");
|
||||
_eventBus.RaiseEvent<IUIPanelLoadedHandle>(ui => ui.UIPanelLoaded(panel, panelType));
|
||||
}
|
||||
|
||||
public void ReleasePanel(UIPanel panel)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning($"Panel released {panel.gameObject.name}");
|
||||
Addressables.ReleaseInstance(panel.gameObject);
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ namespace Code.Infrastructure.UI
|
||||
Loading,
|
||||
DebugSceneChooser,
|
||||
PlayerScoreCounter,
|
||||
WinScreen,
|
||||
DebugMenu
|
||||
}
|
||||
}
|
||||
@@ -15,6 +15,7 @@ namespace Code.Infrastructure.UI
|
||||
void TryLoadPanel(UIPanelType uiPanelType);
|
||||
void TryRemovePanel(UIPanelType uiPanelType);
|
||||
void SetCanvasCamera(UnityEngine.Camera camera);
|
||||
UIPanel TryGetPanel(UIPanelType panelType);
|
||||
}
|
||||
|
||||
public class UIService : IUIPanelLoadedHandle, IUIService
|
||||
@@ -34,6 +35,7 @@ namespace Code.Infrastructure.UI
|
||||
public void SetCanvasCamera(UnityEngine.Camera camera)
|
||||
{
|
||||
_factory.Canvas.worldCamera = camera;
|
||||
_factory.Canvas.planeDistance = 0.3f;
|
||||
}
|
||||
|
||||
public void OpenPanel(UIPanelType uiPanelType)
|
||||
@@ -75,6 +77,8 @@ namespace Code.Infrastructure.UI
|
||||
_factory.ReleasePanel(_loadedPanels[panelType]);
|
||||
_loadedPanels.Remove(panelType);
|
||||
}
|
||||
|
||||
public UIPanel TryGetPanel(UIPanelType panelType) => _loadedPanels.GetValueOrDefault(panelType);
|
||||
}
|
||||
|
||||
public interface IUIPanelLoaded : IGlobalSubscriber
|
||||
|
||||
Reference in new issue
Block a user