Example #1
0
 /// <summary>
 /// Creates a new instance of Level class.
 /// </summary>
 public Level()
 {
     this.countDown = new CountDownDefinition();
     this.pipeQueue = new PipeQueueDefinition();
     this.squareMap = new SquareMapDefinition();
 }
Example #2
0
        /// <summary>
        /// Applies definition to square map.
        /// </summary>
        /// <param name="definition">The square map definition to apply from.</param>
        public void FromDefinition(SquareMapDefinition definition)
        {
            if (definition != null)
            {
                /* normally, we would not use element service upon definition parse.
                 * however, squaremap is somewhat special, since it redefines contents
                 * of squaremap as well. therefore, we clear maps content and recreate
                 * its items using element service.
                 * */
                IElementService elements = this.GetElementService();

                if (elements != null)
                {
                    /* clear first */
                    this.Clear();
                    this.boundary = definition.Boundary;

                    foreach (SquareMapItemDefinition itemDefinition in definition)
                    {
                        ISquareMapItemElement item = elements.CreateSquareMapItem(itemDefinition);

                        if (item != null)
                        {
                            this.SetItem(item);
                        }
                    }
                }
            }
        }
Example #3
0
        /// <summary>
        /// Returns definition for square map.
        /// </summary>
        /// <returns>The definition for this square map.</returns>
        public SquareMapDefinition ToDefinition()
        {
            SquareMapDefinition definition = new SquareMapDefinition();
            definition.Boundary = this.boundary;

            foreach (ISquareMapItemElement item in this.items.Values)
            {
                definition.Put(item.ToDefinition());
            }

            return definition;
        }
Example #4
0
        /// <summary>
        /// Creates square map.
        /// </summary>
        /// <param name="definition">The square map definition used to create square map.</param>
        /// <returns>Newly created square map if possible, otherwise null.</returns>
        public ISquareMapElement CreateSquareMap(SquareMapDefinition definition)
        {
            ISquareMapElement element = this.CreateSquareMap();

            if (element != null)
            {
                element.FromDefinition(definition);
            }

            return element;
        }