diff --git a/Assets/Prefabs/Player.prefab b/Assets/Prefabs/Player.prefab index 74b4ff7..9d4b7fb 100644 --- a/Assets/Prefabs/Player.prefab +++ b/Assets/Prefabs/Player.prefab @@ -19,7 +19,7 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 4676354101874032} - m_Layer: 0 + m_Layer: 8 m_Name: BulletSpawn m_TagString: Untagged m_Icon: {fileID: 0} @@ -34,7 +34,7 @@ GameObject: serializedVersion: 5 m_Component: - component: {fileID: 4830909199357604} - m_Layer: 0 + m_Layer: 8 m_Name: Graphics m_TagString: Untagged m_Icon: {fileID: 0} @@ -53,7 +53,7 @@ GameObject: - component: {fileID: 114874769993434856} - component: {fileID: 114835806183609276} - component: {fileID: 60772848946696534} - m_Layer: 0 + m_Layer: 8 m_Name: Player m_TagString: Player m_Icon: {fileID: 0} @@ -69,7 +69,7 @@ GameObject: m_Component: - component: {fileID: 4564951497896744} - component: {fileID: 212241819326847048} - m_Layer: 0 + m_Layer: 8 m_Name: vehicleTMP m_TagString: Untagged m_Icon: {fileID: 0} @@ -86,7 +86,7 @@ GameObject: - component: {fileID: 4240907079511616} - component: {fileID: 198696209911726984} - component: {fileID: 199437974736988364} - m_Layer: 0 + m_Layer: 8 m_Name: Particle System m_TagString: Untagged m_Icon: {fileID: 0} diff --git a/Assets/Prefabs/Scorpion.prefab b/Assets/Prefabs/Scorpion.prefab index 1a31e25..f2743e5 100644 --- a/Assets/Prefabs/Scorpion.prefab +++ b/Assets/Prefabs/Scorpion.prefab @@ -22,7 +22,7 @@ GameObject: - component: {fileID: 61708904748430096} - component: {fileID: 50733723059255246} - component: {fileID: 114448442531622302} - m_Layer: 0 + m_Layer: 9 m_Name: Scorpion m_TagString: Enemy m_Icon: {fileID: 0} @@ -38,7 +38,7 @@ GameObject: m_Component: - component: {fileID: 4615957218218632} - component: {fileID: 212910646889249274} - m_Layer: 0 + m_Layer: 9 m_Name: Graphics m_TagString: Untagged m_Icon: {fileID: 0} diff --git a/Assets/Prefabs/UI.prefab b/Assets/Prefabs/UI.prefab index 73cc28c..c6cd3dd 100644 --- a/Assets/Prefabs/UI.prefab +++ b/Assets/Prefabs/UI.prefab @@ -1013,13 +1013,13 @@ RectTransform: m_PrefabParentObject: {fileID: 0} m_PrefabInternal: {fileID: 100100000} m_GameObject: {fileID: 1505922857439362} - m_LocalRotation: {x: -0, y: -0, z: 0.08715578, w: 0.9961947} + m_LocalRotation: {x: 0, y: 0, z: -0.7071068, w: 0.7071068} m_LocalPosition: {x: 0, y: 0, z: 0} m_LocalScale: {x: 0.49999988, y: 0.49999988, z: 1} m_Children: [] m_Father: {fileID: 224833383346886274} m_RootOrder: 0 - m_LocalEulerAnglesHint: {x: 0, y: 0, z: 10} + m_LocalEulerAnglesHint: {x: 0, y: 0, z: -90} m_AnchorMin: {x: 0.5, y: 0.5} m_AnchorMax: {x: 0.5, y: 0.5} m_AnchoredPosition: {x: -7.3055115, y: -3.7793121} @@ -1058,7 +1058,7 @@ RectTransform: m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} m_AnchorMin: {x: 0, y: 0} m_AnchorMax: {x: 0, y: 0} - m_AnchoredPosition: {x: 66.396866, y: 0} + m_AnchoredPosition: {x: 64.16286, y: 0} m_SizeDelta: {x: 0, y: 0} m_Pivot: {x: 1, y: 0.5} --- !u!224 &224218339018349506 diff --git a/Assets/Scenes/CodeDEV.unity b/Assets/Scenes/CodeDEV.unity index 571e45c..9e2335c 100644 --- a/Assets/Scenes/CodeDEV.unity +++ b/Assets/Scenes/CodeDEV.unity @@ -727,11 +727,6 @@ Prefab: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: - - target: {fileID: 224011665836974194, guid: 460d856ea4eb14cedb5fecde1fe6d743, - type: 2} - propertyPath: m_RootOrder - value: 2 - objectReference: {fileID: 0} - target: {fileID: 224011665836974194, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2} propertyPath: m_LocalPosition.x @@ -825,7 +820,7 @@ Prefab: - target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2} propertyPath: m_AnchoredPosition.x - value: 64.16286 + value: 0 objectReference: {fileID: 0} - target: {fileID: 224150154901314796, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2} @@ -865,6 +860,48 @@ GameObject: m_PrefabParentObject: {fileID: 1998375241450644, guid: 460d856ea4eb14cedb5fecde1fe6d743, type: 2} m_PrefabInternal: {fileID: 1379476068} +--- !u!1001 &1597985551 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} + propertyPath: m_LocalPosition.x + value: 7.6580257 + objectReference: {fileID: 0} + - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} + propertyPath: m_LocalPosition.y + value: 3.506653 + objectReference: {fileID: 0} + - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} + propertyPath: m_LocalPosition.z + value: -0.08491792 + objectReference: {fileID: 0} + - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} + propertyPath: m_RootOrder + value: 5 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} + m_IsPrefabParent: 0 --- !u!1 &1600556433 GameObject: m_ObjectHideFlags: 0 @@ -989,53 +1026,6 @@ AudioSource: m_PreInfinity: 2 m_PostInfinity: 2 m_RotationOrder: 4 ---- !u!1001 &1597985551 -Prefab: - m_ObjectHideFlags: 0 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: - - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} - propertyPath: m_LocalPosition.x - value: 7.6580257 - objectReference: {fileID: 0} - - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} - propertyPath: m_LocalPosition.y - value: 3.506653 - objectReference: {fileID: 0} - - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} - propertyPath: m_LocalPosition.z - value: -0.08491792 - objectReference: {fileID: 0} - - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 4612758478389004, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} - propertyPath: m_RootOrder - value: 5 - objectReference: {fileID: 0} - - target: {fileID: 50733723059255246, guid: 4c5ecfd27b4038941a6e493a8117ea0a, - type: 2} - propertyPath: m_GravityScale - value: 0 - objectReference: {fileID: 0} - m_RemovedComponents: [] - m_ParentPrefab: {fileID: 100100000, guid: 4c5ecfd27b4038941a6e493a8117ea0a, type: 2} - m_IsPrefabParent: 0 --- !u!1 &1624368723 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Entities/Attack/MeleeAttack.cs b/Assets/Scripts/Entities/Attack/MeleeAttack.cs index 77e5b48..2b137d2 100644 --- a/Assets/Scripts/Entities/Attack/MeleeAttack.cs +++ b/Assets/Scripts/Entities/Attack/MeleeAttack.cs @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using UnityEngine; namespace Assets.Scripts.Entities.Attack { @@ -15,8 +16,14 @@ namespace Assets.Scripts.Entities.Attack { } public void Attack() { - RaycastHit2D hit = Physics2D.Raycast(owner.transform.position, owner.transform.localRotation * Vector3.up, range); - Mob m = hit.collider.gameObject.GetComponent(typeof(Mob)) as Mob; + RaycastHit2D[] hits = Physics2D.RaycastAll(owner.transform.position, owner.transform.localRotation * Vector3.up, range); + List rh = new List(hits); + RaycastHit2D hit = rh.Find(x => x.fraction != 0); + Mob m = null; + if (hit.collider != null && hit.collider.gameObject != null) { + m = hit.collider.gameObject.GetComponent(typeof(Mob)) as Mob; + } + Debug.Log(m.tag); if ( m != null && m.tag != owner.tag) { m.InflictDamage(damage); } diff --git a/Assets/Scripts/Entities/Attack/SingleShot.cs b/Assets/Scripts/Entities/Attack/SingleShot.cs index f835e54..76ddcfe 100644 --- a/Assets/Scripts/Entities/Attack/SingleShot.cs +++ b/Assets/Scripts/Entities/Attack/SingleShot.cs @@ -34,7 +34,6 @@ namespace Assets.Scripts.Entities.Attack { Bullet bu = b.GetComponent(); bu.SetDamage(damage); bu.SetOwner(owner); - } public float GetCooldownTime() { diff --git a/Assets/Scripts/Entities/Enemy.cs b/Assets/Scripts/Entities/Enemy.cs index 2bb5c3e..ee08494 100644 --- a/Assets/Scripts/Entities/Enemy.cs +++ b/Assets/Scripts/Entities/Enemy.cs @@ -21,13 +21,17 @@ namespace Assets.Scripts.Entities { } void Update() { + if ( victim == null || attack == null ) { return; } if ( Time.timeSinceLevelLoad >= nextAttackTime ) { - RaycastHit2D hit = Physics2D.Raycast(transform.position, transform.position - victim.transform.position, attack.GetRange()); - if ( hit.collider.gameObject == victim ) { + RaycastHit2D[] hits = Physics2D.RaycastAll(transform.position, transform.localRotation * Vector3.up, attack.GetRange()); + List rh = new List(hits); + RaycastHit2D hit = rh.Find(x => x.fraction != 0); + if ( hit.collider != null && hit.collider.gameObject == victim ) { + Debug.Log("Attacking Player!!!"); attack.Attack(); nextAttackTime = Time.timeSinceLevelLoad + attack.GetCooldownTime(); } diff --git a/Assets/Scripts/Entities/Mob.cs b/Assets/Scripts/Entities/Mob.cs index e008430..9fab2e8 100644 --- a/Assets/Scripts/Entities/Mob.cs +++ b/Assets/Scripts/Entities/Mob.cs @@ -1,4 +1,5 @@ using Assets.Scripts.Entities.Attack; +using UnityEngine; public abstract class Mob : Entity { protected readonly int maxHP; @@ -25,6 +26,7 @@ public abstract class Mob : Entity { /// /// public void InflictDamage(int damage) { + Debug.Log(tag + " received " + damage + " Damage"); currentHP -= damage; if ( !isDead && currentHP <= 0 ) { isDead = true; diff --git a/Assets/Scripts/Entities/Player.cs b/Assets/Scripts/Entities/Player.cs index 0cbaffc..d684978 100644 --- a/Assets/Scripts/Entities/Player.cs +++ b/Assets/Scripts/Entities/Player.cs @@ -40,10 +40,11 @@ public class Player : Mob { Debug.Log("Collision"); if ( collision.collider.tag == "wall" ) { Death(); - } else if ( collision.collider.tag == "enemy" ) { + } else if ( collision.collider.tag == "Enemy" ) { Mob m = collision.collider.GetComponent(typeof(Mob)) as Mob; if ( m != null ) { - InflictDamage(carDamage); + //m.InflictDamage(carDamage); + //InflictDamage(carDamage); // TODO } } } diff --git a/Assets/Scripts/GameController.cs b/Assets/Scripts/GameController.cs index 6577de9..c415790 100644 --- a/Assets/Scripts/GameController.cs +++ b/Assets/Scripts/GameController.cs @@ -107,7 +107,6 @@ public class GameController : MonoBehaviour { genPrefabs.Add(GenerationProcessor.ExtendedTileType.RockLRD, RockLRD); genPrefabs.Add(GenerationProcessor.ExtendedTileType.Ground, Ground); genPrefabs.Add(GenerationProcessor.ExtendedTileType.Door, Door); - } // Update is called once per frame @@ -226,6 +225,7 @@ public class GameController : MonoBehaviour { player = goal.GetPlayer(); if ( player != null ) { cam.GetComponent().SetFollow(player.gameObject); + GetUI().InitHealthController(player); } else { Debug.Log("No Player spawned!"); } diff --git a/ProjectSettings/Physics2DSettings.asset b/ProjectSettings/Physics2DSettings.asset index 8c4c1e6..22ec811 100644 --- a/ProjectSettings/Physics2DSettings.asset +++ b/ProjectSettings/Physics2DSettings.asset @@ -4,10 +4,10 @@ Physics2DSettings: m_ObjectHideFlags: 0 serializedVersion: 3 - m_Gravity: {x: 0, y: -9.81} + m_Gravity: {x: 0, y: 0} m_DefaultMaterial: {fileID: 0} - m_VelocityIterations: 8 - m_PositionIterations: 3 + m_VelocityIterations: 10 + m_PositionIterations: 4 m_VelocityThreshold: 1 m_MaxLinearCorrection: 0.2 m_MaxAngularCorrection: 8 @@ -52,4 +52,4 @@ Physics2DSettings: m_ColliderAsleepColor: {r: 0.5686275, g: 0.95686275, b: 0.54509807, a: 0.36078432} m_ColliderContactColor: {r: 1, g: 0, b: 1, a: 0.6862745} m_ColliderAABBColor: {r: 1, g: 1, b: 0, a: 0.2509804} - m_LayerCollisionMatrix: c9ffffffc8ffffffc8ffffffffffffffc8ffffffc8ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff + m_LayerCollisionMatrix: c9ffffffc8ffffffc8fcffffffffffffc8ffffffc8fffffffffffffffffffffffbfffffffbffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff diff --git a/ProjectSettings/TagManager.asset b/ProjectSettings/TagManager.asset index fef188b..613de67 100644 --- a/ProjectSettings/TagManager.asset +++ b/ProjectSettings/TagManager.asset @@ -18,8 +18,8 @@ TagManager: - UI - - - - - - + - Player + - Mobs - - -