public void CheckMeleeAttackStatus(Friendly friendlyActor)
        {
            // If I'm colliding with my target
            if (friendlyActor.Sprite.SpriteFrame.Intersects(friendlyActor.TargetQueue.PeekFirst().Sprite.SpriteFrame) &&
                 friendlyActor.FriendlyAggroMode != FriendlyAggroMode.IDLING)
            {
                // I should start attacking
                UpdateUnitSpeed(friendlyActor);
                friendlyActor.FriendlyAggroMode = FriendlyAggroMode.ATTACKING;
            }
            // But if I'm NOT colliding with my target
            else if (!friendlyActor.Sprite.SpriteFrame.Intersects(friendlyActor.TargetQueue.PeekFirst().Sprite.SpriteFrame))
            {
                // I should be moving :)
                friendlyActor.FriendlyAggroMode = FriendlyAggroMode.MOVING;
                UpdateUnitSpeed(friendlyActor);
                MoveTowardsTargetCoordinate(friendlyActor);

            }
        }
        public void ScanGlobalList(Friendly friendlyActor)
        {
            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 friendlyActor.
                // And if the other object is not a castle.
                // And if the other object is not a structure.
                if (friendlyActor.FieldOfView.Intersects(currentTarget.Sprite.SpriteFrame)
                    && currentTarget.Hostility != Hostility.FRIENDLY
                    && currentTarget.Hostility != Hostility.CASTLE
                    && currentTarget.Hostility != Hostility.STRUCTURE)
                {
                    // Reset current node back to first node.
                    friendlyActor.TargetQueue.mTargetList.Reset();

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

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

                }

                GameObject.mPotentialTargetListList.NextNode();

            }
        }
        public static void PrintUpgradeUnitAttributes(ref float textScale, ref TextBoxString gameObjectAttribute,
												ref List<TextBoxString> gameObjectAttributeList, ref string gameObjectAttributeString)
        {
            //TODO: unit name, HP, armor, damage

            switch (tempStructure.UnitType)
            {
                case ObjectType.DRAGON:
                    tempFriendly = GameController.FriendlyPool[7];
                    break;

                case ObjectType.NECROMANCER:
                    tempFriendly = GameController.FriendlyPool[5];
                    break;

                case ObjectType.ARCANE_MAGE:
                    tempFriendly = GameController.FriendlyPool[2];
                    break;

                case ObjectType.FIRE_MAGE:
                    tempFriendly = GameController.FriendlyPool[6];
                    break;

                case ObjectType.AXE_THROWER:
                    tempFriendly = GameController.FriendlyPool[3];
                    break;

                case ObjectType.BERSERKER:
                    tempFriendly = GameController.FriendlyPool[1];
                    break;

                case ObjectType.WOLF:
                    tempFriendly = GameController.FriendlyPool[0];
                    break;

                case ObjectType.CLERIC:
                    tempFriendly = GameController.FriendlyPool[4];
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
            }

            // Print Upgrade Stats
            gameObjectAttributeString = "Unit Type: " + tempStructure.UnitType + "\nHealth Points: " + tempFriendly.FriendlyAttribute.MaxHealthPoints +
                                        "\nArmor: " + tempFriendly.FriendlyAttribute.CurrentArmor + "\nDamge: "
                                       + tempFriendly.FriendlyAttribute.CurrentMinimumDamage + " - " + tempFriendly.FriendlyAttribute.CurrentMaximumDamage;
            WriteLine(ref gameObjectAttribute, textScale, gameObjectAttributeString, gameObjectAttributeList);

            gameObjectAttributeString = " ";
        }
        private void PlayProjectileAudio(Friendly friendlyActor)
        {
            switch (friendlyActor.CreatureType)
            {

                case ObjectType.NECROMANCER:

                    PlayNecromancerProjectileSound();
                    break;
                case ObjectType.ARCANE_MAGE:
                    PlayArcaneMageProjectileSound();
                    break;
                case ObjectType.FIRE_MAGE:
                    PlayFireMageProjectileSound();
                    break;
                case ObjectType.AXE_THROWER:
                    PlayAxeThrowerProjectileSound();
                    break;

                default:
                    break;
            }
        }
        public void InitializeFriendlyPool(ref Friendly[] FriendlyPool)
        {
            FriendlyPool = new Friendly[8];

            FriendlyPool[0] = new Friendly(ObjectType.WOLF, content, SpriteState.MOVE_LEFT,
                Vector2.Zero, Vector2.Zero, 1, 1);

            FriendlyPool[1] = new Friendly(ObjectType.BERSERKER, content, SpriteState.MOVE_LEFT,
                Vector2.Zero, Vector2.Zero, 1, 1);

            FriendlyPool[2] = new Friendly(ObjectType.ARCANE_MAGE, content, SpriteState.MOVE_LEFT,
                Vector2.Zero, Vector2.Zero, 1, 1);

            FriendlyPool[3] = new Friendly(ObjectType.AXE_THROWER, content, SpriteState.MOVE_LEFT,
                Vector2.Zero, Vector2.Zero, 1, 1);

            FriendlyPool[4] = new Friendly(ObjectType.CLERIC, content, SpriteState.MOVE_LEFT,
                Vector2.Zero, Vector2.Zero, 1, 1);

            FriendlyPool[5] = new Friendly(ObjectType.NECROMANCER, content, SpriteState.MOVE_LEFT,
                Vector2.Zero, Vector2.Zero, 1, 1);

            FriendlyPool[6] = new Friendly(ObjectType.FIRE_MAGE, content, SpriteState.MOVE_LEFT,
                Vector2.Zero, Vector2.Zero, 1, 1);

            FriendlyPool[7] = new Friendly(ObjectType.DRAGON, content, SpriteState.MOVE_LEFT,
                Vector2.Zero, Vector2.Zero, 1, 1);
        }
        private void HandleHealingUnitBehavior(Friendly friendlyActor)
        {
            TimeStamp += friendlyActor.gameTime.ElapsedGameTime.Milliseconds;

            UpdateUnitSpeed(friendlyActor);

            // Always Move To CurrentTarget Unless I'm attacking
            if (!isAttacking)
            {
                friendlyActor.FriendlyAttribute.UnitSpeed = 2.0f;

                MoveTowardsTargetCoordinate(friendlyActor);
            }
            StopWhenAtTargetCoordinate(friendlyActor);

            HealTimer += friendlyActor.gameTime.ElapsedGameTime.Milliseconds;

            if (HealTimer >= friendlyActor.FriendlyAttribute.AttackSpeed)
            {
                // Time to play heal animation
                AnimationTimer += friendlyActor.gameTime.ElapsedGameTime.Milliseconds;
                if (AnimationTimer <= GetAnimationLength(friendlyActor))
                {
                    PlayAttackAnimation(friendlyActor);
                }
                else
                {
                    PlayClericAnimationSound();
                    friendlyActor.FriendlyAttribute.Heal();
                    HealTimer = 0;
                    AnimationTimer = 0;
                }

            }
        }
        // Play the death animation after our HP has dropped below 0.
        private void BeginDying(Friendly friendlyActor)
        {
            switch (friendlyActor.CreatureType)
            {

                case ObjectType.DRAGON:
                    if (mDeathAnimationTimer <= friendlyActor.DragonDeathAnimationFrames * friendlyActor.DragonDeathAnimationInterval
                        && (friendlyActor.SpriteState == SpriteState.ATTACK_LEFT || friendlyActor.SpriteState == SpriteState.MOVE_LEFT
                        || friendlyActor.SpriteState == SpriteState.IDLE_LEFT))
                    {
                        friendlyActor.SpriteState = SpriteState.DEATH_LEFT;

                    }

                    else if (mDeathAnimationTimer <= friendlyActor.DragonDeathAnimationFrames * friendlyActor.DragonDeathAnimationInterval
                        && (friendlyActor.SpriteState == SpriteState.ATTACK_RIGHT || friendlyActor.SpriteState == SpriteState.MOVE_RIGHT
                        || friendlyActor.SpriteState == SpriteState.IDLE_RIGHT))
                    {
                        friendlyActor.SpriteState = SpriteState.DEATH_RIGHT;
                    }
                    else if (mDeathAnimationTimer >= friendlyActor.DragonDeathAnimationFrames * friendlyActor.DragonDeathAnimationInterval)
                    {
                        friendlyActor.HasDied = true;
                    }

                    break;
                case ObjectType.NECROMANCER:

                    if (mDeathAnimationTimer <= friendlyActor.NecromancerDeathAnimationFrames * friendlyActor.NecromancerDeathAnimationInterval
            && (friendlyActor.SpriteState == SpriteState.ATTACK_LEFT || friendlyActor.SpriteState == SpriteState.MOVE_LEFT
            || friendlyActor.SpriteState == SpriteState.IDLE_LEFT))
                    {
                        friendlyActor.SpriteState = SpriteState.DEATH_LEFT;
                    }

                    else if (mDeathAnimationTimer <= friendlyActor.NecromancerDeathAnimationFrames * friendlyActor.NecromancerDeathAnimationInterval
                        && (friendlyActor.SpriteState == SpriteState.ATTACK_RIGHT || friendlyActor.SpriteState == SpriteState.MOVE_RIGHT
                        || friendlyActor.SpriteState == SpriteState.IDLE_RIGHT))
                    {
                        friendlyActor.SpriteState = SpriteState.DEATH_RIGHT;
                    }
                    else if (mDeathAnimationTimer >= friendlyActor.NecromancerDeathAnimationFrames * friendlyActor.NecromancerDeathAnimationInterval)
                    {
                        friendlyActor.HasDied = true;
                    }

                    break;
                case ObjectType.ARCANE_MAGE:
                    if (mDeathAnimationTimer <= friendlyActor.ArcaneMageDeathAnimationFrames * friendlyActor.ArcaneMageDeathAnimationInterval
            && (friendlyActor.SpriteState == SpriteState.ATTACK_LEFT || friendlyActor.SpriteState == SpriteState.MOVE_LEFT
            || friendlyActor.SpriteState == SpriteState.IDLE_LEFT))
                    {
                        friendlyActor.SpriteState = SpriteState.DEATH_LEFT;
                    }

                    else if (mDeathAnimationTimer <= friendlyActor.ArcaneMageDeathAnimationFrames * friendlyActor.ArcaneMageDeathAnimationInterval
                        && (friendlyActor.SpriteState == SpriteState.ATTACK_RIGHT || friendlyActor.SpriteState == SpriteState.MOVE_RIGHT
                        || friendlyActor.SpriteState == SpriteState.IDLE_RIGHT))
                    {
                        friendlyActor.SpriteState = SpriteState.DEATH_RIGHT;
                    }
                    else if (mDeathAnimationTimer >= friendlyActor.ArcaneMageDeathAnimationFrames * friendlyActor.ArcaneMageDeathAnimationInterval)
                    {
                        friendlyActor.HasDied = true;
                    }

                    break;
                case ObjectType.FIRE_MAGE:

                    if (mDeathAnimationTimer <= friendlyActor.FireMageDeathAnimationFrames * friendlyActor.FireMageDeathAnimationInterval
            && (friendlyActor.SpriteState == SpriteState.ATTACK_LEFT || friendlyActor.SpriteState == SpriteState.MOVE_LEFT
            || friendlyActor.SpriteState == SpriteState.IDLE_LEFT))
                    {
                        friendlyActor.SpriteState = SpriteState.DEATH_LEFT;
                    }

                    else if (mDeathAnimationTimer <= friendlyActor.FireMageDeathAnimationFrames * friendlyActor.FireMageDeathAnimationInterval
                        && (friendlyActor.SpriteState == SpriteState.ATTACK_RIGHT || friendlyActor.SpriteState == SpriteState.MOVE_RIGHT
                        || friendlyActor.SpriteState == SpriteState.IDLE_RIGHT))
                    {
                        friendlyActor.SpriteState = SpriteState.DEATH_RIGHT;
                    }
                    else if (mDeathAnimationTimer >= friendlyActor.FireMageDeathAnimationFrames * friendlyActor.FireMageDeathAnimationInterval)
                    {
                        friendlyActor.HasDied = true;
                    }

                    break;
                case ObjectType.WOLF:

                    if (mDeathAnimationTimer <= friendlyActor.WolfDeathAnimationFrames * friendlyActor.WolfDeathAnimationInterval
            && (friendlyActor.SpriteState == SpriteState.ATTACK_LEFT || friendlyActor.SpriteState == SpriteState.MOVE_LEFT
            || friendlyActor.SpriteState == SpriteState.IDLE_LEFT))
                    {
                        friendlyActor.SpriteState = SpriteState.DEATH_LEFT;
                    }

                    else if (mDeathAnimationTimer <= friendlyActor.WolfDeathAnimationFrames * friendlyActor.WolfDeathAnimationInterval
                        && (friendlyActor.SpriteState == SpriteState.ATTACK_RIGHT || friendlyActor.SpriteState == SpriteState.MOVE_RIGHT
                        || friendlyActor.SpriteState == SpriteState.IDLE_RIGHT))
                    {
                        friendlyActor.SpriteState = SpriteState.DEATH_RIGHT;
                    }
                    else if (mDeathAnimationTimer >= friendlyActor.WolfDeathAnimationFrames * friendlyActor.WolfDeathAnimationInterval)
                    {
                        friendlyActor.HasDied = true;
                    }

                    break;
                case ObjectType.AXE_THROWER:
                    if (mDeathAnimationTimer <= friendlyActor.AxeThrowerDeathAnimationFrames * friendlyActor.AxeThrowerDeathAnimationInterval
                         && (friendlyActor.SpriteState == SpriteState.ATTACK_LEFT || friendlyActor.SpriteState == SpriteState.MOVE_LEFT ||
                         friendlyActor.SpriteState == SpriteState.IDLE_LEFT))
                    {
                        friendlyActor.SpriteState = SpriteState.DEATH_LEFT;
                    }

                    else if (mDeathAnimationTimer <= friendlyActor.AxeThrowerDeathAnimationFrames * friendlyActor.AxeThrowerDeathAnimationInterval
                        && (friendlyActor.SpriteState == SpriteState.ATTACK_RIGHT || friendlyActor.SpriteState == SpriteState.MOVE_RIGHT
                         || friendlyActor.SpriteState == SpriteState.IDLE_RIGHT))
                    {
                        friendlyActor.SpriteState = SpriteState.DEATH_RIGHT;
                    }
                    else if (mDeathAnimationTimer >= friendlyActor.AxeThrowerDeathAnimationFrames * friendlyActor.AxeThrowerDeathAnimationInterval)
                    {
                        friendlyActor.HasDied = true;
                    }

                    break;
                case ObjectType.BERSERKER:
                    if (mDeathAnimationTimer <= friendlyActor.BerserkerDeathAnimationFrames * friendlyActor.BerserkerDeathAnimationInterval
                        && (friendlyActor.SpriteState == SpriteState.ATTACK_LEFT || friendlyActor.SpriteState == SpriteState.MOVE_LEFT
                        || friendlyActor.SpriteState == SpriteState.IDLE_LEFT))
                    {
                        friendlyActor.SpriteState = SpriteState.DEATH_LEFT;
                    }

                    else if (mDeathAnimationTimer <= friendlyActor.BerserkerDeathAnimationFrames * friendlyActor.BerserkerDeathAnimationInterval
                        && (friendlyActor.SpriteState == SpriteState.ATTACK_RIGHT || friendlyActor.SpriteState == SpriteState.MOVE_RIGHT
                        || friendlyActor.SpriteState == SpriteState.IDLE_RIGHT))
                    {
                        friendlyActor.SpriteState = SpriteState.DEATH_RIGHT;
                    }
                    else if (mDeathAnimationTimer >= friendlyActor.BerserkerDeathAnimationFrames * friendlyActor.BerserkerDeathAnimationInterval)
                    {
                        friendlyActor.HasDied = true;
                    }

                    break;
                case ObjectType.CLERIC:
                    if (mDeathAnimationTimer <= friendlyActor.ClericDeathAnimationFrames * friendlyActor.ClericDeathAnimationInterval
            && (friendlyActor.SpriteState == SpriteState.ATTACK_LEFT || friendlyActor.SpriteState == SpriteState.MOVE_LEFT))
                    {
                        friendlyActor.SpriteState = SpriteState.DEATH_LEFT;
                    }

                    else if (mDeathAnimationTimer <= friendlyActor.ClericDeathAnimationFrames * friendlyActor.ClericDeathAnimationInterval
                        && (friendlyActor.SpriteState == SpriteState.ATTACK_RIGHT || friendlyActor.SpriteState == SpriteState.MOVE_RIGHT))
                    {
                        friendlyActor.SpriteState = SpriteState.DEATH_RIGHT;
                    }
                    else if (mDeathAnimationTimer >= friendlyActor.ClericDeathAnimationFrames * friendlyActor.ClericDeathAnimationInterval)
                    {
                        friendlyActor.HasDied = true;
                    }

                    break;

                default:
                    break;
            }
        }
        public void Update(Friendly friendlyActor, GameTime gameTime)
        {
            this.gameTime = gameTime;

            CheckVitalSigns(friendlyActor);

            if (!isDying)
            {

                // Hmmm.. What type of attacks do I have again?
                if (friendlyActor.CombatType == CombatType.MELEE)
                {
                    HandleMeleeUnitBehavior(friendlyActor);
                }
                else if (friendlyActor.CombatType == CombatType.RANGED)
                {
                    HandleRangedUnitBehavior(friendlyActor);
                }
                else if (friendlyActor.CombatType == CombatType.HEALER)
                {
                    HandleHealingUnitBehavior(friendlyActor);
                }

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

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

                if (friendlyActor.CreatureType != ObjectType.CLERIC)
                {
                    ScanGlobalList(friendlyActor);

                    // Check if current target is in our field of view still
                    MaintainTarget(friendlyActor);
                }
            }
        }
        // Will play Idle Animation for duration of animation
        public void PlayAttackAnimation(Friendly friendlyActor)
        {
            switch (friendlyActor.CreatureType)
            {

                case ObjectType.DRAGON:
                    if (friendlyActor.SpriteState == SpriteState.IDLE_LEFT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.IDLE_RIGHT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.MOVE_LEFT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.MOVE_RIGHT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    PlayUnitAnimationAudio(friendlyActor);
                    break;
                case ObjectType.NECROMANCER:
                    if (friendlyActor.SpriteState == SpriteState.IDLE_LEFT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.IDLE_RIGHT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.MOVE_LEFT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.MOVE_RIGHT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    PlayUnitAnimationAudio(friendlyActor);
                    break;
                case ObjectType.ARCANE_MAGE:
                    if (friendlyActor.SpriteState == SpriteState.IDLE_LEFT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.IDLE_RIGHT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.MOVE_LEFT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.MOVE_RIGHT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    PlayUnitAnimationAudio(friendlyActor);
                    break;
                case ObjectType.FIRE_MAGE:
                    if (friendlyActor.SpriteState == SpriteState.IDLE_LEFT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.IDLE_RIGHT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.MOVE_LEFT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.MOVE_RIGHT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    PlayUnitAnimationAudio(friendlyActor);
                    break;
                case ObjectType.WOLF:
                    if (friendlyActor.SpriteState == SpriteState.IDLE_LEFT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.IDLE_RIGHT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.MOVE_LEFT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.MOVE_RIGHT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    PlayUnitAnimationAudio(friendlyActor);
                    break;
                case ObjectType.AXE_THROWER:
                    if (friendlyActor.SpriteState == SpriteState.IDLE_LEFT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.IDLE_RIGHT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.MOVE_LEFT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.MOVE_RIGHT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    PlayUnitAnimationAudio(friendlyActor);
                    break;
                case ObjectType.BERSERKER:
                    if (friendlyActor.SpriteState == SpriteState.IDLE_LEFT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.IDLE_RIGHT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.MOVE_LEFT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.MOVE_RIGHT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    PlayUnitAnimationAudio(friendlyActor);
                    break;
                case ObjectType.CLERIC:
                    if (friendlyActor.SpriteState == SpriteState.IDLE_LEFT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.IDLE_RIGHT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.MOVE_LEFT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_LEFT;
                    }
                    else if (friendlyActor.SpriteState == SpriteState.MOVE_RIGHT)
                    {
                        friendlyActor.SpriteState = SpriteState.ATTACK_RIGHT;
                    }
                    PlayUnitAnimationAudio(friendlyActor);
                    break;

                default:
                    break;
            }
        }
        // Decides if we are moving left or right based on time stamps taken at different frames of reference.
        public void MoveTowardsTargetCoordinate(Friendly friendlyActor)
        {
            if (TimeStamp < 100.0f)
            {

                InitialPosition = friendlyActor.Sprite.WorldPosition.X;
            }

            if (TimeStamp >= 200.0f)
            {

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

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

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

                }
            }
        }
 public void MaintainTarget(Friendly friendlyActor)
 {
     // If my target queue is not empty.
     // And my FOV is no longer intersecting my first target's sprite frame.
     if (!(friendlyActor.TargetQueue.IsEmpty()) &&
         !(friendlyActor.FieldOfView.Intersects(friendlyActor.TargetQueue.PeekFirst().Sprite.SpriteFrame)))
     {
         friendlyActor.TargetQueue.PopTarget();
     }
 }
        public void InsertTargetIntoQueue(Friendly friendlyActor)
        {
            // current object = THIS object.
            // hostile object = object that ran into my field of view.

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

                    // If the hostile object is a creature.
            else if (currentTarget.Hostility == Hostility.ENEMY)
            {

                // Reset the current object's target queue's current node to = first node.
                friendlyActor.TargetQueue.mTargetList.Reset();

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

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

                    friendlyActor.TargetQueue.mTargetList.NextNode();
                }
            }
        }
        public void HandleRangedUnitBehavior(Friendly friendlyActor)
        {
            TimeStamp += friendlyActor.gameTime.ElapsedGameTime.Milliseconds;

            UpdateUnitSpeed(friendlyActor);

            // Always Move To CurrentTarget Unless I'm attacking
            if (!isAttacking)
            {
                friendlyActor.FriendlyAttribute.UnitSpeed = 2.0f;

                MoveTowardsTargetCoordinate(friendlyActor);
            }
            StopWhenAtTargetCoordinate(friendlyActor);

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

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

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

                        Console.WriteLine("Now I'm playing attacking Animation");
                    }
                    else
                    {
                        // Then I should apply my damage to the current target
                        Console.WriteLine("Applying Damage");
                        PlayUnitAttackLandedAudio(friendlyActor);
                        friendlyActor.FriendlyAttribute.Attack();
                        friendlyActor.FriendlyAggroMode = FriendlyAggroMode.IDLING;
                        WaitTimer = 0;
                    }
                }
                // Now I'm done playing my animation for attack. Now play idle while I cool off
                else if (friendlyActor.FriendlyAggroMode == FriendlyAggroMode.IDLING && WaitTimer <= friendlyActor.FriendlyAttribute.AttackSpeed)
                {
                    WaitTimer += friendlyActor.gameTime.ElapsedGameTime.Milliseconds;
                    PlayIdleAnimationFromAttacking(friendlyActor);
                }
                // After I wait I should play my attack animation again
                else if (WaitTimer >= friendlyActor.FriendlyAttribute.AttackSpeed)
                {
                    AnimationTimer = 0;
                    friendlyActor.FriendlyAggroMode = FriendlyAggroMode.ATTACKING;
                }
            }
            else
            {
                //If we are done slaughtering our foes.
                friendlyActor.FriendlyAggroMode = FriendlyAggroMode.MOVING;
                isAttacking = false;
                UpdateUnitSpeed(friendlyActor);
                StopWhenAtTargetCoordinate(friendlyActor);
            }
        }
        //Gets how long my attack animation lasts
        public float GetAnimationLength(Friendly friendlyActor)
        {
            switch (friendlyActor.CreatureType)
            {

                case ObjectType.DRAGON:
                    PlayDragonAnimationSound();
                    return friendlyActor.DragonAttackAnimationFrames * friendlyActor.DragonAttackAnimationInterval;
                    break;
                case ObjectType.NECROMANCER:
                    return friendlyActor.NecromancerAttackAnimationFrames * friendlyActor.NecromancerAttackAnimationInterval;
                    break;
                case ObjectType.ARCANE_MAGE:
                    return friendlyActor.ArcaneMageAttackAnimationFrames * friendlyActor.ArcaneMageAttackAnimationInterval;
                    break;
                case ObjectType.FIRE_MAGE:
                    return friendlyActor.FireMageAttackAnimationFrames * friendlyActor.FireMageAttackAnimationInterval;
                    break;
                case ObjectType.WOLF:
                    return friendlyActor.WolfAttackAnimationFrames * friendlyActor.WolfAttackAnimationInterval;
                    break;
                case ObjectType.AXE_THROWER:
                    return friendlyActor.AxeThrowerAttackAnimationFrames * friendlyActor.AxeThrowerAttackAnimationInterval;
                    break;
                case ObjectType.BERSERKER:
                    return friendlyActor.BerserkerAttackAnimationFrames * friendlyActor.BerserkerAttackAnimationInterval;
                    break;

                case ObjectType.CLERIC:
                    return friendlyActor.ClericAttackAnimationFrames * friendlyActor.ClericAttackAnimationInterval;
                    break;

                default:
                    return 0.0f;
                    break;
            }
        }
        // WIll play the idle animation if we were attacking before
        public void PlayIdleAnimationFromAttacking(Friendly friendlyActor)
        {
            if (friendlyActor.SpriteState == SpriteState.ATTACK_LEFT)
            {
                friendlyActor.SpriteState = SpriteState.IDLE_LEFT;
            }

            if (friendlyActor.SpriteState == SpriteState.ATTACK_RIGHT)
            {
                friendlyActor.SpriteState = SpriteState.IDLE_RIGHT;
            }
        }
 // Will cause the unit to stop moving when target location is reached.
 public void StopWhenAtTargetCoordinate(Friendly friendlyActor)
 {
     if ((friendlyActor.Sprite.WorldPosition.X >= friendlyActor.CurrentTarget.X - 30 &&
              friendlyActor.Sprite.WorldPosition.Y >= friendlyActor.CurrentTarget.Y - 30) &&
              (friendlyActor.Sprite.WorldPosition.X <= friendlyActor.CurrentTarget.X + 30 &&
              friendlyActor.Sprite.WorldPosition.Y <= friendlyActor.CurrentTarget.Y + 30))
     {
         friendlyActor.FriendlyAttribute.UnitSpeed = 0.0f;
         PlayIdleAnimationFromMotion(friendlyActor);
     }
 }
        // Will play idle animation if we were moving prior to calling
        public void PlayIdleAnimationFromMotion(Friendly friendlyActor)
        {
            if (friendlyActor.SpriteState == SpriteState.MOVE_LEFT)
            {
                friendlyActor.SpriteState = SpriteState.IDLE_LEFT;
            }

            if (friendlyActor.SpriteState == SpriteState.MOVE_RIGHT)
            {
                friendlyActor.SpriteState = SpriteState.IDLE_RIGHT;
            }
        }
 public void UpdateUnitSpeed(Friendly friendlyActor)
 {
     switch (friendlyActor.FriendlyAggroMode)
     {
         case FriendlyAggroMode.ATTACKING:
             friendlyActor.FriendlyAttribute.UnitSpeed = 0.0f;
             break;
         case FriendlyAggroMode.IDLING:
             friendlyActor.FriendlyAttribute.UnitSpeed = 0.0f;
             break;
         case FriendlyAggroMode.MOVING:
             friendlyActor.FriendlyAttribute.UnitSpeed = 2.0f;
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
 }
        public void PlayUnitAnimationAudio(Friendly friendlyActor)
        {
            // Decide what type of unit I am.
            // Pick a random number and use that to select which sound effect I make this time.

            switch (friendlyActor.CreatureType)
            {

                case ObjectType.DRAGON:
                    PlayDragonAnimationSound();
                    break;
                case ObjectType.NECROMANCER:

                    break;
                case ObjectType.ARCANE_MAGE:
                    PlayArcaneMageAnimationSound();
                    break;
                case ObjectType.FIRE_MAGE:
                    PlayFireMageAnimationSound();
                    break;
                case ObjectType.WOLF:
                    PlayWolfAnimationSound();
                    break;
                case ObjectType.AXE_THROWER:
                    PlayAxeThrowerAnimationSound();

                    break;
                case ObjectType.BERSERKER:
                    PlayBerserkerAnimationSound();
                    break;

                case ObjectType.CLERIC:

                    break;

                default:
                    break;
            }
        }
 private void CheckVitalSigns(Friendly friendlyActor)
 {
     if (0 >= friendlyActor.FriendlyAttribute.CurrentHealthPoints)
     {
         mDeathAnimationTimer += friendlyActor.gameTime.ElapsedGameTime.Milliseconds;
         PlayUnitDeathAudio(friendlyActor);
         isDying = true;
         BeginDying(friendlyActor);
     }
     else
     {
         isDying = false;
     }
 }
        public void PlayUnitAttackLandedAudio(Friendly friendlyActor)
        {
            // Decide what type of unit I am.
            // Pick a random number and use that to select which sound effect I make this time.

            switch (friendlyActor.CreatureType)
            {
                case ObjectType.WOLF:
                    PlayWolfAttackLandedSound();
                    break;

                case ObjectType.BERSERKER:
                    PlayBerserkerAttackLandedSound();
                    break;

                default:
                    break;
            }
        }
Beispiel #22
0
        public void PlayUnitStruckAudio(Friendly friendlyActor)
        {
            //TODO: place holder
            switch (friendlyActor.CreatureType)
            {

                case ObjectType.DRAGON:
                    PlayDragonStruckSound();
                    break;
                case ObjectType.NECROMANCER:
                    PlayNecromancerStruckSound();
                    break;
                case ObjectType.ARCANE_MAGE:
                    PlayArcaneMageStruckSound();
                    break;
                case ObjectType.FIRE_MAGE:
                    PlayFireMageStruckSound();
                    break;
                case ObjectType.WOLF:
                    PlayWolfStruckSound();
                    break;
                case ObjectType.AXE_THROWER:
                    PlayAxeThrowerStruckSound();
                    break;
                case ObjectType.BERSERKER:
                    PlayBerserkerStruckSound();
                    break;

                case ObjectType.CLERIC:
                    PlayClericStruckSound();
                    break;

                default:
                    break;
            }
        }
        public void PlayUnitDeathAudio(Friendly friendlyActor)
        {
            switch (friendlyActor.CreatureType)
            {

                case ObjectType.DRAGON:
                    PlayDragonDeathSounds();
                    break;

                case ObjectType.NECROMANCER:
                    PlayNecromancerDeathSounds();
                    break;

                case ObjectType.ARCANE_MAGE:
                    PlayArcaneMageDeathSounds();
                    break;

                case ObjectType.FIRE_MAGE:
                    PlayFireMageDeathSounds();
                    break;

                case ObjectType.WOLF:
                    PlayWolfDeathSounds();
                    break;

                case ObjectType.AXE_THROWER:
                    PlayAxeThrowerDeathSounds();
                    break;

                case ObjectType.BERSERKER:
                    PlayBerserkerDeathSounds();
                    break;

                case ObjectType.CLERIC:
                    PlayClericDeathSound();
                    break;

                default:
                    break;
            }
        }
        public void SpawnFriendly(int i)
        {
            bool notCapped = false;

            switch (InPlayStructures[i].UnitType)
            {
                case ObjectType.DRAGON:
                    if (InPlayStructures[i].StructureAttribute.CurrentAmountDragons <
                        InPlayStructures[i].StructureAttribute.MaxDragonAmount)
                        notCapped = true;
                    break;

                case ObjectType.NECROMANCER:
                    if (InPlayStructures[i].StructureAttribute.CurrentAmountNecromancers <
                        InPlayStructures[i].StructureAttribute.MaxNecromancerAmount)
                        notCapped = true;
                    break;

                case ObjectType.ARCANE_MAGE:
                    if (InPlayStructures[i].StructureAttribute.CurrentAmountArcaneMages <
                        InPlayStructures[i].StructureAttribute.MaxArcaneMageAmount)
                        notCapped = true;
                    break;

                case ObjectType.FIRE_MAGE:
                    if (InPlayStructures[i].StructureAttribute.CurrentAmountFireMages <
                        InPlayStructures[i].StructureAttribute.MaxFireMageAmount)
                        notCapped = true;
                    break;

                case ObjectType.AXE_THROWER:
                    if (InPlayStructures[i].StructureAttribute.CurrentAmountAxeThrowers <
                        InPlayStructures[i].StructureAttribute.MaxAxeThrowerAmount)
                        notCapped = true;
                    break;

                case ObjectType.BERSERKER:
                    if (InPlayStructures[i].StructureAttribute.CurrentAmountBerserkers <
                        InPlayStructures[i].StructureAttribute.MaxBerserkerAmount)
                        notCapped = true;
                    break;

                case ObjectType.WOLF:
                    if (InPlayStructures[i].StructureAttribute.CurrentAmountWolfs <
                        InPlayStructures[i].StructureAttribute.MaxWolfAmount)
                        notCapped = true;
                    break;

                case ObjectType.CLERIC:
                    if (InPlayStructures[i].StructureAttribute.CurrentAmountClerics <
                        InPlayStructures[i].StructureAttribute.MaxClericAmount)
                        notCapped = true;
                    break;

                default:
                    Console.WriteLine("Spawn Friendly problems");
                    break;
            }

            if (notCapped)
            {
                Friendly tempFriendly = new Friendly(InPlayStructures[i].UnitType, content, SpriteState.MOVE_LEFT,
                                                     Vector2.Zero, InPlayStructures[i].StructureAttribute.DefaultUnitTarget, InPlayStructures[i].StructureAttribute.AttackLevel, InPlayStructures[i].StructureAttribute.DefenseLevel);

                mInPlayObjectList.InsertLast(tempFriendly);
                GameObject.mPotentialTargetListList.InsertLast(tempFriendly);

                tempFriendly.Sprite.LoadContent();
                tempFriendly.Sprite.WorldPosition =
                    new Vector2(InPlayStructures[i].Sprite.WorldPosition.X - tempFriendly.Sprite.SpriteFrame.Width,
                                InPlayStructures[i].Sprite.WorldPosition.Y);
                tempFriendly.Color = InPlayStructures[i].StructureColor;
                tempFriendly.PostSetFOV();

                PassGameTime();

                switch (InPlayStructures[i].UnitType)
                {
                    case ObjectType.DRAGON:
                        InPlayStructures[i].StructureAttribute.CurrentAmountDragons++;
                        break;

                    case ObjectType.NECROMANCER:
                        InPlayStructures[i].StructureAttribute.CurrentAmountNecromancers++;
                        break;

                    case ObjectType.ARCANE_MAGE:
                        InPlayStructures[i].StructureAttribute.CurrentAmountArcaneMages++;
                        break;

                    case ObjectType.FIRE_MAGE:
                        InPlayStructures[i].StructureAttribute.CurrentAmountFireMages++;
                        break;

                    case ObjectType.AXE_THROWER:
                        InPlayStructures[i].StructureAttribute.CurrentAmountAxeThrowers++;
                        break;

                    case ObjectType.BERSERKER:
                        InPlayStructures[i].StructureAttribute.CurrentAmountBerserkers++;
                        break;

                    case ObjectType.WOLF:
                        InPlayStructures[i].StructureAttribute.CurrentAmountWolfs++;
                        break;

                    case ObjectType.CLERIC:
                        InPlayStructures[i].StructureAttribute.CurrentAmountClerics++;
                        break;

                    default:
                        Console.WriteLine("Spawn Friendly problems");
                        break;
                }

                    notCapped = false;

            }
        }
        public void PlayUnitStruckAudio(Friendly friendlyActor, Enemy EnemyActor)
        {
            //TODO: place holder
            switch (friendlyActor.TargetQueue.PeekFirst().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;
            }
        }
 public FriendlyAttribute(Friendly mFriendlyActor, ContentManager content)
     : base(content)
 {
     randomNumberGenerator = new Random();
     this.mFriendlyActor = mFriendlyActor;
 }
        public static void PrintFriendlyAttributes(ref float textScale, ref TextBoxString gameObjectAttribute,
												ref List<TextBoxString> gameObjectAttributeList, ref string gameObjectAttributeString,
												 Friendly tempFriendly)
        {
            // Print Health
            gameObjectAttributeString = "Health: " + tempFriendly.FriendlyAttribute.CurrentHealthPoints.ToString();
            WriteLine(ref gameObjectAttribute, textScale, gameObjectAttributeString, gameObjectAttributeList);

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

            //Print Sprite Frame
            gameObjectAttributeString = "Damage: " + tempFriendly.FriendlyAttribute.CurrentMinimumDamage + " - " + tempFriendly.FriendlyAttribute.CurrentMaximumDamage;
            WriteLine(ref gameObjectAttribute, textScale, gameObjectAttributeString, gameObjectAttributeList);

            gameObjectAttributeString = " ";
        }