Exemple #1
0
        public BaseField AddField(Direction location, BaseField field, bool updateRowColumn = true)
        {
            _fieldDictionary[location] = field;

            if (updateRowColumn)
            {
                field.Row = Row;
                field.Column = Column;

                switch (location)
                {
                    case Direction.Up:
                        field.Row = Row + 1;
                        break;
                    case Direction.Down:
                        field.Row = Row - 1;
                        break;
                    case Direction.Left:
                        field.Column = Column - 1;
                        break;
                    case Direction.Right:
                        field.Column = Column + 1;
                        break;
                }
            }

            if (field.GetField(location.Opposite()) == null)
                field.AddField(location.Opposite(), this, false);
            
            return this;
        }
Exemple #2
0
        BaseField CreateSeventhRow(BaseField sixth)
        {
            sixth.AddField(Direction.Up, new CityField());

            var seventh = sixth.GetField(Direction.Up);

            seventh.AddField(Direction.Right, 8, typeof(CityField));

            var b1 = seventh.GetField(Direction.Right, 4) as CityField;
            AddBaricade(b1);            

            seventh.GetField(Direction.Right, 8)
                   .AddField(Direction.Down, sixth.GetField(Direction.Right, 8));

            return seventh;
        }
Exemple #3
0
        public static Colors Convert(BaseField field)
        {
            if(Game.Current.IsBaricadeMoveModeActive &&
                field == Game.Current.BaricadeCursor)
            {
                return new Colors(ConsoleColor.Black, ConsoleColor.Cyan);
            }

            if(field is ContainerField)
            {
                var container = (ContainerField)field;

                
                Movable movable = container.TempChild;                

                if (movable == null)
                    movable = container.Child;

                if (movable != null)
                {
                    if(movable is Core.Movables.Baricade)
                    {
                        return Colors.WithDefaultBackground(ConsoleColor.White);
                    }
                    return GetPawnColor(movable.Owner.Number);
                }
                    
            }

            if(field is SpawnField)
            {
                var spawnField = (SpawnField)field;

                int number = spawnField.Player.Number;
                return GetPawnColor(number);
            }

            if(field is RestingField)
            {
                return Colors.WithDefaultBackground(ConsoleColor.DarkGray);
            }

            return Colors.Default;
        }
Exemple #4
0
        BaseField CreateSixthRow(BaseField fifth)
        {
            var middle = fifth.GetField(Direction.Right, 3)
                 .AddField(Direction.Up, new CityField())
                 .GetField(Direction.Up);

            var mid = middle as CityField;
            AddBaricade(mid);

            middle.AddField(Direction.Left, new RestingField());
            middle.GetField(Direction.Left)
                  .AddField(Direction.Left, 3, typeof(CityField));

            middle.AddField(Direction.Right, new RestingField());
            middle.GetField(Direction.Right)
                  .AddField(Direction.Right, 3, typeof(CityField));

            var sixth = middle.GetField(Direction.Left, 4);

            return sixth;
        }
Exemple #5
0
        public static string Convert(BaseField field)
        {
            var container = field as ContainerField;
            if(container != null)
            {
                Movable child = container.TempChild;

                if (Game.Current.IsBaricadeMoveModeActive)
                {
                    if (Game.Current.BaricadeCursor == field)
                        return MovableToString.Convert(child);
                }

                if (child == null)
                    child = container.Child;

                if (child != null)
                    return MovableToString.Convert(child);
            }

            if (field is FinishField)
                return "*";

            if (field is SpawnField)
            {
                var sf = field as SpawnField;
                return $"{sf.Children.Count}";
            }

            if (field is RestingField)
                return "R";

            if (field is ForestField)
                return "F";

            return "x";
        }
Exemple #6
0
        void CreateSpawnPoints(Game game, BaseField first)
        {
            var sp1 = first.GetField(Direction.Right)
                 .AddField(Direction.Down, new SpawnField(game.Players.ElementAt(0)))
                 .GetField(Direction.Down);

            var sp2 = first.GetField(Direction.Right, 3)
               .AddField(Direction.Down, new SpawnField(game.Players.ElementAt(1)))
               .GetField(Direction.Down);

            var sp3 = first.GetField(Direction.Right, 7)
               .AddField(Direction.Down, new SpawnField(game.Players.ElementAt(2)))
               .GetField(Direction.Down);

            var sp4 = first.GetField(Direction.Right, 9)
               .AddField(Direction.Down, new SpawnField(game.Players.ElementAt(3)))
               .GetField(Direction.Down);

            _spawnPoints.Add(game.Players.ElementAt(0), sp1 as CollectionField);
            _spawnPoints.Add(game.Players.ElementAt(1), sp2 as CollectionField);
            _spawnPoints.Add(game.Players.ElementAt(2), sp3 as CollectionField);
            _spawnPoints.Add(game.Players.ElementAt(3), sp4 as CollectionField);
        }
