diff --git a/.vs/GlobalGameJame/v16/Server/sqlite3/storage.ide b/.vs/GlobalGameJame/v16/Server/sqlite3/storage.ide index daf122e..bec9e51 100644 Binary files a/.vs/GlobalGameJame/v16/Server/sqlite3/storage.ide and b/.vs/GlobalGameJame/v16/Server/sqlite3/storage.ide differ diff --git a/.vs/GlobalGameJame/v16/Server/sqlite3/storage.ide-wal b/.vs/GlobalGameJame/v16/Server/sqlite3/storage.ide-wal index 24d8274..b9ed5bf 100644 Binary files a/.vs/GlobalGameJame/v16/Server/sqlite3/storage.ide-wal and b/.vs/GlobalGameJame/v16/Server/sqlite3/storage.ide-wal differ diff --git a/Assets/Prefabs/BarricadeField.prefab b/Assets/Prefabs/BarricadeField.prefab index df51695..56f1a96 100644 --- a/Assets/Prefabs/BarricadeField.prefab +++ b/Assets/Prefabs/BarricadeField.prefab @@ -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 diff --git a/Assets/Scenes/Test-Haitem.unity b/Assets/Scenes/Test-Haitem.unity index b1489c2..8b27a1b 100644 --- a/Assets/Scenes/Test-Haitem.unity +++ b/Assets/Scenes/Test-Haitem.unity @@ -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 diff --git a/Assets/Scenes/Test-Haitem/NavMesh.asset b/Assets/Scenes/Test-Haitem/NavMesh.asset index 1671fb3..709ea68 100644 Binary files a/Assets/Scenes/Test-Haitem/NavMesh.asset and b/Assets/Scenes/Test-Haitem/NavMesh.asset differ diff --git a/Assets/Scripts/BarricadeManager.cs b/Assets/Scripts/BarricadeManager.cs index d2b36bd..c4a555b 100644 --- a/Assets/Scripts/BarricadeManager.cs +++ b/Assets/Scripts/BarricadeManager.cs @@ -8,6 +8,7 @@ public class BarricadeManager : MonoBehaviour public float health = 0; public List barricadePlanks = new List(); public OffMeshLink offMeshLink; + public Transform walkPoint; // Start is called before the first frame update void Start() diff --git a/Assets/Scripts/BlockManager.cs b/Assets/Scripts/BlockManager.cs index 3bef289..edf37ed 100644 --- a/Assets/Scripts/BlockManager.cs +++ b/Assets/Scripts/BlockManager.cs @@ -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(); if (blockType == BlockType.Door) { animation = this.GetComponent(); } + 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; @@ -42,7 +59,14 @@ public class BlockManager : MonoBehaviour action = false; } 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)); + } } } } diff --git a/Assets/Scripts/EnemyManager.cs b/Assets/Scripts/EnemyManager.cs index 728fb2b..afcd444 100644 --- a/Assets/Scripts/EnemyManager.cs +++ b/Assets/Scripts/EnemyManager.cs @@ -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 bodyParts = new List(); // Start is called before the first frame update @@ -34,29 +34,33 @@ 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 (actualHealth > 0 && barricadeManager == null) + if (navMeshAgent.pathStatus == NavMeshPathStatus.PathComplete) { - Vector3 _dir = player.transform.position - transform.position; - _dir.Normalize(); - transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(_dir), 5 * Time.deltaTime); - } - else if (actualHealth > 0 && barricadeManager != null) - { - Vector3 _dir = barricadeManager.transform.position - transform.position; - _dir.Normalize(); - transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(_dir), 5 * Time.deltaTime); + if (actualHealth > 0 && barricadeManager == null) + { + Vector3 _dir = player.transform.position - transform.position; + _dir.Normalize(); + transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(_dir), 5 * Time.deltaTime); + } + else if (actualHealth > 0 && barricadeManager != null) + { + Vector3 _dir = barricadeManager.transform.position - transform.position; + _dir.Normalize(); + transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.LookRotation(_dir), 5 * Time.deltaTime); + } } } @@ -71,27 +75,29 @@ public class EnemyManager : MonoBehaviour void DestroyBarricades() { NavMeshPath path = new NavMeshPath(); - navMeshAgent.CalculatePath(player.transform.position, path); - if (path.status == NavMeshPathStatus.PathPartial) - { - BarricadeManager[] barricadeManagers = FindObjectsOfType(); - foreach(BarricadeManager localBarricadeManager in barricadeManagers) + if (navMeshAgent != null) { + navMeshAgent.CalculatePath(player.transform.position, path); + if (path.status == NavMeshPathStatus.PathPartial) { - if (barricadeManager == null) + BarricadeManager[] barricadeManagers = GameObject.FindObjectsOfType(); + foreach (BarricadeManager localBarricadeManager in barricadeManagers) { - barricadeManager = localBarricadeManager; - } - else - { - if (localBarricadeManager.health <= 0 || Vector3.Distance(barricadeManager.transform.position, transform.position) > Vector3.Distance(localBarricadeManager.transform.position, transform.position)) { + if (barricadeManager == null) + { barricadeManager = localBarricadeManager; } + else + { + if (localBarricadeManager.health < barricadeManager.health || Vector3.Distance(barricadeManager.transform.position, transform.position) > Vector3.Distance(localBarricadeManager.transform.position, transform.position)) { + barricadeManager = localBarricadeManager; + } + } } } - } - else - { - barricadeManager = null; + else + { + barricadeManager = null; + } } } @@ -147,21 +153,22 @@ 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(); if (barricadeManager != null) { barricadeManager.Damage(damage); + attackTime = attackRate + Time.time; } } - attackTime = attackRate + Time.time; } } diff --git a/Assets/Scripts/PlayerManager.cs b/Assets/Scripts/PlayerManager.cs index cdd0d4e..f5905ac 100644 --- a/Assets/Scripts/PlayerManager.cs +++ b/Assets/Scripts/PlayerManager.cs @@ -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.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.Action(); + } } }