Beispiel #1
0
        public AI(Vehicle vehicle, int theLevel, int randomSeed)
        {
            this.vehicle = vehicle;
            level = theLevel;

            rand = new Random(randomSeed);

            IsTurning = false;
            dir = "NORTH";
            interDone = true;

            prevInterX = 0;
            prevInterZ = 0;
            prevXZ = false;
        }
Beispiel #2
0
        private void DrawModel(Vehicle vehicle)
        {
            Model vModel = vehicle.GetModel();
            Texture2D vTex = vehicle.GetTexture();
            Vector3 vPos = vehicle.GetPosition();
            Quaternion vRot = vehicle.GetRotation();

            Matrix worldMatrix = Matrix.CreateScale(0.05f, 0.05f, 0.05f) * Matrix.CreateRotationY(MathHelper.Pi) * Matrix.CreateFromQuaternion(vRot) * Matrix.CreateTranslation(vPos);
            Matrix[] xwingTransforms = new Matrix[vModel.Bones.Count];
            vModel.CopyAbsoluteBoneTransformsTo(xwingTransforms);

            foreach (ModelMesh mesh in vModel.Meshes)
            {
                foreach (Effect currentEffect in mesh.Effects)
                {
                    currentEffect.CurrentTechnique = currentEffect.Techniques["Textured"];
                    currentEffect.Parameters["World"].SetValue(xwingTransforms[mesh.ParentBone.Index] * worldMatrix);
                    currentEffect.Parameters["View"].SetValue(viewMatrix);
                    currentEffect.Parameters["Projection"].SetValue(projectionMatrix);
                    currentEffect.Parameters["EnableLighting"].SetValue(true);
                    currentEffect.Parameters["LightDirection"].SetValue(lightDirection);
                    currentEffect.Parameters["Ambient"].SetValue(0.5f);
                    currentEffect.Parameters["xTexture"].SetValue(vTex);
                }

                mesh.Draw();
            }
        }
Beispiel #3
0
        protected override void LoadContent()
        {
            device = graphics.GraphicsDevice;
            rand = new Random();
            buildingCreator = new BuildingCreator();
            effects = Content.Load<Effect>("Effects");
            lamModel = LoadModel("Lamborghini");
            lamTex = Content.Load<Texture2D>("Lamburghini");
            ferTex = Content.Load<Texture2D>("FerrariPIC");
            retTex = Content.Load<Texture2D>("txRFCar1");
            buildingTex1 = Content.Load<Texture2D>("buildingTex1");
            buildingTex2 = Content.Load<Texture2D>("buildingTex2");
            buildingTex3 = Content.Load<Texture2D>("buildingTex3");
            buildingTex4 = Content.Load<Texture2D>("buildingTex4");
            buildingTex5 = Content.Load<Texture2D>("buildingTex5");
            buildingTex6 = Content.Load<Texture2D>("brickTex");
             //       combBuildTex = Content.Load<Texture2D>("combBuildTex");
            roofTex1 = Content.Load<Texture2D>("roofTex1");
            mapTex = Content.Load<Texture2D>("map");
            yellowSq = Content.Load<Texture2D>("yellowSquare");
            redSq = Content.Load<Texture2D>("redSquare");
            streetTexture = Content.Load<Texture2D>("streetTex");
            winTex = Content.Load<Texture2D>("winnerScreen");
            loseTex = Content.Load<Texture2D>("loserScreen");

            Quaternion rotation = Quaternion.Identity;
            rotation = rotation * Quaternion.CreateFromAxisAngle(new Vector3(0, 1, 0), -MathHelper.Pi);

            playerVehicle = new Vehicle(lamModel, lamTex, new Vector3(1.5f, 0.04f, -2.5f), rotation, 0.0002f, 0.001f, 0.012f, 0.1f);
            AIs = new AI[2];
            AIs[0] = new AI(new Vehicle(lamModel, ferTex, new Vector3(1.25f, 0.04f, -3.0f), rotation, 0.00017f, 0.001f, 0.0065f, 0.076f), 0, DateTime.Now.Second % 3);
            AIs[1] = new AI(new Vehicle(lamModel, retTex, new Vector3(1.25f, 0.04f, -2.5f), rotation, 0.000165f, 0.001f, 0.0065f, 0.076f), 0, DateTime.Now.Second % 7);

            buildingVertexBuffer = new VertexBuffer[6];
            buildingVertexDeclaration = new VertexDeclaration[6];
            SetUpVertices();
            buildings = buildingCreator.CreateBuildings();
            SetUpBuildings();

            //        map = new Map();
             //       map.SetUpMap(playerVehicle.GetPosition(), device);

            screenWidth = device.PresentationParameters.BackBufferWidth;
            screenHeight = device.PresentationParameters.BackBufferHeight;

            GenerateRaceEndLocation();
            SetUpEndLocationVertices(raceEnd.getX(), raceEnd.getY());
            SetUpBoundingBoxes();
            UpdateBoundingBoxes();

            spriteBatch = new SpriteBatch(GraphicsDevice);
        }