Exemplo n.º 1
0
        public Map(SerializationInfo info, StreamingContext context)
        {
            name                  = (string)info.GetValue(nameSerializableName, typeof(string));
            table                 = (BidimensionalArray <Atom>)info.GetValue(tableSerializableName, typeof(BidimensionalArray <Atom>));
            buffer                = (BidimensionalArray <Atom>)info.GetValue(bufferSerializableName, typeof(BidimensionalArray <Atom>));
            dark                  = (BidimensionalArray <bool>)info.GetValue(darkSerializableName, typeof(BidimensionalArray <bool>));
            explored              = (BidimensionalArray <TernaryValue>)info.GetValue(exploredSerializableName, typeof(BidimensionalArray <TernaryValue>));
            untangibles           = (BidimensionalArray <AtomCollection>)info.GetValue(untangiblesSerializableName, typeof(BidimensionalArray <AtomCollection>));
            playerInitialPosition = (Coord)info.GetValue(playerInitialPosSerializableName, typeof(Coord));
            //views = (List<IMapViewer>)info.GetValue(viewsSerializableName, typeof(List<IMapViewer>));
            this.views = new List <IMapViewer>();

            table.ForEach(a => a.SetMap(this));
            buffer.ForEach(a => a.SetMap(this));
            untangibles.ForEach(uL => uL.ForEach(a => a.SetMap(this)));
        }
Exemplo n.º 2
0
        public Map(string name,
                   Coord playerInitialPosition,
                   BidimensionalArray <Atom> table,
                   TernaryValue notToExplore,
                   bool dark)
        {
            this.name = name;
            this.playerInitialPosition = playerInitialPosition;
            this.table = table;
            this.table.ForEach(a => a.SetMap(this));
            this.buffer = new BidimensionalArray <Atom>(table.Rows, table.Cols, (pos) => {
                var f = new Floor(pos);
                f.SetMap(this);
                return(f);
            });
            this.untangibles = new BidimensionalArray <AtomCollection>(table.Rows, table.Cols, () => new AtomCollection());
            this.explored    = new BidimensionalArray <TernaryValue>(table.Rows, table.Cols, notToExplore);
            this.dark        = new BidimensionalArray <bool>(table.Rows, table.Cols, dark);
            this.views       = new List <IMapViewer>();

            table.ForEach(atom => atom.InsertInMap(this, atom.Position, true));
        }