Adds knight on horse and its animations #8
Binary file not shown.
@ -1,135 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 0f9488183cb57b242b27a65ea48f8dcb
|
|
||||||
TextureImporter:
|
|
||||||
internalIDToNameTable: []
|
|
||||||
externalObjects: {}
|
|
||||||
serializedVersion: 12
|
|
||||||
mipmaps:
|
|
||||||
mipMapMode: 0
|
|
||||||
enableMipMap: 0
|
|
||||||
sRGBTexture: 1
|
|
||||||
linearTexture: 0
|
|
||||||
fadeOut: 0
|
|
||||||
borderMipMap: 0
|
|
||||||
mipMapsPreserveCoverage: 0
|
|
||||||
alphaTestReferenceValue: 0.5
|
|
||||||
mipMapFadeDistanceStart: 1
|
|
||||||
mipMapFadeDistanceEnd: 3
|
|
||||||
bumpmap:
|
|
||||||
convertToNormalMap: 0
|
|
||||||
externalNormalMap: 0
|
|
||||||
heightScale: 0.25
|
|
||||||
normalMapFilter: 0
|
|
||||||
isReadable: 0
|
|
||||||
streamingMipmaps: 0
|
|
||||||
streamingMipmapsPriority: 0
|
|
||||||
vTOnly: 0
|
|
||||||
ignoreMasterTextureLimit: 0
|
|
||||||
grayScaleToAlpha: 0
|
|
||||||
generateCubemap: 6
|
|
||||||
cubemapConvolution: 0
|
|
||||||
seamlessCubemap: 0
|
|
||||||
textureFormat: 1
|
|
||||||
maxTextureSize: 2048
|
|
||||||
textureSettings:
|
|
||||||
serializedVersion: 2
|
|
||||||
filterMode: 1
|
|
||||||
aniso: 1
|
|
||||||
mipBias: 0
|
|
||||||
wrapU: 1
|
|
||||||
wrapV: 1
|
|
||||||
wrapW: 1
|
|
||||||
nPOTScale: 0
|
|
||||||
lightmap: 0
|
|
||||||
compressionQuality: 50
|
|
||||||
spriteMode: 1
|
|
||||||
spriteExtrude: 1
|
|
||||||
spriteMeshType: 1
|
|
||||||
alignment: 0
|
|
||||||
spritePivot: {x: 0.5, y: 0.5}
|
|
||||||
spritePixelsToUnits: 100
|
|
||||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
|
||||||
spriteGenerateFallbackPhysicsShape: 1
|
|
||||||
alphaUsage: 1
|
|
||||||
alphaIsTransparency: 1
|
|
||||||
spriteTessellationDetail: -1
|
|
||||||
textureType: 8
|
|
||||||
textureShape: 1
|
|
||||||
singleChannelComponent: 0
|
|
||||||
flipbookRows: 1
|
|
||||||
flipbookColumns: 1
|
|
||||||
maxTextureSizeSet: 0
|
|
||||||
compressionQualitySet: 0
|
|
||||||
textureFormatSet: 0
|
|
||||||
ignorePngGamma: 0
|
|
||||||
applyGammaDecoding: 0
|
|
||||||
cookieLightType: 0
|
|
||||||
platformSettings:
|
|
||||||
- serializedVersion: 3
|
|
||||||
buildTarget: DefaultTexturePlatform
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
- serializedVersion: 3
|
|
||||||
buildTarget: Standalone
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
- serializedVersion: 3
|
|
||||||
buildTarget: Server
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
- serializedVersion: 3
|
|
||||||
buildTarget: Android
|
|
||||||
maxTextureSize: 2048
|
|
||||||
resizeAlgorithm: 0
|
|
||||||
textureFormat: -1
|
|
||||||
textureCompression: 1
|
|
||||||
compressionQuality: 50
|
|
||||||
crunchedCompression: 0
|
|
||||||
allowsAlphaSplitting: 0
|
|
||||||
overridden: 0
|
|
||||||
androidETC2FallbackOverride: 0
|
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
|
||||||
spriteSheet:
|
|
||||||
serializedVersion: 2
|
|
||||||
sprites: []
|
|
||||||
outline: []
|
|
||||||
physicsShape: []
|
|
||||||
bones: []
|
|
||||||
spriteID: 5e97eb03825dee720800000000000000
|
|
||||||
internalID: 0
|
|
||||||
vertices: []
|
|
||||||
indices:
|
|
||||||
edges: []
|
|
||||||
weights: []
|
|
||||||
secondaryTextures: []
|
|
||||||
nameFileIdTable: {}
|
|
||||||
spritePackingTag:
|
|
||||||
pSDRemoveMatte: 0
|
|
||||||
pSDShowRemoveMatteOption: 0
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -10,7 +10,7 @@ MonoBehaviour:
|
|||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: a92d696df7037b44585aaac56ec9ed98, type: 3}
|
m_Script: {fileID: 11500000, guid: a92d696df7037b44585aaac56ec9ed98, type: 3}
|
||||||
m_Name: Rider
|
m_Name: KnightOnHorse
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_wood: 0
|
_wood: 0
|
||||||
_rock: 0
|
_rock: 0
|
||||||
@ -10,7 +10,7 @@ MonoBehaviour:
|
|||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_EditorHideFlags: 0
|
m_EditorHideFlags: 0
|
||||||
m_Script: {fileID: 11500000, guid: d1391306ffe53984bb2bc314f1d2919f, type: 3}
|
m_Script: {fileID: 11500000, guid: d1391306ffe53984bb2bc314f1d2919f, type: 3}
|
||||||
m_Name: Upgrade_Rider
|
m_Name: Upgrade_KnightOnHorse
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
_upgradeUnitCard: {fileID: 11400000, guid: 4855deb66869b934bb7a63c02d4442fe, type: 2}
|
_upgradeUnitCard: {fileID: 11400000, guid: 4855deb66869b934bb7a63c02d4442fe, type: 2}
|
||||||
_upgradePrefab: {fileID: 2230360378425099702, guid: a857e93871a186749879c021675f5a13, type: 3}
|
_upgradePrefab: {fileID: 2230360378425099702, guid: a857e93871a186749879c021675f5a13, type: 3}
|
||||||
File diff suppressed because it is too large
Load Diff
@ -1,7 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: d57d97357919087419f8097e907c7a7e
|
|
||||||
PrefabImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -2,7 +2,7 @@ using System.Collections;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class Rider : Ally
|
public class KnightOnHorse : Ally
|
||||||
{
|
{
|
||||||
[SerializeField]
|
[SerializeField]
|
||||||
private int _chargeAttackDamage;
|
private int _chargeAttackDamage;
|
||||||
@ -21,17 +21,23 @@ public class Rider : Ally
|
|||||||
[SerializeField]
|
[SerializeField]
|
||||||
private GameObject _root;
|
private GameObject _root;
|
||||||
|
|
||||||
|
// scripts
|
||||||
private Root _rootScript;
|
private Root _rootScript;
|
||||||
private Detection _detectionScript;
|
private Detection _detectionScript;
|
||||||
|
|
||||||
|
// attack variables
|
||||||
private int _originalAttackDamage;
|
private int _originalAttackDamage;
|
||||||
|
|
||||||
|
// movement variables
|
||||||
private Vector3 _originalPos;
|
private Vector3 _originalPos;
|
||||||
private Vector2 _movementVector = Vector2.zero;
|
private Vector2 _movementVector = Vector2.zero;
|
||||||
|
|
||||||
|
// charge variables
|
||||||
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>();
|
||||||
|
|
||||||
|
// fading variables
|
||||||
private float _fadeProgress;
|
private float _fadeProgress;
|
||||||
private bool _isFading;
|
private bool _isFading;
|
||||||
private int _fadeState;
|
private int _fadeState;
|
||||||
@ -43,37 +49,151 @@ public class Rider : Ally
|
|||||||
_rootScript = _root.GetComponent<Root>();
|
_rootScript = _root.GetComponent<Root>();
|
||||||
_detectionScript = _detection.GetComponent<Detection>();
|
_detectionScript = _detection.GetComponent<Detection>();
|
||||||
|
|
||||||
|
// keep originals to go back to them eventually
|
||||||
_originalAttackDamage = _chargeAttackDamage;
|
_originalAttackDamage = _chargeAttackDamage;
|
||||||
_originalPos = transform.position;
|
_originalPos = transform.position;
|
||||||
|
|
||||||
|
// makes sure the entity charges on creation
|
||||||
_timeSinceLastCharge = _chargeCooldown + 1;
|
_timeSinceLastCharge = _chargeCooldown + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Update()
|
public override void Update()
|
||||||
{
|
{
|
||||||
|
// fade if charge done
|
||||||
if (_isFading)
|
if (_isFading)
|
||||||
{
|
{
|
||||||
if (_fadeProgress < _fadeDistance && _fadeState == 0)
|
HandleFading();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// check if charge is ready
|
||||||
|
if (_timeSinceLastCharge > _chargeCooldown && !_isCharging)
|
||||||
|
{
|
||||||
|
SweepAttack();
|
||||||
|
|
||||||
|
_isCharging = true;
|
||||||
|
Animation.ToggleChargeAnim(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_isCharging)
|
||||||
|
{
|
||||||
|
// sweep attack if an enemy slips behind the tip's hitbox
|
||||||
|
SweepAttack();
|
||||||
|
|
||||||
|
// toggle charge detection
|
||||||
|
_chargeDetection.SetActive(true);
|
||||||
|
|
||||||
|
// movement
|
||||||
|
HandleMovement();
|
||||||
|
|
||||||
|
// attack
|
||||||
|
if (IsEnemyDetected && !_opponentsHit.Contains(Enemy))
|
||||||
|
{
|
||||||
|
AttackEnemyRiding();
|
||||||
|
}
|
||||||
|
|
||||||
|
// reset
|
||||||
|
if (transform.position.x - _originalPos.x >= _maxChargeDistance || _opponentsHit.Count >= _maxChargeHitCount)
|
||||||
|
{
|
||||||
|
// charge state
|
||||||
|
_isCharging = false;
|
||||||
|
_timeSinceLastCharge = 0;
|
||||||
|
_opponentsHit.Clear();
|
||||||
|
|
||||||
|
// detection state
|
||||||
|
IsEnemyDetected = false;
|
||||||
|
Enemy = null;
|
||||||
|
_chargeDetection.SetActive(false);
|
||||||
|
|
||||||
|
// start fading
|
||||||
|
_isFading = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// charge cooldown
|
||||||
|
_timeSinceLastCharge += Time.deltaTime;
|
||||||
|
|
||||||
|
// regular attack
|
||||||
|
if (IsEnemyDetected)
|
||||||
|
{
|
||||||
|
AttackEnemy();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleMovement()
|
||||||
{
|
{
|
||||||
_movementVector.x = Time.deltaTime * Speed;
|
_movementVector.x = Time.deltaTime * Speed;
|
||||||
transform.position += (Vector3)_movementVector;
|
transform.position += (Vector3)_movementVector;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AttackEnemy()
|
||||||
|
{
|
||||||
|
//Attack Cooldown
|
||||||
|
if (AttackSpeedWait > AttackInterval)
|
||||||
|
{
|
||||||
|
AttackDamage = _originalAttackDamage;
|
||||||
|
Animation.PlayAttackAnim();
|
||||||
|
|
||||||
|
AttackSpeedWait = 0f;
|
||||||
|
}
|
||||||
|
|
||||||
|
AttackSpeedWait += Time.deltaTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void AttackEnemyRiding()
|
||||||
|
{
|
||||||
|
AttackDamage = _chargeAttackDamage;
|
||||||
|
|
||||||
|
// call root attack cause no specific animation
|
||||||
|
_rootScript.Attack();
|
||||||
|
_opponentsHit.Add(Enemy);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Attacks all enemies already in the default detection box during charge.
|
||||||
|
* Charge uses a different detection (at the tip) due to Enemy being the first opponent to enter the hitbox.
|
||||||
|
* Therefore enemies would only get hit when the previous Enemy exits the hitbox, 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
|
||||||
|
* and during in case something goes wrong and a monster slips through the charge hitbox.
|
||||||
|
*/
|
||||||
|
private void SweepAttack()
|
||||||
|
{
|
||||||
|
foreach (Entity entity in _detectionScript.DetectedEntities)
|
||||||
|
{
|
||||||
|
if (!_opponentsHit.Contains(entity))
|
||||||
|
{
|
||||||
|
Enemy = entity;
|
||||||
|
AttackEnemyRiding();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleFading()
|
||||||
|
{
|
||||||
|
if (_fadeState == 0 && _fadeProgress < _fadeDistance)
|
||||||
|
{
|
||||||
|
HandleMovement();
|
||||||
|
|
||||||
|
//fade out
|
||||||
_fadeProgress += _movementVector.x / _fadeDistance;
|
_fadeProgress += _movementVector.x / _fadeDistance;
|
||||||
foreach (SpriteRenderer spriteRenderer in SpriteRenderers)
|
foreach (SpriteRenderer spriteRenderer in SpriteRenderers)
|
||||||
{
|
{
|
||||||
spriteRenderer.color = new Color(1.0f, 1.0f, 1.0f, 1.0f - _fadeProgress);
|
spriteRenderer.color = new Color(1.0f, 1.0f, 1.0f, 1.0f - _fadeProgress);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (_fadeProgress > _fadeDistance && _fadeState == 0)
|
else if (_fadeState == 0 && _fadeProgress > _fadeDistance)
|
||||||
{
|
{
|
||||||
|
// teleport behind original position to fade in
|
||||||
transform.position = new Vector3(_originalPos.x - _fadeDistance, _originalPos.y, _originalPos.z);
|
transform.position = new Vector3(_originalPos.x - _fadeDistance, _originalPos.y, _originalPos.z);
|
||||||
_fadeState = 1;
|
_fadeState = 1;
|
||||||
}
|
}
|
||||||
else if (_fadeProgress > _fadeDistance && _fadeState == 1 && _fadeProgress < _fadeDistance * 2)
|
else if (_fadeState == 1 && _fadeProgress < _fadeDistance * 2)
|
||||||
{
|
{
|
||||||
_movementVector.x = Time.deltaTime * Speed;
|
HandleMovement();
|
||||||
transform.position += (Vector3)_movementVector;
|
|
||||||
|
|
||||||
|
// fade in
|
||||||
_fadeProgress += _movementVector.x / _fadeDistance;
|
_fadeProgress += _movementVector.x / _fadeDistance;
|
||||||
foreach (SpriteRenderer spriteRenderer in SpriteRenderers)
|
foreach (SpriteRenderer spriteRenderer in SpriteRenderers)
|
||||||
{
|
{
|
||||||
@ -102,104 +222,5 @@ public class Rider : Ally
|
|||||||
// toggle animation
|
// toggle animation
|
||||||
Animation.ToggleChargeAnim(false);
|
Animation.ToggleChargeAnim(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// check for charge cooldown
|
|
||||||
if (_timeSinceLastCharge > _chargeCooldown && !_isCharging)
|
|
||||||
{
|
|
||||||
SweepAttack();
|
|
||||||
|
|
||||||
_isCharging = true;
|
|
||||||
Animation.ToggleChargeAnim(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_isCharging)
|
|
||||||
{
|
|
||||||
SweepAttack();
|
|
||||||
|
|
||||||
// toggle charge detection
|
|
||||||
_chargeDetection.SetActive(true);
|
|
||||||
|
|
||||||
// movement
|
|
||||||
_movementVector.x = Time.deltaTime * Speed;
|
|
||||||
transform.position += (Vector3)_movementVector;
|
|
||||||
|
|
||||||
// attack
|
|
||||||
if (IsEnemyDetected && !_opponentsHit.Contains(Enemy))
|
|
||||||
{
|
|
||||||
AttackEnemyRiding();
|
|
||||||
}
|
|
||||||
|
|
||||||
// reset
|
|
||||||
if (transform.position.x - _originalPos.x >= _maxChargeDistance || _opponentsHit.Count >= _maxChargeHitCount)
|
|
||||||
{
|
|
||||||
// charge state
|
|
||||||
_isCharging = false;
|
|
||||||
_timeSinceLastCharge = 0;
|
|
||||||
_opponentsHit.Clear();
|
|
||||||
|
|
||||||
// detection state
|
|
||||||
IsEnemyDetected = false;
|
|
||||||
Enemy = null;
|
|
||||||
|
|
||||||
// toggle detection
|
|
||||||
_detection.SetActive(false);
|
|
||||||
_chargeDetection.SetActive(false);
|
|
||||||
|
|
||||||
// start fading
|
|
||||||
_isFading = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
_timeSinceLastCharge += Time.deltaTime;
|
|
||||||
if (IsEnemyDetected)
|
|
||||||
{
|
|
||||||
AttackEnemy();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
private void AttackEnemy()
|
|
||||||
{
|
|
||||||
//Attack Cooldown
|
|
||||||
if (AttackSpeedWait > AttackInterval)
|
|
||||||
{
|
|
||||||
AttackDamage = _originalAttackDamage;
|
|
||||||
Animation.PlayAttackAnim();
|
|
||||||
|
|
||||||
|
|
||||||
AttackSpeedWait = 0f;
|
|
||||||
}
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -27,9 +27,11 @@ public class Detection : MonoBehaviour
|
|||||||
_hasStartBeenCalled = true;
|
_hasStartBeenCalled = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if Start ran once already.
|
/*
|
||||||
// onEnable runs by default before Start so not everything is initialized.
|
* Checks if Start ran once already.
|
||||||
// And I don't want to reinitialize the collider everytime I re-enable a unit's detection.
|
* onEnable runs by default before Start so not everything is initialized
|
||||||
|
* and I don't want to reinitialize the collider everytime I re-enable a unit's detection.
|
||||||
|
*/
|
||||||
protected void OnEnable()
|
protected void OnEnable()
|
||||||
{
|
{
|
||||||
if (_hasStartBeenCalled)
|
if (_hasStartBeenCalled)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user