Adds knight on horse and its animations #8
@ -1010,7 +1010,8 @@ MonoBehaviour:
|
|||||||
_chargeAttackDamage: 3
|
_chargeAttackDamage: 3
|
||||||
_chargeCooldown: 10
|
_chargeCooldown: 10
|
||||||
_maxChargeHitCount: 3
|
_maxChargeHitCount: 3
|
||||||
_maxChargeDistance: 10
|
_maxChargeDistance: 7
|
||||||
|
_fadeDistance: 1
|
||||||
_detection: {fileID: 9048754633958631738}
|
_detection: {fileID: 9048754633958631738}
|
||||||
_chargeDetection: {fileID: 3062706309015911873}
|
_chargeDetection: {fileID: 3062706309015911873}
|
||||||
_root: {fileID: 2230360378127571586}
|
_root: {fileID: 2230360378127571586}
|
||||||
@ -2776,7 +2777,7 @@ Transform:
|
|||||||
m_PrefabAsset: {fileID: 0}
|
m_PrefabAsset: {fileID: 0}
|
||||||
m_GameObject: {fileID: 9048754633958631738}
|
m_GameObject: {fileID: 9048754633958631738}
|
||||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||||
m_LocalPosition: {x: -0.33, y: 0, z: 0}
|
m_LocalPosition: {x: -0.57, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||||
m_ConstrainProportionsScale: 0
|
m_ConstrainProportionsScale: 0
|
||||||
m_Children: []
|
m_Children: []
|
||||||
@ -2796,7 +2797,7 @@ BoxCollider2D:
|
|||||||
m_IsTrigger: 1
|
m_IsTrigger: 1
|
||||||
m_UsedByEffector: 0
|
m_UsedByEffector: 0
|
||||||
m_UsedByComposite: 0
|
m_UsedByComposite: 0
|
||||||
m_Offset: {x: 1.33, y: 0}
|
m_Offset: {x: 1.57, y: 0}
|
||||||
m_SpriteTilingProperty:
|
m_SpriteTilingProperty:
|
||||||
border: {x: 0, y: 0, z: 0, w: 0}
|
border: {x: 0, y: 0, z: 0, w: 0}
|
||||||
pivot: {x: 0, y: 0}
|
pivot: {x: 0, y: 0}
|
||||||
|
|||||||
@ -13,6 +13,8 @@ public class Rider : Ally
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
private int _maxChargeDistance;
|
private int _maxChargeDistance;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
|
private float _fadeDistance;
|
||||||
|
[SerializeField]
|
||||||
private GameObject _detection;
|
private GameObject _detection;
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private GameObject _chargeDetection;
|
private GameObject _chargeDetection;
|
||||||
@ -25,10 +27,15 @@ public class Rider : Ally
|
|||||||
private int _originalAttackDamage;
|
private int _originalAttackDamage;
|
||||||
private Vector3 _originalPos;
|
private Vector3 _originalPos;
|
||||||
private Vector2 _movementVector = Vector2.zero;
|
private Vector2 _movementVector = Vector2.zero;
|
||||||
|
|
||||||
private bool _isCharging;
|
private bool _isCharging;
|
||||||
private float _timeSinceLastCharge;
|
private float _timeSinceLastCharge;
|
||||||
private List<Entity> _opponentsHit = new List<Entity>();
|
private List<Entity> _opponentsHit = new List<Entity>();
|
||||||
|
|
||||||
|
private float _fadeProgress;
|
||||||
|
private bool _isFading;
|
||||||
|
private int _fadeState;
|
||||||
|
|
||||||
public override void Start()
|
public override void Start()
|
||||||
{
|
{
|
||||||
base.Start();
|
base.Start();
|
||||||
@ -44,6 +51,61 @@ public class Rider : Ally
|
|||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
if (_isFading)
|
||||||
|
{
|
||||||
|
if (_fadeProgress < _fadeDistance && _fadeState == 0)
|
||||||
|
{
|
||||||
|
_movementVector.x = Time.deltaTime * Speed;
|
||||||
|
transform.position += (Vector3)_movementVector;
|
||||||
|
|
||||||
|
_fadeProgress += _movementVector.x / _fadeDistance;
|
||||||
|
foreach (SpriteRenderer spriteRenderer in SpriteRenderers)
|
||||||
|
{
|
||||||
|
spriteRenderer.color = new Color(1.0f, 1.0f, 1.0f, 1.0f - _fadeProgress);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (_fadeProgress > _fadeDistance && _fadeState == 0)
|
||||||
|
{
|
||||||
|
transform.position = new Vector3(_originalPos.x - _fadeDistance, _originalPos.y, _originalPos.z);
|
||||||
|
_fadeState = 1;
|
||||||
|
}
|
||||||
|
else if (_fadeProgress > _fadeDistance && _fadeState == 1 && _fadeProgress < _fadeDistance * 2)
|
||||||
|
{
|
||||||
|
_movementVector.x = Time.deltaTime * Speed;
|
||||||
|
transform.position += (Vector3)_movementVector;
|
||||||
|
|
||||||
|
_fadeProgress += _movementVector.x / _fadeDistance;
|
||||||
|
foreach (SpriteRenderer spriteRenderer in SpriteRenderers)
|
||||||
|
{
|
||||||
|
spriteRenderer.color = new Color(1.0f, 1.0f, 1.0f, _fadeProgress - _fadeDistance);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// disable fading
|
||||||
|
_isFading = false;
|
||||||
|
_fadeProgress = 0;
|
||||||
|
_fadeState = 0;
|
||||||
|
foreach (SpriteRenderer spriteRenderer in SpriteRenderers)
|
||||||
|
{
|
||||||
|
spriteRenderer.color = new Color(1.0f, 1.0f, 1.0f, 1.0f);
|
||||||
|
}
|
||||||
|
|
||||||
|
// reset position
|
||||||
|
_movementVector.x = 0;
|
||||||
|
transform.position = _originalPos;
|
||||||
|
|
||||||
|
// toggle detection
|
||||||
|
_detection.SetActive(true);
|
||||||
|
_chargeDetection.SetActive(false);
|
||||||
|
|
||||||
|
// toggle animation
|
||||||
|
Animation.ToggleChargeAnim(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
// check for charge cooldown
|
// check for charge cooldown
|
||||||
if (_timeSinceLastCharge > _chargeCooldown && !_isCharging)
|
if (_timeSinceLastCharge > _chargeCooldown && !_isCharging)
|
||||||
{
|
{
|
||||||
@ -73,10 +135,6 @@ public class Rider : Ally
|
|||||||
// reset
|
// reset
|
||||||
if (transform.position.x - _originalPos.x >= _maxChargeDistance || _opponentsHit.Count >= _maxChargeHitCount)
|
if (transform.position.x - _originalPos.x >= _maxChargeDistance || _opponentsHit.Count >= _maxChargeHitCount)
|
||||||
{
|
{
|
||||||
// position
|
|
||||||
_movementVector = Vector2.zero;
|
|
||||||
transform.position = _originalPos;
|
|
||||||
|
|
||||||
// charge state
|
// charge state
|
||||||
_isCharging = false;
|
_isCharging = false;
|
||||||
_timeSinceLastCharge = 0;
|
_timeSinceLastCharge = 0;
|
||||||
@ -86,12 +144,12 @@ public class Rider : Ally
|
|||||||
IsEnemyDetected = false;
|
IsEnemyDetected = false;
|
||||||
Enemy = null;
|
Enemy = null;
|
||||||
|
|
||||||
// toggle animation
|
|
||||||
Animation.ToggleChargeAnim(false);
|
|
||||||
|
|
||||||
// toggle detection
|
// toggle detection
|
||||||
_detection.SetActive(true);
|
_detection.SetActive(false);
|
||||||
_chargeDetection.SetActive(false);
|
_chargeDetection.SetActive(false);
|
||||||
|
|
||||||
|
// start fading
|
||||||
|
_isFading = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -103,31 +161,6 @@ public class Rider : Ally
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// attacks all enemies already in the default detection box at start of the charge.
|
|
||||||
// charge uses a different detection due to Enemy being the oldest opponent to enter the hitbox.
|
|
||||||
// therefore enemies would only get hit when the previous Enemy exits, which is at the handle instead of the tip`.
|
|
||||||
// to cover for the enemies behind the charge detection which is at the tip, we hit them all as the charge starts
|
|
||||||
private void SweepAttack()
|
|
||||||
{
|
|
||||||
foreach (Entity entity in _detectionScript.DetectedEntities)
|
|
||||||
{
|
|
||||||
Enemy = entity;
|
|
||||||
AttackEnemyRiding();
|
|
||||||
}
|
|
||||||
if (_detectionScript.DetectedEntities.Count > 0)
|
|
||||||
{
|
|
||||||
_detection.SetActive(false);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AttackEnemyRiding()
|
|
||||||
{
|
|
||||||
AttackDamage = _chargeAttackDamage;
|
|
||||||
_rootScript.Attack();
|
|
||||||
_opponentsHit.Add(Enemy);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void AttackEnemy()
|
private void AttackEnemy()
|
||||||
{
|
{
|
||||||
//Attack Cooldown
|
//Attack Cooldown
|
||||||
@ -142,4 +175,31 @@ public class Rider : Ally
|
|||||||
|
|
||||||
AttackSpeedWait += Time.deltaTime;
|
AttackSpeedWait += Time.deltaTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void AttackEnemyRiding()
|
||||||
|
{
|
||||||
|
AttackDamage = _chargeAttackDamage;
|
||||||
|
_rootScript.Attack();
|
||||||
|
_opponentsHit.Add(Enemy);
|
||||||
|
}
|
||||||
|
|
||||||
|
// attacks all enemies already in the default detection box at start of the charge.
|
||||||
|
// charge uses a different detection due to Enemy being the oldest opponent to enter the hitbox.
|
||||||
|
// therefore enemies would only get hit when the previous Enemy exits, which is at the handle instead of the tip`.
|
||||||
|
// to cover for the enemies behind the charge detection which is at the tip, we hit them all as the charge starts
|
||||||
|
private void SweepAttack()
|
||||||
|
{
|
||||||
|
foreach (Entity entity in _detectionScript.DetectedEntities)
|
||||||
|
{
|
||||||
|
if (!_opponentsHit.Contains(entity))
|
||||||
|
{
|
||||||
|
Enemy = entity;
|
||||||
|
AttackEnemyRiding();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (_detectionScript.DetectedEntities.Count > 0)
|
||||||
|
{
|
||||||
|
_detection.SetActive(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@ -33,7 +33,7 @@ public abstract class Entity : LevelObject
|
|||||||
public virtual void Start()
|
public virtual void Start()
|
||||||
{
|
{
|
||||||
_maxHp = _hp;
|
_maxHp = _hp;
|
||||||
_spriteRenderers = GetComponentsInChildren<SpriteRenderer>();
|
_spriteRenderers = GetComponentsInChildren<SpriteRenderer>(true);
|
||||||
_audioPlayerComponent = GetComponent<AudioPlayerComponent>();
|
_audioPlayerComponent = GetComponent<AudioPlayerComponent>();
|
||||||
Animation = gameObject.AddComponent<AnimationEntity>();
|
Animation = gameObject.AddComponent<AnimationEntity>();
|
||||||
}
|
}
|
||||||
@ -155,6 +155,8 @@ public abstract class Entity : LevelObject
|
|||||||
set { _animation = value; }
|
set { _animation = value; }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public SpriteRenderer[] SpriteRenderers { get { return _spriteRenderers; } }
|
||||||
|
|
||||||
#region [LevelManager code]
|
#region [LevelManager code]
|
||||||
public override bool Equals(ILevelObject other)
|
public override bool Equals(ILevelObject other)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user