protected override void InitializeGame() { System.Windows.Forms.Cursor.Hide(); renderer.ProjectionMode = ProjectionMode.Orthogonal; renderer.ViewMatrix = Matrix.LookAtLH( new Vector3( 0, 0, -5.0f ), new Vector3(), new Vector3( 0, 1, 0 ) ); renderer.Device.RenderState.Lighting = false; showFPS = config.GetSetting<bool>( "ShowFPS" ); fpsFont = renderer.CreateFont( "Arial", 16 ); fpsFont.ShadowColor = Color.Gray; cursor = new Cursor( renderer, "cursor", new Size( 10, 10 ) ); useBloom = config.GetSetting<bool>( "UseBloom" ); sceneTex = new Gas.Graphics.Texture( renderer, renderer.FullscreenSize.Width, renderer.FullscreenSize.Height, true ); bloomProcessor = new BloomPostProcessor( renderer ); bloomProcessor.Blur = config.GetSetting<float>( "BloomBlur" ); bloomProcessor.BloomScale = config.GetSetting<float>( "BloomScale" ); bloomProcessor.BrightPassThreshold = config.GetSetting<float>( "BloomBrightPassThreshold" ); cursorInfluenceMagnitude = config.GetSetting<int>( "CursorInfluenceMagnitude" ); InitializeGrid(); this.KeyDown += new KeyEventHandler( OnKeyDown ); }
protected override void InitializeGame() { this.Icon = new Icon(Application.StartupPath + @"\GasIcon.ico"); Cursor.Hide(); useBloom = config.GetSetting<bool>("UseBloom"); renderer.ProjectionMode = ProjectionMode.Orthogonal; renderer.ViewMatrix = Matrix.LookAtLH(new Vector3(0, 0, 5.0f), new Vector3(), new Vector3(0, 1, 0)); font = new Gas.Graphics.Font(renderer, "Arial", 16); font.ShadowColor = Color.Red; sceneImage = new Texture(renderer, renderer.FullscreenSize.Width, renderer.FullscreenSize.Height, true); bloomProcessor = new BloomPostProcessor(renderer); bloomProcessor.BloomScale = config.GetSetting<float>("BloomScale"); bloomProcessor.Blur = config.GetSetting<float>("Blur"); bloomProcessor.BrightPassThreshold = config.GetSetting<float>("BrightPassThreshold"); sceneGraph = new SceneGraph(renderer); string lightColorName = config.GetSetting<string>("LightColor"); Color lightColor = Color.FromName(lightColorName); light = new LightNode(renderer, sceneGraph, Matrix.Identity, 250.0f, 1.0f, lightColor); backgroundQuad = new GeometryNode(renderer, sceneGraph, Matrix.Translation(0.0f, 0.0f, -1.0f), Mesh.Rectangle(renderer, Color.Black, renderer.FullscreenSize.Width, renderer.FullscreenSize.Height, 2.0f), "roughWall"); waterMesh = new GeometryNode(renderer, sceneGraph, Matrix.Translation(0.0f, 0.0f, 0.0f), Mesh.Circle(renderer, Color.Black, 500, 64, 1.0f), "water"); object1 = new GeometryNode(renderer, sceneGraph, Matrix.Translation(0.0f, 0.0f, 1.0f), Mesh.Circle(renderer, Color.Blue, 85, 12), "stones"); object2 = new GeometryNode(renderer, sceneGraph, Matrix.Identity, Mesh.Circle(renderer, Color.Blue, 65, 8), "stones"); object3 = new GeometryNode(renderer, sceneGraph, Matrix.Identity, Mesh.Circle(renderer, Color.Blue, 25, 6), "stones"); sceneGraph.Root.AddChild(backgroundQuad); sceneGraph.Root.AddChild(waterMesh); sceneGraph.Root.AddChild(object1); object1.AddChild(object2); object1.AddChild(light); object2.AddChild(object3); this.KeyDown += new KeyEventHandler(OnKeyDown); }
public Scene( Renderer renderer ) { this.renderer = renderer; camera = new Camera( renderer ); crosshair = new Cursor( renderer, "crosshair", new Size( 50, 49 ) ); arenaSize = new Size( config.GetSetting<int>( "ArenaWidth" ), config.GetSetting<int>( "ArenaHeight" ) ); aimMode = config.GetSetting<string>( "AimMode" ); cameraMode = config.GetSetting<string>( "CameraMode" ); shadows = config.GetSetting<bool>( "Shadows" ); if ( aimMode != "Relative" && aimMode != "Absolute" ) { Log.Write( "Invalid value for setting 'AimMode'. Defaulting to AimMode = 'Absolute'." ); aimMode = "Absolute"; } if ( cameraMode != "Fixed" && cameraMode != "Floating" ) { Log.Write( "Invalid value for setting 'CameraMode'. Defaulting to CameraMode = 'Floating'." ); cameraMode = "Floating"; } lavaTexCoordTiling = config.GetSetting<float>( "LavaTexCoordTiling" ); arenaGround = new Surface( renderer, "arenaGround", arenaSize, 2.0f ); lava = new Surface( renderer, "lava", new Size( renderer.FullscreenSize.Width, renderer.FullscreenSize.Height ), lavaTexCoordTiling ); playerBot = new Robot( renderer, new PlayerRobotControl( crosshair ), this ); cpuBot = new Robot( renderer, new CPURobotControl( this ), this ); statsFont = new Gas.Graphics.Font( renderer, "Arial", 14 ); statsFont.ShadowColor = Color.Black; playerBot.Position = new Vector2( 500.0f, 0.0f ); cpuBot.Position = new Vector2( -500.0f, 0.0f ); entityArbiter.AddEntity( playerBot ); entityArbiter.AddEntity( cpuBot ); PopulateArenaWithObstacles(); }
/// <summary> /// Creates a font. If the font has already been created, the cached version is returned. /// </summary> public static Font CreateFont( Renderer renderer, string familyName, int height ) { // Search cache first foreach ( CachedFont cf in fontCache.Keys ) { if ( StringHelper.CaseInsensitiveCompare( cf.FamilyName, familyName ) && cf.Height == height ) return fontCache[ cf ] as Font; } Font newFont = new Font( renderer, familyName, height ); CachedFont cachedFont = new CachedFont(); cachedFont.FamilyName = familyName; cachedFont.Height = height; fontCache.Add( cachedFont, newFont ); return newFont; }
public Button( Renderer renderer, Cursor cursor, Gas.Graphics.Font font, Surface unpressedSurf, Surface pressedSurf, string text, Vector2 position) { this.renderer = renderer; this.cursor = cursor; this.font = font; this.unpressedSurf = unpressedSurf; this.pressedSurf = pressedSurf; this.text = text; this.position = position; this.cursor.Clicked += new EventHandler( OnCursorClicked ); this.cursor.Unclicked += new EventHandler( OnCursorUnclicked ); CreateTextSurface( text ); }
public Menu( Renderer renderer, Vector2 position, float buttonYSpacing, string fontName, Cursor cursor, string pressedMaterialName, string unpressedMaterialName, Size buttonSize) { this.renderer = renderer; this.position = position; this.buttonYSpacing = buttonYSpacing; this.cursor = cursor; textFont = new Gas.Graphics.Font( renderer, fontName, 16 ); unpressedSurf = new Surface( renderer, unpressedMaterialName, buttonSize ); pressedSurf = new Surface( renderer, pressedMaterialName, buttonSize ); }