Beispiel #1
0
        public GameRenderer(DDGameGraphics graphic, DDGameSurface surface)
        {
            this.m_graphics = graphic;
            this.m_surface = surface;

            this.Initialize();
        }
Beispiel #2
0
        public void Initialize()
        {
            // Initialize game components.
            this.m_surface = new DDGameSurface(this.m_form);

            Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("BattleCity.Resources.Graphics.xml");
            this.m_graphics = new DDGameGraphics(stream, this.m_surface);
            stream.Close();

            this.m_keyboard = new DIKeyboard(this.m_form);

            this.m_game = new GameRenderer(this.m_graphics, this.m_surface);

            TraceFrm.TRACE(this.m_form, "Initialize : OK");

            if (this.m_processThread == null)
            {
                this.m_processThread = new Thread(new ThreadStart(this.DoProcess));
                this.m_processThread.IsBackground = true;
                this.m_processThread.Start();
            }

            System.Diagnostics.Trace.Write("RunGame");

            this.m_game.RunningState = RunningStates.Loading;
            this.RunGame();
        }
 public TitleText(DDGameGraphics graphic, DDGameSurface surface, PointF location)
     : base(graphic["Title"], surface, location)
 {
 }
 public PlayerLifeIcon(DDGameGraphics graphic, DDGameSurface surface, PointF location, bool secondPlayer)
     : base(graphic["InfoIcons"], surface, location, (secondPlayer) ? 2 : 1)
 {
 }
 public MapItem(DDGameGraphics graphic, DDGameSurface surface, PointF location)
     : base(graphic["MapItems"], surface, location)
 {
     this.m_framesPerSecond = 16F;
 }
 /// <summary>
 /// Creates a new DDGameGraphics.
 /// </summary>
 /// <param name="file">XML list of DDGraphic descriptions.</param>
 /// <param name="gameSurface">DDGameSurface to create a list of DDGraphics with.</param>
 public DDGameGraphics(string file, DDGameSurface gameSurface)
 {
     XmlTextReader reader = new XmlTextReader(file);
     _readElements(reader, gameSurface);
     reader.Close();
 }
        /// <summary>
        /// Creates a graphic.
        /// </summary>
        /// <param name="reader">XmlTextReader to read graphic attributes from.</param>
        /// <param name="gameSurface">DDGameSurface that graphics will be created with.</param>
        private void _readAttributes(XmlTextReader reader, DDGameSurface gameSurface)
        {
            // Default graphic values.
            string key = String.Empty;
            string path = String.Empty;

            bool embedded = false;

            Size frameSize = Size.Empty;
            int transColor = -1;

            // Read each graphic attribute.
            while (reader.MoveToNextAttribute()) {
                switch (reader.Name) {
                    case "key":
                        key = reader.Value;
                        break;

                    case "path":
                        path = reader.Value;
                        break;

                    case "frameWidth":
                        frameSize.Width = int.Parse(reader.Value);
                        break;

                    case "frameHeight":
                        frameSize.Height = int.Parse(reader.Value);
                        break;

                    case "transColor":
                        transColor = int.Parse(reader.Value, NumberStyles.HexNumber);
                        break;

                    case "embedded":
                        embedded = bool.Parse(reader.Value);
                        break;

                    default:
                        // No other attributes to handle.
                        break;
                }
            }

            // Add graphic to graphics list.
            _addGraphic(key, path, frameSize, transColor, gameSurface, embedded);
        }
 public Effect(DDGameGraphics graphic, DDGameSurface surface, PointF location)
     : base(graphic["Effect"], surface, location)
 {
     this.m_framesPerSecond = 12F;
 }
Beispiel #9
0
 public GameObject(DDGraphic graphic, DDGameSurface surface, PointF location)
 {
     this.m_graphic = graphic;
     this.m_surface = surface;
     this.m_location = location;
 }
Beispiel #10
0
 public StaticObject(DDGraphic graphic, DDGameSurface surface, PointF location, int defaultFrame)
     : base(graphic, surface, location)
 {
     this.m_defaultFrame = defaultFrame;
 }
