예제 #1
0
        public void Attack(Hero heroActor, Enemy target)
        {
            WaitTimer += heroActor.gameTime.ElapsedGameTime.Milliseconds;

            if (WaitTimer <= HeroAttribute.AttackSpeed)
            {
                playingAttackAnimation = false;
                if (heroActor.SpriteState == SpriteState.IDLE_LEFT)
                {
                    heroActor.SpriteState = SpriteState.ATTACK_LEFT;
                }
                else
                {
                    heroActor.SpriteState = SpriteState.ATTACK_RIGHT;
                }

                AttackTimer = 0;
            }
            else
            {
                playingAttackAnimation = true;
                AttackTimer += heroActor.gameTime.ElapsedGameTime.Milliseconds;
                if (AttackTimer >= heroActor.HeroAttackAnimationInterval * heroActor.HeroAttackAnimationFrames)
                {
                    if (playingAttackAnimation && (heroActor.SpriteState == SpriteState.ATTACK_LEFT ||
             heroActor.SpriteState == SpriteState.ATTACK_RIGHT))
                    {
                        heroActor.HeroAttribute.Attack(target);
                        AudioController.HeroAttack1SoundEffectInstance.Play();
                        WaitTimer = 0;
                    }

                }
            }
        }
예제 #2
0
 public EnemyAttribute(Enemy enemyActor, ContentManager content, Castle castle)
     : base(content)
 {
     randomNumberGenerator = new Random();
     this.mEnemyActor = enemyActor;
     this.mCastle = castle;
 }
예제 #3
0
        // TODO: Check Melee Attack Status
        public void CheckMeleeAttackStatus(Enemy enemyActor)
        {
            // If I'm colliding with my target
            if (enemyActor.Sprite.SpriteFrame.Intersects(enemyActor.TargetQueue.PeekFirst().Sprite.SpriteFrame) &&
                 enemyActor.EnemyAggroMode != EnemyAggroMode.IDLING)
            {
                // I should start attacking
                enemyActor.EnemyAggroMode = EnemyAggroMode.ATTACKING;
                UpdateUnitSpeed(enemyActor);
            }
            // But if I'm NOT colliding with my target
            else if (!enemyActor.Sprite.SpriteFrame.Intersects(enemyActor.TargetQueue.PeekFirst().Sprite.SpriteFrame))
            {
                // I should be moving :)
                enemyActor.EnemyAggroMode = EnemyAggroMode.MOVING;
                UpdateUnitSpeed(enemyActor);
                MoveTowardsTargetCoordinate(enemyActor);

            }
        }
