Compare commits
11 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
00e347cc56 | ||
|
|
70518b2b69 | ||
|
|
36815eb876 | ||
|
|
bbaebadbed | ||
|
|
a32e858f6f | ||
|
|
1e6872f0fb | ||
|
|
390c742d03 | ||
|
|
62a0b7e4e1 | ||
|
|
5a379ec239 | ||
|
|
164df0339c | ||
|
|
e8b62b8fb7 |
1405
Assets/Prefabs/Block.anim
Normal file
1405
Assets/Prefabs/Block.anim
Normal file
File diff suppressed because it is too large
Load Diff
8
Assets/Prefabs/Block.anim.meta
Normal file
8
Assets/Prefabs/Block.anim.meta
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: 896bcaa1220cb294480528aa82dbc0e7
|
||||||
|
NativeFormatImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
mainObjectFileID: 7400000
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
||||||
68
Assets/Scripts/Block.cs
Normal file
68
Assets/Scripts/Block.cs
Normal file
@@ -0,0 +1,68 @@
|
|||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.InputSystem;
|
||||||
|
|
||||||
|
[RequireComponent(typeof(PlayerInput))]
|
||||||
|
[RequireComponent(typeof(Animation))]
|
||||||
|
public class Block : MonoBehaviour
|
||||||
|
{
|
||||||
|
//public bool cancelable = true;
|
||||||
|
[SerializeField] private BoxCollider2D blockArea;
|
||||||
|
|
||||||
|
private InputActionAsset actions;
|
||||||
|
private Animation animationComponent;
|
||||||
|
|
||||||
|
public bool blocking = false;
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
actions = GetComponent<PlayerInput>().actions;
|
||||||
|
animationComponent = GetComponent<Animation>();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
var blockAction = actions.FindAction("Block");
|
||||||
|
|
||||||
|
if (blockAction.ReadValue<float>() == 1f)
|
||||||
|
{
|
||||||
|
Debug.Log("Block action triggered!");
|
||||||
|
|
||||||
|
//if (!cancelable) return;
|
||||||
|
|
||||||
|
//animationComponent.Play("Block");
|
||||||
|
GetComponent<AnimationPlayer>().Block();
|
||||||
|
|
||||||
|
DisableCancellation();
|
||||||
|
ActivateBlockArea();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DeactivateBlockArea();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ActivateBlockArea()
|
||||||
|
{
|
||||||
|
blockArea.enabled = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DeactivateBlockArea()
|
||||||
|
{
|
||||||
|
blockArea.enabled = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void DisableCancellation()
|
||||||
|
{
|
||||||
|
//cancelable = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void EnableCancellation()
|
||||||
|
{
|
||||||
|
//cancelable = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool IsBlocking()
|
||||||
|
{
|
||||||
|
return blockArea.enabled;
|
||||||
|
}
|
||||||
|
}
|
||||||
2
Assets/Scripts/Block.cs.meta
Normal file
2
Assets/Scripts/Block.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: c8c9288561905664eade3f6b2634fc6d
|
||||||
@@ -32,4 +32,9 @@ public class AnimationPlayer : MonoBehaviour
|
|||||||
{
|
{
|
||||||
animator.SetTrigger("punch");
|
animator.SetTrigger("punch");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Block()
|
||||||
|
{
|
||||||
|
animator.SetTrigger("Block");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user