Esempio n. 1
0
        /// <summary>
        /// Function to render the scene and draw the Gorgon logo at the bottom-right of the screen.
        /// </summary>
        private void RenderWithLogo()
        {
            I2DCamera      camera           = _camera;
            GorgonViewport?previousViewport = _viewPort;
            Rectangle?     previousClip     = _clip;

            // Reset any view/projection/clip/viewport.
            // This will force a flush of the pipeline before drawing the logo.
            // If none of these values have changed, the the flush will be
            // peformed when we draw the logo (due to a texture switch).
            if (_camera != null)
            {
                Camera = null;
            }

            if (_viewPort != null)
            {
                Viewport = null;
            }

            if (_clip != null)
            {
                ClipRegion = null;
            }

            _logoSprite.Position = new Vector2(_currentTarget.Width, _currentTarget.Height);
            _logoSprite.Draw();

            // This flush will force the logo to appear.
            Flush();

            // Restore the active camera, viewport and clipping region.
            if (camera != null)
            {
                Camera = camera;
            }

            if (previousViewport != null)
            {
                Viewport = previousViewport;
            }

            if (previousClip != null)
            {
                ClipRegion = previousClip;
            }
        }
        /// <summary>
        /// Load contents for the simulation.
        /// LoadContent will be called only once, at the beginning of the simulation,
        /// is the place to load all of your content (e.g. graphics and sounds).
        /// </summary>
        protected override void LoadContent()
        {
            base.LoadContent();

            // Instantiate and initialize scene, specifying its horizontal size (800)
            // and vertical size (600).
            // Note, the third parameter is set to 0 because unused in FishORama.
            mScene = XNAGame.CreateA2DScene(800, 600, 0);

            /*
             * Create Tokens
             */
            Console.WriteLine("Welcome to the FishORama Framework");

            AquariumToken aquarium = new AquariumToken("Aquarium", this, 800, 600);         // Create aquarium token.

            /*
             * Place tokens in the scene.
             */

            Vector3 tokenPos;                 // Empty Vector3 object to be used to position tokens.

            tokenPos = new Vector3(0, 0, 0);  // Define scene position for the aquarium.
            mScene.Place(aquarium, tokenPos); // Place token in scene.

            //Nested for loop using an array of Piranhas which assigns each team three piranhas, and sets each of them their own number
            //This then also assigns them either team 1 or team 2
            for (int j = 0; j < 2; j++)
            {
                for (int i = 0; i < piranha.Length; i++)
                {
                    //Where: ("String", aqarium reference, piranha number, team number)
                    piranha[i] = new PiranhaToken("Pirahna", aquarium, i + 1, j + 1);
                    //X and Y are hard coded positions declared inside Data Members
                    piranhaPos = new Vector3(x, y, 1);
                    //Places Piranha into the scene
                    mScene.Place(piranha[i], piranhaPos);
                    //Spaces the piranhas out vertically across the stage so they are not on top of one another
                    y += 150;
                }
                //Moves the Piranhas over to the other side of the scene
                x = 300;
                //Resets the Y coordinate
                y = -150;
            }

            /*
             * Create and Initialize camera
             */

            // Define the position for the camera as a 3D vector object, created as a new
            // instance of class Vector3, and initialized to (0, 0, 1),
            // which means that in FishORama it is centered on the origin of the world.
            Vector3 camPosition = new Vector3(0, 0, 1);

            // Instantiate and initialize camera, specifying its ID ("Camera 01"
            // in this case), and its position (camPosition in this case).
            mCamera = mScene.CreateCameraAt("Camera 01", camPosition);

            //Startup the visualization, giving the "...and ACTION!" directive.
            this.PlayScene(mScene);
        }
Esempio n. 3
0
        /// <summary>
        /// Load contents for the simulation.
        /// LoadContent will be called only once, at the beginning of the simulation,
        /// is the place to load all of your content (e.g. graphics and sounds).
        /// </summary>
        protected override void LoadContent()
        {
            base.LoadContent();

            // Instantiate and initialize scene, specifying its horizontal size (800)
            // and vertical size (600).
            // Note, the third parameter is set to 0 because unused in FishORama.
            mScene = XNAGame.CreateA2DScene(800, 600, 0);

            /*
             * Create Tokens
             */
            Console.WriteLine("Welcome to the FishORama Framework");

            AquariumToken aquarium = new AquariumToken("Aquarium", this, 800, 600, rand);         // Create aquarium token.

            /* LEARNING PILL: placing tokens in a scene.
             * In order to be managed by the Machinationis Ratio engine, tokens must be placed
             * in a scene.
             *
             * In FishORama the procedure for the creation and placement of tokens that must be
             * placed in the scene at startup is carried out byn the method LoadContent of
             * class Kernel.
             * Tokens can also be created in runtime by any method of any class, provided that
             * the method has access to the simulation scene object encapsulated in class Kernel.
             * This object can be accessed through the property Scene of class Kernel.
             */

            /*
             * Place tokens in the scene.
             */

            Vector3 tokenPos;                 // Empty Vector3 object to be used to position tokens.

            tokenPos = new Vector3(0, 0, 0);  // Define scene position for the aquarium.
            mScene.Place(aquarium, tokenPos); // Place token in scene.

            PiranhaToken piranha;
            string       fishName = "Piranha";

            // Create teams array to hold each team
            Team[] teams = new Team[2];

            // Initialise Fish
            // For each team
            for (int i = 0; i < teams.Length; i++)
            {
                // Create fish array to hold each fish in the team
                PiranhaToken[] fish = new PiranhaToken[3];

                // For each fish in the team
                for (int o = 0; o < fish.Length; o++)
                {
                    piranha = new PiranhaToken(fishName, aquarium, rand, o + 1, i + 1);

                    // Initialise upper left point, for fish (0, 0)
                    tokenPos = new Vector3(-300, 150, 1);
                    // Increment the X position of the fish based on the team number
                    tokenPos.X += 600 * i;
                    // Increment the Y position of the fish based on the fish number
                    tokenPos.Y -= 150 * o;

                    mScene.Place(piranha, tokenPos);

                    fish[o] = piranha;
                }

                teams[i] = new Team(fish);
            }

            referee = new Referee(aquarium, rand, teams, 3);

            /*
             * Create and Initialize camera
             */

            // Define the position for the camera as a 3D vector object, created as a new
            // instance of class Vector3, and initialized to (0, 0, 1),
            // which means that in FishORama it is centered on the origin of the world.
            Vector3 camPosition = new Vector3(0, 0, 1);

            // Instantiate and initialize camera, specifying its ID ("Camera 01"
            // in this case), and its position (camPosition in this case).
            mCamera = mScene.CreateCameraAt("Camera 01", camPosition);

            //Startup the visualization, giving the "...and ACTION!" directive.
            this.PlayScene(mScene);
        }