C# 클래스 Terrarium.Renderer.TerrariumGameView

Encapsulates all of the drawing code for the Terrarium Game View. This class makes heavy use of the DirectDraw APIs in order to provide high speed animation.
상속: System.Windows.Forms.PictureBox
파일 보기 프로젝트 열기: eugeniomiro/Terrarium 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
_backBufferSurface IGraphicsSurface
_screenSurface IGraphicsSurface

공개 메소드들

메소드 설명
AddBackgroundSlide ( ) : void

Used to change the background slide of the Terrarium. Only a single background slide can be added with this revision.

AddComplexSizedSpriteSurface ( string name, int xFrames, int yFrames ) : void

Add a complex sprite surface that takes advantage of sized sprites

AddComplexSpriteSurface ( string name, int xFrames, int yFrames ) : void

Add a complex sprite surface given the number of frames.

AddSpriteSurface ( string name ) : void

Adds a generic 10frame by 40frame sprite surface that is compatible with creature animation.

CenterTo ( int xOffset, int yOffset ) : void

Controls scrolling of the viewport around the world map. Attempts to center the view to the defined point.

ClearProfiler ( ) : void

Clear the profiler

CreateFullScreenSurfaces ( ) : bool

Creates the surfaces required for full screen operation.

CreateWindowedSurfaces ( ) : bool

Method used to create the necessary surfaces required for windowed mode.

CreateWorld ( int xPixels, int yPixels ) : Rectangle

Tell the game view to create a new world and reset the rendering surfaces.

InitializeGraphicEngine ( bool fullscreen ) : bool

Initializes DirectDraw rendering APIs. The function can be called to initialize both Windowed and FullScreen mode, but FullScreen mode isn't fully implemented.

RenderFrame ( ) : void

Renders a new frame of animation. This is the entry point for drawing code and is required every time a new frame is to be drawn.

ResizeViewer ( ) : bool

Handles logic for resizing the game view

ScrollDown ( int pixels ) : int

Controls scrolling of the viewport around the world map.

ScrollLeft ( int pixels ) : int

Controls scrolling of the viewport around the world map.

ScrollRight ( int pixels ) : int

Controls scrolling of the viewport around the world map.

ScrollUp ( int pixels ) : int

Controls scrolling of the viewport around the world map.

SelectAnimalFromPoint ( Point p, bool selectThisAnimalOnly ) : void

Attempts to select a creature given the world offset point.

TerrariumGameView ( ) : System

Creates a new instance of the game view and initializes any properties.

UpdateWorld ( WorldVector worldVector ) : void

Updates the sprites controlled by the game view by providing a new world vector from the game engine.

보호된 메소드들

메소드 설명
OnMouseEnter ( EventArgs e ) : void

Overrides the OnMouseEnter event to provide custom cursor manipulation

OnMouseLeave ( EventArgs e ) : void

Overrides the OnMouseLeave event to provide custom cursor manipulation

OnMouseMove ( MouseEventArgs e ) : void

Overrides OnMouseMove to enable custom cursor rendering.

OnMouseUp ( MouseEventArgs e ) : void

Overrides OnMouseUp in order to enable creature selection.

OnPaint ( PaintEventArgs e ) : void

Overrides the Painting logic because painting will be handled using timers and DirectX. If the control is in design mode, then clear it because DirectX isn't available yet.

OnPaintBackground ( PaintEventArgs e ) : void

Don't paint the background when a background erase is requested. Hurts performance and causes flicker.

비공개 메소드들

메소드 설명
CheckScroll ( ) : void

Computes whether scrolling should occur based on mouse location and hovering.

ClearBackground ( ) : void

Clear any background surfaces to black. This helps find rendering artifacts where portions of a scene aren't updated. Since the background is cleared to black, the portions not updated are clearly visible.

ComputeCursorRectangle ( ) : Rectangle
GetBoundsOfState ( OrganismBase.OrganismState orgState ) : Rectangle

Uses the bounding box computation methods to compute a box that can be printed within the graphics engine. This is used for debugging creature pathing.

