Beispiel #1
0
        private void InitSpells()
        {
            //testing function
            Action <List <Sprite> > spell = (sprites) =>
            {
                var fireballAnimation = new Dictionary <string, Animation>()
                {
                    { "fireball", new Animation(State.Content.Load <Texture2D>("Projectiles/fireball"), 1, 6)
                      {
                          FrameSpeed = 0.05f
                      } }
                };
                var animation = new AnimationSprite(fireballAnimation, GlobalOrigin);
                animation.Position -= animation.Origin * animation.Scale;
                sprites.Add(animation);
            };


            Func <bool> canExecute = () =>
            {
                return(true);
            };

            Spellbar.Add(SpellDepository.TrippleFireball(this));
            Spellbar.Add(new Spell(spell, 15, State.Content.Load <Texture2D>("Projectiles/projectile"), 1));
            Spellbar.Add(new Spell(spell, 20, State.Content.Load <Texture2D>("Projectiles/fireball_icon"), 1));
            Spellbar.Add(new Spell(spell, 25, State.Content.Load <Texture2D>("Projectiles/projectile"), 1));
        }
Beispiel #2
0
        private void CastSpells(List <Sprite> sprites)
        {
            if (currentKey.IsKeyDown(input.ShootUp) && currentKey.IsKeyUp(input.ShootDown) && currentKey.IsKeyUp(input.ShootLeft) && currentKey.IsKeyUp(input.ShootRight))
            {
                AttackDirection.X = 0;
                AttackDirection.Y = -1;
                CastAutoAttack(sprites);
                animationManager.Animation.SetRow(3);
            }
            if (currentKey.IsKeyDown(input.ShootDown) && currentKey.IsKeyUp(input.ShootUp) && currentKey.IsKeyUp(input.ShootLeft) && currentKey.IsKeyUp(input.ShootRight))
            {
                AttackDirection.X = 0;
                AttackDirection.Y = 1;
                CastAutoAttack(sprites);
                animationManager.Animation.SetRow(0);
            }
            if (currentKey.IsKeyDown(input.ShootRight) && currentKey.IsKeyUp(input.ShootUp) && currentKey.IsKeyUp(input.ShootLeft) && currentKey.IsKeyUp(input.ShootDown))
            {
                AttackDirection.X = 1;
                AttackDirection.Y = 0;
                CastAutoAttack(sprites);
                animationManager.Animation.SetRow(2);
            }
            if (currentKey.IsKeyDown(input.ShootLeft) && currentKey.IsKeyUp(input.ShootUp) && currentKey.IsKeyUp(input.ShootDown) && currentKey.IsKeyUp(input.ShootRight))
            {
                AttackDirection.X = -1;
                AttackDirection.Y = 0;
                CastAutoAttack(sprites);
                animationManager.Animation.SetRow(1);
            }

            if (currentKey.IsKeyDown(input.Spell1) && !previousKey.IsKeyDown(input.Spell1))
            {
                Spellbar.GetSpell(0)?.Cast(sprites);
            }
            if (currentKey.IsKeyDown(input.Spell2) && !previousKey.IsKeyDown(input.Spell2))
            {
                Spellbar.GetSpell(1)?.Cast(sprites);
            }
            if (currentKey.IsKeyDown(input.Spell3) && !previousKey.IsKeyDown(input.Spell3))
            {
                Spellbar.GetSpell(2)?.Cast(sprites);
            }
            if (currentKey.IsKeyDown(input.Spell4) && !previousKey.IsKeyDown(input.Spell4))
            {
                Spellbar.GetSpell(3)?.Cast(sprites);
            }
            if (currentKey.IsKeyDown(input.Spell5) && !previousKey.IsKeyDown(input.Spell5))
            {
                Spellbar.GetSpell(4)?.Cast(sprites);
            }
            if (currentKey.IsKeyDown(input.Spell6) && !previousKey.IsKeyDown(input.Spell6))
            {
                Spellbar.GetSpell(5)?.Cast(sprites);
            }
        }
Beispiel #3
0
        public Player(Dictionary <string, Animation> animations, Vector2 position, Identity identity) : base(animations, position)
        {
            currentKey      = Keyboard.GetState();
            previousKey     = Keyboard.GetState();
            velocity        = new Vector2(0f);
            input           = new Input();
            Scale           = 1.2f;
            baseAttackSpeed = 1f;
            AttackDirection = new Vector2(0, -1);
            Inventory       = new Inventory();
            Spellbar        = new Spellbar();
            Faction         = Faction.FRIENDLY;
            level           = 1;
            XP = 0;
            CharacterPoints = 5;
            nextLevelXP     = 100;
            this.Identity   = identity;

            InitAutoattack();
            InitSpells();
        }
Beispiel #4
0
        public void Draw(SpriteBatch spriteBatch)
        {
            foreach (List <Tile> row in Tiles)
            {
                foreach (Tile tile in row)
                {
                    tile.Draw(spriteBatch, tile.PosX * Tile.diameter, tile.PosY * Tile.diameter);
                }
            }

            EndTurnBox.Draw(spriteBatch);

            if (HighlightedTile != null)
            {
                spriteBatch.Draw(
                    Textures.TileHighlight,
                    new Vector2((HighlightedTile.PosX * Tile.diameter) + HighlightBorderWidth, (HighlightedTile.PosY * Tile.diameter) + HighlightBorderWidth),
                    Color.White);
            }

            int offset = (Tile.diameter / 2) - (Hero.diameter / 2);

            foreach (Hero hero in Heroes)
            {
                hero.Draw(spriteBatch, (hero.PosX * Tile.diameter) + offset, (hero.PosY * Tile.diameter) + offset);
            }

            if (SelectedHero != null)
            {
                spriteBatch.Draw(
                    Textures.SelectedHero,
                    new Vector2((SelectedHero.PosX * Tile.diameter) + offset - HighlightBorderWidth, (SelectedHero.PosY * Tile.diameter) + offset - HighlightBorderWidth),
                    Color.White);
                StatsBox.DrawHeroStats(spriteBatch, SelectedHero, true);
            }

            if (HighlightedHero != null && HighlightedHero != SelectedHero)
            {
                StatsBox.DrawHeroStats(spriteBatch, HighlightedHero, false);
            }

            if (SelectedHero != null)
            {
                Spellbar.Draw(spriteBatch, SelectedHero);
            }

            if (HighlightedAbility != null)
            {
                StatsBox.DrawAbilityStats(spriteBatch, HighlightedAbility);
            }

            if (SelectedAbility != null && HighlightedTile != null)
            {
                Texture2D filter;
                bool      validTarget = SelectedAbility.ValidateTarget(HighlightedTile);

                if (validTarget)
                {
                    filter = Textures.GreenFilter;
                }
                else
                {
                    filter = Textures.RedFilter;
                }

                List <Tile> affectedTiles = SelectedAbility.GetAffectedTiles(HighlightedTile);
                foreach (Tile tile in affectedTiles)
                {
                    int posX = (tile.PosX * Tile.diameter) + HighlightBorderWidth;
                    int posY = (tile.PosY * Tile.diameter) + HighlightBorderWidth;

                    spriteBatch.Draw(filter, new Vector2(posX, posY), new Color(Color.White, 0.1f));
                }
            }

            #endregion
        }