Beispiel #1
0
        public override bool TakeTurn(Level level)
        {
            turnCounter++;
            CheckElementDamage();

            if (!IsAggro)
            {
                Aggro(level);
            }

            if (IsAggro && !isFrozen)
            {
                if (AStar.getPathBetween(level, level.CharacterEntities.FindPosition(this), level.CharacterEntities.FindPosition(targets[0])) != null)
                {
                    Direction[] path = AStar.getPathBetween(level, level.CharacterEntities.FindPosition(this), level.CharacterEntities.FindPosition(targets[0]));
                    if (path.Length > range)
                    {
                        Move(path[0], level);
                    }
                    else if (turnCounter % 3 == 0)
                    {
                        Engine.Engine.AddVisualAttack(this, targets[0], Engine.Engine.GetTexture("Enemies/Attacks/TwoArrow"));
                        targets[0].TakeDamage(attacks[0]*2, this);
                        eSprite.Direction = GetCorrectDirection(path[0]);
                    }
                    else
                    {
                        Engine.Engine.AddVisualAttack(this, targets[0], Engine.Engine.GetTexture("Enemies/Attacks/Arrow"));
                        targets[0].TakeDamage(attacks[0], this);
                        eSprite.Direction = GetCorrectDirection(path[0]);
                    }
                }
            }
            return true;
        }
Beispiel #2
0
 public Minimap(Level level)
 {
     this.level = level;
     detected = new bool[level.GetWidth(), level.GetHeight()];
     active = new Rectangle();
     ViewWidth = 30;
     ViewHeight = 17;
 }
Beispiel #3
0
 public override void finishCastandDealDamage(int heroLevel, int heroDamage, Level mapLevel, HeroClasses.Hero hero)
 {
     damage = calculateDamage(heroLevel, heroDamage);
     cooldown = abilityCooldown;
     wasJustCast = true;
     finishCast(damage, mapLevel, hero);
     isFinished = false;
 }
Beispiel #4
0
 public override IntVec[] viewCastRange(Level level, IntVec start)
 {
     List<IntVec> lines = new List<IntVec>();
     lines.AddRange(AStar.getTargetLine(level, start, new IntVec(start.X-radius,start.Y), false));
     lines.AddRange(AStar.getTargetLine(level, start, new IntVec(start.X+radius,start.Y), false));
     lines.AddRange(AStar.getTargetLine(level, start, new IntVec(start.X,start.Y-radius), false));
     lines.AddRange(AStar.getTargetLine(level, start, new IntVec(start.X,start.Y+radius), false));
     radiusSquares = lines.ToArray();
     return radiusSquares;
 }
Beispiel #5
0
        public GeneratedLevel(int seed, int levels, int dungeonLevel = 1, int heroLevel = 1)
        {
            this.seed = seed;
            this.levels = levels;
            this.dungeonLevel = dungeonLevel;
            this.heroLevel = heroLevel;
            level = null;

            Thread thread = new Thread( run );
            thread.Start();
        }
Beispiel #6
0
        public override void Aggro(Level level)
        {
            GameCharacter hero = null;

            foreach(GameCharacter g in level.GetCharactersIsFriendly(true))
            {
                hero = g;
                break;
            }

            if(AStar.getPathBetween(level, level.CharacterEntities.FindPosition(this), level.CharacterEntities.FindPosition(hero)).Length < 4)
            {
                targets.Add(hero);
            }
        }
