Attack cooldown works fr this time
This commit is contained in:
@@ -112,6 +112,7 @@ MonoBehaviour:
|
|||||||
attackCooldownSeconds: 2
|
attackCooldownSeconds: 2
|
||||||
dashDistance: 5
|
dashDistance: 5
|
||||||
dashCooldownSeconds: 5
|
dashCooldownSeconds: 5
|
||||||
|
lastAttackTime: 0
|
||||||
--- !u!50 &-4152331571693237436
|
--- !u!50 &-4152331571693237436
|
||||||
Rigidbody2D:
|
Rigidbody2D:
|
||||||
serializedVersion: 5
|
serializedVersion: 5
|
||||||
|
|||||||
@@ -215,6 +215,7 @@ RectTransform:
|
|||||||
m_Children:
|
m_Children:
|
||||||
- {fileID: 1394869899}
|
- {fileID: 1394869899}
|
||||||
- {fileID: 782734291}
|
- {fileID: 782734291}
|
||||||
|
- {fileID: 1698359317}
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
m_AnchorMin: {x: 0, y: 0}
|
m_AnchorMin: {x: 0, y: 0}
|
||||||
@@ -858,6 +859,94 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: d13803709cc4d9259a92b5dc9f49fe05, type: 3}
|
m_Script: {fileID: 11500000, guid: d13803709cc4d9259a92b5dc9f49fe05, type: 3}
|
||||||
m_Name:
|
m_Name:
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
|
--- !u!1 &1698359316
|
||||||
|
GameObject:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
serializedVersion: 6
|
||||||
|
m_Component:
|
||||||
|
- component: {fileID: 1698359317}
|
||||||
|
- component: {fileID: 1698359319}
|
||||||
|
- component: {fileID: 1698359318}
|
||||||
|
- component: {fileID: 1698359320}
|
||||||
|
m_Layer: 5
|
||||||
|
m_Name: AttackCooldown
|
||||||
|
m_TagString: Untagged
|
||||||
|
m_Icon: {fileID: 0}
|
||||||
|
m_NavMeshLayer: 0
|
||||||
|
m_StaticEditorFlags: 0
|
||||||
|
m_IsActive: 1
|
||||||
|
--- !u!224 &1698359317
|
||||||
|
RectTransform:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1698359316}
|
||||||
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
|
m_ConstrainProportionsScale: 0
|
||||||
|
m_Children: []
|
||||||
|
m_Father: {fileID: 109163895}
|
||||||
|
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||||
|
m_AnchorMin: {x: 0.5, y: 0.5}
|
||||||
|
m_AnchorMax: {x: 0.5, y: 0.5}
|
||||||
|
m_AnchoredPosition: {x: 0, y: -75}
|
||||||
|
m_SizeDelta: {x: 100, y: 10}
|
||||||
|
m_Pivot: {x: 0.5, y: 0.5}
|
||||||
|
--- !u!114 &1698359318
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1698359316}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
|
m_Material: {fileID: 0}
|
||||||
|
m_Color: {r: 1, g: 0, b: 0, a: 1}
|
||||||
|
m_RaycastTarget: 1
|
||||||
|
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||||
|
m_Maskable: 1
|
||||||
|
m_OnCullStateChanged:
|
||||||
|
m_PersistentCalls:
|
||||||
|
m_Calls: []
|
||||||
|
m_Sprite: {fileID: 0}
|
||||||
|
m_Type: 0
|
||||||
|
m_PreserveAspect: 0
|
||||||
|
m_FillCenter: 1
|
||||||
|
m_FillMethod: 4
|
||||||
|
m_FillAmount: 1
|
||||||
|
m_FillClockwise: 1
|
||||||
|
m_FillOrigin: 0
|
||||||
|
m_UseSpriteMesh: 0
|
||||||
|
m_PixelsPerUnitMultiplier: 1
|
||||||
|
--- !u!222 &1698359319
|
||||||
|
CanvasRenderer:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1698359316}
|
||||||
|
m_CullTransparentMesh: 1
|
||||||
|
--- !u!114 &1698359320
|
||||||
|
MonoBehaviour:
|
||||||
|
m_ObjectHideFlags: 0
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_GameObject: {fileID: 1698359316}
|
||||||
|
m_Enabled: 1
|
||||||
|
m_EditorHideFlags: 0
|
||||||
|
m_Script: {fileID: 11500000, guid: 44c4f0b9443ce51e7bb9fbb5e2ee3e47, type: 3}
|
||||||
|
m_Name:
|
||||||
|
m_EditorClassIdentifier:
|
||||||
--- !u!1 &1873397570
|
--- !u!1 &1873397570
|
||||||
GameObject:
|
GameObject:
|
||||||
m_ObjectHideFlags: 0
|
m_ObjectHideFlags: 0
|
||||||
|
|||||||
@@ -11,9 +11,9 @@ public class Teo : MonoBehaviour
|
|||||||
public float attackCooldownSeconds = 10;
|
public float attackCooldownSeconds = 10;
|
||||||
public float dashDistance = 5;
|
public float dashDistance = 5;
|
||||||
public float dashCooldownSeconds = 5;
|
public float dashCooldownSeconds = 5;
|
||||||
|
public float lastAttackTime = 0;
|
||||||
Rigidbody2D controller;
|
Rigidbody2D controller;
|
||||||
GameState gameState;
|
GameState gameState;
|
||||||
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>();
|
||||||
@@ -27,7 +27,6 @@ public class Teo : MonoBehaviour
|
|||||||
Input.GetAxis("Horizontal"),
|
Input.GetAxis("Horizontal"),
|
||||||
Input.GetAxis("Vertical")
|
Input.GetAxis("Vertical")
|
||||||
).normalized * moveSpeed;
|
).normalized * moveSpeed;
|
||||||
|
|
||||||
// Attack on click if not on cooldown
|
// Attack on click if not on cooldown
|
||||||
if (Input.GetMouseButtonDown(0)) {
|
if (Input.GetMouseButtonDown(0)) {
|
||||||
Attack();
|
Attack();
|
||||||
@@ -35,7 +34,7 @@ public class Teo : MonoBehaviour
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
void Attack() {
|
void Attack() {
|
||||||
if (Time.fixedTime-attackCooldownSeconds > lastAttackTime) {
|
if (Time.fixedTime-lastAttackTime < attackCooldownSeconds) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Get all objects in range in the direction of cursor
|
// Get all objects in range in the direction of cursor
|
||||||
|
|||||||
17
Assets/UI overlay/AttackCooldown.cs
Normal file
17
Assets/UI overlay/AttackCooldown.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
public class AttackCooldown : MonoBehaviour
|
||||||
|
{
|
||||||
|
Teo player;
|
||||||
|
TMPro.TMP_Sprite bar;
|
||||||
|
// 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()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/UI overlay/AttackCooldown.cs.meta
Normal file
2
Assets/UI overlay/AttackCooldown.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 44c4f0b9443ce51e7bb9fbb5e2ee3e47
|
||||||
Reference in New Issue
Block a user