Exemplo n.º 1
0
        //Constructor------------------------------------------------------------------------
        public Player(Stage theStage, string label, Vector3 pos, Vector3 orientAxis, float radians, string meshFile, TreasureList tl, bool isCollidable = true)
            : base(theStage, label, pos, orientAxis, radians, meshFile)
        {
            //Camera Name ID's
            first.Name = "First";
            follow.Name = "Follow";
            above.Name = "Above";

            //Set if this object is collidable
            this.IsCollidable = isCollidable;
            if(this.isCollidable)
                stage.Collidable.Add(agentObject);

            this.treasreList = tl;
            this.treasureCount = 0;

            //Set initial orientation of player
            this.rotate = 0;
            this.angle = 0.01f;
            initialOrientation = agentObject.Orientation;
        }
Exemplo n.º 2
0
        /// <summary>
        /// Set GraphicDevice display and rendering BasicEffect effect.  
        /// Create SpriteBatch, font, and font positions.
        /// Creates the traceViewport to display information and the sceneViewport
        /// to render the environment.
        /// Create and add all DrawableGameComponents and Cameras.
        /// First, add all required contest:  Inspector, Cameras, Terrain, Agents
        /// Second, add all optional (scene specific) content
        /// </summary>
        protected override void LoadContent()
        {
            display = graphics.GraphicsDevice;
            effect = new BasicEffect(display);
            // Set up Inspector display
            spriteBatch = new SpriteBatch(display);      // Create a new SpriteBatch
            inspectorFont = Content.Load<SpriteFont>("Consolas");    // Windows XNA && MonoGames
            // viewports
            defaultViewport = GraphicsDevice.Viewport;
            inspectorViewport = defaultViewport;
            sceneViewport = defaultViewport;
            inspectorViewport.Height = InfoPaneSize * inspectorFont.LineSpacing;
            inspectorProjection = Matrix.CreatePerspectiveFieldOfView((float)Math.PI / 4.0f,
               inspectorViewport.Width / inspectorViewport.Height, 1.0f, 200.0f);
            sceneViewport.Height = defaultViewport.Height - inspectorViewport.Height;
            sceneViewport.Y = inspectorViewport.Height;
            sceneProjection = Matrix.CreatePerspectiveFieldOfView((float)Math.PI / 4.0f,
               sceneViewport.Width / sceneViewport.Height, 1.0f, 1000.0f);
            // create Inspector display
            Texture2D inspectorBackground = Content.Load<Texture2D>("inspectorBackground");
            inspector = new Inspector(display, inspectorViewport, inspectorFont, Color.Black, inspectorBackground);
            // create information display strings
            // help strings
            inspector.setInfo(0, "AGMGSKv6 -- Academic Graphics MonoGames/XNA Starter Kit for CSUN Comp 565 assignments.");
            inspector.setInfo(1, "Press keyboard for input (not case sensitive 'H' || 'h')");
            inspector.setInfo(2, "Inspector toggles:  'H' help or info   'M'  matrix or info   'I'  displays next info pane.");
            inspector.setInfo(3, "Arrow keys move the player in, out, left, or right.  'R' resets player to initial orientation.");
            inspector.setInfo(4, "Stage toggles:  'B' bounding spheres, 'C' || 'X' cameras, 'F' fog, 'T' updates, 'Y' yon");
            // initialize empty info strings
            for (int i = 5; i < 20; i++) inspector.setInfo(i, "  ");
            // set blending for bounding sphere drawing
            blending = new BlendState();
            blending.ColorSourceBlend = Blend.SourceAlpha;
            blending.ColorDestinationBlend = Blend.InverseSourceAlpha;
            blending.ColorBlendFunction = BlendFunction.Add;
            notBlending = new BlendState();
            notBlending = display.BlendState;
            // Create and add stage components
            // You must have a TopDownCamera, BoundingSphere3D, WayPoint3D, Terrain, and Agents (player, npAgent) in your stage!
            // Place objects at a position, provide rotation axis and rotation radians.
            // All location vectors are specified relative to the center of the stage.
            // Create a top-down "Whole stage" camera view, make it first camera in collection.
            topDownCamera = new Camera(this, Camera.CameraEnum.TopDownCamera);
            camera.Add(topDownCamera);
            // Set initial camera and projection matrix
            setCamera(0);  // select the first camera

            boundingSphere3D = Content.Load<Model>("boundingSphereV3");

            wayPoint3D = Content.Load<Model>("100x50x100Marker");				// model for navigation node display

            // Create required entities:
            collidable = new List<Object3D>();  // collection of objects to test for collisions
            terrain = new Terrain(this, "terrain", "heightTexture", "colorTexture");
            Components.Add(terrain);

            //Add treasure locations and meshes to map (this needs to be done before agent loads)
            treasure = new TreasureList(this, "TreasureList", "tea", false);
            Components.Add(treasure);

            // create walls for navigation algorithms
            Wall wall = new Wall(this, "wall", "100x100x100Brick");
            Components.Add(wall);

            //Create Moon Base Alpha
            EyeCandy_MoonBaseAlpha mba = new EyeCandy_MoonBaseAlpha(this, "mba", "MoonBaseAlpha", true);
            Components.Add(mba);

            //Create Rocket
            EyeCandy_Rocket rocket = new EyeCandy_Rocket(this, "rocket", "Rocket_jwf", true);
            Components.Add(rocket);

            // Load Agent mesh objects, meshes do not have textures
            npAgent = new NPAgent(this, "Evader",
            new Vector3(490 * spacing, terrain.surfaceHeight(490, 450), 450 * spacing),
            new Vector3(0, 1, 0), 0.0f, "magentaAvatarV6", treasure, true);
            Components.Add(npAgent);

            player = new Player(this, "Chaser",
               new Vector3(510 * spacing, terrain.surfaceHeight(510, 507), 507 * spacing),
               new Vector3(0, 1, 0), 0.78f, "redAvatarV6", treasure, true);
            Components.Add(player);

            // create a Pack of aliens
            pack = new Pack(this, "alien", "dogV6", 450, 430, player.Instance[0], true);
            Components.Add(pack);

            // create 20 clouds
            Cloud cloud = new Cloud(this, "cloud", "cloudV3", 1);
            Components.Add(cloud);
        }
