Ejemplo n.º 1
0
        /// <summary>
        /// Adds an item to the <see cref="T:System.Collections.Generic.ICollection`1"/>.
        /// </summary>
        /// <param name="item">The object to add to the <see cref="T:System.Collections.Generic.ICollection`1"/>.</param>
        /// <exception cref="T:System.NotSupportedException">The <see cref="T:System.Collections.Generic.ICollection`1"/> is read-only.
        /// </exception>
        public void Add(ILight item)
        {
            if (item.Sprite == null)
            {
                if (DefaultSprite != null)
                {
                    // Use a copy of the DefaultSprite
                    item.Sprite = DefaultSprite.DeepCopy();
                }
                else
                {
                    // No sprite was given, and no DefaultSprite to be used
                    const string errmsg =
                        "Added light `{0}` to `{1}` with no sprite, but couldn't use LightManager.DefaultSprite" +
                        " because the property is null.";
                    if (log.IsWarnEnabled)
                    {
                        log.WarnFormat(errmsg, item, this);
                    }
                    Debug.Fail(string.Format(errmsg, item, this));
                }
            }

            if (!_list.Contains(item))
            {
                _list.Add(item);
            }
        }
Ejemplo n.º 2
0
        internal static void LoadDefaultSprite()
        {
            Bitmap   defaultBitmap = new Bitmap(32, 32);
            Graphics g             = Graphics.FromImage(defaultBitmap);

            g.Clear(Color.White);

            DefaultSprite = LoadFromBitmap(defaultBitmap);
            DefaultSprite.Create();

            defaultBitmap.Dispose();

            TackConsole.EngineLog(EngineLogType.Message, "Loaded the default sprite into Sprite.DefaultSprite");
        }