Esempio n. 1
0
        private void GenerateFields()
        {
            WaterField TempWaterField2 = null;

            FieldArray[0, 0] = new EndWaterField {
                Game = this
            };
            for (int i = 1; i < 12; i++)
            {
                WaterField TempWaterField = new WaterField {
                    Game = this
                };
                FieldArray[i, 0] = TempWaterField;
                if (i == 9)
                {
                    TempWaterField2 = TempWaterField;
                }
                if (i == 11)
                {
                    TempWaterField.MoveAble = this.Ship;
                    Ship.CurrentField       = TempWaterField;
                    ShipField = TempWaterField;
                }
            }
            FieldArray[0, 1] = new EndField();
            for (int i = 1; i < 12; i++)
            {
                FieldArray[i, 1] = new Field();
                if (i == 9)
                {
                    Quay TempQuay = new Quay {
                        Game = this
                    };
                    FieldArray[i, 1]           = TempQuay;
                    TempWaterField2.LowerField = TempQuay;
                }
            }
            FieldArray[11, 2] = new Field();
            Warehouse TempHouse = new Warehouse {
                Game = this
            };

            FieldArray[0, 3] = TempHouse;
            Warehouses.Add(TempHouse);
            for (int i = 1; i < 12; i++)
            {
                if (i != 4 && i != 10)
                {
                    FieldArray[i, 3] = new Field();
                }
            }
            FieldArray[3, 5]  = new Field();
            FieldArray[4, 4]  = new Field();
            FieldArray[10, 4] = new Field();
            FieldArray[11, 4] = new Field();
            TempHouse         = new Warehouse {
                Game = this
            };
            FieldArray[0, 5] = TempHouse;
            Warehouses.Add(TempHouse);
            FieldArray[1, 5] = new Field();
            FieldArray[2, 5] = new Field();
            FieldArray[5, 5] = new Field();
            FieldArray[9, 5] = new Field();
            FieldArray[6, 6] = new Field();
            FieldArray[8, 6] = new Field();
            FieldArray[7, 7] = new Field();
            TempHouse        = new Warehouse {
                Game = this
            };
            FieldArray[0, 8] = TempHouse;
            Warehouses.Add(TempHouse);
            for (int i = 1; i < 12; i++)
            {
                if (i != 7)
                {
                    FieldArray[i, 8] = new Field();
                }
            }
            FieldArray[1, 9] = new ManeuveringField();
            FieldArray[0, 9] = new EndManeuveringField();
            for (int i = 2; i < 12; i++)
            {
                FieldArray[i, 9] = new ManeuveringField();
                if (i == 9 || i == 10 || i == 11)
                {
                    FieldArray[i, 9] = new Field();
                }
            }
            Switch TempSwitch = new Switch {
                UpperField = FieldArray[5, 3], LowerField = FieldArray[5, 5], MayChangeNextField = true
            };

            FieldArray[5, 4] = TempSwitch;
            Switches.Add(TempSwitch);
            TempSwitch = new Switch {
                UpperField = FieldArray[9, 3], LowerField = FieldArray[9, 5]
            };
            FieldArray[9, 4] = TempSwitch;
            Switches.Add(TempSwitch);
            TempSwitch = new Switch {
                UpperField = FieldArray[8, 6], LowerField = FieldArray[8, 8], MayChangeNextField = true
            };
            FieldArray[8, 7] = TempSwitch;
            Switches.Add(TempSwitch);
            TempSwitch = new Switch {
                UpperField = FieldArray[6, 6], LowerField = FieldArray[6, 8]
            };
            FieldArray[6, 7] = TempSwitch;
            Switches.Add(TempSwitch);
            TempSwitch = new Switch {
                UpperField = FieldArray[3, 3], LowerField = FieldArray[3, 5]
            };
            FieldArray[3, 4] = TempSwitch;
            Switches.Add(TempSwitch);
        }
Esempio n. 2
0
        private void generateField()
        {
            this._gameField = new LinkedList <Field>();


            _filePath  = Directory.GetParent(Directory.GetParent(_filePath).FullName).FullName;
            _filePath += @"\Level\map1.txt";


            string[] lines = System.IO.File.ReadAllLines(_filePath);


            Field prev = null;
            Field next = null;

            int i = 0;

            foreach (string line in lines)
            {
                foreach (char Char in line)
                {
                    if (prev == null)
                    {
                        prev     = new WaterField();
                        prev.Pos = i;
                    }

                    switch (Char)
                    {
                    case '~':
                        next = new WaterField();
                        break;

                    case '-':
                        next = new Track("-");
                        break;

                    case '|':
                        next = new Track("|");
                        break;

                    case '.':
                        next = new EmptyField();
                        break;

                    case 'D':
                        next = new Dock();
                        break;

                    case 'Y':
                        next = new Yard();
                        break;

                    // ╮
                    case 'w':
                        next = new Track("╮");
                        break;

                    // ╭
                    case 'x':
                        next = new Track("╭");
                        break;

                    // ╯
                    case 'y':
                        next = new Track("╯");
                        break;

                    // ╰
                    case 'z':
                        next = new Track("╰");
                        break;

                    // In
                    case 'S':
                        next = new SwitchIn("╭");
                        break;

                    // Out
                    case 's':
                        next = new SwitchOut("╮");
                        break;

                    case 'A':
                        next = new Warehouse();
                        break;

                    // Ship
                    case '0':
                        next     = new WaterField();
                        next.Pos = i;
                        next.PutMoveAbleObjectOnThisField(new Ship(), this);
                        break;

                    default:
                        Console.WriteLine("CORRUPT MAP FILE :(");
                        Console.ReadKey();
                        break;
                    }

                    next.Pos       = i;
                    prev.NextField = next;
                    prev           = next;
                    this._gameField.AddLast(prev);

                    i++;
                }
            }

            generateTrackLinks();
        }