Esempio n. 1
0
        public RealGame(int numberOfSections, int numPlayers, BlockBasedSceneGraph sceneGraph)
        {
            // setup
            Globals.gameInstance = this;
            this.sceneGraph = sceneGraph;

            // object to store collisions (the size of the world)
            cellCollider = new CellCollider(32, numberOfSections * 32);

            // holds links between current spawn populations, doors and lights
            campaignManager = new CampaignManager(numberOfSections);

            // now build all the shit
            WorldBuilder.Build(numberOfSections, Vector3.Zero);
            
            // now spawn all player
            players = new PlayerObject[numPlayers];
            for (int i = 0; i < numPlayers; i++)
            {                
                players[i] = new PlayerObject((i==0) ? PlayerIndex.One : PlayerIndex.Two, playerColours[i], spawns[i], MathHelper.ToRadians(-90));
            }

            Globals.audioManager.SwitchToGame();
            //Globals.audioManager.PlayGameSound("start_game");
            Globals.audioManager.PlayGameSound("music");

        }
Esempio n. 2
0
        //players = 1 or 2
        //sections = 1,2 or 3 (small, medium, long) ---> has scaling factor. default set to 6
        //difficulty = 1, 2, or 3 (easy, medium, hard)
        public GameLayer(int players, int numSections, int difficulty) : base()
        {
            cooloffBlue = 2000;
            cooloffGreen = 2000;
            // Screen layer attributes
            numPlayers = players;
            numSectionScalingFactor = 6;
            isTransparent = false;
            transitionOnTime = TimeSpan.FromSeconds(0.6);
            transitionOffTime = TimeSpan.FromSeconds(0.5);

            // 3D view vars
            viewport = Globals.graphics.GraphicsDevice.Viewport;

            // drawable layers
            canvas = new SpriteBatch(Globals.graphics.GraphicsDevice);
            game3DLayer = new RenderTarget2D(
                Globals.graphics.GraphicsDevice,
                viewport.Width,
                viewport.Height,
                false,
                SurfaceFormat.Color,
                DepthFormat.Depth24,
                0,
                RenderTargetUsage.DiscardContents);

            // Create the renderer, this renderer binds to the graphics device and with the given width and height, is used to 
            // draw everything on each frame
            renderer = new Renderer(Globals.graphics.GraphicsDevice, Globals.content, viewport.Width, viewport.Height);

            // The light and mesh container is used to store mesh and light obejcts. This is just for RENDERING. Not for DRAWING
            sceneGraph = new BlockBasedSceneGraph(numSections * numSectionScalingFactor);
            sceneGraph.SetSubMeshDelegate(delegate(Mesh.SubMesh subMesh) 
            {                
                renderer.SetupSubMesh(subMesh);
                subMesh.RenderEffect.AmbientParameter.SetValue(Vector4.Zero);
            });
            sceneGraph.SetLightDelegate(delegate(Light l) { });

            // Load the Game
            //second number is number of players
            
            Globals.gameInstance = new RealGame(numSections * numSectionScalingFactor, numPlayers, sceneGraph);

            cameraController = new CameraController(viewport, Matrix.Identity);
            cameraController.Fit(Globals.gameInstance.GetCriticalPoints());
            cameraController.MoveToTarget();            
        }