Beispiel #1
0
        /// <summary>
        /// Creates a new background as per of the collection, initializes from the given xnaMugen.IO.TextSection.
        /// </summary>
        /// <param name="section">The text section used to create and initialize the created background.</param>
        /// <returns>The created background, if it could be created; null otherwise.</returns>
        public void CreateBackground(TextSection section)
        {
            if (section == null)
            {
                throw new ArgumentNullException(nameof(section));
            }

            var  bgtype = section.GetAttribute <BackgroundType>("type");
            Base background;

            switch (bgtype)
            {
            case BackgroundType.Static:
                background = new Static(section, m_spritemanager.Clone());
                break;

            case BackgroundType.Parallax:
                background = new Parallax(section, m_spritemanager.Clone());
                break;

            case BackgroundType.Animated:
                background = new Animated(section, m_spritemanager.Clone(), m_animationmanager.Clone());
                break;

            default:
                Log.Write(LogLevel.Error, LogSystem.BackgroundCollection, "Cannot create background with TextSection: {0}", section);
                return;
            }

            background.Reset();
            m_backgrounds.Add(background);
        }
Beispiel #2
0
		/// <summary>
		/// Creates a new background as per of the collection, initializes from the given xnaMugen.IO.TextSection.
		/// </summary>
		/// <param name="section">The text section used to create and initialize the created background.</param>
		/// <returns>The created background, if it could be created; null otherwise.</returns>
		public void CreateBackground(TextSection section)
		{
			if (section == null) throw new ArgumentNullException("section");

			BackgroundType bgtype = section.GetAttribute<BackgroundType>("type");
			Base background = null;

			switch (bgtype)
			{
				case BackgroundType.Static:
					background = new Static(section, m_spritemanager.Clone());
					break;

				case BackgroundType.Parallax:
					background = new Parallax(section, m_spritemanager.Clone());
					break;

				case BackgroundType.Animated:
					background = new Animated(section, m_spritemanager.Clone(), m_animationmanager.Clone());
					break;

				case BackgroundType.None:
				default:
					Log.Write(LogLevel.Error, LogSystem.BackgroundCollection, "Cannot create background with TextSection: {0}", section);
					return;
			}

			background.Reset();
			m_backgrounds.Add(background);
		}