Exemple #7
0
        BaseField CreateSecondRow(BaseField first)
        {
            var second = first.AddField(Direction.Up, new RestingField())
                                        .GetField(Direction.Up);

            second.AddField(Direction.Right);

            second.GetField(Direction.Right)
                  .AddField(Direction.Right, new RestingField());

            second.GetField(Direction.Right, 2)
                  .AddField(Direction.Right, 2);

            second.GetField(Direction.Right, 4)
                  .AddField(Direction.Right, new RestingField());

            second.GetField(Direction.Right, 5)
                  .AddField(Direction.Right, 2);

            second.GetField(Direction.Right, 7)
                  .AddField(Direction.Right, new RestingField());

            second.GetField(Direction.Right, 8)
                  .AddField(Direction.Right);

            second.GetField(Direction.Right, 9)
                  .AddField(Direction.Right, new RestingField());

            // Link First & Second
            first.GetField(Direction.Right, 2)
               .AddField(Direction.Up, second.GetField(Direction.Right, 2));

            first.GetField(Direction.Right, 5)
               .AddField(Direction.Up, second.GetField(Direction.Right, 5));

            first.GetField(Direction.Right, 8)
               .AddField(Direction.Up, second.GetField(Direction.Right, 8));

            first.GetField(Direction.Right, 10)
               .AddField(Direction.Up, second.GetField(Direction.Right, 10));

            return second;
        }
Exemple #8
0
        BaseField CreateThridRow(BaseField second)
        {
            var third = second.GetField(Direction.Right, 3)
                            .AddField(Direction.Up)
                            .GetField(Direction.Up);

            third.AddField(Direction.Right);

            third.GetField(Direction.Right)
                 .AddField(Direction.Right, new RestingField());

            third.GetField(Direction.Right, 2)
                 .AddField(Direction.Right, 2);

            _forestField = new ForestField();

            third.GetField(Direction.Right, 2)
                 .AddField(Direction.Down, _forestField);


            // Link Second & Third
            second.GetField(Direction.Right, 7)
                  .AddField(Direction.Up, third.GetField(Direction.Right, 4));

            return third;
        }
Exemple #9
0
        BaseField CreateFourthRow(BaseField third)
        {
            var middleOfFourth = third.GetField(Direction.Right, 2)
                  .AddField(Direction.Up)
                  .GetField(Direction.Up);

            middleOfFourth.AddField(Direction.Left, 2);
            middleOfFourth.AddField(Direction.Right, 2);

            middleOfFourth.GetField(Direction.Left, 2)
                  .AddField(Direction.Left, new RestingField());

            middleOfFourth.GetField(Direction.Right, 2)
                  .AddField(Direction.Right, new RestingField());

            var cf1 = middleOfFourth.GetField(Direction.Right, 2) as ContainerField;
            AddBaricade(cf1);

            var cf2 = middleOfFourth.GetField(Direction.Left, 2) as ContainerField;
            AddBaricade(cf2);

            //var middleOfThird = third.GetField(Direction.Right, 2);

            //third.GetField(Direction.Right, 2)
            //     .AddField(Direction.Up, middle);

            var forth = middleOfFourth.GetField(Direction.Left, 3);
            return forth;

        }
Exemple #10
0
        BaseField CreateFifthRow(BaseField fourth)
        {
            var fifth = fourth.AddField(Direction.Up, new CityField())
                  .GetField(Direction.Up);

            fifth.AddField(Direction.Right, 6, typeof(CityField));

            var b1 = fifth.GetField(Direction.Right, 2) as CityField;
            AddBaricade(b1);

            var b2 = fifth.GetField(Direction.Right, 4) as CityField;
            AddBaricade(b2);

            fourth.GetField(Direction.Right, 6)
                  .AddField(Direction.Up, fifth.GetField(Direction.Right, 6));

            return fifth;
        }
Exemple #11
0
 public void ShowBaricade(BaseField baricadeCursor)
 {
     Console.ForegroundColor = ConsoleColor.Gray;
     Console.WriteLine("Herplaats de Baricade");
     Console.Write($"Staat op {baricadeCursor}");
 }
Exemple #12
0
        void Show(BaseField obj)
        {
            Colors colors = FieldToColors.Convert(obj);
            Console.BackgroundColor = colors.Background;
            Console.ForegroundColor = colors.Foreground;

            Console.Write(FieldToString.Convert(obj));

            Console.BackgroundColor = Colors.DefaultBackground;
            Console.ForegroundColor = Colors.DefaultForeground;
        }
Exemple #13
0
 public void SetBaricadeCursor(BaseField field)
 {
     BaricadeCursor = field;
 }