Esempio n. 1
0
        public Player()
        {
            TgcSceneLoader loaderSniper = new TgcSceneLoader();

            string media = GuiController.Instance.AlumnoEjemplosMediaDir;

            TgcScene sniperRifle = loaderSniper.loadSceneFromFile(media + "CEGA\\Sniper-TgcScene.xml");

            rifle = sniperRifle.Meshes[0];
            rifle.AlphaBlendEnable    = true;
            rifle.AutoTransformEnable = false;

            rifleBaseTransforms =
                Matrix.Scaling(new Vector3(0.01f, 0.01f, 0.01f)) *
                Matrix.RotationY(FastMath.PI - 0.03f) *
                Matrix.Translation(new Vector3(0.5f, -1.0f, 2.0f));

            // Configuracion de la camara
            //
            GuiController.Instance.CurrentCamera.Enable = false;
            camera = new FpsCamera();
            GuiController.Instance.CurrentCamera = camera;
            camera.MovementSpeed = WALKING_SPEED;
            camera.RotationSpeed = ROTATION_SPEED_NO_SCOPE;
            posicionSegura       = camera.getPosition();
            posicionInicial      = camera.getPosition();
            lookAtInicial        = camera.getLookAt();

            // Configuracion del stencil para el modo scope
            //
            scope_stencil         = new TgcSprite();
            scope_stencil.Texture = TgcTexture.createTexture(media + @"CEGA\Textures\scope.png");

            Size screenSize  = GuiController.Instance.Panel3d.Size;
            Size textureSize = scope_stencil.Texture.Size;

            float scope_scale = FastMath.Min(
                (float)screenSize.Width / textureSize.Width,
                (float)screenSize.Height / textureSize.Height) * 0.9f;

            scope_stencil.Scaling = new Vector2(scope_scale, scope_scale);

            scope_stencil.Position = new Vector2(
                FastMath.Max(screenSize.Width / 2 - textureSize.Width * scope_scale / 2, 0),
                FastMath.Max(screenSize.Height / 2 - textureSize.Height * scope_scale / 2, 0));

            // El radio, ajustado a -1% para cubrir el borde
            scope_radius = (textureSize.Height * scope_scale / 2.0f) * 0.99f;

            LoadSounds(media);

            //Inicializo vidas , balas y puntos.

            this.vidas  = 5;
            this.ammo   = -1; //Por ahora son infinitas
            this.puntos = 0;

            //Configuracion de la mira sin scope.
            float mira_scale = 0.08f;

            mira         = new TgcSprite();
            mira.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "CEGA\\Textures\\Mira.png");
            mira.Scaling = new Vector2(mira_scale, mira_scale);

            Size miraSize = mira.Texture.Size;

            miraSize.Height = (int)(miraSize.Height * mira_scale);
            miraSize.Width  = (int)(miraSize.Width * mira_scale);
            mira.Position   = new Vector2(FastMath.Max(screenSize.Width / 2 - miraSize.Width / 2, 0), FastMath.Max(screenSize.Height / 2 - miraSize.Height / 2, 0));

            //Inicialización UI (Texto)
            LoadUI(screenSize);
        }
Esempio n. 2
0
        public Player()
        {
            TgcSceneLoader loaderSniper = new TgcSceneLoader();

            string media = GuiController.Instance.AlumnoEjemplosMediaDir;

            TgcScene sniperRifle = loaderSniper.loadSceneFromFile(media + "CEGA\\Sniper-TgcScene.xml");

            rifle = sniperRifle.Meshes[0];
            rifle.AlphaBlendEnable = true;
            rifle.AutoTransformEnable = false;

            rifleBaseTransforms =
                Matrix.Scaling(new Vector3(0.01f, 0.01f, 0.01f)) *
                Matrix.RotationY(FastMath.PI - 0.03f) *
                Matrix.Translation(new Vector3(0.5f, -1.0f, 2.0f));

            // Configuracion de la camara
            //
            GuiController.Instance.CurrentCamera.Enable = false;
            camera = new FpsCamera();
            GuiController.Instance.CurrentCamera = camera;
            camera.MovementSpeed = WALKING_SPEED;
            camera.RotationSpeed = ROTATION_SPEED_NO_SCOPE;
            posicionSegura = camera.getPosition();
            posicionInicial = camera.getPosition();
            lookAtInicial = camera.getLookAt();

            // Configuracion del stencil para el modo scope
            //
            scope_stencil = new TgcSprite();
            scope_stencil.Texture = TgcTexture.createTexture(media + @"CEGA\Textures\scope.png");

            Size screenSize = GuiController.Instance.Panel3d.Size;
            Size textureSize = scope_stencil.Texture.Size;

            float scope_scale = FastMath.Min(
                (float)screenSize.Width / textureSize.Width,
                (float)screenSize.Height / textureSize.Height) * 0.9f;

            scope_stencil.Scaling = new Vector2(scope_scale, scope_scale);

            scope_stencil.Position = new Vector2(
                FastMath.Max(screenSize.Width / 2 - textureSize.Width * scope_scale / 2, 0),
                FastMath.Max(screenSize.Height / 2 - textureSize.Height * scope_scale / 2, 0));

            // El radio, ajustado a -1% para cubrir el borde
            scope_radius = (textureSize.Height * scope_scale / 2.0f) * 0.99f;

            LoadSounds(media);

            //Inicializo vidas , balas y puntos.

            this.vidas = 5;
            this.ammo = -1; //Por ahora son infinitas
            this.puntos = 0;

            //Configuracion de la mira sin scope.
            float mira_scale = 0.08f;
            mira = new TgcSprite();
            mira.Texture = TgcTexture.createTexture(GuiController.Instance.AlumnoEjemplosMediaDir + "CEGA\\Textures\\Mira.png");
            mira.Scaling = new Vector2(mira_scale, mira_scale);

            Size miraSize = mira.Texture.Size;
            miraSize.Height = (int)(miraSize.Height * mira_scale);
            miraSize.Width = (int)(miraSize.Width * mira_scale);
            mira.Position = new Vector2(FastMath.Max(screenSize.Width / 2 - miraSize.Width / 2, 0), FastMath.Max(screenSize.Height / 2 - miraSize.Height / 2, 0));

            //Inicialización UI (Texto)
            LoadUI(screenSize);
        }