예제 #1
0
 public void UpdateConsoleSize(Arena arena)
 {
     Console.WindowWidth = arena.Width + StatsWidth;
     Console.WindowHeight = arena.Height + LogSize;
     Console.BufferWidth = arena.Width + StatsWidth;
     Console.BufferHeight = arena.Height + LogSize;
 }
예제 #2
0
        internal override void Do(Arena arena)
        {
            int x = Creature.X;
            int y = Creature.Y;

            if (direction == Direction.Up)
            {
                y--;
            }

            if (direction == Direction.Down)
            {
                y++;
            }

            if (direction == Direction.Left)
            {
                x--;
            }

            if (direction == Direction.Right)
            {
                x++;
            }

            if (x >= 0 && x < arena.Width && y >= 0 && y < arena.Height)
            {
                Creature.X = x;
                Creature.Y = y;

                PickUpItems(arena);
            }
        }
예제 #3
0
        public void Draw(Arena arena)
        {
            Console.Clear();

            DrawItems(arena.HealthPacks, 'H');
            DrawItems(arena.Weapons, 'W');
            DrawItems(arena.Armors, 'A');
            DrawCreatures(arena.Creatures);
            DrawLog(arena.Log);
            DrawStats(arena.Creatures, arena);
        }
예제 #4
0
        private void PickUpItems(Arena arena)
        {
            var item = (from i in arena.Items
                        where i.X == Creature.X && i.Y == Creature.Y
                        select i).FirstOrDefault();

            if (item != null)
            {
                //string message;

                //switch (item.Type)
                //{
                //    case ItemType.HealthPack:
                //        message = "{0} picks up a health pack and receives {1} HP.";
                //        Creature.Health += item.Strength;
                //        break;

                //    case ItemType.Weapon:
                //        message = "{0} picks up a weapon with an attack of {1}.";
                //        Creature.Attack = item.Strength;
                //        break;

                //    case ItemType.Armor:
                //        message = "{0} picks up an armor with a defense of {1}.";
                //        Creature.Defense = item.Strength;
                //        break;
                //    default:
                //        message = "{0} picks up an unknown item with strength {1}. Debug time!";
                //        throw new Exception();
                //}

                //message = String.Format(message, Creature.Name, item.Strength);
                //arena.Log.Add(message);

                bool isPickedUp = item.PickUp(Creature);

                if (isPickedUp)
                {
                    arena.InternalItems.Remove(item);
                }
            }
        }
예제 #5
0
        internal override void Do(Arena arena)
        {
            string message;

            if (Creature.Attack <= 0)
            {
                message = String.Format(
                    "{0} attacks {1} without a weapon. Nothing happens.",
                    Creature.Name,
                    enemy.Name);
            }
            else
            {
                if (Creature.X == enemy.X && Creature.Y == enemy.Y)
                {
                    int damage = Math.Max(0, Creature.Attack - enemy.Defense);
                    enemy.Health -= damage;
                    enemy.Defense = 0;

                    message = String.Format(
                        "{0} attacks {1} and does {2} damage.",
                        Creature.Name,
                        enemy.Name,
                        damage,
                        enemy.Health);
                }
                else
                {
                    message = String.Format(
                        "{0} tries to hit {1}, but misses.",
                        Creature.Name,
                        enemy.Name);
                }

                Creature.Attack = 0;
            }

            arena.Log.Add(message);
        }
예제 #6
0
        private void DrawStats(IEnumerable<Creature> creatures, Arena arena)
        {
            int x = arena.Width + 2;
            int y = 0;
            int color = 0;

            foreach (var creature in creatures)
            {
                Console.ForegroundColor = colors[color];
                color = (color + 1) % colors.Length;

                Console.SetCursorPosition(x, y);
                Console.WriteLine(creature.Name);

                y++;
                Console.SetCursorPosition(x, y);
                Console.WriteLine(String.Format(
                    "HP: {0} - Att: {1} - Def: {2}",
                    creature.Health,
                    creature.Attack,
                    creature.Defense));
                y += 2;
            }

            Console.ResetColor();
        }
예제 #7
0
 internal override void Do(Arena arena)
 {
 }
예제 #8
0
 internal CreatureFinder(Arena arena)
 {
     this.arena = arena;
 }
예제 #9
0
 internal abstract void Do(Arena arena);
예제 #10
0
 internal ItemFinder(Arena arena)
 {
     this.arena = arena;
 }