diff --git a/Assets/Prefabs/SceneStuff.prefab b/Assets/Prefabs/SceneStuff.prefab index c637583..2b00741 100644 --- a/Assets/Prefabs/SceneStuff.prefab +++ b/Assets/Prefabs/SceneStuff.prefab @@ -230,8 +230,8 @@ Camera: m_GameObject: {fileID: 8365024802335227871} m_Enabled: 1 serializedVersion: 2 - m_ClearFlags: 1 - m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_ClearFlags: 2 + m_BackGroundColor: {r: 0.1771983, g: 0.18900065, b: 0.20754719, a: 0} m_projectionMatrixMode: 1 m_GateFitMode: 2 m_FOVAxisMode: 0 diff --git a/Assets/Prefabs/Vampire.prefab b/Assets/Prefabs/Vampire.prefab index f3b2369..9cc2cc2 100644 --- a/Assets/Prefabs/Vampire.prefab +++ b/Assets/Prefabs/Vampire.prefab @@ -14,6 +14,7 @@ GameObject: - component: {fileID: 1214567908930553477} - component: {fileID: 945832017} - component: {fileID: 945832018} + - component: {fileID: 3126145803593047825} m_Layer: 0 m_Name: Vampire m_TagString: Untagged @@ -200,6 +201,10 @@ MonoBehaviour: m_Calls: [] m_ActionId: 6e7e8be9-9198-4490-bb0c-a25fa63601b6 m_ActionName: UI/TrackedDeviceOrientation + - m_PersistentCalls: + m_Calls: [] + m_ActionId: d0405457-c534-4103-a0b6-cf113432b467 + m_ActionName: Player/SwitchMinion[/Keyboard/q,/Keyboard/e,/XInputControllerWindows/leftShoulder,/XInputControllerWindows/rightShoulder] m_NeverAutoSwitchControlSchemes: 0 m_DefaultControlScheme: m_DefaultActionMap: Player @@ -242,3 +247,24 @@ CircleCollider2D: m_Offset: {x: 0, y: 0} serializedVersion: 2 m_Radius: 0.5 +--- !u!114 &3126145803593047825 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1214567908930553593} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 3d475633c5bc498fac5a9e5ead64da55, type: 3} + m_Name: + m_EditorClassIdentifier: + k__BackingField: 10 + movementSpeed: 0 + rotSpeed: 0 + fov: 0 + attackRange: 0 + attackDmg: 0 + attackCooldown: 0 + target: {fileID: 0} + healthBar: {fileID: 0} diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index 2f3bac9..236943a 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -250,6 +250,17 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 581322f036f3ff1448d4d2ec70f295a4, type: 3} +--- !u!114 &1464970062 stripped +MonoBehaviour: + m_CorrespondingSourceObject: {fileID: 1878107874314509256, guid: e1dac4f28fe75a547b919b7aa8240fed, type: 3} + m_PrefabInstance: {fileID: 1551362086} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: aadb67b8f73573a44b31b015f38561ee, type: 3} + m_Name: + m_EditorClassIdentifier: --- !u!1001 &1551362086 PrefabInstance: m_ObjectHideFlags: 0 @@ -465,5 +476,14 @@ PrefabInstance: propertyPath: m_SortingOrder value: 0 objectReference: {fileID: 0} - m_RemovedComponents: [] + - target: {fileID: 3126145803593047825, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3} + propertyPath: healthBar + value: + objectReference: {fileID: 1464970062} + - target: {fileID: 3126145803593047825, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3} + propertyPath: k__BackingField + value: 100 + objectReference: {fileID: 0} + m_RemovedComponents: + - {fileID: 7731321959366517533, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3} m_SourcePrefab: {fileID: 100100000, guid: 3e0aae8cda56aef44af9598dc5471020, type: 3} diff --git a/Assets/Scripts/Arena.cs b/Assets/Scripts/Arena.cs index 72490e6..78c76bd 100644 --- a/Assets/Scripts/Arena.cs +++ b/Assets/Scripts/Arena.cs @@ -17,7 +17,7 @@ public class Arena : MonoBehaviour { void SpawnEnemy(int spawnerIndex) { var monster = Instantiate(monsterPrefab, spawners[spawnerIndex], Quaternion.identity).GetComponent(); //TODO Replace hardcoded target with entity discovery - monster.SetTarget(safeZone.transform); + monster.SetTarget(FindObjectOfType().transform); } IEnumerator SpawnEnemies() { diff --git a/Assets/Scripts/Entity.cs b/Assets/Scripts/Entity.cs index 4358336..cc4f38a 100644 --- a/Assets/Scripts/Entity.cs +++ b/Assets/Scripts/Entity.cs @@ -4,7 +4,7 @@ using UnityEngine; public class Entity : MonoBehaviour { - [SerializeField]private float health; + [field: SerializeField]protected float Health { get; private set; } [SerializeField]private float movementSpeed; [SerializeField]private float rotSpeed; [SerializeField]private float fov; @@ -23,6 +23,7 @@ public class Entity : MonoBehaviour } protected virtual void Attack(){ + // jason: TODO Either have target be Entity instead of transform, or skip Attack when GetComponent() is null Entity targetEntity = target.GetComponent(); bool isTargetAlive = targetEntity.TakeDamage(attackDmg); } @@ -49,9 +50,9 @@ public class Entity : MonoBehaviour } //Apply damage to the entity, returns true if it is still alive - public bool TakeDamage(float amount){ - health -= amount; - if(health <= 0){ + public virtual bool TakeDamage(float amount){ + Health -= amount; + if(Health <= 0){ return false; } return true; diff --git a/Assets/Scripts/VampireEntity.cs b/Assets/Scripts/VampireEntity.cs new file mode 100644 index 0000000..51561e8 --- /dev/null +++ b/Assets/Scripts/VampireEntity.cs @@ -0,0 +1,22 @@ +//TODO Replace with Damageable? + +using UnityEngine; + +public class VampireEntity : Entity { + [SerializeField] HealthBar healthBar; + float initialHealth; + + protected override void Start() { + base.Start(); + SetName("Vampire"); + + initialHealth = Health; + } + + public override bool TakeDamage(float amount) { + bool stillAlive = base.TakeDamage(amount); + healthBar.SetHealthFraction(Health / initialHealth); + + return stillAlive; + } +} \ No newline at end of file diff --git a/Assets/Scripts/VampireEntity.cs.meta b/Assets/Scripts/VampireEntity.cs.meta new file mode 100644 index 0000000..968a5e9 --- /dev/null +++ b/Assets/Scripts/VampireEntity.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 3d475633c5bc498fac5a9e5ead64da55 +timeCreated: 1648889808 \ No newline at end of file