Beispiel #7
0
        public override bool TakeTurn(Level level)
        {
            CheckElementDamage();
            if (health <= 0)
            {
                Die();
            }
            else
            {
                if (IsAggro && !isFrozen)
                {
                    Direction[] path = AStar.getPathBetween(level, level.CharacterEntities.FindPosition(this), level.CharacterEntities.FindPosition(target));
                    int pathCost = AStar.getCost(path);

                    if (path.Length > 0)
                    {
                        if (pathCost == 1)
                        {
                            Audio.playSound("Mugging");
                            Engine.Engine.AddVisualAttack(target, "Hero/HammerSmash", .25f, 2.0f, .15f);
                            Attack(GetCorrectDirection(path[0]));
                        }
                        else
                        {
                            Move(path[0], level);
                        }
                    }
                    else
                    {
                        //IntVec[] possible = AStar.getPossiblePositionsFrom(level, level.CharacterEntities.FindPosition(this), moveSpeed);
                        //IntVec targetPos = null;
                        //foreach (IntVec pos in possible)
                        //{
                        //    if (targetPos == null)
                        //    {
                        //        targetPos = pos;
                        //    }
                        //    else if (AStar.getCost(AStar.getPathBetween(level, level.CharacterEntities.FindPosition(this), targetPos)) > AStar.getCost(AStar.getPathBetween(level, level.CharacterEntities.FindPosition(this), pos)))
                        //    {
                        //        targetPos = pos;
                        //    }
                        //}
                        //level.Move(this, targetPos, true);
                    }
                }
            }
            return true;
        }
Beispiel #8
0
 public override void finishCastandDealDamage(int heroLevel, int heroDamage, Level mapLevel, HeroClasses.Hero hero)
 {
     int damage = calculateDamage(heroLevel, heroDamage);
     cooldown = abilityCooldown;
     wasJustCast = true;
     for (int i = 0; i < castSquares.Length; i++)
     {
         GameCharacter enemy = (GameCharacter)mapLevel.CharacterEntities.FindEntity(castSquares[i]);
         if (enemy != null)
         {
             drawVisualEffect(hero, enemy);
             enemy.DealElementalDamage(Enums.ElementAttributes.Ice, 7);
         }
         castSquares[i] = new IntVec(0, 0);
     }
     isActuallyFilled = false;
 }
Beispiel #9
0
        public override bool TakeTurn(Level level)
        {
            turnCounter++;
            CheckElementDamage();

            if (IsAggro && !isFrozen)
            {
                if (AStar.getPathBetween(level, level.CharacterEntities.FindPosition(this), level.CharacterEntities.FindPosition(targets[0])) != null)
                {
                    bool pathIsClear = false;
                    Direction[] path = AStar.getPathBetween(level, level.CharacterEntities.FindPosition(this), level.CharacterEntities.FindPosition(targets[0]), ref pathIsClear);

                    if (pathIsClear)
                    {
                        if (path.Length > 2)
                        {
                            Move(path[0], level);
                        }

                        else if (turnCounter % 3 == 0)
                        {
                            foreach (GameCharacter g in targets)
                            {
                                Engine.Engine.AddVisualAttack(this, targets[0], Engine.Engine.GetTexture("Enemies/Attacks/Blood"));
                                Audio.playSound("bloodSpit");
                                g.TakeDamage(attacks[1], this);
                                health = (health * 4) / 5;
                                eSprite.Direction = GetCorrectDirection(path[0]);
                            }
                        }
                        else
                        {
                            Engine.Engine.AddVisualAttack(this, targets[0], Engine.Engine.GetTexture("Enemies/Attacks/Blood"));
                            Engine.Engine.AddVisualAttack(targets[0], this, Engine.Engine.GetTexture("Enemies/Attacks/Blood"));
                            Audio.playSound("bloodSpit");
                            targets[0].TakeDamage(attacks[0], this);
                            Heal(attacks[0] / 10);
                            eSprite.Direction = GetCorrectDirection(path[0]);
                        }
                    }
                }
            }

            return true;
        }
Beispiel #10
0
 public override void finishCastandDealDamage(int heroLevel, int heroDamage, Level mapLevel, HeroClasses.Hero hero)
 {
     damage = calculateDamage(heroLevel, heroDamage);
     cooldown = abilityCooldown;
     wasJustCast = true;
     isActuallyFilled = false;
     for (int i = 0; i < castSquares.Length; i++)
     {
         GameCharacter test = (GameCharacter)mapLevel.CharacterEntities.FindEntity(castSquares[i]);
         if (test != null && !test.isFriendly)
         {
             Audio.playSound("ArrowShot");
             Engine.Engine.AddVisualAttack(hero, test, "Enemies/Attacks/Arrow", 1.0f, 1.0f, 0);
             test.TakeDamage(damage, hero);
         }
         castSquares[i] = new IntVec(0, 0);
     }
 }
