コード例 #1
0
ファイル: Cursor.cs プロジェクト: zpconn/TheGrid
        public Cursor( Renderer renderer, string materialName, Size size )
        {
            this.renderer = renderer;

            this.size = size;
            surface = new Surface( renderer, materialName, size );

            mouse = new MouseDevice( null );
        }
コード例 #2
0
ファイル: Cursor.cs プロジェクト: zpconn/TheGrid
        public Cursor( Renderer renderer, string materialName, Size size,
            float movementScaleFactor)
        {
            this.renderer = renderer;

            this.size = size;
            this.movementScaleFactor = movementScaleFactor;
            surface = new Surface( renderer, materialName, size );

            mouse = new MouseDevice( null );
        }
コード例 #3
0
ファイル: Scene.cs プロジェクト: zpconn/Gas
        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();
        }
コード例 #4
0
ファイル: Robot.cs プロジェクト: zpconn/Gas
        public Robot( Renderer renderer, Scene scene )
            : base(renderer, EntityType.Robot)
        {
            mesh = Mesh.Circle( renderer, Color.White, 60, 24 );
            turret = new Surface( renderer, "turret", new Size( 20, 75 ) );
            this.scene = scene;

            frictionalCoefficient = config.GetSetting<float>( "FrictionalCoefficient" );
            mass = config.GetSetting<float>( "RobotMass" );
            coefficientOfRestitution = config.GetSetting<float>( "CoefficientOfRestitution" );

            projectileFireInterval = config.GetSetting<float>( "ProjectileFireInterval" );
            timeSinceLastProjFire = projectileFireInterval;

            explodingProjFireInterval = config.GetSetting<float>( "ExplodingProjectileFireInterval" );
            timeSinceLastExplodingProjFire = explodingProjFireInterval;

            health = config.GetSetting<int>( "RobotStartHealth" );
        }
コード例 #5
0
ファイル: Game.cs プロジェクト: zpconn/Gas
 public SplashScreenState( Renderer renderer )
 {
     this.renderer = renderer;
     type = ( int )StateTypes.SplashScreen;
     splashScreen = new Surface( renderer, "splashScreen", renderer.FullscreenSize );
 }
コード例 #6
0
ファイル: Game.cs プロジェクト: zpconn/Gas
            public MainMenuState( Renderer renderer )
            {
                type = ( int )StateTypes.MainMenu;
                this.renderer = renderer;

                background = new Surface( renderer, "mainMenuBg", renderer.FullscreenSize );

                cursor = new Cursor( renderer, "cursor", new Size( 50, 50 ) );

                mainMenu = new Menu( renderer, new Vector2( 0, -30 ), 80.0f, config.GetSetting<string>( "MainMenuFont" ),
                    cursor, "buttonPressed", "buttonUnpressed", new Size( 200, 50 ) );

                mainMenu.AddButton( "Duel", "Duel" );
                mainMenu.AddButton( "Survival", "Survival" );
                mainMenu.AddButton( "Quit", "Quit" );

                mainMenu.GetButton( "Duel" ).Pressed += new EventHandler( OnDuelPressed );
                mainMenu.GetButton( "Survival" ).Pressed += new EventHandler( OnSurvivalPressed );
                mainMenu.GetButton( "Quit" ).Pressed += new EventHandler( OnQuitButtonPressed );
            }
コード例 #7
0
ファイル: Menu.cs プロジェクト: zpconn/Gas
            private void CreateTextSurface( string text )
            {
                Material textMat = new Material( renderer );
                textMat.VisualEffectName = "lighting";

                Texture textTex = new Texture( renderer, pressedSurf.Size.Width, pressedSurf.Size.Height,
                    true );

                renderer.SaveRenderTarget();
                textTex.SetAsRenderTarget();
                renderer.Clear( Microsoft.DirectX.Direct3D.ClearFlags.Target, Color.FromArgb( 0, 0, 0, 0 ),
                    1.0f, 0 );

                renderer.Begin( null );
                font.RenderTextCentered( new Vector2( pressedSurf.Size.Width / 2, pressedSurf.Size.Height / 2 ),
                    text, Color.White, false );
                renderer.End();

                renderer.RestoreRenderTarget();

                textMat.Textures[ 0 ] = textTex;
                renderer.AddMaterial( textMat, typeof( Button ).ToString() + ". Text: " + text );

                textSurf = new Surface( renderer, typeof( Button ).ToString() + ". Text: " + text,
                    pressedSurf.Size );
            }
コード例 #8
0
ファイル: Menu.cs プロジェクト: zpconn/Gas
            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 );
            }
コード例 #9
0
ファイル: Menu.cs プロジェクト: zpconn/Gas
        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 );
        }