public GameRenderer(DDGameGraphics graphic, DDGameSurface surface) { this.m_graphics = graphic; this.m_surface = surface; this.Initialize(); }
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; }
public GameObject(DDGraphic graphic, DDGameSurface surface, PointF location) { this.m_graphic = graphic; this.m_surface = surface; this.m_location = location; }
public StaticObject(DDGraphic graphic, DDGameSurface surface, PointF location, int defaultFrame) : base(graphic, surface, location) { this.m_defaultFrame = defaultFrame; }
public StaticObject(DDGraphic graphic, DDGameSurface surface, PointF location) : base(graphic, surface, location) { }
/// <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); }
/// <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); }
/// <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); }
public TotalTankIcon(DDGameGraphics graphic, DDGameSurface surface, PointF location, int type) : base(graphic["InfoIcons"], surface, location, type + 3) { }
public BonusItem(DDGameGraphics graphic, DDGameSurface surface, PointF location) : base(graphic["Bonus"], surface, location) { }
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); }
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); } } }
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(); }
public LoadingText(DDGameGraphics graphic, DDGameSurface surface, PointF location) : base(graphic["Loading"], surface, location) { this.m_framesPerSecond = 7F; }