Beispiel #11
0
 public override void finishCastandDealDamage(int heroLevel, int heroDamage, Level mapLevel, HeroClasses.Hero hero)
 {
     int damage = calculateDamage(heroLevel, heroDamage);
     cooldown = abilityCooldown;
     wasJustCast = true;
     for (int i = 0; i < castSquares.Length; i++)
     {
         Audio.playSound("HammerSmash");
         Engine.Engine.AddVisualAttack(castSquares[i], "Hero/hammerSmash", .5f, 1.0f, .05f);
         GameCharacter enemy = (GameCharacter)mapLevel.CharacterEntities.FindEntity(castSquares[i]);
         if (enemy != null)
         {
             enemy.TakeDamage(damage, hero);
         }
         castSquares[i] = new IntVec(0, 0);
     }
     isActuallyFilled = false;
 }
Beispiel #12
0
 public override void finishCastandDealDamage(int heroLevel, int heroDamage, Level mapLevel, HeroClasses.Hero hero)
 {
     int damage = calculateDamage(heroLevel, heroDamage);
     cooldown = abilityCooldown;
     wasJustCast = true;
     willBeCast = false;
     for (int i = 0; i < castSquares.Length; i++)
     {
         drawVisualEffect(castSquares[i]);
         GameCharacter enemy = (GameCharacter)mapLevel.CharacterEntities.FindEntity(castSquares[i]);
         if (enemy != null)
         {
             enemy.TakeDamage(damage, hero);
         }
         castSquares[i] = new IntVec(0, 0);
     }
     turnCount--;
     isActuallyFilled = false;
 }
Beispiel #13
0
        public static void GenerateLevel()
        {
            //levelSeed = enginerand.Next();

            levelComplexity = currentDungeonLevel * 30 + 50;
            //enginerand.Next(currentDungeonLevel*50 + 20) + currentDungeonLevel* 30 + 50;
            if (nextLevel == null)
            {
                nextLevel = new GeneratedLevel(levelSeed++, levelComplexity, currentDungeonLevel);
                currentDungeonLevel = 1;
            }
            currentLevel = nextLevel.RetrieveLevel();
            charIndex = 0;
            nextLevel = new GeneratedLevel(levelSeed++, levelComplexity, currentDungeonLevel);
            Log("Level generated.");
            currentLevel.CharacterEntities.Add(hero, currentLevel.GetStartPoint());
            drawXP = hero.getExperience();
            currentDungeonLevel++;
        }
Beispiel #14
0
        public static void LoadGame(string filename)
        {
            IFormatter formatter = new BinaryFormatter();
            Stream stream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read);
            SaveGameData gd = (SaveGameData)formatter.Deserialize(stream);
            stream.Close();
            File.Delete(filename);
            //Create a new class of the hero just to set the static texture.

            GameCharacter temp;
            switch (gd.heroRole)
            {
                case Enums.Classes.Mage:
                    temp = new HeroClasses.Mage();
                    break;
                case Enums.Classes.Warrior:
                    temp = new HeroClasses.Warrior();
                    break;
                case Enums.Classes.Rogue:
                    temp = new HeroClasses.Rogue();
                    break;
                case Enums.Classes.Brawler:
                    temp = new HeroClasses.Brawler();
                    break;
                case Enums.Classes.Magus:
                    temp = new HeroClasses.Magus();
                    break;
                case Enums.Classes.Duelist:
                    temp = new HeroClasses.Duelist();
                    break;
                case Enums.Classes.Sentinel:
                    temp = new HeroClasses.Sentinel();
                    break;
                case Enums.Classes.Sorcerer:
                    temp = new HeroClasses.Sorcerer();
                    break;
                case Enums.Classes.Ranger:
                    temp = new HeroClasses.Ranger();
                    break;
                case Enums.Classes.Marksman:
                    temp = new HeroClasses.Marksman();
                    break;
                case Enums.Classes.Berserker:
                    temp = new HeroClasses.Berserker();
                    break;
                case Enums.Classes.Juggernaut:
                    temp = new HeroClasses.Juggernaut();
                    break;
                case Enums.Classes.SpellBlade:
                    temp = new HeroClasses.SpellBlade();
                    break;
                case Enums.Classes.SpellWeaver:
                    temp = new HeroClasses.Spellweaver();
                    break;
                case Enums.Classes.Assassin:
                    temp = new HeroClasses.Assassin();
                    break;
            }
            currentSaveSlot = gd.saveSlot;
            hero = gd.character;
            HeroClasses.Hero.level = gd.level;
            HeroClasses.Hero.jarBarAmount = gd.jarBarAmount;
            HeroClasses.Hero.MaxJarBarAmount = gd.jarBarMax;
            HeroClasses.Hero.heroRole = gd.heroRole;
            UpdateAbilities();
            GeneratedLevel nlevel = new GeneratedLevel(gd.seed, gd.levelComplexity, gd.dungeonLevel);
            currentLevel = nlevel.RetrieveLevel();
            currentLevel.CharacterEntities.Add(hero, currentLevel.GetStartPoint());
            showSaveSlotSelection = false;
            mainMenuOpen = false;
            gameStarted = true;
        }
