Beispiel #1
0
 private void BindStatsBoxes(Formation f)
 {
     foreach (var pos in AbsolutePosition.All)
     {
         var relpos = pos.RelativeTo(f.Facing);
         if (f.CreaturePositions.ContainsKey(relpos))
         {
             FindStatsBox(pos).Creature = f.CreaturePositions[relpos];
         }
         else
         {
             FindStatsBox(pos).Creature = null;
         }
     }
 }
Beispiel #2
0
        private void PlaceHeroes()
        {
            Heroes = new Formation();
            Heroes.CreaturePositions[RelativePosition.Front]     = Creature.Warrior;
            Heroes.CreaturePositions[RelativePosition.RearLeft]  = Creature.Mage;
            Heroes.CreaturePositions[RelativePosition.RearRight] = Creature.Priest;

            var lowDanger = Tiles.Cast <Tile>().Where(t => t.DangerLevel == 1);

            lowDanger.Pick().Formation = Heroes;
            bool foundHeroes           = false;

            for (var x = 0; x < Width; x++)
            {
                for (var y = 0; y < Height; y++)
                {
                    if (Tiles[x, y].Formation == Heroes)
                    {
                        HeroX       = x;
                        HeroY       = y;
                        foundHeroes = true;
                        break;
                    }
                }
                if (foundHeroes)
                {
                    break;
                }
            }

            for (var x = 0; x < Width; x++)
            {
                for (var y = 0; y < Height; y++)
                {
                    if (TestLineOfSight(HeroX, HeroY, x, y))
                    {
                        Tiles[x, y].HasBeenSeen = true;
                    }
                }
            }
        }
Beispiel #3
0
        public Color GetColor(AbsolutePosition pos)
        {
            if (Formation == null)
            {
                if (Items.ContainsKey(pos))
                {
                    return(Items[pos].Color);
                }
                return(Terrain.Color);
            }
            var creature = Formation.GetCreature(pos);

            if (creature == null)
            {
                if (Items.ContainsKey(pos))
                {
                    return(Items[pos].Color);
                }
                return(Terrain.Color);
            }
            return(creature.Color);
        }
Beispiel #4
0
        public char GetSymbol(AbsolutePosition pos)
        {
            if (Formation == null)
            {
                if (Items.ContainsKey(pos))
                {
                    return(Items[pos].Symbol);
                }
                return(Terrain.Symbol);
            }
            var creature = Formation.GetCreature(pos);

            if (creature == null)
            {
                if (Items.ContainsKey(pos))
                {
                    return(Items[pos].Symbol);
                }
                return(Terrain.Symbol);
            }
            return(creature.Symbol);
        }
Beispiel #5
0
        public static Formation SpawnMonsters(int dangerLevel)
        {
            var f = new Formation();

            // final boss is special
            if (dangerLevel == Map.MaxDangerLevel)
            {
                foreach (var pos in RelativePosition.All)
                {
                    if (pos == RelativePosition.Center)
                    {
                        f.CreaturePositions[pos] = MonsterTemplate.ChaosLord.Archetype.Clone();
                    }
                    else
                    {
                        f.CreaturePositions[pos] = MonsterTemplate.ChaosDisciple.Archetype.Clone();
                    }
                }
            }
            else
            {
                do
                {
                    foreach (var pos in RelativePosition.All)
                    {
                        if (Dice.Range(0, 2) == 0)
                        {
                            f.CreaturePositions[pos] = MonsterTemplate.Spawn(dangerLevel);
                        }
                    }
                } while (!f.CreaturePositions.Any());                 // don't allow zero creature formations!
            }

            f.Facing = Direction.All.Pick();
            return(f);
        }
Beispiel #6
0
        public void Move(Formation f, Direction dir)
        {
            // find formation
            bool found = false;
            int  fx = -99, fy = -99;

            for (var x = 0; x < Width; x++)
            {
                for (var y = 0; y < Height; y++)
                {
                    if (Tiles[x, y].Formation == f)
                    {
                        fx    = x;
                        fy    = y;
                        found = true;
                        break;
                    }
                }
                if (found)
                {
                    break;
                }
            }

            if (CoordsInBounds(fx + dir.DeltaX, fy + dir.DeltaY))
            {
                var targetTile = Tiles[fx + dir.DeltaX, fy + dir.DeltaY];
                if (targetTile.Formation == null)
                {
                    // move
                    Tiles[fx, fy].Formation = null;
                    targetTile.Formation    = f;
                    if (f == Heroes)
                    {
                        HeroX = fx + dir.DeltaX;
                        HeroY = fy + dir.DeltaY;

                        // pick up items
                        foreach (var item in targetTile.Items.Values)
                        {
                            item.Found(Heroes);
                        }
                        targetTile.Items.Clear();

                        // update fog of war
                        for (var x = 0; x < Width; x++)
                        {
                            for (var y = 0; y < Height; y++)
                            {
                                if (TestLineOfSight(HeroX, HeroY, x, y))
                                {
                                    Tiles[x, y].HasBeenSeen = true;
                                }
                            }
                        }
                    }
                }
                else
                {
                    // fight
                    Fight(Tiles[fx, fy], targetTile);
                }

                // spend time
                f.Act(Tiles[fx + dir.DeltaX, fy + dir.DeltaY].Terrain.MovementCost);
            }
        }
Beispiel #7
0
 /// <summary>
 /// What happens when this item is found by the heroes?
 /// </summary>
 public abstract void Found(Formation heroes);
Beispiel #8
0
 public override void Found(Formation heroes)
 {
     Log.Append("The party finds a " + Name + ".", Color.Cyan);
     Action(heroes);
 }
Beispiel #9
0
 public override void Found(Formation heroes)
 {
     HasBeenFound = true;
     Log.Append("The party finds a " + Name + ".", Color.Cyan);
 }