C# 클래스 ChaseAndEvade.ChaseAndEvadeGame

Sample showing how to implement simple chase, evade, and wander AI behaviors. The behaviors are based on the TurnToFace function, which was explained in AI Sample 1: Aiming.
상속: Microsoft.Xna.Framework.Game
파일 보기 프로젝트 열기: Jorgemagic/MonoGame 1 사용 예제들

공개 메소드들

메소드 설명
ChaseAndEvadeGame ( ) : System
ChaseAndEvadeGame ( Android.App.Activity activity ) : System

보호된 메소드들

메소드 설명
Draw ( GameTime gameTime ) : void

This is called when the game should draw itself. Nothing too fancy in here, we'll just call Begin on the SpriteBatch, and then draw the tank, cat, and mouse, and some overlay text. Once we're finished drawing, we'll call SpriteBatch.End.

Initialize ( ) : void

Overridden from the base Game.Initialize. Once the GraphicsDevice is setup, we'll use the viewport to initialize some values.

LoadContent ( ) : void

Load your graphics content.

Update ( GameTime gameTime ) : void

Allows the game to run logic.

비공개 메소드들

메소드 설명
ClampToViewport ( Vector2 vector ) : Vector2

This function takes a Vector2 as input, and returns that vector "clamped" to the current graphics viewport. We use this function to make sure that no one can go off of the screen.

HandleInput ( ) : void

Handles input for quitting the game.

TurnToFace ( Vector2 position, Vector2 faceThis, float currentAngle, float turnSpeed ) : float

Calculates the angle that an object should face, given its position, its target's position, its current angle, and its maximum turning speed.

UpdateMouse ( ) : void

This function contains the code that controls the mouse. It decides what the mouse should do based on the position of the cat: if the cat is too close, it will attempt to flee. Otherwise, it will idly wander around the screen.

UpdateTank ( ) : void

UpdateTank runs the AI code that will update the tank's orientation and position. It is very similar to UpdateMouse, but is slightly more complicated: where mouse only has two states, idle and active, the Tank has three.

Wander ( Vector2 position, Vector2 &wanderDirection, float &orientation, float turnSpeed ) : void

Wander contains functionality that is shared between both the mouse and the tank, and does just what its name implies: makes them wander around the screen. The specifics of the function are described in more detail in the accompanying doc.

WrapAngle ( float radians ) : float

Returns the angle expressed in radians between -Pi and Pi. the angle to wrap, in radians. the input value expressed in radians from -Pi to Pi.

메소드 상세

ChaseAndEvadeGame() 공개 메소드

public ChaseAndEvadeGame ( ) : System
리턴 System

ChaseAndEvadeGame() 공개 메소드

public ChaseAndEvadeGame ( Android.App.Activity activity ) : System
activity Android.App.Activity
리턴 System

Draw() 보호된 메소드

This is called when the game should draw itself. Nothing too fancy in here, we'll just call Begin on the SpriteBatch, and then draw the tank, cat, and mouse, and some overlay text. Once we're finished drawing, we'll call SpriteBatch.End.
protected Draw ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime
리턴 void

Initialize() 보호된 메소드

Overridden from the base Game.Initialize. Once the GraphicsDevice is setup, we'll use the viewport to initialize some values.
protected Initialize ( ) : void
리턴 void

LoadContent() 보호된 메소드

Load your graphics content.
protected LoadContent ( ) : void
리턴 void

Update() 보호된 메소드

Allows the game to run logic.
protected Update ( GameTime gameTime ) : void
gameTime Microsoft.Xna.Framework.GameTime
리턴 void