Example #1
0
        void Update()
        {
            // Handle state in progress before hit frame
            if (mobile.IsPlayingOneShot())
            {
                if (mobile.LastFrameAnimated < mobile.Summary.Enemy.HitFrame &&
                    mobile.Summary.EnemyState == MobileStates.PrimaryAttack)
                {
                    // Are we melee attacking?
                    if (mobile.IsAttacking())
                    {
                        isMeleeAttackingPreHitFrame = true;
                    }

                    return;
                }
                else if (mobile.LastFrameAnimated < 2 && // TODO: Animate bow correctly
                         (mobile.Summary.EnemyState == MobileStates.RangedAttack1 ||
                          mobile.Summary.EnemyState == MobileStates.RangedAttack2))
                {
                    // Are we shooting bow?
                    if (mobile.IsAttacking())
                    {
                        isShootingPreHitFrame = true;
                    }

                    return;
                }
            }

            // If a melee attack has reached the hit frame we can apply damage
            if (isMeleeAttackingPreHitFrame && mobile.LastFrameAnimated == mobile.Summary.Enemy.HitFrame)
            {
                MeleeDamage();
                isMeleeAttackingPreHitFrame = false;
            }
            // Same for shooting bow
            else if (isShootingPreHitFrame && mobile.LastFrameAnimated == 2) // TODO: Animate bow correctly
            {
                BowDamage();
                isShootingPreHitFrame = false;

                DaggerfallAudioSource dfAudioSource = GetComponent <DaggerfallAudioSource>();
                if (dfAudioSource)
                {
                    dfAudioSource.PlayOneShot((int)SoundClips.ArrowShoot, 1, 1.0f);
                }
            }

            // Countdown to next melee attack
            meleeTimer -= Time.deltaTime;
            if (meleeTimer < 0)
            {
                MeleeAnimation();
                meleeTimer = MeleeAttackSpeed;
                // Randomize
                meleeTimer += Random.Range(-.50f, .50f);
            }
        }
Example #2
0
        void Update()
        {
            // Handle state in progress
            if (mobile.IsPlayingOneShot() && (mobile.LastFrameAnimated < mobile.Summary.Enemy.HitFrame))
            {
                // Are we attacking?
                if (mobile.IsAttacking())
                {
                    isAttacking = true;
                }

                return;
            }

            // If an attack was in progress it is now complete and we can apply damage
            if (isAttacking && mobile.LastFrameAnimated == mobile.Summary.Enemy.HitFrame)
            {
                MeleeDamage();
                isAttacking = false;
            }

            // Countdown to next attack
            meleeTimer -= Time.deltaTime;
            if (meleeTimer < 0)
            {
                MeleeAnimation();
                meleeTimer = MeleeAttackSpeed;
                // Randomize
                meleeTimer += Random.Range(-.50f, .50f);
            }
        }
Example #3
0
        void Update()
        {
            // Handle state in progress
            if (mobile.IsPlayingOneShot())
            {
                // Are we attacking?
                if (mobile.IsAttacking())
                {
                    isAttacking = true;
                }

                return;
            }

            // If an attack was in progress it is now complete and we can apply damage
            if (isAttacking)
            {
                MeleeDamage();
                isAttacking = false;
            }

            // Countdown to next attack
            meleeTimer -= Time.deltaTime;
            if (meleeTimer < 0)
            {
                MeleeAnimation();
                meleeTimer = MeleeAttackSpeed;
            }
        }