Ejemplo n.º 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;
                    }

                }
            }
        }
Ejemplo n.º 2
0
        public GlobeFrame(GraphicsDevice graphics, SpriteBatch spriteBatch, ContentManager Content, string mGlobeGlassTexturePath, string mGlobeBoxTexturePath,
            string mGlobeLiquidTexturePath, Vector2 mDrawingTexturePosition, Hero mHero)
        {
            this.graphics = graphics;
            this.spriteBatch = spriteBatch;
            this.Content = Content;
            this.mDrawingTexturePosition = mDrawingTexturePosition;
            this.mGlobeBoxTexturePath = mGlobeBoxTexturePath;
            this.mGlobeGlassTexturePath = mGlobeGlassTexturePath;
            this.mGlobeLiquidTexturePath = mGlobeLiquidTexturePath;
            this.mHero = mHero;

            newLocationY = 0;
            newLocationX = 0;
            // initialize keyboard state
            keyboardState = Keyboard.GetState();
            previousKeyboardState = keyboardState;
        }
Ejemplo n.º 3
0
        private void PopulateLists()
        {
            // Friendlies = new List<Friendly>();

            // DRAGON, NECROMANCER, ARCANE_MAGE, FIRE_MAGE,
            //WOLF, AXE_THROWER, TROLL, BERSERKER

            mLevelTexture = content.Load<Texture2D>("Sprites/Levels/background_composite");

            Vector2 position = new Vector2(1250, 159);

            float x = position.X;
            float y = position.Y;

            //Create Hero
            mHero = new Hero(ObjectType.HERO, content, SpriteState.MOVE_LEFT, new Vector2(900, 450));

            mCastle = new Castle(ObjectType.ORC_CASTLE, content, SpriteState.CASTLE, new Vector2(1450, 450));
            //mCastle.Speed = 0.5f;
        }
Ejemplo n.º 4
0
 public HeroAttribute(Hero hero, ContentManager content)
     : base(content)
 {
     this.hero = hero;
 }
Ejemplo n.º 5
0
        public void PlayUnitStruckAudio(Hero friendlyActor)
        {
            int temp = randomNumberGenerator.Next(0, 2);

            switch (temp)
            {
                case 0:
                    AudioController.HeroStruck1SoundEffectInstance.Volume = mMeleeHitSoundVolume;
                    AudioController.HeroStruck1SoundEffectInstance.Play();

                    break;
                case 1:
                    AudioController.HeroStruck2SoundEffectInstance.Volume = mMeleeHitSoundVolume;
                    AudioController.HeroStruck2SoundEffectInstance.Play();
                    break;
                default:
                    break;

            }
        }
        public static void PrintHeroAttributes(ref float textScale, ref TextBoxString gameObjectAttribute,
												ref List<TextBoxString> gameObjectAttributeList, ref string gameObjectAttributeString,
												 Hero tempHero)
        {
            // Print Name
            gameObjectAttributeString = "The Hero";
            WriteLine(ref gameObjectAttribute, textScale, gameObjectAttributeString, gameObjectAttributeList);

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

            //Print Level
            gameObjectAttributeString = "Level: " + tempHero.HeroAttribute.Level;
            WriteLine(ref gameObjectAttribute, textScale, gameObjectAttributeString, gameObjectAttributeList);

            //Print Damage
            gameObjectAttributeString = "Damage: " + tempHero.HeroAttribute.CurrentMinimumDamage + " - " + tempHero.HeroAttribute.CurrentMaximumDamage;
            WriteLine(ref gameObjectAttribute, textScale, gameObjectAttributeString, gameObjectAttributeList);
            gameObjectAttributeString = " ";
        }
Ejemplo n.º 7
0
        private void PlayIntmidateAnimation(Hero heroActor)
        {
            if (HeroAttribute.IntimidateSpellState == IntimidateSpellState.ACTIVE && !isCasting)
            {
                mWarCryAnimationTimer = 0;
                PlayHeroWarCrySound();
                isCasting = true;
            }

            if (mWarCryAnimationTimer <= heroActor.IntimidateAnimationFrames * heroActor.IntimitadeAnimationInterval && isCasting)
            {
                if (heroActor.SpriteState == SpriteState.IDLE_LEFT
                    || heroActor.SpriteState == SpriteState.MOVE_LEFT
                    || heroActor.SpriteState == SpriteState.ATTACK_LEFT)
                {
                    heroActor.SpriteState = SpriteState.INTIMIDATE_LEFT;

                }
                else if (heroActor.SpriteState == SpriteState.IDLE_RIGHT
                    || heroActor.SpriteState == SpriteState.MOVE_RIGHT
                    || heroActor.SpriteState == SpriteState.ATTACK_RIGHT)
                {
                    heroActor.SpriteState = SpriteState.INTIMIDATE_RIGHT;

                }

            }
            else if (mWarCryAnimationTimer >= (heroActor.IntimidateAnimationFrames * heroActor.IntimitadeAnimationInterval) && isCasting)
            {
                isCasting = false;
            }
        }
Ejemplo n.º 8
0
        private void HandleWarCries(Hero heroActor)
        {
            PlayBattleCryAnimation(heroActor);

                 PlayIntmidateAnimation(heroActor);
        }