Beispiel #15
0
 public override IntVec[] viewCastRange(Level level, IntVec start)
 {
     radiusSquares = AStar.getPossiblePositionsInBox(level, start, radius, radius, AStar.CharacterTargeting.PASS_THROUGH, true);
     return radiusSquares;
 }
Beispiel #16
0
 public override void finishCastandDealDamage(int heroLevel, int heroDamage, Level mapLevel, HeroClasses.Hero hero)
 {
     Audio.playSound("WhirlwindSlash");
     base.finishCastandDealDamage(heroLevel, heroDamage, mapLevel, hero);
 }
Beispiel #17
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);
            Random rand = new Random();
            currentLevel = LevelGenerator.generate(rand.Next(), 10);
            //Tile.tileset = Content.Load<Texture2D>("levelTileset");

            // TODO: use this.Content to load your game content here
        }
Beispiel #18
0
 protected abstract void finishCast(int damage, Level mapLevel, HeroClasses.Hero hero);
Beispiel #19
0
        /// <summary>
        /// Moves a single square based on a Direction
        /// </summary>
        /// <param name="d">Direction</param>
        /// <param name="level">The current level</param>
        public void Move(Direction d, Level level)
        {
            if (IsAggro)
            {
                level.Move(this, d);
            }

            d = GetCorrectDirection(d);

            eSprite.Direction = d;
        }
Beispiel #20
0
 public override bool Aggro(Level level)
 {
     throw new NotImplementedException();
 }
Beispiel #21
0
 public abstract IntVec[] viewCastRange(Level level, IntVec start);
Beispiel #22
0
 private void run()
 {
     Level temp = LevelGenerator.generate(seed, levels, dungeonLevel, heroLevel);
     level = temp;
 }
Beispiel #23
0
 public abstract void finishCastandDealDamage(int heroLevel, int heroDamage, Level mapLevel, Hero hero);
Beispiel #24
0
        public override bool Aggro(Level level)
        {
            bool targetFound = false;

            IEnumerable<GameCharacter> chars = level.GetCharactersIsFriendly(true);

            if (target != null)
            {
                bool tIsPossible = false;
                Direction[] tPath = AStar.getPathBetween(level, level.CharacterEntities.FindPosition(this), level.CharacterEntities.FindPosition(target), ref tIsPossible);
                if (tIsPossible)
                {
                    if (tPath.Length > deAggroRange)
                    {
                        target = null;
                    }
                    else
                    {
                        targetFound = true;
                    }
                }
                else
                {
                    target = null;
                }
            }

            foreach (GameCharacter g in chars)
            {
                GameCharacter hero = g;

                bool canSee = false;
                Direction[] nextPath;

                if (AStar.calculateHeuristic(level.CharacterEntities.FindPosition(this), level.CharacterEntities.FindPosition(g)) < aggroRange)
                {
                    nextPath = AStar.getPathBetween(level, level.CharacterEntities.FindPosition(this), level.CharacterEntities.FindPosition(hero), ref canSee);
                    if (canSee && target == null && nextPath.Length < aggroRange)
                    {
                        target = hero;
                        targetFound = true;
                    }
                    else if (canSee && target != null && nextPath.Length < AStar.getPathBetween(level, level.CharacterEntities.FindPosition(this), level.CharacterEntities.FindPosition(target)).Length)
                    {
                        target = hero;
                        targetFound = true;
                    }
                }

                break;
            }

            if (targetFound)
            {
                foreach (Enemy e in GetAllEnemies())
                {
                    if (AStar.calculateHeuristic(level.CharacterEntities.FindPosition(this), level.CharacterEntities.FindPosition(e)) < 3)
                    {
                        e.ForceAggro(target);
                    }
                }
            }

            return targetFound;
        }
