fixed player in bot fights and their scaled time features (player not time scaled). Now player can join to fights for justice.

This commit is contained in:
2022-05-20 02:22:22 +07:00
parent 7db8dbcfcf
commit 9faeccdae3
20 changed files with 176 additions and 224 deletions

View File

@ -1,11 +1,12 @@
using System.Collections;
using UnityEngine;
using Weapons;
[RequireComponent(typeof(NPC))]
public class AimAssistant : MonoBehaviour
{
[HideInInspector] public GameObject enemy;
private Shooting _shooting;
private BotShooter _botShooter;
public bool isFiring = false;
private NPC _myNpc;
[SerializeField] private float lookSpeed = 400f;
@ -19,14 +20,13 @@ public class AimAssistant : MonoBehaviour
private void Awake()
{
_myNpc = GetComponent<NPC>();
_shooting = GetComponent<Shooting>();
_botShooter = GetComponent<BotShooter>();
_myTransform = transform;
_fireCountdown = 1f / SettingsReader.Instance.GetSettings.RateOfFire;
}
private void FixedUpdate()
{
//Ищем противника на сцене.
if (isFiring == false)
{
var enemies = GameManager.GetVisibleEnemies(_myNpc.GetCharacter.Team.GetOppositeTeam(), transform.position);
@ -72,6 +72,7 @@ public class AimAssistant : MonoBehaviour
if (enemy != null)
{
var direction = enemy.transform.position - gameObject.transform.position;
if (direction == Vector3.zero) return;
var targetRotation = Quaternion.LookRotation(direction);
var lookAt = Quaternion.RotateTowards(gameObject.transform.rotation, targetRotation,
Time.deltaTime * lookSpeed);
@ -92,8 +93,9 @@ public class AimAssistant : MonoBehaviour
{
while (true)
{
_shooting.BotShoot();
_botShooter.BotShoot();
yield return new WaitForSeconds(_fireCountdown);
}
}
}