InitOrganism ( OrganismBase.OrganismState orgState ) : void

Initializes a new organism state by computed and attaching a TerrariumSprite class that can be used to control on screen movement, animation skins, and selection.

InitTeleporter ( TeleportZone zone ) : void

Sets up the hack table with teleporter information. The hack table is used to quickly implement new types of sprites or implement sprites linked to immutable objects (like the teleporter).

InitializeComponent ( ) : void

Initialize Component

OnMiniMapUpdated ( Terrarium.Renderer.MiniMapUpdatedEventArgs e ) : void

Helper function for firing the MiniMapUpdated event whenever a new mini-map becomes available.

OnOrganismClicked ( OrganismClickedEventArgs e ) : void

Helper function for firing the OrganismClicked event whenever an organism is selected within the game view.

PaintBackground ( ) : void

Renders the Terrarium background image. Also renders plants on the background for static plant drawing to enable higher performance.

PaintCursor ( ) : void

Paints a custom cursor rather than the default windows cursors. Can be used to enable cursor animation, but in the current revision simply paints a custom cursor based on mouse location.

PaintMessage ( ) : void

Controls the rendering of textual messages to the Terrarium client screen. Since DrawText is invoked each time, this method is slow.

PaintSprites ( IGraphicsSurface surf, bool PlantsOnly ) : void

Paint sprites on the given surface. This method is the meat of the graphics engine. Normally, creatures are painted to the work surface using this method. To increase performance plants are rendered to the background surface only once every 10 frames. Lots of work happening in this function so either read through the code or examine the Terrarium Graphics Engine whitepaper for more information.

ReInitSurfaces ( ) : void

Reinitialize all surfaces after they have been lost. This method invokes the garbage collector to make sure that any COM references have been cleaned up, else surface renewal won't work correctly.

RenderTeleporter ( int lowZ, int highZ ) : void

Renders any teleporters that exist between the given z ordered locations.

ResetTerrarium ( ) : void

Resets the Terrarium and prepares it for a new world, without having to reboot the entire game.

TeleporterZIndex ( ) : int[]

ZIndexes the teleporters so they can be properly rendered on the screen.

메소드 상세

AddBackgroundSlide() 공개 메소드

Used to change the background slide of the Terrarium. Only a single background slide can be added with this revision.
public AddBackgroundSlide ( ) : void
리턴 void

AddComplexSizedSpriteSurface() 공개 메소드

Add a complex sprite surface that takes advantage of sized sprites
public AddComplexSizedSpriteSurface ( string name, int xFrames, int yFrames ) : void
name string The name of the sprite sheet.
xFrames int The number of frames width wise.
yFrames int The number of frames height wise.
리턴 void

AddComplexSpriteSurface() 공개 메소드

Add a complex sprite surface given the number of frames.
public AddComplexSpriteSurface ( string name, int xFrames, int yFrames ) : void
name string The name of the sprite sheet.
xFrames int The number of frames width-wise.
yFrames int The number of frames height-wise.
리턴 void

AddSpriteSurface() 공개 메소드

Adds a generic 10frame by 40frame sprite surface that is compatible with creature animation.
public AddSpriteSurface ( string name ) : void
name string The name of the sprite sheet.
리턴 void

CenterTo() 공개 메소드

Controls scrolling of the viewport around the world map. Attempts to center the view to the defined point.
public CenterTo ( int xOffset, int yOffset ) : void
xOffset int X location to center to.
yOffset int Y location to center to.
리턴 void

ClearProfiler() 공개 메소드

Clear the profiler
public ClearProfiler ( ) : void
리턴 void

CreateFullScreenSurfaces() 공개 메소드

Creates the surfaces required for full screen operation.
public CreateFullScreenSurfaces ( ) : bool
리턴 bool

CreateWindowedSurfaces() 공개 메소드

Method used to create the necessary surfaces required for windowed mode.
public CreateWindowedSurfaces ( ) : bool
리턴 bool

CreateWorld() 공개 메소드