Ejemplo n.º 9
0
        private void PlayBattleCryAnimation(Hero heroActor)
        {
            if (HeroAttribute.BattleCrySpellState == BattleCrySpellState.ACTIVE && !isCasting)
            {
                mWarCryAnimationTimer = 0;
                PlayHeroWarCrySound();
                isCasting = true;
            }

            if (mWarCryAnimationTimer <= heroActor.BattleCryAnimationFrames * heroActor.BattleCryAnimationInterval && isCasting )
            {
                if (heroActor.SpriteState == SpriteState.IDLE_LEFT
                    || heroActor.SpriteState == SpriteState.MOVE_LEFT
                    || heroActor.SpriteState == SpriteState.ATTACK_LEFT)
                {
                    heroActor.SpriteState = SpriteState.BATTLECRY_LEFT;

                }
                else if (heroActor.SpriteState == SpriteState.IDLE_RIGHT
                    || heroActor.SpriteState == SpriteState.MOVE_RIGHT
                    || heroActor.SpriteState == SpriteState.ATTACK_RIGHT)
                {
                    heroActor.SpriteState = SpriteState.BATTLECRY_RIGHT;

                }

            }
            else if (mWarCryAnimationTimer >= (heroActor.BattleCryAnimationFrames * heroActor.BattleCryAnimationInterval) && isCasting)
            {
                isCasting = false;
            }
        }
Ejemplo n.º 10
0
 private void CheckVitalSigns(Hero heroActor)
 {
     if (0 >= heroActor.HeroAttribute.CurrentHealthPoints)
     {
         mDeathAnimationTimer += heroActor.gameTime.ElapsedGameTime.Milliseconds;
         PlayHeroDeathSound(heroActor);
         isDying = true;
         BeginDying(heroActor);
     }
     else
     {
         isDying = false;
     }
 }
Ejemplo n.º 11
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);

            }
        }
Ejemplo n.º 12
0
 public void PlayHeroDeathSound(Hero heroActor)
 {
     AudioController.HeroDeathSoundEffectInstance.Volume = mHeroDeathSoundVolume;
     AudioController.HeroDeathSoundEffectInstance.Play();
 }
Ejemplo n.º 13
0
        public void ChangeSpriteAnimation(Hero actor)
        {
            if (actor is Hero)
            {
                Hero heroActor = (Hero)actor;

                targetDirection = heroActor.GetTarget() - heroActor.Sprite.WorldPosition;
                heroActor.Direction = heroActor.Direction + targetDirection;

                if (heroActor.GetTarget().X - heroActor.Sprite.WorldPosition.X >= 0)
                {
                    heroActor.SpriteState = SpriteState.MOVE_RIGHT;
                }
                else if (heroActor.GetTarget().X - heroActor.Sprite.WorldPosition.X <= 0)
                {
                    heroActor.SpriteState = SpriteState.MOVE_LEFT;
                }
                if (heroActor.Sprite.WorldPosition.Y <= heroActor.GetTarget().Y + 10 &&
                heroActor.Sprite.WorldPosition.Y >= heroActor.GetTarget().Y - 10 &&
                heroActor.Sprite.WorldPosition.X <= heroActor.GetTarget().X + 10 &&
                heroActor.Sprite.WorldPosition.X >= heroActor.GetTarget().X - 10)
                {
                    if (heroActor.SpriteState == SpriteState.MOVE_LEFT)
                    {
                        heroActor.SpriteState = SpriteState.IDLE_LEFT;
                    }
                    else if (heroActor.SpriteState == SpriteState.MOVE_RIGHT)
                    {
                        heroActor.SpriteState = SpriteState.IDLE_RIGHT;
                    }
                    heroActor.HeroAttribute.Speed = 0;
                }
                if (attackingEnemy == true && targetEnemy.Sprite.SpriteFrame.Intersects(heroActor.Sprite.SpriteFrame))
                {
                    if (heroActor.SpriteState == SpriteState.MOVE_LEFT)
                    {
                        heroActor.SpriteState = SpriteState.ATTACK_LEFT;
                        heroActor.HeroAttribute.Speed = 0;
                    }
                    else if (heroActor.SpriteState == SpriteState.MOVE_RIGHT)
                    {
                        heroActor.SpriteState = SpriteState.ATTACK_RIGHT;
                        heroActor.HeroAttribute.Speed = 0;
                    }
                }
                else if (heroActor.SpriteState == SpriteState.MOVE_LEFT || heroActor.SpriteState == SpriteState.MOVE_RIGHT)
                {
                    //we are moving

                    heroActor.HeroAttribute.Speed = heroActor.HeroAttribute.DefaultSpeed;
                }

            }
        }
Ejemplo n.º 14
0
 public void BeginDying(Hero heroActor)
 {
     if (mDeathAnimationTimer <= heroActor.HeroDeathAnimationFrames * heroActor.HeroDeathAnimationInterval
       && (heroActor.SpriteState == SpriteState.ATTACK_LEFT || heroActor.SpriteState == SpriteState.MOVE_LEFT ||
       heroActor.SpriteState == SpriteState.IDLE_LEFT ))
       {
       heroActor.SpriteState = SpriteState.DEATH_LEFT;
       }
       else if (mDeathAnimationTimer <= heroActor.HeroDeathAnimationFrames * heroActor.HeroDeathAnimationInterval
       && (heroActor.SpriteState == SpriteState.ATTACK_RIGHT || heroActor.SpriteState == SpriteState.MOVE_RIGHT ||
       heroActor.SpriteState == SpriteState.IDLE_RIGHT))
       {
       heroActor.SpriteState = SpriteState.DEATH_RIGHT;
       }
       else if (mDeathAnimationTimer >= heroActor.HeroDeathAnimationFrames * heroActor.HeroDeathAnimationInterval)
       {
       heroActor.HasDied = true;
       }
 }