diff --git a/Assets/Animations/Sticks/BaseStick/animator_baseStick.controller b/Assets/Animations/Sticks/BaseStick/animator_baseStick.controller index c8be080..50cef6d 100644 --- a/Assets/Animations/Sticks/BaseStick/animator_baseStick.controller +++ b/Assets/Animations/Sticks/BaseStick/animator_baseStick.controller @@ -36,7 +36,7 @@ AnimatorController: m_DefaultFloat: 0 m_DefaultInt: 0 m_DefaultBool: 0 - m_Controller: {fileID: 9100000} + m_Controller: {fileID: 0} m_AnimatorLayers: - serializedVersion: 5 m_Name: Base Layer diff --git a/Assets/Prefabs/Sticks/riderStick.prefab b/Assets/Prefabs/Sticks/riderStick.prefab index 51b03d7..334ad27 100644 --- a/Assets/Prefabs/Sticks/riderStick.prefab +++ b/Assets/Prefabs/Sticks/riderStick.prefab @@ -1118,11 +1118,13 @@ MonoBehaviour: _attack_damage: 3 _attack_interval: 2 _enemy: {fileID: 0} + _chargeAttackDamage: 5 + _chargeCooldown: 5 + _maxChargeHitCount: 3 + _maxChargeDistance: 10 _detection: {fileID: 9048754633958631738} _chargeDetection: {fileID: 4280547952316628076} _root: {fileID: 2230360378127571586} - _maxChargeHitCount: 3 - _maxChargeDistance: 10 --- !u!1839735485 &3032268583489863936 Tilemap: m_ObjectHideFlags: 0 diff --git a/Assets/Scripts/Ally/Rider.cs b/Assets/Scripts/Ally/Rider.cs index 3145c5b..ca35db2 100644 --- a/Assets/Scripts/Ally/Rider.cs +++ b/Assets/Scripts/Ally/Rider.cs @@ -4,23 +4,29 @@ using UnityEngine; public class Rider : Ally { + [SerializeField] + private int _chargeAttackDamage; + [SerializeField] + private int _chargeCooldown; + [SerializeField] + private int _maxChargeHitCount; + [SerializeField] + private int _maxChargeDistance; [SerializeField] private GameObject _detection; [SerializeField] private GameObject _chargeDetection; - private Detection _chargeDetectionScript; [SerializeField] private GameObject _root; + + private Detection _chargeDetectionScript; private Root _rootScript; + private Vector3 _originalPos; private Vector2 _movementVector = Vector2.zero; private bool _isCharging; - [SerializeField] - private int _maxChargeHitCount; + private float _timeSinceLastCharge; private List _opponentsHit = new List(); - [SerializeField] - private int _maxChargeDistance; - private Vector3 _originalPos; public override void Start() { @@ -35,8 +41,15 @@ public class Rider : Ally public override void Update() { + // check for charge cooldown + if (_timeSinceLastCharge > _chargeCooldown) + { + _isCharging = true; + } + if (_isCharging) { + // toggle charge detection _detection.SetActive(false); _chargeDetection.SetActive(true); @@ -53,20 +66,27 @@ public class Rider : Ally // reset if (transform.position.x - _originalPos.x >= _maxChargeDistance || _opponentsHit.Count >= _maxChargeHitCount) { - _isCharging = false; + // position _movementVector = Vector2.zero; transform.position = _originalPos; + + // charge state + _isCharging = false; + _timeSinceLastCharge = 0; _opponentsHit.Clear(); + // detection state IsEnemyDetected = false; Enemy = null; + // toggle detection _detection.SetActive(true); _chargeDetection.SetActive(false); } } else { + _timeSinceLastCharge += Time.deltaTime; if (IsEnemyDetected) { AttackEnemy(); @@ -76,7 +96,7 @@ public class Rider : Ally void AttackEnemyRiding() { - _rootScript.Attack(); + _rootScript.AttackWithCustomDamage(_chargeAttackDamage); _opponentsHit.Add(Enemy); } diff --git a/Assets/Scripts/Root.cs b/Assets/Scripts/Root.cs index 338cc8f..5578eb9 100644 --- a/Assets/Scripts/Root.cs +++ b/Assets/Scripts/Root.cs @@ -24,6 +24,18 @@ public class Root : MonoBehaviour } } + public void AttackWithCustomDamage(int damage) + { + if (_entity == null || _entity.Enemy == null) return; + + _entity.Enemy.Hit(damage); + if (_entity.Enemy.Hp <= 0) + { + _entity.Enemy.Death(); + _entity.IsEnemyDetected = false; + } + } + public void ShotProjectile() { Rigidbody2D _rigidbodyAlly;