Beispiel #25
0
 public abstract bool TakeTurn(Level level);
Beispiel #26
0
        public override bool TakeTurn(Level level)
        {
            CheckElementDamage();
            if (health <= 0)
            {
                Die();
            }
            else
            {
                if (Aggro(level) && !isFrozen)
                {
                    Direction[] path = AStar.getPathBetween(level, level.CharacterEntities.FindPosition(this), level.CharacterEntities.FindPosition(target));
                    int pathCost = AStar.getCost(path);

                    if (path != null)
                    {
                        if (pathCost <= range)
                        {
                            Audio.playSound("ArrowShot");
                            Engine.Engine.AddVisualAttack(this, target, Engine.Engine.GetTexture("Enemies/Attacks/Arrow"));
                            Attack(GetCorrectDirection(path[0]));
                            //Engine.Engine.Log("Was in range: " + level.CharacterEntities.FindPosition(this) + " to " + level.CharacterEntities.FindPosition(target) + " " + pathCost + " " + String.Join<Direction>(", ", path));
                        }
                        else
                        {
                            Move(path[0], level);
                        }
                    }
                    else
                    {
                        //IntVec[] possible = AStar.getPossiblePositionsFrom(level, level.CharacterEntities.FindPosition(this), moveSpeed);
                        //IntVec targetPos = null;
                        //foreach (IntVec pos in possible)
                        //{
                        //    if (targetPos == null)
                        //    {
                        //        targetPos = pos;
                        //    }
                        //    else if (AStar.getCost(AStar.getPathBetween(level, level.CharacterEntities.FindPosition(this), targetPos)) > AStar.getCost(AStar.getPathBetween(level, level.CharacterEntities.FindPosition(this), pos)))
                        //    {
                        //        targetPos = pos;
                        //    }
                        //}
                        //level.Move(this, targetPos, true);
                    }
                }
            }
            return true;
        }
Beispiel #27
0
 //Direction attackPath;
 public override bool TakeTurn(Level level)
 {
     CheckElementDamage();
     if (health <= 0)
     {
         Die();
     }
     else
     {
         if (Aggro(level) && !isFrozen)
         {
             Audio.playSound("enimeFireball");
             Engine.Engine.AddVisualAttack(this, target, Engine.Engine.GetTexture("Enemies/Attacks/FireBall"));
             Attack(Direction.UP, false);
         }
     }
     return true;
 }
Beispiel #28
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            KeyboardController.Update();

            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            if (KeyboardController.IsPressed( Keys.Space ) )
            {
                Random rand = new Random();
                seed = rand.Next();
                levels = 10;
                currentLevel = LevelGenerator.generate(seed,levels);
            }

            if (KeyboardController.IsPressed(Keys.RightControl))
            {
                levels+=100;
                currentLevel = LevelGenerator.generate(seed, levels);
            }

            currentLevel.testUpdate();

            // TODO: Add your update logic here

            base.Update(gameTime);
        }
Beispiel #29
0
 /// <summary>
 /// Determines whether or not this enemy is able to aggro any targets
 /// </summary>
 /// <param name="level">The current level</param>
 /// <returns>whether or not this enemy has found a target</returns>
 public abstract bool Aggro(Level level);
Beispiel #30
0
 public override IntVec[] viewCastRange(Level level, IntVec start)
 {
     IntVec[] test = AStar.getPossiblePositionsFrom(level, start, radius, AStar.CharacterTargeting.TARGET_FIRST, true);
     return test;
 }