Ejemplo n.º 1
0
        private Field[,] SetDataToPlayGround(string[] rawData)
        {
            int rows    = int.Parse(rawData[1]);
            int columns = int.Parse(rawData[0]);

            Field[,] playground = new Field[columns, rows];

            for (int line = 2; line < rows + 2; line++)
            {
                for (int sign = 0; sign < columns; sign++)
                {
                    Field field = new EmptyField()
                    {
                        Location = new System.Drawing.Point(sign, line - 2)
                    };
                    switch (rawData[line].Substring(sign, 1))
                    {
                    case CommonConstants.POINT: field = new ItemField()
                    {
                            Location = new System.Drawing.Point(sign, line - 2)
                    };
                        break;

                    case CommonConstants.ITEM_SIGN:
                        field = new ItemField()
                        {
                            Location = new System.Drawing.Point(sign, line - 2)
                        };
                        break;

                    case CommonConstants.PAWN:
                        field = new PlayerField()
                        {
                            Location = new System.Drawing.Point(sign, line - 2)
                        };
                        break;

                    case CommonConstants.WALL:
                        field = new WallField()
                        {
                            Location = new System.Drawing.Point(sign, line - 2)
                        };
                        break;

                    default:
                        field = new EmptyField()
                        {
                            Location = new System.Drawing.Point(sign, line - 2)
                        };
                        break;
                    }
                    playground[sign, line - 2] = field;
                }
            }
            return(playground);
        }
Ejemplo n.º 2
0
        public void polymorphPlace()
        {
            Crate crate = new Crate(currentField);
            Truck truck = new Truck(currentField);
            Wall  wall  = new Wall();

            FloorField floorField = new FloorField();
            WallField  wallField  = new WallField();
            EmptyField emptyField = new EmptyField();

            floorField.Place(crate);
            wallField.Place(crate);
            emptyField.Place(crate);
        }
Ejemplo n.º 3
0
        public void polymorphToChar()
        {
            Crate crate = new Crate(currentField);
            Truck truck = new Truck(currentField);
            Wall  wall  = new Wall();

            FloorField  floorField  = new FloorField();
            TargetField targetField = new TargetField();
            WallField   wallField   = new WallField();
            EmptyField  emptyField  = new EmptyField();

            crate.ToChar();
            truck.ToChar();
            wall.ToChar();

            floorField.ToChar();
            wallField.ToChar();
            emptyField.ToChar();
            targetField.ToChar();
        }
Ejemplo n.º 4
0
        public bool PreFilterMessage(ref Message m)
        {
            if (m.HWnd == this.Handle)
            {
                if (m.Msg == 0x201)
                {                           // Trap WM_LBUTTONDOWN
                    Point pos = new Point(m.LParam.ToInt32() & 0xffff, m.LParam.ToInt32() >> 16);

                    if (pos.X / FIELD_DRAW_SIZE < m_map.width &&
                        pos.Y / FIELD_DRAW_SIZE < m_map.height)
                    {
                        Field newField = null;
                        switch (m_chosenType)
                        {
                        case Field.Type.FIELD_TYPE_FLOOR:
                            newField = new FloorField();
                            break;

                        case Field.Type.FIELD_TYPE_FURNITURE:
                            newField = new FurnitureField();
                            break;

                        case Field.Type.FIELD_TYPE_WALL:
                            newField = new WallField();
                            break;

                        case Field.Type.FIELD_TYPE_UNKNOWN:
                            return(false);      // cannot determine new field type, jump out
                        }

                        this.m_map.setField(pos.X / FIELD_DRAW_SIZE, pos.Y / FIELD_DRAW_SIZE, newField);
                        this.Refresh();
                    }

                    return(true);            // konsumujesz
                }
            }
            return(false);
        }
Ejemplo n.º 5
0
 override public void Visit(WallField wallField)
 {
     _fieldRepresentation = '█';
 }