public void HandleAnimationEvent(AnimationEventType type, string animationName) { if (!attacking) { return; } switch (type) { case AnimationEventType.ATTACK_SWING_MOMENT: // if (lastAttack.TypeChoice.IsRanged () & lastAttack.WeaponUsed.IsThrown ()) { // //nothing // } else { WeaponSwingFXType swingFx = lastAttack.WeaponUsed.SwingSoundFX; characterAudioSource.clip = SoundDispenser.instance.SwingFXFromType(swingFx); characterAudioSource.Play(); // } break; case AnimationEventType.ATTACK_HIT_MOMENT: //this is where it should split off and launch the weapon if the attack was ranged if (lastAttack.TypeChoice.IsRanged()) { GenericWeapon wp = lastAttack.WeaponUsed; GameObject missileAnimPrefab = MissileAnimationPrefabDispenser.instance.GetAnimationPrefabByName(wp.MissileAnimationName); if (missileAnimPrefab != null) { LaunchMissileAndSetup(missileAnimPrefab); } else { AttackAnimationHitMoment(); } } else { AttackAnimationHitMoment(); } break; case AnimationEventType.LOOP: if (rangedAttacking) { animationTransform.Idle(); } else { AttackAnimationEnded(); } break; } }
public AudioClip SwingFXFromType(WeaponSwingFXType key) { List <WeaponSwingFXElement> matching = swingFX.Where((fxElem) => { return(fxElem.key == key && fxElem.val != null); }).ToList(); if (matching.Count > 0) { return(matching.Last().val); } else { Debug.LogWarning("Couldn't locate a weapon swing sound effect for " + key); return(null); } }
public WeaponSwingFXElement(WeaponSwingFXType key, AudioClip val) { this.key = key; this.val = val; }