Exemple #1
0
    public static void Generate(string map, Transform container, TileRepository tileRepository, float tileOffset, MapifyLayout layout)
    {
        var localPositionCalculator = new LocalPositionCalculator(tileOffset, layout);
        var iterator = new MapIterator(map.SplitOnNewline(), localPositionCalculator);

        new LevelPopulator(iterator, tileRepository, container).Populate();
    }
 //-----------------------------------------------------------------------
 /**
  * Constructor that decorates the specified iterator.
  *
  * @param iterator  the iterator to decorate, must not be null
  * @throws IllegalArgumentException if the collection is null
  */
 public AbstractMapIteratorDecorator(MapIterator iterator)
     : base()
 {
     if (iterator == null)
     {
         throw new java.lang.IllegalArgumentException("MapIterator must not be null");
     }
     this.iterator = iterator;
 }
Exemple #3
0
        internal IteratorInstance ConstructEntryIterator(MapInstance map)
        {
            var instance = new MapIterator(Engine, map)
            {
                _prototype = this
            };

            return(instance);
        }
Exemple #4
0
        //-----------------------------------------------------------------------

        /**
         * Constructor that decorates the specified iterator.
         *
         * @param iterator  the iterator to decorate, must not be null
         * @throws IllegalArgumentException if the collection is null
         */
        public AbstractMapIteratorDecorator(MapIterator iterator)
            : base()
        {
            if (iterator == null)
            {
                throw new java.lang.IllegalArgumentException("MapIterator must not be null");
            }
            this.iterator = iterator;
        }
Exemple #5
0
 private void IterateMap(MapIterator iterator)
 {
     for (var i = 0; i < Height; i++)
     {
         for (var j = 0; j < Width; j++)
         {
             iterator(j, i);
         }
     }
 }
 //-----------------------------------------------------------------------
 /**
  * Decorates the specified iterator such that it cannot be modified.
  *
  * @param iterator  the iterator to decorate
  * @throws IllegalArgumentException if the iterator is null
  */
 public static MapIterator decorate(MapIterator iterator)
 {
     if (iterator == null)
     {
         throw new java.lang.IllegalArgumentException("MapIterator must not be null");
     }
     if (iterator is Unmodifiable)
     {
         return iterator;
     }
     return new UnmodifiableMapIterator(iterator);
 }
        //-----------------------------------------------------------------------

        /**
         * Decorates the specified iterator such that it cannot be modified.
         *
         * @param iterator  the iterator to decorate
         * @throws IllegalArgumentException if the iterator is null
         */
        public static MapIterator decorate(MapIterator iterator)
        {
            if (iterator == null)
            {
                throw new java.lang.IllegalArgumentException("MapIterator must not be null");
            }
            if (iterator is Unmodifiable)
            {
                return(iterator);
            }
            return(new UnmodifiableMapIterator(iterator));
        }
Exemple #8
0
 public MapIterator mapIterator()
 {
     if (map is IterableMap)
     {
         MapIterator it = ((IterableMap)map).mapIterator();
         return(UnmodifiableMapIterator.decorate(it));
     }
     else
     {
         MapIterator it = new EntrySetMapIterator(map);
         return(UnmodifiableMapIterator.decorate(it));
     }
 }
Exemple #9
0
        //-----------------------------------------------------------------------

        /**
         * Replaces the superclass method to store the state of this class.
         * <p>
         * Serialization is not one of the JDK's nicest topics. Normal serialization will
         * initialise the superclass before the subclass. Sometimes however, this isn't
         * what you want, as in this case the <code>put()</code> method on read can be
         * affected by subclass state.
         * <p>
         * The solution adopted here is to serialize the state data of this class in
         * this protected method. This method must be called by the
         * <code>writeObject()</code> of the first java.io.Serializable subclass.
         * <p>
         * Subclasses may override if they have a specific field that must be present
         * on read before this implementation will work. Generally, the read determines
         * what must be serialized here, if anything.
         *
         * @param out  the output stream
         */
        protected void dowriteObject(java.io.ObjectOutputStream outJ)
        {//throws IOException {
            outJ.writeInt(keyType);
            outJ.writeInt(valueType);
            outJ.writeBoolean(purgeValues);
            outJ.writeFloat(loadFactor);
            outJ.writeInt(data.Length);
            for (MapIterator it = mapIterator(); it.hasNext();)
            {
                outJ.writeObject(it.next());
                outJ.writeObject(it.getValue());
            }
            outJ.writeObject(null);  // null terminate map
            // do not call base.doWriteObject() as code there doesn't work for reference map
        }
