Esempio n. 1
0
    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 void CastAnimationEnded()
    {
        //		Debug.LogError ("Ended anims!");
        casting = false;
        animationTransform.Idle();
        if (OnCastAnimationEnded != null)
        {
            OnCastAnimationEnded(this);

            foreach (CastAnimationEndedAction oneshot in oneShotCastAnimEndeds)
            {
                OnCastAnimationEnded -= oneshot;
            }
        }
    }