diff --git a/Assets/Player.prefab b/Assets/Player.prefab index cc17239..7c81f36 100644 --- a/Assets/Player.prefab +++ b/Assets/Player.prefab @@ -104,10 +104,14 @@ MonoBehaviour: m_Name: m_EditorClassIdentifier: health: 100 + maxHealth: 100 moveSpeed: 15 swingRange: 2 + swingDistance: 10 damageStrength: 10 attackCooldownSeconds: 2 + dashDistance: 5 + dashCooldownSeconds: 5 --- !u!50 &-4152331571693237436 Rigidbody2D: serializedVersion: 5 diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity index e8a896a..aff3797 100644 --- a/Assets/Scenes/SampleScene.unity +++ b/Assets/Scenes/SampleScene.unity @@ -314,6 +314,10 @@ PrefabInstance: propertyPath: m_RenderPostProcessing value: 0 objectReference: {fileID: 0} + - target: {fileID: 6118034672792182209, guid: e05928a0d673caf999d31b31b994a112, type: 3} + propertyPath: attackCooldownSeconds + value: 3 + objectReference: {fileID: 0} m_RemovedComponents: - {fileID: 0} m_RemovedGameObjects: [] @@ -851,7 +855,7 @@ MonoBehaviour: m_GameObject: {fileID: 1394869898} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 07e7096bcd8103c3faadeefc30c8a2f4, type: 3} + m_Script: {fileID: 11500000, guid: d13803709cc4d9259a92b5dc9f49fe05, type: 3} m_Name: m_EditorClassIdentifier: --- !u!1 &1873397570 diff --git a/Assets/Shop/damage.png.meta b/Assets/Shop/damage.png.meta index 826d951..a54b3eb 100644 --- a/Assets/Shop/damage.png.meta +++ b/Assets/Shop/damage.png.meta @@ -96,6 +96,19 @@ TextureImporter: ignorePlatformSupport: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 spriteSheet: serializedVersion: 2 sprites: @@ -134,7 +147,8 @@ TextureImporter: secondaryTextures: [] spriteCustomMetadata: entries: [] - nameFileIdTable: {} + nameFileIdTable: + damage_0: 370836429328893637 mipmapLimitGroupName: pSDRemoveMatte: 0 userData: diff --git a/Assets/Shop/maxHealth.png.meta b/Assets/Shop/maxHealth.png.meta index 32a070c..00bf667 100644 --- a/Assets/Shop/maxHealth.png.meta +++ b/Assets/Shop/maxHealth.png.meta @@ -96,6 +96,19 @@ TextureImporter: ignorePlatformSupport: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 spriteSheet: serializedVersion: 2 sprites: @@ -134,7 +147,8 @@ TextureImporter: secondaryTextures: [] spriteCustomMetadata: entries: [] - nameFileIdTable: {} + nameFileIdTable: + maxHealth_0: -7179106657035232709 mipmapLimitGroupName: pSDRemoveMatte: 0 userData: diff --git a/Assets/Shop/range.png.meta b/Assets/Shop/range.png.meta index 272393e..e67b173 100644 --- a/Assets/Shop/range.png.meta +++ b/Assets/Shop/range.png.meta @@ -96,6 +96,19 @@ TextureImporter: ignorePlatformSupport: 0 androidETC2FallbackOverride: 0 forceMaximumCompressionQuality_BC6H_BC7: 0 + - serializedVersion: 4 + buildTarget: WebGL + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + ignorePlatformSupport: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 spriteSheet: serializedVersion: 2 sprites: @@ -134,7 +147,8 @@ TextureImporter: secondaryTextures: [] spriteCustomMetadata: entries: [] - nameFileIdTable: {} + nameFileIdTable: + range_0: -360538525503843100 mipmapLimitGroupName: pSDRemoveMatte: 0 userData: diff --git a/Assets/Teo.cs b/Assets/Teo.cs index b78b58f..2528510 100644 --- a/Assets/Teo.cs +++ b/Assets/Teo.cs @@ -8,12 +8,12 @@ public class Teo : MonoBehaviour public float swingRange = 3; public float swingDistance = 10; public float damageStrength = 10; - public float attackCooldownSeconds = 2; + public float attackCooldownSeconds = 10; public float dashDistance = 5; public float dashCooldownSeconds = 5; Rigidbody2D controller; GameState gameState; - float lastAttackTime; + float lastAttackTime = 0; // Start is called once before the first execution of Update after the MonoBehaviour is created void Start() { controller = GetComponent(); @@ -29,22 +29,29 @@ public class Teo : MonoBehaviour ).normalized * moveSpeed; // Attack on click if not on cooldown - if (Input.GetMouseButtonDown(0) && Time.fixedTime > lastAttackTime + attackCooldownSeconds) { - // Get all objects in range in the direction of cursor - RaycastHit2D[] hits = Physics2D.CircleCastAll( - transform.position, - swingRange, - new Vector2( - Screen.width/2 - Input.mousePosition.x, - Screen.height/2 - Input.mousePosition.y - ) - ); - // Damage all ratbots in scanned area - foreach (RaycastHit2D hit in hits) { - Ratbot ratbot = hit.collider.GetComponent(); - if (ratbot == null) continue; - ratbot.Damage(damageStrength); - } + if (Input.GetMouseButtonDown(0)) { + Attack(); + lastAttackTime = Time.fixedTime; + } + } + void Attack() { + if (Time.fixedTime-attackCooldownSeconds > lastAttackTime) { + return; + } + // Get all objects in range in the direction of cursor + RaycastHit2D[] hits = Physics2D.CircleCastAll( + transform.position, + swingRange, + new Vector2( + Screen.width/2 - Input.mousePosition.x, + Screen.height/2 - Input.mousePosition.y + ) + ); + // Damage all ratbots in scanned area + foreach (RaycastHit2D hit in hits) { + Ratbot ratbot = hit.collider.GetComponent(); + if (ratbot == null) continue; + ratbot.Damage(damageStrength); } } } diff --git a/Assets/UI overlay/HealthIndicator.cs b/Assets/UI overlay/HealthIndicator.cs new file mode 100644 index 0000000..d7ea638 --- /dev/null +++ b/Assets/UI overlay/HealthIndicator.cs @@ -0,0 +1,17 @@ +using UnityEngine; + +public class HealthIndicator : MonoBehaviour +{ + Teo player; + // Start is called once before the first execution of Update after the MonoBehaviour is created + void Start() + { + player = GameObject.FindGameObjectWithTag("Player").GetComponent(); + } + + // Update is called once per frame + void Update() + { + GetComponent().text = "Health: "+player.health+"/"+player.maxHealth; + } +} diff --git a/Assets/UI overlay/HealthIndicator.cs.meta b/Assets/UI overlay/HealthIndicator.cs.meta new file mode 100644 index 0000000..6afd67b --- /dev/null +++ b/Assets/UI overlay/HealthIndicator.cs.meta @@ -0,0 +1,2 @@ +fileFormatVersion: 2 +guid: d13803709cc4d9259a92b5dc9f49fe05 \ No newline at end of file diff --git a/Assets/UI overlay/healthIndicator.cs b/Assets/UI overlay/healthIndicator.cs deleted file mode 100644 index e22a400..0000000 --- a/Assets/UI overlay/healthIndicator.cs +++ /dev/null @@ -1,17 +0,0 @@ -using UnityEngine; - -public class healthIndicator : MonoBehaviour -{ - GameObject player; - // Start is called once before the first execution of Update after the MonoBehaviour is created - void Start() - { - player = GameObject.FindGameObjectWithTag("Player"); - } - - // Update is called once per frame - void Update() - { - GetComponent().text = "Health: "+player.GetComponent().health.ToString()+"/100"; - } -} diff --git a/Assets/UI overlay/healthIndicator.cs.meta b/Assets/UI overlay/healthIndicator.cs.meta deleted file mode 100644 index 5bd1eb8..0000000 --- a/Assets/UI overlay/healthIndicator.cs.meta +++ /dev/null @@ -1,2 +0,0 @@ -fileFormatVersion: 2 -guid: 07e7096bcd8103c3faadeefc30c8a2f4 \ No newline at end of file