Finally bots can die. Player to. And another fixes.
This commit is contained in:
114
Assets/Prefabs/PlayerPrefab/Player.prefab
generated
114
Assets/Prefabs/PlayerPrefab/Player.prefab
generated
@ -1394,10 +1394,9 @@ GameObject:
|
||||
- component: {fileID: 2528273238195332182}
|
||||
- component: {fileID: 2528273238195332176}
|
||||
- component: {fileID: 2528273238195332168}
|
||||
- component: {fileID: 2851493361974364939}
|
||||
- component: {fileID: 5170482295850327424}
|
||||
- component: {fileID: 5519976521156458274}
|
||||
- component: {fileID: -4820536401884566159}
|
||||
- component: {fileID: 8568640505362233545}
|
||||
- component: {fileID: 5876264296742387244}
|
||||
m_Layer: 10
|
||||
m_Name: Player
|
||||
m_TagString: Untagged
|
||||
@ -1472,7 +1471,7 @@ Animator:
|
||||
m_Controller: {fileID: 9100000, guid: 3ebf60422b6cb1c498ee4cf238072b43, type: 2}
|
||||
m_CullingMode: 1
|
||||
m_UpdateMode: 0
|
||||
m_ApplyRootMotion: 0
|
||||
m_ApplyRootMotion: 1
|
||||
m_LinearVelocityBlending: 0
|
||||
m_WarningMessage:
|
||||
m_HasTransformHierarchy: 1
|
||||
@ -1530,21 +1529,7 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
anim: {fileID: 2528273238195332174}
|
||||
canRotate: 1
|
||||
--- !u!114 &2851493361974364939
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2528273238195332181}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e5f5f761e43327448b64038300d71e5b, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
enemy: {fileID: 164324136889094180, guid: 2d8d8fcef9fc43144982428bd40ad6f0, type: 3}
|
||||
isFiring: 0
|
||||
lookSpeed: 50
|
||||
isCrouching: 0
|
||||
--- !u!114 &5170482295850327424
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -1559,10 +1544,10 @@ MonoBehaviour:
|
||||
m_EditorClassIdentifier:
|
||||
raycast: {fileID: 9178730298827149128}
|
||||
firePoint: {fileID: 6083229256174510991}
|
||||
_projectilePrefab: {fileID: 1990380580032880, guid: 46b312e00ed9c1f459ea9f0e55bfac77,
|
||||
projectilePrefab: {fileID: 1990380580032880, guid: 46b312e00ed9c1f459ea9f0e55bfac77,
|
||||
type: 3}
|
||||
gun: {fileID: 6083229256174510991}
|
||||
--- !u!114 &5519976521156458274
|
||||
--- !u!114 &8568640505362233545
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
@ -1571,55 +1556,29 @@ MonoBehaviour:
|
||||
m_GameObject: {fileID: 2528273238195332181}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: e63e19e155f6b6348897150b67863072, type: 3}
|
||||
m_Script: {fileID: 11500000, guid: 3d606407023147d7b4d530a9593e9697, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
moveSpeed: 1
|
||||
shiftAdditionalSpeed: 1
|
||||
mouseSensitivity: 0
|
||||
invertMouse: 0
|
||||
autoLockCursor: 0
|
||||
cam: {fileID: 5592602041335177245}
|
||||
character: {fileID: 2528273238195332181}
|
||||
--- !u!23 &-4820536401884566159
|
||||
MeshRenderer:
|
||||
targetTransform: {fileID: 2528273238195566709}
|
||||
cameraTransform: {fileID: 3401070369230030472}
|
||||
lookSpeed: 0.1
|
||||
followSpeed: 0.1
|
||||
pivotSpeed: 0.03
|
||||
LookAngle: 0
|
||||
minimumPivot: -35
|
||||
maximumPivot: 35
|
||||
--- !u!114 &5876264296742387244
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2528273238195332181}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 1
|
||||
m_ReceiveShadows: 1
|
||||
m_DynamicOccludee: 1
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 2
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 0}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 3
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: a8c9a8e604d395c4ab9d03d28adc4982, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!1 &2528273238195332183
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -3128,8 +3087,8 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5234455722044222527}
|
||||
m_LocalRotation: {x: -0.7071068, y: 0, z: 0, w: 0.7071068}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 1}
|
||||
m_LocalScale: {x: 0.01, y: 0.01, z: 0.01}
|
||||
m_LocalPosition: {x: 0, y: -0.642, z: 4.02}
|
||||
m_LocalScale: {x: 0.03831688, y: 0.03831688, z: 0.03831688}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 3401070369230030472}
|
||||
m_RootOrder: 0
|
||||
@ -3141,7 +3100,7 @@ MeshFilter:
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5234455722044222527}
|
||||
m_Mesh: {fileID: 10207, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0}
|
||||
--- !u!23 &1446591995090098502
|
||||
MeshRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -3206,7 +3165,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5585342347362633954}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0.099999994, y: 2.5029998, z: -1.8900003}
|
||||
m_LocalPosition: {x: -0.049, y: 2.5029998, z: -1.8900003}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 7744902250868623004}
|
||||
@ -3476,7 +3435,6 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 3808104189668072889}
|
||||
- component: {fileID: 6900876834040779050}
|
||||
m_Layer: 0
|
||||
m_Name: Camera Holder
|
||||
m_TagString: Untagged
|
||||
@ -3499,26 +3457,6 @@ Transform:
|
||||
m_Father: {fileID: 2528273238195566709}
|
||||
m_RootOrder: 8
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &6900876834040779050
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 7419068246808297193}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 3d606407023147d7b4d530a9593e9697, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
targetTransform: {fileID: 2528273238195566709}
|
||||
cameraTransform: {fileID: 3401070369230030472}
|
||||
cameraPivotTransform: {fileID: 916820916668423615}
|
||||
LookSpeed: 0.1
|
||||
FollowSpeed: 0.1
|
||||
PivotSpeed: 0.03
|
||||
minimumPivot: -35
|
||||
maximumPivot: 35
|
||||
--- !u!1 &8287218850849767936
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -3545,7 +3483,7 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8287218850849767936}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0.09401773, y: 0.40798557, z: 0.68032074}
|
||||
m_LocalPosition: {x: 0.09401773, y: 2.297, z: -2.12}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children:
|
||||
- {fileID: 77805209700100364}
|
||||
|
@ -1774,7 +1774,7 @@ Mesh:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: pb_Mesh19226
|
||||
m_Name: pb_Mesh26546
|
||||
serializedVersion: 10
|
||||
m_SubMeshes:
|
||||
- serializedVersion: 2
|
||||
|
@ -1,4 +1,6 @@
|
||||
using Unity.Mathematics;
|
||||
using System;
|
||||
using CameraScripts;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Animators.Leonid_Animator
|
||||
@ -10,7 +12,7 @@ namespace Animators.Leonid_Animator
|
||||
|
||||
private int _horizontal;
|
||||
private int _vertical;
|
||||
private bool _isCrouching = false;
|
||||
public bool isCrouching = false;
|
||||
private bool _isJumping;
|
||||
|
||||
private int _crouch;
|
||||
@ -77,14 +79,8 @@ namespace Animators.Leonid_Animator
|
||||
|
||||
if (pressedCrouching == true)
|
||||
{
|
||||
_isCrouching = !_isCrouching;
|
||||
if (_isCrouching == true)
|
||||
transform.Rotate(Vector3.up, 45);
|
||||
else
|
||||
{
|
||||
transform.Rotate(Vector3.up, -45);
|
||||
}
|
||||
anim.SetBool(_crouch, _isCrouching);
|
||||
isCrouching = !isCrouching;
|
||||
anim.SetBool(_crouch, isCrouching);
|
||||
}
|
||||
|
||||
anim.SetBool(_jump, pressedJumped);
|
||||
|
@ -1,4 +1,5 @@
|
||||
using UnityEngine;
|
||||
using System;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Animators.Leonid_Animator.Player
|
||||
{
|
||||
@ -19,15 +20,19 @@ namespace Animators.Leonid_Animator.Player
|
||||
[SerializeField] public float jumpForce;
|
||||
|
||||
[Header("Stats")]
|
||||
[SerializeField] private float movementSpeed = 5;
|
||||
[SerializeField] private float movementSpeed = 25;
|
||||
[SerializeField] private float rotationSpeed = 10;
|
||||
|
||||
private void Start()
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
myRigidbody = GetComponent<Rigidbody>();
|
||||
_inputHandler = GetComponent<InputHandler>();
|
||||
myAnimatorHandler = GetComponent<AnimatorHandler>();
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_cameraObject = Camera.main.transform;
|
||||
myTransform = transform;
|
||||
myAnimatorHandler.Initialize();
|
||||
@ -70,6 +75,16 @@ namespace Animators.Leonid_Animator.Player
|
||||
_inputHandler.crouchPressed = false;
|
||||
}
|
||||
|
||||
public Vector3 GetMeshCenter()
|
||||
{
|
||||
if (myAnimatorHandler.isCrouching)
|
||||
return transform.position + 1f * Vector3.up;
|
||||
else
|
||||
{
|
||||
return transform.position + 2f * Vector3.up;
|
||||
}
|
||||
}
|
||||
|
||||
#region Movement
|
||||
|
||||
private Vector3 _normalVector;
|
||||
|
@ -1,4 +1,5 @@
|
||||
using CameraScripts;
|
||||
using System;
|
||||
using CameraScripts;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Animators.Leonid_Animator.Player
|
||||
@ -21,7 +22,7 @@ namespace Animators.Leonid_Animator.Player
|
||||
|
||||
private CameraHandler _cameraHandler;
|
||||
|
||||
private void Awake()
|
||||
private void Start()
|
||||
{
|
||||
_cameraHandler = CameraHandler.Singleton;
|
||||
if (_cameraHandler == null)
|
||||
|
@ -1,7 +1,9 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Unity.Barracuda;
|
||||
using Unity.MLAgents.Policies;
|
||||
using UnityEngine;
|
||||
using Random = UnityEngine.Random;
|
||||
|
||||
public class CharacterFactory : MonoBehaviour
|
||||
{
|
||||
@ -14,7 +16,7 @@ public class CharacterFactory : MonoBehaviour
|
||||
[SerializeField] private GameObject PlayerPrefab;
|
||||
|
||||
private List<GameObject> bots = new List<GameObject>();
|
||||
public GameObject player { get; private set; }
|
||||
public GameObject Player { get; private set; }
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
@ -27,6 +29,11 @@ public class CharacterFactory : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
print(Player == null);
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
var attcNum = SettingsReader.Instance.GetSettings.NumOfAttackers;
|
||||
@ -37,12 +44,6 @@ public class CharacterFactory : MonoBehaviour
|
||||
if (humanAtc == 1 && humanDef == 1)
|
||||
throw new System.ArgumentException("Can be only one human player");
|
||||
|
||||
for (int i = 0; i < attcNum - humanAtc; i++)
|
||||
InstantiateEntity(Team.Attackers, TypeAI.D0DiskAI,
|
||||
spawnPointsForAttackersTeam[Random.Range(0, spawnPointsForAttackersTeam.Count)]);
|
||||
for (int i = 0; i < defNum - humanDef; i++)
|
||||
InstantiateEntity(Team.Defenders, TypeAI.D0DiskAI,
|
||||
spawnPointsForDefendersTeam[Random.Range(0, spawnPointsForDefendersTeam.Count)]);
|
||||
if (humanAtc == 1)
|
||||
InstantiateEntity(Team.Attackers, TypeAI.HumanAI,
|
||||
spawnPointsForAttackersTeam[Random.Range(0, spawnPointsForAttackersTeam.Count)]);
|
||||
@ -50,6 +51,13 @@ public class CharacterFactory : MonoBehaviour
|
||||
InstantiateEntity(Team.Defenders, TypeAI.HumanAI,
|
||||
spawnPointsForDefendersTeam[Random.Range(0, spawnPointsForDefendersTeam.Count)]);
|
||||
|
||||
for (int i = 0; i < attcNum - humanAtc; i++)
|
||||
InstantiateEntity(Team.Attackers, TypeAI.D0DiskAI,
|
||||
spawnPointsForAttackersTeam[Random.Range(0, spawnPointsForAttackersTeam.Count)]);
|
||||
for (int i = 0; i < defNum - humanDef; i++)
|
||||
InstantiateEntity(Team.Defenders, TypeAI.D0DiskAI,
|
||||
spawnPointsForDefendersTeam[Random.Range(0, spawnPointsForDefendersTeam.Count)]);
|
||||
|
||||
GameManager.OnResetScene += ResetCharacters;
|
||||
}
|
||||
|
||||
@ -65,8 +73,9 @@ public class CharacterFactory : MonoBehaviour
|
||||
|
||||
if (typeAi == TypeAI.HumanAI)
|
||||
{
|
||||
print("added player to list");
|
||||
gameobject.GetComponent<Player>().GetCharacter.Team = team;
|
||||
player = gameobject;
|
||||
Player = gameobject;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -101,18 +110,23 @@ public class CharacterFactory : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void ReSpawn(ICharacter character, ref Vector3 pos, ref int startPointId)
|
||||
public void ReSpawn(ICharacter character, GameObject go)
|
||||
{
|
||||
character.ResetCharacter();
|
||||
var team = character.GetCharacter.Team;
|
||||
var ai = character.GetCharacter.TypeAi;
|
||||
NavPoint navPoint;
|
||||
if (team == Team.Attackers)
|
||||
navPoint = spawnPointsForAttackersTeam[Random.Range(0, spawnPointsForAttackersTeam.Count)];
|
||||
else
|
||||
navPoint = spawnPointsForDefendersTeam[Random.Range(0, spawnPointsForDefendersTeam.Count)];
|
||||
|
||||
pos = navPoint.Position;
|
||||
startPointId = navPoint.PointId;
|
||||
go.transform.position = navPoint.Position;
|
||||
if (ai == TypeAI.D0DiskAI)
|
||||
{
|
||||
var mc =go.GetComponent<MovementController>();
|
||||
mc.PointStartID = navPoint.PointId;
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetCharacters()
|
||||
@ -131,9 +145,9 @@ public class CharacterFactory : MonoBehaviour
|
||||
{
|
||||
player.ResetCharacter();
|
||||
if (player.GetCharacter.Team == Team.Attackers)
|
||||
this.player.transform.position = spawnPointsForAttackersTeam[Random.Range(0, spawnPointsForAttackersTeam.Count)].Position;
|
||||
this.Player.transform.position = spawnPointsForAttackersTeam[Random.Range(0, spawnPointsForAttackersTeam.Count)].Position;
|
||||
else
|
||||
this.player.transform.position = spawnPointsForDefendersTeam[Random.Range(0, spawnPointsForDefendersTeam.Count)].Position;
|
||||
this.Player.transform.position = spawnPointsForDefendersTeam[Random.Range(0, spawnPointsForDefendersTeam.Count)].Position;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,4 +1,6 @@
|
||||
using System;
|
||||
using Animators.Leonid_Animator;
|
||||
using Animators.Leonid_Animator.Player;
|
||||
using Unity.Mathematics;
|
||||
using UnityEngine;
|
||||
|
||||
@ -7,50 +9,52 @@ namespace CameraScripts
|
||||
public class CameraHandler : MonoBehaviour
|
||||
{
|
||||
public Transform targetTransform;
|
||||
public Transform cameraTransform;
|
||||
public Transform cameraPivotTransform;
|
||||
private Transform _myTransform;
|
||||
private Vector3 _cameraTransformPosition;
|
||||
private LayerMask ignoreLayers = ~(1 << 8 | 1 << 9 | 1 << 10);
|
||||
[SerializeField] private Transform cameraTransform;
|
||||
|
||||
public static CameraHandler Singleton;
|
||||
|
||||
[SerializeField] private float LookSpeed = 0.1f;
|
||||
[SerializeField] private float FollowSpeed = 0.1f;
|
||||
[SerializeField] private float PivotSpeed = 0.03f;
|
||||
[SerializeField] private float lookSpeed = 0.1f;
|
||||
[SerializeField] private float followSpeed = 0.1f;
|
||||
[SerializeField] private float pivotSpeed = 0.03f;
|
||||
|
||||
private float _defaultPosition;
|
||||
private float _lookAngle;
|
||||
public float LookAngle;
|
||||
private float _pivotAngle;
|
||||
|
||||
public float minimumPivot = -35;
|
||||
public float maximumPivot = 35;
|
||||
|
||||
private AnimatorHandler _animatorHandler;
|
||||
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Application.targetFrameRate = 60;
|
||||
Singleton = this;
|
||||
_myTransform = transform;
|
||||
_defaultPosition = _myTransform.localPosition.z;
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_animatorHandler = gameObject.GetComponent<AnimatorHandler>();
|
||||
if (_animatorHandler == null)
|
||||
print(gameObject.name);
|
||||
}
|
||||
|
||||
public void TargetPosition(float delta)
|
||||
{
|
||||
var toTargetPosition = Vector3.Lerp(_myTransform.position, targetTransform.position, delta /FollowSpeed);
|
||||
var toTargetPosition = Vector3.Lerp(_myTransform.position, targetTransform.position, delta /followSpeed);
|
||||
_myTransform.position = toTargetPosition;
|
||||
}
|
||||
|
||||
public void HandleCameraRotation(float delta, float mouseX, float mouseY)
|
||||
{
|
||||
_lookAngle += (mouseX * LookSpeed) / delta;
|
||||
_pivotAngle -= (mouseY * PivotSpeed) / delta;
|
||||
LookAngle += (mouseX * lookSpeed) / delta;
|
||||
_pivotAngle -= (mouseY * pivotSpeed) / delta;
|
||||
_pivotAngle = Mathf.Clamp(_pivotAngle, minimumPivot, maximumPivot);
|
||||
|
||||
var rotation = Vector3.zero;
|
||||
rotation.y = _lookAngle;
|
||||
var targetRotation = Quaternion.Euler(rotation);
|
||||
targetTransform.rotation = targetRotation;
|
||||
rotation.y = LookAngle;
|
||||
transform.rotation = Quaternion.Euler(rotation);
|
||||
}
|
||||
}
|
||||
}
|
@ -4,6 +4,7 @@ public class Character
|
||||
public Team Team { get; set; }
|
||||
public float LastTimeHit = 0;
|
||||
public CharacterCondition Condition;
|
||||
public TypeAI TypeAi;
|
||||
|
||||
public Character()
|
||||
{
|
||||
|
@ -204,18 +204,20 @@ public class NPC : Agent, ICharacter
|
||||
_condition.GiveHealth(-Mathf.RoundToInt(damage * (1 - _condition.ArmourPoints * 0.5f)));
|
||||
_condition.GiveArmour(-Mathf.RoundToInt(Mathf.Sqrt(damage) * 5));
|
||||
OnDamageReceived?.Invoke(damage, GetCharacter.Team);
|
||||
|
||||
if (_condition.HealthPoints < 0)
|
||||
if (_condition.HealthPoints < 1)
|
||||
{
|
||||
OnDeathEvent?.Invoke(true);
|
||||
MapManager.AddDeathAttributeToPoints(_moveController.PointStartID, _moveController.PointEndID,
|
||||
_moveController.DistanceToGo, _moveController.RemainingDistance);
|
||||
var pos = gameObject.transform.position;
|
||||
var id = _moveController.PointStartID;
|
||||
CharacterFactory.Instance.ReSpawn(this, ref pos, ref id);
|
||||
Die();
|
||||
}
|
||||
}
|
||||
|
||||
private void Die()
|
||||
{
|
||||
OnDeathEvent?.Invoke(true);
|
||||
MapManager.AddDeathAttributeToPoints(_moveController.PointStartID, _moveController.PointEndID,
|
||||
_moveController.DistanceToGo, _moveController.RemainingDistance);
|
||||
CharacterFactory.Instance.ReSpawn(this, gameObject);
|
||||
}
|
||||
|
||||
public void ResetCharacter()
|
||||
{
|
||||
_condition.Reset();
|
||||
|
@ -27,8 +27,15 @@ public class Player : MonoBehaviour, ICharacter
|
||||
Condition.GiveHealth(-Mathf.RoundToInt(damage * (1 - Condition.ArmourPoints * 0.5f)));
|
||||
Condition.GiveArmour(-Mathf.RoundToInt(Mathf.Sqrt(damage) * 5));
|
||||
|
||||
if (Condition.HealthPoints < 0)
|
||||
OnDeathEvent?.Invoke(true);
|
||||
if (Condition.HealthPoints < 1)
|
||||
Die();
|
||||
}
|
||||
|
||||
private void Die()
|
||||
{
|
||||
print("dead");
|
||||
OnDeathEvent?.Invoke(true);
|
||||
CharacterFactory.Instance.ReSpawn(this, gameObject);
|
||||
}
|
||||
|
||||
public void ResetCharacter()
|
||||
|
@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Animators.Leonid_Animator.Player;
|
||||
using Unity.MLAgents;
|
||||
using UnityEngine;
|
||||
|
||||
@ -48,7 +49,7 @@ public class GameManager : MonoBehaviour
|
||||
if ((SettingsReader.Instance.GetSettings.HasHumanAttacker == true && oppositeTeam == Team.Attackers) ||
|
||||
(SettingsReader.Instance.GetSettings.HasHumanDefender == true && oppositeTeam == Team.Defenders))
|
||||
{
|
||||
if (distToNavPoint > (currentTransform - CharacterFactory.Instance.player.transform.position).magnitude)
|
||||
if (distToNavPoint > (currentTransform - CharacterFactory.Instance.Player.transform.position).magnitude)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -64,7 +65,7 @@ public class GameManager : MonoBehaviour
|
||||
if ((SettingsReader.Instance.GetSettings.HasHumanAttacker == true && oppositeTeam == Team.Attackers) ||
|
||||
(SettingsReader.Instance.GetSettings.HasHumanDefender == true && oppositeTeam == Team.Defenders))
|
||||
{
|
||||
if ((currentTransform - CharacterFactory.Instance.player.transform.position).magnitude < SettingsReader.Instance.GetSettings.ViewDistance)
|
||||
if ((currentTransform - CharacterFactory.Instance.Player.transform.position).magnitude < SettingsReader.Instance.GetSettings.ViewDistance)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@ -99,9 +100,9 @@ public class GameManager : MonoBehaviour
|
||||
if ((SettingsReader.Instance.GetSettings.HasHumanAttacker == true && oppositeTeam == Team.Attackers) ||
|
||||
(SettingsReader.Instance.GetSettings.HasHumanDefender == true && oppositeTeam == Team.Defenders))
|
||||
{
|
||||
var player = CharacterFactory.Instance.player;
|
||||
var player = CharacterFactory.Instance.Player;
|
||||
if (Physics.Raycast(position,
|
||||
(player.GetComponent<MeshRenderer>().bounds.center - position).normalized,
|
||||
(player.GetComponent<CharacterLocomotion>().GetMeshCenter() - position).normalized,
|
||||
out rayHit,
|
||||
SettingsReader.Instance.GetSettings.ViewDistance))
|
||||
{
|
||||
|
@ -47,16 +47,15 @@ public class MapManager : MonoBehaviour
|
||||
var startNavPoint = _instance.IDToNavPoint[startPoint];
|
||||
var endNavPoint = _instance.IDToNavPoint[endPoint];
|
||||
float coef;
|
||||
try
|
||||
if (allDistance != 0)
|
||||
{
|
||||
coef = remainingDistance / allDistance;
|
||||
startNavPoint.DeathAttr += 1 - coef;
|
||||
endNavPoint.DeathAttr += coef;
|
||||
}
|
||||
catch (System.ArithmeticException)
|
||||
else
|
||||
{
|
||||
Debug.LogError("Path Length is zero");
|
||||
return;
|
||||
startNavPoint.DeathAttr += 1;
|
||||
}
|
||||
startNavPoint.DeathAttr += 1 - coef;
|
||||
endNavPoint.DeathAttr += coef;
|
||||
}
|
||||
}
|
||||
|
@ -30,9 +30,6 @@ public class FlagZone : MonoBehaviour
|
||||
case "Attacker":
|
||||
occupAttackers++;
|
||||
break;
|
||||
default:
|
||||
Debug.LogWarning("Entered non-team entity");
|
||||
break;
|
||||
}
|
||||
}
|
||||
private void OnTriggerExit(Collider other)
|
||||
|
@ -11,7 +11,7 @@ public class Shooting : MonoBehaviour
|
||||
[SerializeField] private GameObject projectilePrefab;
|
||||
|
||||
private float hSliderValue = 0.1f;
|
||||
private float _fireCountdown = 1f;
|
||||
private float _fireCountdown = 0.1f;
|
||||
|
||||
public GameObject gun;
|
||||
private void Update()
|
||||
@ -25,18 +25,32 @@ public class Shooting : MonoBehaviour
|
||||
{
|
||||
_fireCountdown = 0;
|
||||
_fireCountdown += hSliderValue;
|
||||
Shoot();
|
||||
PlayerShoot();
|
||||
}
|
||||
_fireCountdown -= Time.deltaTime;
|
||||
}
|
||||
|
||||
private void PlayerShoot()
|
||||
{
|
||||
Instantiate(projectilePrefab, firePoint.transform.position, firePoint.transform.rotation);
|
||||
if (Physics.Raycast(raycast.transform.position,
|
||||
raycast.transform.forward, out var hit,
|
||||
SettingsReader.Instance.GetSettings.ViewDistance))
|
||||
{
|
||||
if (hit.transform.TryGetComponent<NPC>(out var target))
|
||||
{
|
||||
target.GetDamage(SettingsReader.Instance.GetSettings.RifleDamage);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Shoot()
|
||||
{
|
||||
if (Physics.Raycast(raycast.transform.position,
|
||||
raycast.transform.forward, out var hit,
|
||||
SettingsReader.Instance.GetSettings.ViewDistance))
|
||||
{
|
||||
if (hit.transform.TryGetComponent<NPC>(out var target))
|
||||
if (hit.transform.TryGetComponent<ICharacter>(out var target))
|
||||
{
|
||||
Instantiate(projectilePrefab, firePoint.transform.position, firePoint.transform.rotation);
|
||||
target.GetDamage(SettingsReader.Instance.GetSettings.RifleDamage);
|
||||
|
8
Assets/Settings/Game Settings.asset
generated
8
Assets/Settings/Game Settings.asset
generated
@ -19,9 +19,9 @@ MonoBehaviour:
|
||||
MovementSpeed: 1
|
||||
DefTeamAI: 3
|
||||
AtcTeamAI: 3
|
||||
NumOfDefenders: 2
|
||||
NumOfAttackers: 2
|
||||
HasHumanDefender: 0
|
||||
NumOfDefenders: 1
|
||||
NumOfAttackers: 1
|
||||
HasHumanDefender: 1
|
||||
HasHumanAttacker: 0
|
||||
HealthPickupAmount: 50
|
||||
ArmourPickupAmount: 50
|
||||
@ -37,7 +37,7 @@ MonoBehaviour:
|
||||
DoDamageChanceInDirectPoint: 70
|
||||
DoDamageChanceInRunning: 30
|
||||
DoDamageChanceInCover: 25
|
||||
RifleDamage: 0
|
||||
RifleDamage: 100
|
||||
RateOfFire: 1
|
||||
CrouchingCoefficient: 1.4
|
||||
atcMaterial: {fileID: 2100000, guid: ce639cf318364cf449d4fd87a69da579, type: 2}
|
||||
|
Reference in New Issue
Block a user