added endscreen
This commit is contained in:
1 parent
a33eb50ca0
commit
8328f2a979
15 files changed
+991
-89
No files matched your search
@@ -24,9 +24,8 @@ namespace Code.Gameplay.Camera
|
||||
private void Awake()
|
||||
{
|
||||
_camera = GetComponent<UnityEngine.Camera>();
|
||||
if (_camera == null)
|
||||
if (!_camera)
|
||||
{
|
||||
Debug.LogError("CameraController requires a Camera component!");
|
||||
enabled = false;
|
||||
return;
|
||||
}
|
||||
@@ -56,12 +55,12 @@ namespace Code.Gameplay.Camera
|
||||
|
||||
private void UpdateCamera(float deltaTime, Vector3 lookInput)
|
||||
{
|
||||
var targetRotation = HandleRotation(deltaTime, lookInput);
|
||||
HandleRotation(deltaTime, lookInput);
|
||||
|
||||
HandlePosition(deltaTime, targetRotation);
|
||||
HandlePosition(deltaTime);
|
||||
}
|
||||
|
||||
private Quaternion HandleRotation(float deltaTime, Vector3 lookInput)
|
||||
private void HandleRotation(float deltaTime, Vector3 lookInput)
|
||||
{
|
||||
var horizontalRotation = Quaternion.Euler(Vector3.up * (lookInput.x * rotationSpeed));
|
||||
_planarDirection = horizontalRotation * _planarDirection;
|
||||
@@ -73,11 +72,9 @@ namespace Code.Gameplay.Camera
|
||||
|
||||
var targetRotation = planarRotation * verticalRotation;
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, targetRotation, deltaTime * rotationSharpness);
|
||||
|
||||
return targetRotation;
|
||||
}
|
||||
|
||||
private void HandlePosition(float deltaTime, Quaternion targetRotation)
|
||||
private void HandlePosition(float deltaTime)
|
||||
{
|
||||
_currentFollowPosition = Vector3.Lerp(
|
||||
_currentFollowPosition,
|
||||
@@ -102,15 +99,5 @@ namespace Code.Gameplay.Camera
|
||||
{
|
||||
return _planarDirection;
|
||||
}
|
||||
|
||||
public void SetFollowTransform(Transform target)
|
||||
{
|
||||
followTransform = target;
|
||||
|
||||
if (target == null) return;
|
||||
|
||||
_currentFollowPosition = target.position;
|
||||
_planarDirection = target.forward;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,5 @@ namespace Code.Gameplay.Character.Core
|
||||
public Vector3 CameraPlanarDirection;
|
||||
public bool JumpPressed;
|
||||
public bool SprintPressed;
|
||||
public bool SlidePressed;
|
||||
}
|
||||
}
|
||||
@@ -18,25 +18,12 @@ namespace Code.Gameplay.Character.Core
|
||||
private IInputService _inputService;
|
||||
private CameraController _cameraController;
|
||||
|
||||
public CustomCharacterController CustomCharacterController => customCharacterController;
|
||||
public HealthSystem HealthSystem => healthSystem;
|
||||
public WeaponInventory WeaponInventory => weaponInventory;
|
||||
public Transform GetFollowTransform() => cameraFollowPoint;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_inputService = FindFirstObjectByType<DIContainer>()?.Resolve<IInputService>();
|
||||
_cameraController = FindFirstObjectByType<CameraController>();
|
||||
|
||||
if (_inputService == null)
|
||||
{
|
||||
Debug.LogError("IInputService not found!");
|
||||
}
|
||||
|
||||
if (_cameraController == null)
|
||||
{
|
||||
Debug.LogError("CameraController not found!");
|
||||
}
|
||||
|
||||
if (healthSystem != null)
|
||||
{
|
||||
@@ -55,15 +42,6 @@ namespace Code.Gameplay.Character.Core
|
||||
Debug.Log("Character died!");
|
||||
}
|
||||
|
||||
public void Teleport(Vector3 position, Quaternion rotation)
|
||||
{
|
||||
if (customCharacterController != null)
|
||||
{
|
||||
customCharacterController.SetPosition(position);
|
||||
customCharacterController.SetRotation(rotation);
|
||||
}
|
||||
}
|
||||
|
||||
private void HandleCharacterInput()
|
||||
{
|
||||
if (_inputService == null || _cameraController == null || customCharacterController == null)
|
||||
|
||||
@@ -24,10 +24,7 @@ namespace Code.Gameplay.Character.Controller
|
||||
private float _jumpCooldownTimer;
|
||||
private float JumpCooldownDuration => jumpCooldownDuration;
|
||||
public bool CanJump => _jumpCooldownTimer <= 0f;
|
||||
|
||||
public void SetPosition(Vector3 position) => motor.SetPosition(position);
|
||||
public void SetRotation(Quaternion rotation) => motor.SetRotation(rotation);
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_inputHandler = new CharacterInputHandler(
|
||||
|
||||
@@ -7,10 +7,10 @@ namespace Code.Gameplay.Character.Inventory
|
||||
{
|
||||
public class WeaponInventory : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private List<WeaponBase> weapons = new List<WeaponBase>();
|
||||
[SerializeField] private List<WeaponBase> weapons = new();
|
||||
[SerializeField] private Transform weaponHolder;
|
||||
|
||||
[SerializeField] private int currentWeaponIndex = 0;
|
||||
[SerializeField] private int currentWeaponIndex;
|
||||
|
||||
public event Action<WeaponBase> OnWeaponSwitched;
|
||||
public event Action OnWeaponsInitialized;
|
||||
@@ -54,13 +54,13 @@ namespace Code.Gameplay.Character.Inventory
|
||||
|
||||
public void NextWeapon()
|
||||
{
|
||||
int nextIndex = (currentWeaponIndex + 1) % weapons.Count;
|
||||
var nextIndex = (currentWeaponIndex + 1) % weapons.Count;
|
||||
SwitchWeapon(nextIndex);
|
||||
}
|
||||
|
||||
public void PreviousWeapon()
|
||||
{
|
||||
int prevIndex = (currentWeaponIndex - 1 + weapons.Count) % weapons.Count;
|
||||
var prevIndex = (currentWeaponIndex - 1 + weapons.Count) % weapons.Count;
|
||||
SwitchWeapon(prevIndex);
|
||||
}
|
||||
|
||||
@@ -68,7 +68,7 @@ namespace Code.Gameplay.Character.Inventory
|
||||
{
|
||||
if (weapons.Contains(weapon))
|
||||
{
|
||||
int index = weapons.IndexOf(weapon);
|
||||
var index = weapons.IndexOf(weapon);
|
||||
weapons.Remove(weapon);
|
||||
Destroy(weapon.gameObject);
|
||||
|
||||
|
||||
@@ -64,7 +64,7 @@ namespace Code.Gameplay.Enemy
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (!IsAlive || target == null) return;
|
||||
if (!IsAlive || !target) return;
|
||||
|
||||
var distanceToTarget = Vector3.Distance(transform.position, target.position);
|
||||
|
||||
@@ -115,7 +115,7 @@ namespace Code.Gameplay.Enemy
|
||||
private void Attack()
|
||||
{
|
||||
if (Time.time - lastAttackTime < attackCooldown) return;
|
||||
if (weapon == null) return;
|
||||
if (!weapon) return;
|
||||
|
||||
if (!HasLineOfSight()) return;
|
||||
|
||||
@@ -128,7 +128,7 @@ namespace Code.Gameplay.Enemy
|
||||
|
||||
private bool HasLineOfSight()
|
||||
{
|
||||
if (target == null) return false;
|
||||
if (!target) return false;
|
||||
|
||||
var direction = (target.position - weaponPoint.position).normalized;
|
||||
var distance = Vector3.Distance(weaponPoint.position, target.position);
|
||||
|
||||
@@ -47,12 +47,12 @@ namespace Code.Gameplay.Weapons
|
||||
var damageable = hit.collider.GetComponentInParent<IDamageable>();
|
||||
damageable?.TakeDamage(_damage);
|
||||
|
||||
if (impactEffect != null)
|
||||
if (impactEffect)
|
||||
{
|
||||
Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
|
||||
}
|
||||
|
||||
if (impactSound != null && _audioSource != null)
|
||||
if (impactSound && _audioSource)
|
||||
{
|
||||
_audioSource.PlayOneShot(impactSound);
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ namespace Code.Gameplay.Weapons
|
||||
{
|
||||
public class Rifle : WeaponBase
|
||||
{
|
||||
|
||||
protected override void Awake()
|
||||
{
|
||||
base.Awake();
|
||||
|
||||
@@ -104,10 +104,10 @@ namespace Code.Gameplay.Weapons
|
||||
|
||||
SpawnBullet();
|
||||
|
||||
if (muzzleFlash != null)
|
||||
if (muzzleFlash)
|
||||
muzzleFlash.Play();
|
||||
|
||||
if (shootSound != null)
|
||||
if (shootSound)
|
||||
audioSource.PlayOneShot(shootSound);
|
||||
|
||||
OnShoot();
|
||||
@@ -115,7 +115,7 @@ namespace Code.Gameplay.Weapons
|
||||
|
||||
protected virtual void SpawnBullet()
|
||||
{
|
||||
if (bulletPrefab == null) return;
|
||||
if (!bulletPrefab) return;
|
||||
|
||||
var spread = Random.insideUnitSphere * (spreadAngle / 100f);
|
||||
var direction = (_firePoint.forward + spread).normalized;
|
||||
@@ -123,7 +123,7 @@ namespace Code.Gameplay.Weapons
|
||||
var bullet = Instantiate(bulletPrefab, _firePoint.position, Quaternion.LookRotation(direction));
|
||||
var bulletComponent = bullet.GetComponent<Bullet>();
|
||||
|
||||
if (bulletComponent != null)
|
||||
if (bulletComponent)
|
||||
{
|
||||
bulletComponent.Initialize(bulletSpeed, damage, direction);
|
||||
}
|
||||
@@ -159,7 +159,7 @@ namespace Code.Gameplay.Weapons
|
||||
{
|
||||
isReloading = true;
|
||||
|
||||
if (reloadSound != null)
|
||||
if (reloadSound)
|
||||
audioSource.PlayOneShot(reloadSound);
|
||||
|
||||
yield return new WaitForSeconds(reloadTime);
|
||||
@@ -178,7 +178,7 @@ namespace Code.Gameplay.Weapons
|
||||
if (Time.time - lastShotTryTime < fireRate)
|
||||
return;
|
||||
lastShotTryTime = Time.time;
|
||||
if (emptySound != null)
|
||||
if (emptySound)
|
||||
audioSource.PlayOneShot(emptySound);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user