// PUBLIC METHODS: ------------------------------------------------------------------------ public IEnumerator Sheathe() { if (this.Character.characterLocomotion.isBusy) { yield break; } if (!this.CanAttack()) { yield break; } if (this.IsAttacking) { yield break; } this.ReleaseTargetFocus(); WaitForSeconds wait = new WaitForSeconds(0f); if (this.currentWeapon != null) { if (this.currentWeapon.characterState != null) { CharacterState currentState = this.CharacterAnimator.GetState(MeleeWeapon.LAYER_STANCE); if (currentState != null) { float time = this.ResetState(currentState, MeleeWeapon.LAYER_STANCE); wait = new WaitForSeconds(time); } } this.PlayAudio(this.currentWeapon.audioSheathe); } this.Character.characterLocomotion.isBusy = true; this.IsSheathing = true; yield return(wait); if (this.EventSheatheWeapon != null) { this.EventSheatheWeapon.Invoke(this.currentWeapon); } if (this.modelWeapon != null) { Destroy(this.modelWeapon); } this.OnSheatheWeapon(); yield return(wait); this.IsSheathing = false; this.currentWeapon = null; this.currentShield = null; this.comboSystem = null; this.Character.characterLocomotion.isBusy = false; }
public IEnumerator Draw(MeleeWeapon weapon, MeleeShield shield = null) { if (this.Character.characterLocomotion.isBusy) { yield break; } if (this.IsAttacking) { yield break; } if (!this.CanAttack()) { yield break; } yield return(this.Sheathe()); if (weapon != null) { this.currentWeapon = weapon; this.currentShield = shield != null ? shield : weapon.defaultShield; this.comboSystem = new ComboSystem(this, weapon.combos); WaitForSeconds wait = new WaitForSeconds(0f); if (this.currentWeapon.characterState != null) { CharacterState state = this.currentWeapon.characterState; float time = this.ChangeState( this.currentWeapon.characterState, this.currentWeapon.characterMask, MeleeWeapon.LAYER_STANCE ); if (state.enterClip != null) { wait = new WaitForSeconds(time); } } this.PlayAudio(this.currentWeapon.audioDraw); this.Character.characterLocomotion.isBusy = true; this.IsDrawing = true; yield return(wait); if (this.EventDrawWeapon != null) { this.EventDrawWeapon.Invoke(this.currentWeapon); } this.modelWeapon = this.currentWeapon.EquipWeapon(this.CharacterAnimator); this.blade = this.modelWeapon.GetComponentInChildren <BladeComponent>(); if (this.blade != null) { this.blade.Setup(this); } this.OnDrawWeapon(); yield return(wait); this.IsDrawing = false; this.Character.characterLocomotion.isBusy = false; } }