Exemplo n.º 3
0
        //Constructor------------------------------------------------------------------------------------
        /// <summary>
        /// Create a NPC. 
        /// AGXNASK distribution has npAgent move following a Path.
        /// </summary>
        /// <param name="theStage"> the world</param>
        /// <param name="label"> name of </param>
        /// <param name="pos"> initial position </param>
        /// <param name="orientAxis"> initial rotation axis</param>
        /// <param name="radians"> initial rotation</param>
        /// <param name="meshFile"> Direct X *.x Model in Contents directory </param>
        public NPAgent(Stage theStage, string label, Vector3 pos, Vector3 orientAxis, float radians, string meshFile, TreasureList tl, bool isCollidable = false)
            : base(theStage, label, pos, orientAxis, radians, meshFile)
        {
            //Set variables
            this.isCollidable = isCollidable;
            this.treasureList = tl;
            this.treasureCount = 0;
            this.treasurePath = false;

            //Change names for on-screen display of current camera
            first.Name = "npFirst";
            follow.Name = "npFollow";
            above.Name = "npAbove";

            // path is built to work on specific terrain, made from int[x,z] array pathNode
            path = new Path(stage, pathNode, Path.PathType.LOOP); // continuous search path
            stage.Components.Add(path);

            //Get the first path goal
            nextGoal = path.NextNode;

            //Orient to face the first goal
            agentObject.turnToFace(nextGoal.Translation);

            //Set snapDistance to be a little larger than step * stepSize
            snapDistance = (UInt32)(1.5 * (agentObject.Step * agentObject.StepSize));
        }