Exemple #10
0
        //-----------------------------------------------------------------------

        /**
         * Removes all mappings where the first key is that specified.
         * <p>
         * This method removes all the mappings where the <code>MultiKey</code>
         * has one or more keys, and the first matches that specified.
         *
         * @param key1  the first key
         * @return true if any elements were removed
         */
        public bool removeAll(Object key1)
        {
            bool        modified = false;
            MapIterator it       = mapIterator();

            while (it.hasNext())
            {
                MultiKey multi = (MultiKey)it.next();
                if (multi.size() >= 1 &&
                    (key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))))
                {
                    it.remove();
                    modified = true;
                }
            }
            return(modified);
        }
Exemple #11
0
        /**
         * Removes all mappings where the first four keys are those specified.
         * <p>
         * This method removes all the mappings where the <code>MultiKey</code>
         * has four or more keys, and the first four match those specified.
         *
         * @param key1  the first key
         * @param key2  the second key
         * @param key3  the third key
         * @param key4  the fourth key
         * @return true if any elements were removed
         */
        public bool removeAll(Object key1, Object key2, Object key3, Object key4)
        {
            bool        modified = false;
            MapIterator it       = mapIterator();

            while (it.hasNext())
            {
                MultiKey multi = (MultiKey)it.next();
                if (multi.size() >= 4 &&
                    (key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) &&
                    (key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) &&
                    (key3 == null ? multi.getKey(2) == null : key3.equals(multi.getKey(2))) &&
                    (key4 == null ? multi.getKey(3) == null : key4.equals(multi.getKey(3))))
                {
                    it.remove();
                    modified = true;
                }
            }
            return(modified);
        }
        public override MapIterator mapIterator()
        {
            MapIterator it = getBidiMap().mapIterator();

            return(UnmodifiableMapIterator.decorate(it));
        }
        //-----------------------------------------------------------------------

        /**
         * Constructor.
         *
         * @param iterator  the iterator to decorate
         */
        private UnmodifiableMapIterator(MapIterator iterator)
            : base()
        {
            this.iterator = iterator;
        }
 //-----------------------------------------------------------------------
 /**
  * Constructor.
  *
  * @param iterator  the iterator to decorate
  */
 private UnmodifiableMapIterator(MapIterator iterator)
     : base()
 {
     this.iterator = iterator;
 }
 /**
  * Gets an immutable version of a {@link MapIterator}. The returned object
  * will always throw an {@link UnsupportedOperationException} for
  * the {@link Iterator#remove}, {@link MapIterator#setValue(Object)} methods.
  *
  * @param mapIterator  the iterator to make immutable
  * @return an immutable version of the iterator
  */
 public static MapIterator unmodifiableMapIterator(MapIterator mapIterator)
 {
     return(UnmodifiableMapIterator.decorate(mapIterator));
 }
Exemple #16
0
 private void IterateMap(MapIterator iterator)
 {
     for(var i = 0; i < Height; i++)
     {
         for(var j = 0; j < Width; j++)
         {
             iterator(j, i);
         }
     }
 }
 /**
  * Gets an immutable version of a {@link MapIterator}. The returned object
  * will always throw an {@link UnsupportedOperationException} for
  * the {@link Iterator#remove}, {@link MapIterator#setValue(Object)} methods.
  *
  * @param mapIterator  the iterator to make immutable
  * @return an immutable version of the iterator
  */
 public static MapIterator unmodifiableMapIterator(MapIterator mapIterator)
 {
     return UnmodifiableMapIterator.decorate(mapIterator);
 }