예제 #4
0
        // TODO: Play Attack Animation
        // Will play Idle Animation for duration of animation
        public void PlayAttackAnimation(Enemy enemyActor)
        {
            switch (enemyActor.CreatureType)
            {

                case ObjectType.BANSHEE:
                    if (enemyActor.SpriteState == SpriteState.IDLE_LEFT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (enemyActor.SpriteState == SpriteState.IDLE_RIGHT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    else if (enemyActor.SpriteState == SpriteState.MOVE_LEFT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (enemyActor.SpriteState == SpriteState.MOVE_RIGHT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    // TODO:   PlayUnitAnimationAudio(friendlyActor);
                    break;
                case ObjectType.REAPER:
                    if (enemyActor.SpriteState == SpriteState.IDLE_LEFT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (enemyActor.SpriteState == SpriteState.IDLE_RIGHT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    else if (enemyActor.SpriteState == SpriteState.MOVE_LEFT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (enemyActor.SpriteState == SpriteState.MOVE_RIGHT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    // TODO:   PlayUnitAnimationAudio(friendlyActor);
                    break;
                case ObjectType.GOG:
                    if (enemyActor.SpriteState == SpriteState.IDLE_LEFT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (enemyActor.SpriteState == SpriteState.IDLE_RIGHT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    else if (enemyActor.SpriteState == SpriteState.MOVE_LEFT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (enemyActor.SpriteState == SpriteState.MOVE_RIGHT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    // TODO:       PlayUnitAnimationAudio(friendlyActor);
                    break;
                case ObjectType.IMP:
                    if (enemyActor.SpriteState == SpriteState.IDLE_LEFT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (enemyActor.SpriteState == SpriteState.IDLE_RIGHT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    else if (enemyActor.SpriteState == SpriteState.MOVE_LEFT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (enemyActor.SpriteState == SpriteState.MOVE_RIGHT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    // TODO:     PlayUnitAnimationAudio(friendlyActor);
                    break;
                case ObjectType.DOOM_HOUND:
                    if (enemyActor.SpriteState == SpriteState.IDLE_LEFT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (enemyActor.SpriteState == SpriteState.IDLE_RIGHT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    else if (enemyActor.SpriteState == SpriteState.MOVE_LEFT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (enemyActor.SpriteState == SpriteState.MOVE_RIGHT)
                    {
                        enemyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    // TODO:         PlayUnitAnimationAudio(friendlyActor);
                    break;

                default:
                    break;
            }
            PlayUnitAnimationAudio(enemyActor);
        }
예제 #5
0
        private void MeleeAttackCastle(Enemy enemyActor)
        {
            if (enemyActor.TargetQueue.IsEmpty() && enemyActor.Sprite.SpriteFrame.Intersects(enemyActor.DefaultTarget))
            {

                if (isAttackingCastle == false)
                {
                    enemyActor.EnemyAggroMode = EnemyAggroMode.ATTACKING;
                    AnimationTimer = 0;
                    isAttackingCastle = true;
                }

                // Check if I made it to my target's sprite frame.
                CheckMeleeStatusCastle(enemyActor);

                if (enemyActor.EnemyAggroMode == EnemyAggroMode.ATTACKING)
                {
                    AnimationTimer += enemyActor.gameTime.ElapsedGameTime.Milliseconds;
                    // If I'm attacking then I should play my Attack animation from start to finish.
                    if (AnimationTimer <= GetAnimationLength(enemyActor))
                    {
                        PlayAttackAnimation(enemyActor);

                        //    Console.WriteLine("Now I'm playing attacking Animation");
                    }
                    else if (AnimationTimer >= GetAnimationLength(enemyActor))
                    {
                        // Then I should apply my damage to the current target
                        Console.WriteLine("Applying Damage");
                        //TODO:       PlayUnitAttackLandedAudio(friendlyActor);
                        PlayMeleeUnitAttackLandedAudio(enemyActor);

                        enemyActor.EnemyAttribute.Attack();
                        enemyActor.EnemyAggroMode = EnemyAggroMode.IDLING;
                        WaitTimer = 0;
                    }

                }
                // Now I'm done playing my animation for attack. Now play idle while I cool off
                else if (enemyActor.EnemyAggroMode == EnemyAggroMode.IDLING &&
                    WaitTimer <= enemyActor.EnemyAttribute.AttackSpeed)
                {
                    WaitTimer += enemyActor.gameTime.ElapsedGameTime.Milliseconds;
                    PlayIdleAnimationFromAttacking(enemyActor);
                }
                // After I wait I should play my attack animation again
                else if (WaitTimer >= enemyActor.EnemyAttribute.AttackSpeed)
                {
                    AnimationTimer = 0;
                    enemyActor.EnemyAggroMode = EnemyAggroMode.ATTACKING;
                }

            }
            else if (isAttackingCastle)
            {
                //If we are done slaughtering our foes.
                enemyActor.EnemyAggroMode = EnemyAggroMode.MOVING;

                isAttackingCastle = false;

            }
        }
예제 #6
0
        private void PlayProjectileAudio(Enemy enemyActor)
        {
            switch (enemyActor.CreatureType)
            {

                case ObjectType.BANSHEE:

                    PlayBansheeProjectileSound();
                    break;
                case ObjectType.GOG:
                    PlayGogProjectileSound();
                    break;

                default:
                    break;
            }
        }
        public static void PrintEnemyAttributes(ref float textScale, ref TextBoxString gameObjectAttribute,
												ref List<TextBoxString> gameObjectAttributeList, ref string gameObjectAttributeString,
												 Enemy tempEnemy)
        {
            // Print Name
            gameObjectAttributeString = tempEnemy.CreatureType.ToString();
            WriteLine(ref gameObjectAttribute, textScale, gameObjectAttributeString, gameObjectAttributeList);

            // Print Health
            gameObjectAttributeString = "Health: " + tempEnemy.EnemyAttribute.CurrentHealthPoints.ToString();
            WriteLine(ref gameObjectAttribute, textScale, gameObjectAttributeString, gameObjectAttributeList);

            // Print Armor
            gameObjectAttributeString = "Armor: " + tempEnemy.EnemyAttribute.CurrentArmor;
            WriteLine(ref gameObjectAttribute, textScale, gameObjectAttributeString, gameObjectAttributeList);

            //Print Damage
            gameObjectAttributeString = "Damage: " + tempEnemy.EnemyAttribute.BaseMinimumDamage.ToString() + " - " + tempEnemy.EnemyAttribute.BaseMaximumDamage.ToString();
            WriteLine(ref gameObjectAttribute, textScale, gameObjectAttributeString, gameObjectAttributeList);
            gameObjectAttributeString = " ";
        }
예제 #8
0
        //private static void InitializeAttributes()
        //{
        //    mImpSpawnLimit = 15;
        //    mDoomHoundSpawnLimit = 20;
        //    mGogSpawnLimit = 20;
        //    mBansheeSpawnLimit = 25;
        //    mReaperSpawnLimit = 20;
        //    mImpStartingHealth = 20;
        //    mImpCurrentHealth = mImpStartingHealth;
        //    mImpStartingArmor = 1;
        //    mImpCurrentArmor = mImpStartingArmor;
        //    mImpStartingDamage = 10;
        //    mImpCurrentDamage = mImpStartingDamage;
        //    mDoomHoundStartingHealth = 45;
        //    mDoomHoundCurrentHealth = mDoomHoundStartingHealth;
        //    mDoomHoundStartingArmor = 2;
        //    mDoomHoundCurrentArmor = mDoomHoundStartingArmor;
        //    mDoomHoundStartingDamage = 20;
        //    mDoomHoundCurrentDamage = mDoomHoundStartingDamage;
        //    mGogStartingHealth = 100;
        //    mGogCurrentHealth = mGogStartingHealth;
        //    mGogStartingArmor = 2;
        //    mGogCurrentArmor = mGogStartingArmor;
        //    mGogStartingDamage = 20;
        //    mGogCurrentDamage = mGogStartingDamage;
        //    mBansheeCurrentHealth = 250;
        //    mBansheeCurrentHealth = mBansheeStartingHealth;
        //    mBansheeCurrentArmor = 5;
        //    mBansheeCurrentArmor = mBansheeStartingArmor;
        //    mBansheeStartingDamage = 35;
        //    mBansheeCurrentDamage = mBansheeStartingDamage;
        //    mReaperStartingHealth = 500;
        //    mReaperCurrentHealth = mReaperStartingHealth;
        //    mReaperStartingArmor = 25;
        //    mReaperCurrentArmor = mReaperStartingArmor;
        //    mReaperStartingDamage = 50;
        //    mReaperCurrentDamage = mReaperStartingDamage;
        //}
        private static Enemy CreateEnemy()
        {
            randomNumber = randomGenerator.Next(0, 100);

            if (randomNumber >= 0 && randomNumber <= mCurrentImpSpawnChance - 1)
            {
                //Spawn Imp

                //                Console.WriteLine("Initializing Imp");

                Enemy tempImp = new Enemy(ObjectType.IMP, content,
                                          SpriteState.MOVE_RIGHT, mCastle,
                                          Vector2.Zero);

                //tempImp.Damage = mImpCurrentDamage;
                tempImp.Sprite.LoadContent();
                tempImp.PostSetSpriteFrame();
                return tempImp;
            }

            else if (randomNumber >= mCurrentImpSpawnChance && randomNumber <= mCurrentDoomHoundSpawnChance + mCurrentImpSpawnChance - 1)
            {
                //spawn doom hound
                //    Console.WriteLine("Initializing DoomHound");

                Enemy tempDoomHound = new Enemy(ObjectType.DOOM_HOUND,
                    content, SpriteState.MOVE_RIGHT, mCastle, Vector2.Zero);

                // tempDoomHound.Damage = mDoomHoundCurrentDamage;
                tempDoomHound.Sprite.LoadContent();
                tempDoomHound.PostSetSpriteFrame();
                return tempDoomHound;
            }
            else if (randomNumber >= mCurrentDoomHoundSpawnChance + mCurrentImpSpawnChance &&
                     randomNumber <= mCurrentDoomHoundSpawnChance + mCurrentImpSpawnChance + mCurrentGogSpawnChance - 1)
            {
                //spawn gog
                //       Console.WriteLine("Initializing Gog");

                Enemy tempGog = new Enemy(ObjectType.GOG, content,
                                          SpriteState.MOVE_RIGHT, mCastle, Vector2.Zero);

                // tempGog.Damage = mGogCurrentDamage;
                tempGog.Sprite.LoadContent();
                tempGog.PostSetSpriteFrame();

                return tempGog;
            }

            else if (randomNumber >= mCurrentDoomHoundSpawnChance + mCurrentImpSpawnChance + mCurrentGogSpawnChance &&
                     randomNumber <= mCurrentDoomHoundSpawnChance + mCurrentImpSpawnChance + mCurrentGogSpawnChance + mCurrentBansheeSpawnChance - 1)
            {
                //spawn banshee
                //    Console.WriteLine("Initializing Banshee");

                Enemy tempBanshee = new Enemy(ObjectType.BANSHEE, content,
                                              SpriteState.MOVE_RIGHT, mCastle, Vector2.Zero);

                // tempBanshee.Damage = mBansheeCurrentDamage;
                tempBanshee.Sprite.LoadContent();
                tempBanshee.PostSetSpriteFrame();

                return tempBanshee;
            }
            else if (randomNumber >= mCurrentDoomHoundSpawnChance + mCurrentImpSpawnChance + mCurrentGogSpawnChance + mCurrentBansheeSpawnChance &&
                     randomNumber <=
                     mCurrentDoomHoundSpawnChance + mCurrentImpSpawnChance + mCurrentGogSpawnChance + mCurrentBansheeSpawnChance +
                     mCurrentReaperSpawnChance - 1)
            {
                //spawn reaper
                //       Console.WriteLine("Initializing Reaper");

                Enemy tempReaper = new Enemy(ObjectType.REAPER, content,
                                             SpriteState.MOVE_RIGHT, mCastle, Vector2.Zero);

                //  tempReaper.Damage = mReaperCurrentDamage;
                tempReaper.Sprite.LoadContent();
                tempReaper.PostSetSpriteFrame();

                return tempReaper;
            }
            else
            {
                Enemy tempImp = new Enemy(ObjectType.IMP, content,
                                            SpriteState.MOVE_RIGHT, mCastle,
                                            Vector2.Zero);

                // tempImp.Damage = mImpCurrentDamage;
                tempImp.Sprite.LoadContent();
                tempImp.PostSetSpriteFrame();
                return tempImp;
            }
        }
예제 #9
0
        public int DropExperience(int WaveNumber, Enemy mEnemyActor)
        {
            // Base XP at 12.
            // Experience Spread Modifier = 20%
            // Experience Modifier = 15%
            // Wave 10
            // Tier 1

            // XP = (Base XP) * (1 + XPModifier * (WaveNumber * Tier) )
            mInitialExperience = mBaseExperience * (1 + mExperienceModifier * (WaveNumber * mEnemyActor.EnemyAttribute.Tier));

            // calculate a range +- that we can add or subtract from our final experience drop.
            int negativeTempExperienceSpread = (int)(Math.Round(-1 * (mExperienceSpreadModifier * mInitialExperience)));
            int positiveTempExperienceSpread = (int)(Math.Round(mExperienceSpreadModifier * mInitialExperience));

            // Experience spread will be a random number +- between the gold drop amount and the spread modifier.
            mExperienceSpread = randomGenerator.Next(negativeTempExperienceSpread, positiveTempExperienceSpread);

            int finalExperienceDrop = (int)(Math.Round(mInitialExperience + mExperienceSpread));

            return finalExperienceDrop;
        }
예제 #10
0
        public void PlayMeleeUnitAttackLandedAudio(Enemy enemyActor)
        {
            //TODO: place holder
            switch (enemyActor.CreatureType)
            {

                case ObjectType.REAPER:
                    PlayReaperAttackLandedSound();
                    break;
                case ObjectType.DOOM_HOUND:
                    PlayDoomHoundAttackLandedSound();
                    break;
                case ObjectType.IMP:
                    PlayImpAttackLandedSound();
                    break;

                default:
                    break;

            }
        }
예제 #11
0
        public void PlayUnitAnimationAudio(Enemy enemyActor)
        {
            //TODO: place holder
            switch (enemyActor.CreatureType)
            {

                case ObjectType.BANSHEE:
                    PlayBansheeAnimationSound();
                    break;
                case ObjectType.REAPER:
                    PlayReaperAnimationSound();
                    break;
                case ObjectType.DOOM_HOUND:
                    PlayDoomHoundAnimationSound();
                    break;
                case ObjectType.IMP:
                    PlayImpAnimationSound();
                    break;
                case ObjectType.GOG:
                    PlayGogAnimationSound();
                    break;

                default:
                    break;
            }
        }
예제 #12
0
 private void CheckVitalSigns(Enemy enemyActor)
 {
     if (0 >= enemyActor.EnemyAttribute.CurrentHealthPoints)
     {
         mDeathAnimationTimer += enemyActor.gameTime.ElapsedGameTime.Milliseconds;
         PlayUnitDeathAudio(enemyActor);
         isDying = true;
         BeginDying(enemyActor);
     }
     else
     {
         isDying = false;
     }
 }
예제 #13
0
        // TODO: Play Idle Animation From Attacking
        // WIll play the idle animation if we were attacking before
        public void PlayIdleAnimationFromAttacking(Enemy enemyActor)
        {
            if (enemyActor.SpriteState == SpriteState.ATTACK_LEFT)
            {
                enemyActor.SpriteState = SpriteState.IDLE_LEFT;
            }

            if (enemyActor.SpriteState == SpriteState.ATTACK_RIGHT)
            {
                enemyActor.SpriteState = SpriteState.IDLE_RIGHT;
            }
        }
예제 #14
0
        private void BeginDying(Enemy enemyActor)
        {
            switch (enemyActor.CreatureType)
            {

                case ObjectType.BANSHEE:
                    if (mDeathAnimationTimer <=
                        enemyActor.BansheeDeathAnimationFrames * enemyActor.BansheeDeathAnimationInterval
                        &&
                        (enemyActor.SpriteState == SpriteState.ATTACK_LEFT ||
                         enemyActor.SpriteState == SpriteState.MOVE_LEFT
                         || enemyActor.SpriteState == SpriteState.IDLE_LEFT))
                    {
                        enemyActor.SpriteState = SpriteState.DEATH_LEFT;

                    }

                    else if (mDeathAnimationTimer <= enemyActor.BansheeDeathAnimationFrames * enemyActor.BansheeDeathAnimationInterval
                             &&
                             (enemyActor.SpriteState == SpriteState.ATTACK_RIGHT ||
                              enemyActor.SpriteState == SpriteState.MOVE_RIGHT
                         || enemyActor.SpriteState == SpriteState.IDLE_RIGHT))
                    {
                        enemyActor.SpriteState = SpriteState.DEATH_RIGHT;
                    }
                    else if (mDeathAnimationTimer >=
                             enemyActor.BansheeDeathAnimationFrames *
                             enemyActor.BansheeDeathAnimationInterval)
                    {
                        enemyActor.HasDied = true;
                    }

                    break;
                case ObjectType.GOG:

                    if (mDeathAnimationTimer <=
                        enemyActor.GogDeathAnimationFrames * enemyActor.GogDeathAnimationInterval
                        &&
                        (enemyActor.SpriteState == SpriteState.ATTACK_LEFT ||
                         enemyActor.SpriteState == SpriteState.MOVE_LEFT
                          || enemyActor.SpriteState == SpriteState.IDLE_LEFT))
                    {
                        enemyActor.SpriteState = SpriteState.DEATH_LEFT;
                    }

                    else if (mDeathAnimationTimer <=
                             enemyActor.GogDeathAnimationFrames *
                             enemyActor.GogDeathAnimationInterval
                             &&
                             (enemyActor.SpriteState == SpriteState.ATTACK_RIGHT ||
                              enemyActor.SpriteState == SpriteState.MOVE_RIGHT
                         || enemyActor.SpriteState == SpriteState.IDLE_RIGHT))
                    {
                        enemyActor.SpriteState = SpriteState.DEATH_RIGHT;
                    }
                    else if (mDeathAnimationTimer >=
                             enemyActor.GogDeathAnimationFrames *
                             enemyActor.GogDeathAnimationInterval)
                    {
                        enemyActor.HasDied = true;
                    }

                    break;
                case ObjectType.REAPER:
                    if (mDeathAnimationTimer <=
                        enemyActor.ReaperDeathAnimationFrames * enemyActor.ReaperDeathAnimationInterval
                        &&
                        (enemyActor.SpriteState == SpriteState.ATTACK_LEFT ||
                         enemyActor.SpriteState == SpriteState.MOVE_LEFT
                          || enemyActor.SpriteState == SpriteState.IDLE_LEFT))
                    {
                        enemyActor.SpriteState = SpriteState.DEATH_LEFT;
                    }

                    else if (mDeathAnimationTimer <=
                             enemyActor.ReaperDeathAnimationFrames * enemyActor.ReaperDeathAnimationInterval
                             &&
                             (enemyActor.SpriteState == SpriteState.ATTACK_RIGHT ||
                              enemyActor.SpriteState == SpriteState.MOVE_RIGHT
                         || enemyActor.SpriteState == SpriteState.IDLE_RIGHT))
                    {
                        enemyActor.SpriteState = SpriteState.DEATH_RIGHT;
                    }
                    else if (mDeathAnimationTimer >=
                             enemyActor.ReaperDeathAnimationFrames *
                             enemyActor.ReaperDeathAnimationInterval)
                    {
                        enemyActor.HasDied = true;
                    }

                    break;
                case ObjectType.IMP:

                    if (mDeathAnimationTimer <=
                        enemyActor.ImpDeathAnimationFrames * enemyActor.ImpDeathAnimationInterval
                        &&
                        (enemyActor.SpriteState == SpriteState.ATTACK_LEFT ||
                         enemyActor.SpriteState == SpriteState.MOVE_LEFT
                          || enemyActor.SpriteState == SpriteState.IDLE_LEFT))
                    {
                        enemyActor.SpriteState = SpriteState.DEATH_LEFT;
                    }

                    else if (mDeathAnimationTimer <=
                             enemyActor.ImpDeathAnimationFrames * enemyActor.ImpDeathAnimationInterval
                             &&
                             (enemyActor.SpriteState == SpriteState.ATTACK_RIGHT ||
                              enemyActor.SpriteState == SpriteState.MOVE_RIGHT
                         || enemyActor.SpriteState == SpriteState.IDLE_RIGHT))
                    {
                        enemyActor.SpriteState = SpriteState.DEATH_RIGHT;
                    }
                    else if (mDeathAnimationTimer >=
                             enemyActor.ImpDeathAnimationFrames *
                             enemyActor.ImpDeathAnimationInterval)
                    {
                        enemyActor.HasDied = true;
                    }

                    break;
                case ObjectType.DOOM_HOUND:

                    if (mDeathAnimationTimer <=
                        enemyActor.DoomHoundDeathAnimationFrames * enemyActor.DoomHoundDeathAnimationInterval
                        &&
                        (enemyActor.SpriteState == SpriteState.ATTACK_LEFT ||
                         enemyActor.SpriteState == SpriteState.MOVE_LEFT
                          || enemyActor.SpriteState == SpriteState.IDLE_LEFT))
                    {
                        enemyActor.SpriteState = SpriteState.DEATH_LEFT;
                    }

                    else if (mDeathAnimationTimer <=
                             enemyActor.DoomHoundDeathAnimationFrames * enemyActor.DoomHoundDeathAnimationInterval
                             &&
                             (enemyActor.SpriteState == SpriteState.ATTACK_RIGHT ||
                              enemyActor.SpriteState == SpriteState.MOVE_RIGHT
                         || enemyActor.SpriteState == SpriteState.IDLE_RIGHT))
                    {
                        enemyActor.SpriteState = SpriteState.DEATH_RIGHT;
                    }
                    else if (mDeathAnimationTimer >=
                             enemyActor.DoomHoundDeathAnimationFrames *
                             enemyActor.DoomHoundDeathAnimationInterval)
                    {
                        enemyActor.HasDied = true;
                    }

                    break;

                default:
                    break;
            }
        }
예제 #15
0
 // TODO: Update Unit UnitSpeed
 public void UpdateUnitSpeed(Enemy enemyActor)
 {
     switch (enemyActor.EnemyAggroMode)
     {
         case EnemyAggroMode.ATTACKING:
             enemyActor.EnemyAttribute.UnitSpeed = 0.0f;
             break;
         case EnemyAggroMode.IDLING:
             enemyActor.EnemyAttribute.UnitSpeed = 0.0f;
             break;
         case EnemyAggroMode.MOVING:
             enemyActor.EnemyAttribute.UnitSpeed = 1.0f;
             break;
         default:
             break;
     }
 }
예제 #16
0
        public void Update(Enemy enemyActor)
        {
            CheckVitalSigns(enemyActor);

            if (!isDying)
            {
                if (enemyActor.CombatType == CombatType.RANGED)
                {
                    RangedAttackCastle(enemyActor);
                }
                if (enemyActor.CombatType == CombatType.MELEE)
                {
                    MeleeAttackCastle(enemyActor);
                }
                // Hmmm.. What type of attacks do I have again?
                if (enemyActor.CombatType == CombatType.MELEE && !isAttackingCastle)
                {
                    HandleMeleeUnitBehavior(enemyActor);
                }
                else if (enemyActor.CombatType == CombatType.RANGED && !isAttackingCastle)
                {
                    HandleRangedUnitBehavior(enemyActor);
                }

                targetDirection = enemyActor.CurrentTarget - enemyActor.Sprite.WorldPosition;
                targetDirection.Normalize();

                enemyActor.Direction = enemyActor.Direction + targetDirection * this.weight;

                ScanGlobalList(enemyActor);

                MaintainCurrentTarget(enemyActor);

            }
        }
예제 #17
0
        // TODO: Stop When At CurrentTarget
        // Will cause the unit to stop moving when target location is reached.
        public void StopWhenAtTargetCoordinate(Enemy enemyActor)
        {
            if ((enemyActor.Sprite.WorldPosition.X >= enemyActor.CurrentTarget.X - 30 &&
                     enemyActor.Sprite.WorldPosition.Y >= enemyActor.CurrentTarget.Y - 30) &&
                     (enemyActor.Sprite.WorldPosition.X <= enemyActor.CurrentTarget.X + 30 &&
                     enemyActor.Sprite.WorldPosition.Y <= enemyActor.CurrentTarget.Y + 30))
            {
                enemyActor.EnemyAttribute.UnitSpeed = 0.0f;
                //TODO:   PlayIdleAnimationFromMotion(friendlyActor);
            }

            //if (enemyActor.Sprite.SpriteFrame.Intersects(enemyActor.TargetQueue.PeekFirst().Sprite.SpriteFrame))
            //{
            //    enemyActor.EnemyAttribute.UnitSpeed = 0.0f;
            //}
        }
예제 #18
0
        public void ScanGlobalList(Enemy enemyActor)
        {
            GameObject.mPotentialTargetListList.Reset();
            // Check the global list to see if another object's sprite frame intersects our FOV.
            // If so
            // InsertTargetIntoQueue

            for (int i = 0; i < GameObject.mPotentialTargetListList.GetCount(); i++)
            {
                currentTarget = GameObject.mPotentialTargetListList.GetCurrent().gameObject;

                // If my field of view intersects another object's frame.
                // And if the other object is not an enemyActor.
                // And if the other object is not a castle.
                if (enemyActor.FieldOfView.Intersects(currentTarget.Sprite.SpriteFrame)
                    && currentTarget.Hostility != Hostility.ENEMY
                    && currentTarget.Hostility != Hostility.CASTLE)
                {
                    // Reset current node back to first node.
                    enemyActor.TargetQueue.mTargetList.Reset();

                    // Check to make sure he is not already in my queue.
                    isInQueue = false;
                    for (int j = 0; j < enemyActor.TargetQueue.mTargetList.GetCount(); j++)
                    {
                        if (currentTarget.ObjectID == enemyActor.TargetQueue.mTargetList.GetCurrent().gameObject.ObjectID)
                        {
                            isInQueue = true;

                        }
                        // Go to next node in Queue
                        enemyActor.TargetQueue.mTargetList.NextNode();
                    }
                    if (!isInQueue)
                    {
                        InsertTargetIntoQueue(enemyActor);
                    }

                }

                GameObject.mPotentialTargetListList.NextNode();

            }
        }
예제 #19
0
        // TODO: Play Idle Animation From Motion
        // Will play idle animation if we were moving prior to calling
        public void PlayIdleAnimationFromMotion(Enemy enemyActor)
        {
            if (enemyActor.SpriteState == SpriteState.MOVE_LEFT)
            {
                enemyActor.SpriteState = SpriteState.IDLE_LEFT;
            }

            if (enemyActor.SpriteState == SpriteState.MOVE_RIGHT)
            {
                enemyActor.SpriteState = SpriteState.IDLE_RIGHT;
            }
        }
예제 #20
0
        // TODO: Get Animation Length
        //Gets how long my attack animation lasts
        public float GetAnimationLength(Enemy enemyActor)
        {
            switch (enemyActor.CreatureType)
            {

                case ObjectType.BANSHEE:
                    return enemyActor.BansheeAttackAnimationFrames * enemyActor.BansheeAttackAnimationInterval;
                    break;
                case ObjectType.REAPER:
                    return enemyActor.ReaperAttackAnimationFrames * enemyActor.ReaperAttackAnimationInterval;
                    break;
                case ObjectType.GOG:
                    return enemyActor.GogAttackAnimationFrames * enemyActor.GogAttackAnimationInterval;
                    break;
                case ObjectType.IMP:
                    return enemyActor.ImpAttackAnimationFrames * enemyActor.ImpAttackAnimationInterval;
                    break;
                case ObjectType.DOOM_HOUND:
                    return enemyActor.DoomHoundAttackAnimationFrames * enemyActor.DoomHoundAttackAnimationInterval;
                    break;

                default:
                    return 0.0f;
                    break;
            }
        }
예제 #21
0
 public void CheckMeleeStatusCastle(Enemy enemyActor)
 {
     if (enemyActor.Sprite.SpriteFrame.Intersects(enemyActor.DefaultTarget) &&
          enemyActor.EnemyAggroMode != EnemyAggroMode.IDLING)
     {
         // I should start attacking
         enemyActor.EnemyAggroMode = EnemyAggroMode.ATTACKING;
         UpdateUnitSpeed(enemyActor);
     }
     if (!enemyActor.Sprite.SpriteFrame.Intersects(enemyActor.DefaultTarget))
     {
         // I should be moving :)
         enemyActor.EnemyAggroMode = EnemyAggroMode.MOVING;
         UpdateUnitSpeed(enemyActor);
         MoveTowardsTargetCoordinate(enemyActor);
     }
 }
예제 #22
0
        private void PlayUnitDeathAudio(Enemy enemyActor)
        {
            switch (enemyActor.CreatureType)
            {

                case ObjectType.BANSHEE:
                    PlayBansheeDeathSound();

                    break;
                case ObjectType.REAPER:
                    PlayReaperDeathSound();
                    break;
                case ObjectType.DOOM_HOUND:
                    PlayDoomHoundDeathSound();
                    break;
                case ObjectType.IMP:
                    PlayImpDeathSound();
                    break;
                case ObjectType.GOG:
                    PlayGogDeathSound();
                    break;

                default:
                    break;
            }
        }
예제 #23
0
        public void PlayUnitStruckAudio(Enemy EnemyActor)
        {
            //TODO: place holder
            switch (EnemyActor.CreatureType)
            {

                case ObjectType.BANSHEE:
                    PlayBansheeStruckSound();
                    break;
                case ObjectType.REAPER:
                    PlayReaperStruckSound();
                    break;
                case ObjectType.DOOM_HOUND:
                    PlayDoomHoundStruckSound();
                    break;
                case ObjectType.IMP:
                    PlayImpStruckSound();
                    break;
                case ObjectType.GOG:
                    PlayGogStruckSound();
                    break;

                default:
                    break;
            }
        }
예제 #24
0
        // TODO: Handle Melee Behavior
        public void HandleRangedUnitBehavior(Enemy enemyActor)
        {
            TimeStamp += enemyActor.gameTime.ElapsedGameTime.Milliseconds;

            UpdateUnitSpeed(enemyActor);

            // Always Move To CurrentTarget Unless I'm attacking
            if (!isAttacking)
            {
                enemyActor.EnemyAttribute.UnitSpeed = 1.0f;

                MoveTowardsTargetCoordinate(enemyActor);
            }
            StopWhenAtTargetCoordinate(enemyActor);

            // If I have a list of targets. And I am Ranged
            if (!enemyActor.TargetQueue.IsEmpty() && enemyActor.CombatType == CombatType.RANGED)
            {
                // Check if I made it to my target's sprite frame.
                CheckRangedAttackStatus(enemyActor);

                if (enemyActor.EnemyAggroMode == EnemyAggroMode.ATTACKING)
                {
                    //I'm sitting at my enemy's feet. I'm committed, lock me into attack mode.
                    isAttacking = true;
                    AnimationTimer += enemyActor.gameTime.ElapsedGameTime.Milliseconds;

                    // If I'm attacking then I should play my Attack animation from start to finish.
                    if (AnimationTimer <= GetAnimationLength(enemyActor))
                    {
                        PlayAttackAnimation(enemyActor);

                        Console.WriteLine("Now I'm playing attacking Animation");
                    }
                    else
                    {
                        // Then I should apply my damage to the current target
                        Console.WriteLine("Applying Damage");
                        //TODO:   PlayUnitAttackLandedAudio(friendlyActor);
                        PlayMeleeUnitAttackLandedAudio(enemyActor);
                        enemyActor.EnemyAttribute.Attack();
                        enemyActor.EnemyAggroMode = EnemyAggroMode.IDLING;
                        WaitTimer = 0;
                    }
                }
                // Now I'm done playing my animation for attack. Now play idle while I cool off
                else if (enemyActor.EnemyAggroMode == EnemyAggroMode.IDLING && WaitTimer <= enemyActor.EnemyAttribute.AttackSpeed)
                {
                    WaitTimer += enemyActor.gameTime.ElapsedGameTime.Milliseconds;
                    PlayIdleAnimationFromAttacking(enemyActor);
                }
                // After I wait I should play my attack animation again
                else if (WaitTimer >= enemyActor.EnemyAttribute.AttackSpeed)
                {
                    AnimationTimer = 0;
                    enemyActor.EnemyAggroMode = EnemyAggroMode.ATTACKING;
                }
            }
            else
            {
                //If we are done slaughtering our foes.
                enemyActor.EnemyAggroMode = EnemyAggroMode.MOVING;
                isAttacking = false;
                UpdateUnitSpeed(enemyActor);
                StopWhenAtTargetCoordinate(enemyActor);
            }
        }
예제 #25
0
        public void Attack(Enemy target)
        {
            float tempDamage = CalculateDamage();

            Console.WriteLine(tempDamage);

            // Current target's health -= tempDamage.
            target.EnemyAttribute.CurrentHealthPoints -= tempDamage;
        }
예제 #26
0
        public void InsertTargetIntoQueue(Enemy enemyActor)
        {
            // current object = THIS object.
            // hostile object = object that ran into my field of view.

            // If my target queue is empty
            if (enemyActor.TargetQueue.IsEmpty())
            {
                //Push onto queue.
                enemyActor.TargetQueue.InsertTarget(currentTarget);
            }

            // Else If the hostile object is a structure.
            else if (currentTarget.Hostility == Hostility.STRUCTURE)
            {
                // Push the structure at the end of the queue.
                enemyActor.TargetQueue.mTargetList.InsertLast(currentTarget);
            }

                    // If the hostile object is a creature.
            else if (currentTarget.Hostility == Hostility.FRIENDLY)
            {
                // Reset the current object's target queue's current node to = first node.
                enemyActor.TargetQueue.mTargetList.Reset();

                // Iterate through the current object's target queue to determine where to put the new target.
                for (int i = 0; i < enemyActor.TargetQueue.mTargetList.GetCount(); i++)
                {

                    // If first target is a structure
                    if (enemyActor.TargetQueue.mTargetList.GetCurrent().gameObject.Hostility ==
                        Hostility.STRUCTURE)
                    {
                        // Push creatue to front of the line.
                        enemyActor.TargetQueue.mTargetList.InsertFirst(currentTarget);
                        // We placed the target and now we're done.
                        break;
                    }

                    // If the target queue current.next == structure.
                    else if (enemyActor.TargetQueue.mTargetList.GetCurrent().nextNode != null
                        && enemyActor.TargetQueue.mTargetList.GetCurrent().nextNode.gameObject.Hostility ==
                        Hostility.STRUCTURE)
                    {
                        // Push the creature at the current target queue node.
                        enemyActor.TargetQueue.mTargetList.CreateNewNode(currentTarget,
                                                                              enemyActor.TargetQueue
                                                                                        .mTargetList.GetCurrent());
                        // We placed the target and now we're done.
                        break;
                    }
                    // Else  If we are at the end of the queue
                    else if (enemyActor.TargetQueue.mTargetList.AtEnd())
                    {
                        // Push the creature at the current target queue node.
                        enemyActor.TargetQueue.mTargetList.InsertLast(currentTarget);

                        // We placed the target and now we're done.
                        break;
                    }
                    enemyActor.TargetQueue.mTargetList.NextNode();
                }
            }
        }
예제 #27
0
        public void DropHealthOrb(int WaveNumber, Enemy mEnemyActor)
        {
            // Base gold at 12.
            // Gold Spread Modifier = 20%
            // Gold Drop Modifier = 5%
            // Wave 10
            // Tier 1
            int dropChance = randomGenerator.Next(0, 101);

            //               20% chance to get in
            if (dropChance <= 20)
            {
                // initial gold drop calculation formula.
                mInitialHealthDrop = mBaseHealth * (1 + mHealthModifier * (WaveNumber * mEnemyActor.EnemyAttribute.Tier));

                // calculate a range +- that we can add or subtract from our final gold drop.
                int negativeTempHealthSpread = (int)Math.Round(-1 * (mHealthSpreadModifier * mInitialHealthDrop));

                int positiveTempHealthSpread = (int)Math.Round(mHealthSpreadModifier * mInitialHealthDrop);

                // Gold spread will be a random number +- between the gold drop amount and the spread modifier.
                mHealthSpread = randomGenerator.Next(negativeTempHealthSpread, positiveTempHealthSpread);

                // Add the random spread to the gold drop amount.
                int finalHealthDrop = (int)(Math.Round(mInitialHealthDrop + mHealthSpread));

                // Create the health drop with animation.
                mInPlayItemDropList.InsertLast(new ItemDrop(finalHealthDrop, ObjectType.HEALTH, content,
                                                            SpriteState.ITEMDROP,
                                                            mEnemyActor.Sprite.WorldPosition, Hostility.ITEMDROP));
                hasAlreadyDropped = true;
            }
        }
예제 #28
0
        public void MaintainCurrentTarget(Enemy enemyActor)
        {
            // If my target queue is not empty.
            // And my FOV is no longer intersecting my first target's sprite frame.
            //  enemyActor.GetTargetQueue().mTargetList.Reset();
            if (!enemyActor.TargetQueue.IsEmpty() &&
                !(enemyActor.FieldOfView.Intersects(enemyActor.TargetQueue.PeekFirst().Sprite.SpriteFrame)))
            {
                enemyActor.TargetQueue.PopTarget();
                // PrintGlobalList();

            }
        }
예제 #29
0
        // Decides if we are moving left or right based on time stamps taken at different frames of reference.
        public void MoveTowardsTargetCoordinate(Enemy enemyActor)
        {
            if (TimeStamp < 100.0f)
            {

                InitialPosition = enemyActor.Sprite.WorldPosition.X;
            }

            if (TimeStamp >= 200.0f)
            {

                FinalPosition = enemyActor.Sprite.WorldPosition.X;
                DeltaX = FinalPosition - InitialPosition;

                TimeStamp = 0.0f;
                if (DeltaX > 0)
                {
                    enemyActor.SpriteState = SpriteState.MOVE_RIGHT;

                }
                if (DeltaX <= 0)
                {
                    enemyActor.SpriteState = SpriteState.MOVE_LEFT;

                }
            }
        }
예제 #30
0
        public void Update(Hero actor)
        {
            Hero heroActor = (Hero)actor;
            mWarCryAnimationTimer += heroActor.gameTime.ElapsedGameTime.Milliseconds;

            CheckVitalSigns(heroActor);
            HandleWarCries(heroActor);
            if (!isDying && !isCasting)
            {

                mouseState = Mouse.GetState();
                mouseRectangle = new Rectangle((int) (mouseState.X/GameObject.Scale),
                                               (int) (mouseState.Y/GameObject.Scale), 30, 30);

                ChangeSpriteAnimation(actor);

                if (mouseState.RightButton == ButtonState.Pressed)
                {

                    GameObject.mPotentialTargetListList.Reset();
                    for (int i = 0; i < GameObject.mPotentialTargetListList.GetCount(); i++)
                    {
                        GameObject temp = GameObject.mPotentialTargetListList.GetCurrent().gameObject;

                        if (temp is Enemy)
                        {
                            if (temp.Sprite.SpriteFrame.Contains(mouseRectangle))
                            {
                                targetPosition = new Vector2(temp.Sprite.WorldPosition.X/GameObject.Scale,
                                                             temp.Sprite.WorldPosition.Y/GameObject.Scale);
                                attackingEnemy = true;
                                targetEnemy = (Enemy) temp;
                                break;
                            }
                            else
                            {
                                attackingEnemy = false;
                            }
                        }

                        GameObject.mPotentialTargetListList.NextNode();
                    }
                    if (attackingEnemy == false)
                    {
                        targetPosition = new Vector2(mouseState.X/GameObject.Scale,
                                                     mouseState.Y/GameObject.Scale);
                    }
                }

                if (attackingEnemy && targetEnemy.Sprite.SpriteFrame.Intersects(heroActor.Sprite.SpriteFrame))
                {

                    Attack(heroActor, targetEnemy);
                }

                heroActor.SetHeroTarget(targetPosition);

            }
        }