Tell the game view to create a new world and reset the rendering surfaces.
public CreateWorld ( int xPixels, int yPixels ) : Rectangle
xPixels int The number of world pixels
yPixels int The number of world pixels
리턴 System.Drawing.Rectangle

InitializeGraphicEngine() 공개 메소드

Initializes DirectDraw rendering APIs. The function can be called to initialize both Windowed and FullScreen mode, but FullScreen mode isn't fully implemented.
public InitializeGraphicEngine ( bool fullscreen ) : bool
fullscreen bool If true then fullscreen will be enabled.
리턴 bool

OnMouseEnter() 보호된 메소드

Overrides the OnMouseEnter event to provide custom cursor manipulation
protected OnMouseEnter ( EventArgs e ) : void
e System.EventArgs Null
리턴 void

OnMouseLeave() 보호된 메소드

Overrides the OnMouseLeave event to provide custom cursor manipulation
protected OnMouseLeave ( EventArgs e ) : void
e System.EventArgs Null
리턴 void

OnMouseMove() 보호된 메소드

Overrides OnMouseMove to enable custom cursor rendering.
protected OnMouseMove ( MouseEventArgs e ) : void
e MouseEventArgs
리턴 void

OnMouseUp() 보호된 메소드

Overrides OnMouseUp in order to enable creature selection.
protected OnMouseUp ( MouseEventArgs e ) : void
e MouseEventArgs
리턴 void

OnPaint() 보호된 메소드

Overrides the Painting logic because painting will be handled using timers and DirectX. If the control is in design mode, then clear it because DirectX isn't available yet.
protected OnPaint ( PaintEventArgs e ) : void
e PaintEventArgs Graphics context objects
리턴 void

OnPaintBackground() 보호된 메소드

Don't paint the background when a background erase is requested. Hurts performance and causes flicker.
protected OnPaintBackground ( PaintEventArgs e ) : void
e PaintEventArgs Graphics context objects
리턴 void

RenderFrame() 공개 메소드

Renders a new frame of animation. This is the entry point for drawing code and is required every time a new frame is to be drawn.
public RenderFrame ( ) : void
리턴 void

ResizeViewer() 공개 메소드

Handles logic for resizing the game view
public ResizeViewer ( ) : bool
리턴 bool

ScrollDown() 공개 메소드

Controls scrolling of the viewport around the world map.
public ScrollDown ( int pixels ) : int
pixels int The number of pixels to scroll down
리턴 int

ScrollLeft() 공개 메소드

Controls scrolling of the viewport around the world map.
public ScrollLeft ( int pixels ) : int
pixels int The number of pixels to scroll left
리턴 int

ScrollRight() 공개 메소드

Controls scrolling of the viewport around the world map.
public ScrollRight ( int pixels ) : int
pixels int The number of pixels to scroll right
리턴 int

ScrollUp() 공개 메소드

Controls scrolling of the viewport around the world map.
public ScrollUp ( int pixels ) : int
pixels int The number of pixels to scroll up
리턴 int

SelectAnimalFromPoint() 공개 메소드

Attempts to select a creature given the world offset point.
public SelectAnimalFromPoint ( Point p, bool selectThisAnimalOnly ) : void
p Point Point to check for creature intersection.
selectThisAnimalOnly bool Determines if this creature should be added to the selection
리턴 void

TerrariumGameView() 공개 메소드

Creates a new instance of the game view and initializes any properties.
public TerrariumGameView ( ) : System
리턴 System

UpdateWorld() 공개 메소드

Updates the sprites controlled by the game view by providing a new world vector from the game engine.
public UpdateWorld ( WorldVector worldVector ) : void
worldVector Terrarium.Game.WorldVector The new world vector of organisms.
리턴 void

프로퍼티 상세

_backBufferSurface 보호되어 있는 프로퍼티

The back buffer surface used with the picture box.
protected IGraphicsSurface _backBufferSurface
리턴 IGraphicsSurface

_screenSurface 보호되어 있는 프로퍼티

The primary screen surface for the picture box.
protected IGraphicsSurface _screenSurface
리턴 IGraphicsSurface