Attack cooldown works now
This commit is contained in:
@@ -104,10 +104,14 @@ MonoBehaviour:
|
|||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
health: 100
|
health: 100
|
||||||
|
maxHealth: 100
|
||||||
moveSpeed: 15
|
moveSpeed: 15
|
||||||
swingRange: 2
|
swingRange: 2
|
||||||
|
swingDistance: 10
|
||||||
damageStrength: 10
|
damageStrength: 10
|
||||||
attackCooldownSeconds: 2
|
attackCooldownSeconds: 2
|
||||||
|
dashDistance: 5
|
||||||
|
dashCooldownSeconds: 5
|
||||||
--- !u!50 &-4152331571693237436
|
--- !u!50 &-4152331571693237436
|
||||||
Rigidbody2D:
|
Rigidbody2D:
|
||||||
serializedVersion: 5
|
serializedVersion: 5
|
||||||
|
|||||||
@@ -314,6 +314,10 @@ PrefabInstance:
|
|||||||
propertyPath: m_RenderPostProcessing
|
propertyPath: m_RenderPostProcessing
|
||||||
value: 0
|
value: 0
|
||||||
objectReference: {fileID: 0}
|
objectReference: {fileID: 0}
|
||||||
|
- target: {fileID: 6118034672792182209, guid: e05928a0d673caf999d31b31b994a112, type: 3}
|
||||||
|
propertyPath: attackCooldownSeconds
|
||||||
|
value: 3
|
||||||
|
objectReference: {fileID: 0}
|
||||||
m_RemovedComponents:
|
m_RemovedComponents:
|
||||||
- {fileID: 0}
|
- {fileID: 0}
|
||||||
m_RemovedGameObjects: []
|
m_RemovedGameObjects: []
|
||||||
@@ -851,7 +855,7 @@ MonoBehaviour:
|
|||||||
m_GameObject: {fileID: 1394869898}
|
m_GameObject: {fileID: 1394869898}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: 07e7096bcd8103c3faadeefc30c8a2f4, type: 3}
|
m_Script: {fileID: 11500000, guid: d13803709cc4d9259a92b5dc9f49fe05, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &1873397570
|
--- !u!1 &1873397570
|
||||||
|
|||||||
@@ -96,6 +96,19 @@ TextureImporter:
|
|||||||
ignorePlatformSupport: 0
|
ignorePlatformSupport: 0
|
||||||
androidETC2FallbackOverride: 0
|
androidETC2FallbackOverride: 0
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 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:
|
spriteSheet:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
sprites:
|
sprites:
|
||||||
@@ -134,7 +147,8 @@ TextureImporter:
|
|||||||
secondaryTextures: []
|
secondaryTextures: []
|
||||||
spriteCustomMetadata:
|
spriteCustomMetadata:
|
||||||
entries: []
|
entries: []
|
||||||
nameFileIdTable: {}
|
nameFileIdTable:
|
||||||
|
damage_0: 370836429328893637
|
||||||
mipmapLimitGroupName:
|
mipmapLimitGroupName:
|
||||||
pSDRemoveMatte: 0
|
pSDRemoveMatte: 0
|
||||||
userData:
|
userData:
|
||||||
|
|||||||
@@ -96,6 +96,19 @@ TextureImporter:
|
|||||||
ignorePlatformSupport: 0
|
ignorePlatformSupport: 0
|
||||||
androidETC2FallbackOverride: 0
|
androidETC2FallbackOverride: 0
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 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:
|
spriteSheet:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
sprites:
|
sprites:
|
||||||
@@ -134,7 +147,8 @@ TextureImporter:
|
|||||||
secondaryTextures: []
|
secondaryTextures: []
|
||||||
spriteCustomMetadata:
|
spriteCustomMetadata:
|
||||||
entries: []
|
entries: []
|
||||||
nameFileIdTable: {}
|
nameFileIdTable:
|
||||||
|
maxHealth_0: -7179106657035232709
|
||||||
mipmapLimitGroupName:
|
mipmapLimitGroupName:
|
||||||
pSDRemoveMatte: 0
|
pSDRemoveMatte: 0
|
||||||
userData:
|
userData:
|
||||||
|
|||||||
@@ -96,6 +96,19 @@ TextureImporter:
|
|||||||
ignorePlatformSupport: 0
|
ignorePlatformSupport: 0
|
||||||
androidETC2FallbackOverride: 0
|
androidETC2FallbackOverride: 0
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 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:
|
spriteSheet:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
sprites:
|
sprites:
|
||||||
@@ -134,7 +147,8 @@ TextureImporter:
|
|||||||
secondaryTextures: []
|
secondaryTextures: []
|
||||||
spriteCustomMetadata:
|
spriteCustomMetadata:
|
||||||
entries: []
|
entries: []
|
||||||
nameFileIdTable: {}
|
nameFileIdTable:
|
||||||
|
range_0: -360538525503843100
|
||||||
mipmapLimitGroupName:
|
mipmapLimitGroupName:
|
||||||
pSDRemoveMatte: 0
|
pSDRemoveMatte: 0
|
||||||
userData:
|
userData:
|
||||||
|
|||||||
@@ -8,12 +8,12 @@ public class Teo : MonoBehaviour
|
|||||||
public float swingRange = 3;
|
public float swingRange = 3;
|
||||||
public float swingDistance = 10;
|
public float swingDistance = 10;
|
||||||
public float damageStrength = 10;
|
public float damageStrength = 10;
|
||||||
public float attackCooldownSeconds = 2;
|
public float attackCooldownSeconds = 10;
|
||||||
public float dashDistance = 5;
|
public float dashDistance = 5;
|
||||||
public float dashCooldownSeconds = 5;
|
public float dashCooldownSeconds = 5;
|
||||||
Rigidbody2D controller;
|
Rigidbody2D controller;
|
||||||
GameState gameState;
|
GameState gameState;
|
||||||
float lastAttackTime;
|
float lastAttackTime = 0;
|
||||||
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||||||
void Start() {
|
void Start() {
|
||||||
controller = GetComponent<Rigidbody2D>();
|
controller = GetComponent<Rigidbody2D>();
|
||||||
@@ -29,7 +29,15 @@ public class Teo : MonoBehaviour
|
|||||||
).normalized * moveSpeed;
|
).normalized * moveSpeed;
|
||||||
|
|
||||||
// Attack on click if not on cooldown
|
// Attack on click if not on cooldown
|
||||||
if (Input.GetMouseButtonDown(0) && Time.fixedTime > lastAttackTime + attackCooldownSeconds) {
|
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
|
// Get all objects in range in the direction of cursor
|
||||||
RaycastHit2D[] hits = Physics2D.CircleCastAll(
|
RaycastHit2D[] hits = Physics2D.CircleCastAll(
|
||||||
transform.position,
|
transform.position,
|
||||||
@@ -47,4 +55,3 @@ public class Teo : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|||||||
17
Assets/UI overlay/HealthIndicator.cs
Normal file
17
Assets/UI overlay/HealthIndicator.cs
Normal file
@@ -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<Teo>();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update is called once per frame
|
||||||
|
void Update()
|
||||||
|
{
|
||||||
|
GetComponent<TMPro.TMP_Text>().text = "Health: "+player.health+"/"+player.maxHealth;
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/UI overlay/HealthIndicator.cs.meta
Normal file
2
Assets/UI overlay/HealthIndicator.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: d13803709cc4d9259a92b5dc9f49fe05
|
||||||
@@ -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<TMPro.TMP_Text>().text = "Health: "+player.GetComponent<Teo>().health.ToString()+"/100";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 07e7096bcd8103c3faadeefc30c8a2f4
|
|
||||||
Reference in New Issue
Block a user