Repair enemy
This commit is contained in:
parent
4e561971f1
commit
c0ecc18f73
Binary file not shown.
Binary file not shown.
@ -37,6 +37,7 @@ Transform:
|
||||
- {fileID: 7424955828394515863}
|
||||
- {fileID: 8944436269591692549}
|
||||
- {fileID: 5323199187439907686}
|
||||
- {fileID: 9070811066647654375}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@ -73,6 +74,7 @@ MonoBehaviour:
|
||||
- {fileID: 4922531016023278946}
|
||||
- {fileID: 5859715434797674372}
|
||||
offMeshLink: {fileID: 3536865177621166868}
|
||||
walkPoint: {fileID: 9070811066647654375}
|
||||
--- !u!191 &3536865177621166868
|
||||
OffMeshLink:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -120,6 +122,36 @@ Transform:
|
||||
m_Father: {fileID: 2404547677224573952}
|
||||
m_RootOrder: 5
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &5793025160243020386
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 9070811066647654375}
|
||||
m_Layer: 9
|
||||
m_Name: WalkPoint
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &9070811066647654375
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5793025160243020386}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 1.1, y: -1.56, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 2404547677224573952}
|
||||
m_RootOrder: 7
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &8905797841727913353
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -108,8 +108,8 @@ NavMeshSettings:
|
||||
agentTypeID: 0
|
||||
agentRadius: 0.5
|
||||
agentHeight: 0.5
|
||||
agentSlope: 45
|
||||
agentClimb: 0.4
|
||||
agentSlope: 55
|
||||
agentClimb: 0.42
|
||||
ledgeDropHeight: 0
|
||||
maxJumpAcrossDistance: 0
|
||||
minRegionArea: 2
|
||||
@ -446,6 +446,11 @@ PrefabInstance:
|
||||
m_Modification:
|
||||
m_TransformParent: {fileID: 0}
|
||||
m_Modifications:
|
||||
- target: {fileID: 2435173728554922901, guid: 17027e96daa46634eac3c9bcf07b06b0,
|
||||
type: 3}
|
||||
propertyPath: healthRate
|
||||
value: 10
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 5974751188148447902, guid: 17027e96daa46634eac3c9bcf07b06b0,
|
||||
type: 3}
|
||||
propertyPath: m_Name
|
||||
@ -988,6 +993,31 @@ PrefabInstance:
|
||||
propertyPath: m_StaticEditorFlags
|
||||
value: 4294967295
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7271133284078452028, guid: 5322794fa1699704b8e50a14cef106b1,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7271133284078452028, guid: 5322794fa1699704b8e50a14cef106b1,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7271133284078452028, guid: 5322794fa1699704b8e50a14cef106b1,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7271133284078452028, guid: 5322794fa1699704b8e50a14cef106b1,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7271133284078452028, guid: 5322794fa1699704b8e50a14cef106b1,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 180
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7271133284078452029, guid: 5322794fa1699704b8e50a14cef106b1,
|
||||
type: 3}
|
||||
propertyPath: m_StaticEditorFlags
|
||||
@ -1113,6 +1143,36 @@ PrefabInstance:
|
||||
propertyPath: m_StaticEditorFlags
|
||||
value: 4294967295
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8993526177235387293, guid: 5322794fa1699704b8e50a14cef106b1,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.x
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8993526177235387293, guid: 5322794fa1699704b8e50a14cef106b1,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.y
|
||||
value: 1
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8993526177235387293, guid: 5322794fa1699704b8e50a14cef106b1,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8993526177235387293, guid: 5322794fa1699704b8e50a14cef106b1,
|
||||
type: 3}
|
||||
propertyPath: m_LocalRotation.w
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 8993526177235387293, guid: 5322794fa1699704b8e50a14cef106b1,
|
||||
type: 3}
|
||||
propertyPath: m_LocalEulerAnglesHint.y
|
||||
value: 180
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9137252199879611930, guid: 5322794fa1699704b8e50a14cef106b1,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.y
|
||||
value: -1.56
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 9155520659813448952, guid: 5322794fa1699704b8e50a14cef106b1,
|
||||
type: 3}
|
||||
propertyPath: m_RootOrder
|
||||
@ -1147,6 +1207,11 @@ PrefabInstance:
|
||||
propertyPath: m_TagString
|
||||
value: Player
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7985979212931499548, guid: 204c7411afdd01a478b1a1e25607d50c,
|
||||
type: 3}
|
||||
propertyPath: barricadeMaterials
|
||||
value: 50
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 7985979212931499549, guid: 204c7411afdd01a478b1a1e25607d50c,
|
||||
type: 3}
|
||||
propertyPath: m_LocalPosition.x
|
||||
|
Binary file not shown.
@ -8,6 +8,7 @@ public class BarricadeManager : MonoBehaviour
|
||||
public float health = 0;
|
||||
public List<GameObject> barricadePlanks = new List<GameObject>();
|
||||
public OffMeshLink offMeshLink;
|
||||
public Transform walkPoint;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
|
@ -7,28 +7,45 @@ public class BlockManager : MonoBehaviour
|
||||
public enum BlockType {None, Barricade, Door, Wood, Ammo};
|
||||
public BlockType blockType = BlockType.None;
|
||||
public float health = 100;
|
||||
public float healthRate = 5;
|
||||
private float healthTime = 5;
|
||||
private Animation animation;
|
||||
private PlayerManager player;
|
||||
private bool action = false;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
player = FindObjectOfType<PlayerManager>();
|
||||
if (blockType == BlockType.Door)
|
||||
{
|
||||
animation = this.GetComponent<Animation>();
|
||||
}
|
||||
else if (blockType == BlockType.Wood)
|
||||
{
|
||||
healthTime = healthRate;
|
||||
}
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (blockType == BlockType.Wood)
|
||||
{
|
||||
if (health < 100 && healthTime < Time.time)
|
||||
{
|
||||
health += 10;
|
||||
healthTime = healthRate + Time.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Action()
|
||||
{
|
||||
if (blockType == BlockType.Door)
|
||||
{
|
||||
if (!animation.isPlaying) {
|
||||
if (!animation.isPlaying)
|
||||
{
|
||||
if (!action)
|
||||
{
|
||||
animation["Door"].speed = 1;
|
||||
@ -44,5 +61,12 @@ public class BlockManager : MonoBehaviour
|
||||
animation.Play("Door");
|
||||
}
|
||||
}
|
||||
else if (blockType == BlockType.Wood)
|
||||
{
|
||||
if (health > 0 && player.barricadeMaterials < 50) {
|
||||
health -= 10;
|
||||
player.barricadeMaterials += (player.barricadeMaterials <= 40 ? 10 : (50 - player.barricadeMaterials));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -12,7 +12,7 @@ public class EnemyManager : MonoBehaviour
|
||||
public float actualHealth;
|
||||
private NavMeshAgent navMeshAgent;
|
||||
private PlayerManager player;
|
||||
private BarricadeManager barricadeManager;
|
||||
public BarricadeManager barricadeManager;
|
||||
public List<GameObject> bodyParts = new List<GameObject>();
|
||||
|
||||
// Start is called before the first frame update
|
||||
@ -34,17 +34,20 @@ public class EnemyManager : MonoBehaviour
|
||||
}
|
||||
DestroyBarricades();
|
||||
Attack();
|
||||
|
||||
if (navMeshAgent != null && barricadeManager == null)
|
||||
{
|
||||
navMeshAgent.SetDestination(player.transform.position);
|
||||
}
|
||||
else if (navMeshAgent != null && barricadeManager != null)
|
||||
{
|
||||
navMeshAgent.SetDestination(barricadeManager.transform.position);
|
||||
navMeshAgent.SetDestination(new Vector3(barricadeManager.walkPoint.position.x, 0, barricadeManager.walkPoint.position.z));
|
||||
}
|
||||
}
|
||||
|
||||
void FixedUpdate()
|
||||
{
|
||||
if (navMeshAgent.pathStatus == NavMeshPathStatus.PathComplete)
|
||||
{
|
||||
if (actualHealth > 0 && barricadeManager == null)
|
||||
{
|
||||
@ -59,6 +62,7 @@ public class EnemyManager : MonoBehaviour
|
||||
transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(_dir), 5 * Time.deltaTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Damage()
|
||||
{
|
||||
@ -71,10 +75,11 @@ public class EnemyManager : MonoBehaviour
|
||||
void DestroyBarricades()
|
||||
{
|
||||
NavMeshPath path = new NavMeshPath();
|
||||
if (navMeshAgent != null) {
|
||||
navMeshAgent.CalculatePath(player.transform.position, path);
|
||||
if (path.status == NavMeshPathStatus.PathPartial)
|
||||
{
|
||||
BarricadeManager[] barricadeManagers = FindObjectsOfType<BarricadeManager>();
|
||||
BarricadeManager[] barricadeManagers = GameObject.FindObjectsOfType<BarricadeManager>();
|
||||
foreach (BarricadeManager localBarricadeManager in barricadeManagers)
|
||||
{
|
||||
if (barricadeManager == null)
|
||||
@ -83,7 +88,7 @@ public class EnemyManager : MonoBehaviour
|
||||
}
|
||||
else
|
||||
{
|
||||
if (localBarricadeManager.health <= 0 || Vector3.Distance(barricadeManager.transform.position, transform.position) > Vector3.Distance(localBarricadeManager.transform.position, transform.position)) {
|
||||
if (localBarricadeManager.health < barricadeManager.health || Vector3.Distance(barricadeManager.transform.position, transform.position) > Vector3.Distance(localBarricadeManager.transform.position, transform.position)) {
|
||||
barricadeManager = localBarricadeManager;
|
||||
}
|
||||
}
|
||||
@ -94,6 +99,7 @@ public class EnemyManager : MonoBehaviour
|
||||
barricadeManager = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DropBodyPart()
|
||||
{
|
||||
@ -147,23 +153,24 @@ public class EnemyManager : MonoBehaviour
|
||||
void Attack()
|
||||
{
|
||||
RaycastHit hit;
|
||||
if (Physics.Raycast(transform.position + new Vector3(0,1f,0),transform.forward,out hit,2) && attackTime <= Time.time)
|
||||
if (Physics.Raycast(transform.position + new Vector3(0,0.5f,0),transform.forward,out hit,3) && attackTime <= Time.time)
|
||||
{
|
||||
if (hit.transform.CompareTag("Player"))
|
||||
{
|
||||
player.Damage(damage);
|
||||
attackTime = attackRate + Time.time;
|
||||
}
|
||||
else if (hit.transform.CompareTag("BarricadeField"))
|
||||
if (hit.transform.CompareTag("BarricadeField"))
|
||||
{
|
||||
BarricadeManager barricadeManager = hit.transform.GetComponent<BarricadeManager>();
|
||||
if (barricadeManager != null)
|
||||
{
|
||||
barricadeManager.Damage(damage);
|
||||
}
|
||||
}
|
||||
attackTime = attackRate + Time.time;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnParticleCollision(GameObject other)
|
||||
{
|
||||
|
@ -12,7 +12,7 @@ public class PlayerManager : MonoBehaviour
|
||||
public float mouseSensitive = 200;
|
||||
public float buildRate = 0.5f;
|
||||
public float health = 100;
|
||||
private float actualHealth = 100;
|
||||
public float actualHealth = 100;
|
||||
private float buildTime;
|
||||
private bool run = false;
|
||||
private Camera playerCamera;
|
||||
@ -186,13 +186,17 @@ public class PlayerManager : MonoBehaviour
|
||||
{
|
||||
BarricadeManager barricadeManager = hit.transform.GetComponent<BarricadeManager>();
|
||||
barricadeManager.addPlank();
|
||||
//barricadeMaterials--; //než bude jistota že uděláme zbírání materiálu
|
||||
barricadeMaterials--;
|
||||
buildTime = buildRate + Time.time;
|
||||
}
|
||||
if (Input.GetAxisRaw("Build") > 0 && hit.transform.tag == "Interact")
|
||||
{
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.E) && hit.transform.tag == "Interact")
|
||||
{
|
||||
BlockManager blockManager = hit.transform.GetComponent<BlockManager>();
|
||||
blockManager.Action();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user