Example #1
0
        public TankPlayer(Vector3 initialPosition, Terrain.Terrain terrain, string scenePath)
            : base(initialPosition, terrain, scenePath)
        {
            var loader = new TgcSceneLoader { MeshFactory = new MeshShaderFactory() };
            var turretScene = loader.loadSceneFromFile(Path.Turret);
            this.turret = turretScene.Meshes[0];
            this.turretAngle = 0;

            this.turret.AutoUpdateBoundingBox = this.turret.AutoTransformEnable = false;
        }
Example #2
0
        /// <summary>Código de inicialización: cargar modelos, texturas, modifiers, uservars, etc.</summary>
        public override void init()
        {
            var d3dDevice = Gui.I.D3dDevice;

            this.terrain = new Terrain.Terrain(SCALE_XZ, SCALE_Y);

            var tankY = this.terrain.heightmapData[64, 64] * SCALE_Y;
            this.tank = new Tank.TankPlayer(new Vector3(0, tankY + 15, 0), this.terrain, Path.Tank);

            var rand = new Randomizer((int)-this.terrain.heightmapSizeScaled/2 + 500, (int)this.terrain.heightmapSizeScaled/2 - 500);
            this.tankEnemy = new Tank.TankEnemy(new Vector3(rand.getNext(), tankY + 15, rand.getNext()), this.terrain);

            this.tank.enemy = this.tankEnemy;
            this.tankEnemy.enemy = this.tank;

            Gui.I.Modifiers.addFloat("Cam Velocity", 0f, 1000f, 500f);
            Gui.I.Modifiers.addFloat("rotationVelocity", 0f, 1000f, 100f);
            Gui.I.Modifiers.addBoolean("ShowBoundingBox", "Show bounding box", false);
            object[] values = {"Third Person","First Person(Free)" };
            Gui.I.Modifiers.addInterval("Camera", values, 0);

            UserVars.addMany(
                "posX",
                "posY",
                "posZ",
                "viewX",
                "viewY",
                "viewZ",
                "destX",
                "destY",
                "destZ",
                "totalSpeed",
                "direction",
                "enemyColliding",
                "enemyAvoiding",
                "enemyTA"
            );

            //Aumentar distancia del far plane
            d3dDevice.Transform.Projection = Matrix.PerspectiveFovLH(Geometry.DegreeToRadian(45.0f),
                (float)d3dDevice.CreationParameters.FocusWindow.Width / d3dDevice.CreationParameters.FocusWindow.Height, 1f, 30000f);
            this.setUpCamera();

            //Carga del sonido ambiente
            this.ambientSound = new TgcStaticSound();
            this.ambientSound.loadSound(Shared.MediaFolder + @"Sound\ambient.wav");
            this.ambientSound.play(true);
        }