示例#1
0
        /// <summary>
        /// Adds a DDGraphic to this DDGameGraphcis list.
        /// </summary>
        /// <param name="key">Key for graphic.</param>
        /// <param name="path">Path of graphic file.</param>
        /// <param name="frameSize">Size of DDGraphics frames.</param>
        /// <param name="transColor">Transparency color of DDGraphic.</param>
        /// <param name="gameSurface">DDGameSurface to create DDGraphic with.</param>
        /// <param name="embedded">Set to true if path is coming from an embedded resource.</param>
        private void _addGraphic(string key, string path, Size frameSize, int transColor, DDGameSurface gameSurface, bool embedded)
        {
            // Make sure a valid path and key was given.
            if (key == String.Empty || path == String.Empty) {
                return;
            }

            // Graphic to add.
            DDGraphic graphic = null;

            if (embedded) {
                // Create graphic from stream.
                Stream stream = Assembly.GetEntryAssembly().GetManifestResourceStream(path);

                try {
                    graphic = new DDGraphic(stream, new SurfaceDescription(), gameSurface);
                }
                catch {
                    // Couldn't create graphic.
                    return;
                }

                stream.Close();
            }
            else {
                // Create graphic from file path.
                try {
                    graphic = new DDGraphic(path, new SurfaceDescription(), gameSurface);
                }
                catch {
                    // Couldn't create graphic.
                    return;
                }
            }

            // Set graphic properties.
            graphic.SetTransparency(transColor);
            graphic.FrameSize = frameSize;

            // Add graphic to graphics list.
            _graphics.Add(key, graphic);
        }
示例#2
0
 public StaticObject(DDGraphic graphic, DDGameSurface surface, PointF location, int defaultFrame)
     : base(graphic, surface, location)
 {
     this.m_defaultFrame = defaultFrame;
 }
示例#3
0
 public GameObject(DDGraphic graphic, DDGameSurface surface, PointF location)
 {
     this.m_graphic = graphic;
     this.m_surface = surface;
     this.m_location = location;
 }
示例#4
0
 public StaticObject(DDGraphic graphic, DDGameSurface surface, PointF location)
     : base(graphic, surface, location)
 {
 }