/// <summary>
        /// Constructor.
        /// </summary>
        /// <param name="parent">The parent entity for this Component.</param>
        /// <note>The parent Entity MUST have a PositionComponent in order to construct this Component.</note>
        /// <note>The parent Entity MUST have an InputComponent in order to construct this Component.</note>
        public TheFinaleCameraComponent_cl(Entity_cl parent)
            : base(parent)
        {
            // Asserting here to ensure that the TheFinaleCameraComponent has all the required Components
            // These will be compiled out of the Release build
            Debug.Assert(mParentEntity.GetComponentOfType(typeof(PositionComponent_cl)) != null, "TheFinaleCameraComponent: No PositionComponent exists on parent Entity!");
            Debug.Assert(mParentEntity.GetComponentOfType(typeof(InputComponent_cl)) != null, "TheFinaleCameraComponent: No InputComponent exists on parent Entity!");

            mPositionComponent = (PositionComponent_cl)mParentEntity.GetComponentOfType(typeof(PositionComponent_cl));
            mInputComponent = (InputComponent_cl)mParentEntity.GetComponentOfType(typeof(InputComponent_cl));

            mInputComponent.AddKey("moveN", Keys.Up);
            mInputComponent.AddKey("moveW", Keys.Left);
            mInputComponent.AddKey("moveS", Keys.Down);
            mInputComponent.AddKey("moveE", Keys.Right);

            mInputComponent.AddKey("ShakeIt", Keys.N);

            // Items at the same position as the camera should appear at the bottom of the screen, horizontally centered
            mScreenOffsetMatrix = Matrix.CreateTranslation(new Vector3((float)Game_cl.BaseInstance.WindowWidth * 0.5f, (float)Game_cl.BaseInstance.WindowHeight, 0));

            RecalculateTransformationMatrix();
        }
Exemple #2
0
        /// <summary>
        /// Initialized for testing.
        /// </summary>
        private void InitializeScene()
        {
            mScene = new Scene_cl();

            ComponentManager_cl.Instance.PreUpdate();

            FNA.Components.InputComponent_cl cameraInput = new FNA.Components.InputComponent_cl(mCameraEntity);
            mCameraEntity.RemoveComponent(mCameraEntity.GetComponentOfType(typeof(SunburnCameraComponent_cl)));

            PositionComponent_cl position = (PositionComponent_cl)mCameraEntity.GetComponentOfType(typeof(PositionComponent_cl));
            position.SetPosition3D(new Vector3(0, 0, 0));

            TheFinaleCameraComponent_cl cameraComponent = new TheFinaleCameraComponent_cl(mCameraEntity);
            cameraComponent.ViewWidth = 20.0f;
            cameraComponent.FarPlane = 100.0f;
            CameraManager_cl.Instance.ActiveCamera = (CameraComponent_cl)mCameraEntity.GetComponentOfType(typeof(CameraComponent_cl));

            /************************************************************************
             * HACK:
             * Use the AmbientLightComponent to set up the scene's ambient light.
             *
             * Jay Sternfield	-	2011/12/07
             ************************************************************************/
            mScene.SetAmbientLight(Color.White.ToVector3(), 0.15f);
            SynapseGaming.LightingSystem.Lights.AmbientLight ambient = new SynapseGaming.LightingSystem.Lights.AmbientLight();
            ambient.Depth = 0.0f;
            ambient.DiffuseColor = new Vector3(1f);
            ambient.Intensity = 1f;
            mSceneInterface.LightManager.Submit(ambient);

            RenderableManager_cl.Instance.Initialize(mWindowWidth, mWindowHeight);

            //// texture to vertices - terrain test
            //Entity_cl floor = new Entity_cl();
            //RenderableComponent floorRenderable = new RenderableComponent(floor);
            //floorRenderable.LoadSpriteContent("terrain");
            //floorRenderable.Sprite.Rectangle = new FloatRectangle(0, 0, 1, 1);

            //PositionComponent floorPosition = new PositionComponent(floor);
            //PhysicsComponent floorPhysics = new PhysicsComponent(floor);

            //floorPhysics.IsStatic = true;
            //floorPhysics.InitializePhysics("Terrain");
            //floorPhysics.SetCollisionGroup((short)1);

            //textureScale.X = floorPhysics._polygonTexture.Width / 64;   // this is converting display to sim units
            //textureScale.Y = floorPhysics._polygonTexture.Height / 64;
            //floorRenderable.Sprite.Size = textureScale;

            //// Scarfellina
            //Entity_cl scarfellina = PrefabManager_cl.Instance.LoadPrefab("C:/dev2/Cohort7-Public/Venture/FSS/Finale/WIP/Content/Prefabs/scarfellina.prefab"); // easier to test hardcoded
            //PositionComponent scarfellinaPosition = (PositionComponent)scarfellina.GetComponentOfType(typeof(PositionComponent));
            //PhysicsComponent scarfellinaPhysics = (PhysicsComponent)scarfellina.GetComponentOfType(typeof(PhysicsComponent));
            //RenderableComponent scarfellinaRenderable = (RenderableComponent)scarfellina.GetComponentOfType(typeof(RenderableComponent));

            //scarfellinaRenderable.Sprite.Rectangle = new FloatRectangle(0, 0, 1, 1); // does this matter for animated entities?
            //scarfellinaRenderable.Sprite.Size = new Vector2(2, 2);

            //scarfellinaPhysics.Position = new Vector2(0, 200);
            //scarfellinaPhysics.SetCollisionGroup((short)1);
            //mScene.AddEntity(scarfellina);

            instance = music.CreateInstance();
            instance.IsLooped = true;
            instance.Play();
        }