Exemplo n.º 1
0
        public void createTrees(int count, int maxRadius)
        {
            var baseSize = Tree.baseSize;

            var maxValue = (int)(maxRadius - 2 * baseSize / terrain.ScaleXZ);
            var randomizer = new Randomizer(5, maxValue);

            for (var i = 1; i < count; i++) {
                var offsetX = randomizer.getNext();
                var offsetZ = randomizer.getNext();

                var adjust = (int)(maxRadius + baseSize / terrain.ScaleXZ);
                var offsetY = terrain.getYValueFor(offsetX + adjust - 100, offsetZ + adjust - 100);

                var initialPosition = new Vector3(offsetX * terrain.ScaleXZ, offsetY * terrain.ScaleY, offsetZ * terrain.ScaleXZ);

                var newTree = Tree.create(initialPosition,terrain);
                newTree.mesh.rotateY(offsetX);

                this.addTree(newTree);
            }
        }
Exemplo n.º 2
0
 private void recalc()
 {
     Randomizer rand = new Randomizer(-200, 200);
     destination.X = Position.X + rand.getNext();
     destination.Z = Position.Z + rand.getNext();
     iddle = true;
     avoiding = true;
 }
Exemplo n.º 3
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);
        }