Beispiel #11
0
 public StaticObject(DDGraphic graphic, DDGameSurface surface, PointF location)
     : base(graphic, surface, location)
 {
 }
Beispiel #12
0
 /// <summary>
 /// Creates a new DDGraphic.
 /// </summary>
 /// <param name="stream">Stream where the graphic is located.</param>
 /// <param name="frameSize">Size of this DDGraphics frames.</param>
 /// <param name="desc">SurfaceDescription of this DDGraphic.</param>
 /// <param name="gameSurface">DDGameSurface this DDGraphic is to be created for.</param>
 public DDGraphic(Stream stream, Size frameSize, SurfaceDescription desc, DDGameSurface gameSurface)
     : base(stream, desc, gameSurface.Device)
 {
     _initGraphic(frameSize, -1);
 }
Beispiel #13
0
 /// <summary>
 /// Creates a new DDGraphic.
 /// </summary>
 /// <param name="file">File path of a graphic.</param>
 /// <param name="transColor">Transparency color to use (0x00RRGGBB format)</param>
 /// <param name="desc">SurfaceDescription of this DDGraphic.</param>
 /// <param name="gameSurface">DDGameSurface this DDGraphic is to be created for.</param>
 public DDGraphic(string file, int transColor, SurfaceDescription desc, DDGameSurface gameSurface)
     : base(file, desc, gameSurface.Device)
 {
     _initGraphic(Size.Empty, transColor);
 }
Beispiel #14
0
 /// <summary>
 /// Creates a new DDGraphic.
 /// </summary>
 /// <param name="file">File path of a graphic.</param>
 /// <param name="frameSize">Size of this DDGraphics frames.</param>
 /// <param name="desc">SurfaceDescription of this DDGraphic.</param>
 /// <param name="gameSurface">DDGameSurface this DDGraphic is to be created for.</param>
 public DDGraphic(string file, Size frameSize, SurfaceDescription desc, DDGameSurface gameSurface)
     : base(file, desc, gameSurface.Device)
 {
     _initGraphic(frameSize, -1);
 }
Beispiel #15
0
 public TotalTankIcon(DDGameGraphics graphic, DDGameSurface surface, PointF location, int type)
     : base(graphic["InfoIcons"], surface, location, type + 3)
 {
 }
Beispiel #16
0
 public BonusItem(DDGameGraphics graphic, DDGameSurface surface, PointF location)
     : base(graphic["Bonus"], surface, location)
 {
 }
Beispiel #17
0
 public FlagIcon(DDGameGraphics graphic, DDGameSurface surface, PointF location)
     : base(graphic["InfoIcons"], surface, location, 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);
        }
Beispiel #19
0
 public GameOverText(DDGameGraphics graphic, DDGameSurface surface, PointF location)
     : base(graphic["GameOver"], surface, location)
 {
 }
 /// <summary>
 /// Reads each graphic element.
 /// </summary>
 /// <param name="reader">Reader to read elements from.</param>
 /// <param name="gameSurface">DDGameSurface that graphics will be created with.</param>
 private void _readElements(XmlTextReader reader, DDGameSurface gameSurface)
 {
     while (reader.Read()) {
         if (reader.NodeType == XmlNodeType.Element && reader.Name == "graphic") {
             _readAttributes(reader, gameSurface);
         }
     }
 }
Beispiel #21
0
 public HomeEagle(DDGameGraphics graphic, DDGameSurface surface, PointF location)
     : base(graphic["HomeEagle"], surface, location)
 {
 }
 /// <summary>
 /// Creates a new DDGameGraphics.
 /// </summary>
 /// <param name="stream">XML list of DDGraphic descriptions.</param>
 /// <param name="gameSurface">DDGameSurface to create a list of DDGraphics with.</param>
 public DDGameGraphics(Stream stream, DDGameSurface gameSurface)
 {
     XmlTextReader reader = new XmlTextReader(stream);
     _readElements(reader, gameSurface);
     reader.Close();
 }
Beispiel #23
0
 public LoadingText(DDGameGraphics graphic, DDGameSurface surface, PointF location)
     : base(graphic["Loading"], surface, location)
 {
     this.m_framesPerSecond = 7F;
 }