/// <summary>
        /// Create terrain at <paramref name="position"/>
        /// </summary>
        /// <param name="position"></param>
        /// <param name="textures"></param>
        /// <param name="device"></param>
        /// <param name="scale"></param>
        /// <param name="Content"></param>
        /// <param name="camera"></param>
        public QuadTree(Vector3 position, List<Texture2D> textures, GraphicsDevice device, int scale, ContentManager Content, GameCamera.FreeCamera camera)
        {
            shadow = new LightsAndShadows.Shadow();
            light = new LightsAndShadows.Light(0.7f, 0.4f, new Vector3(513, 100, 513));

            ViewFrustrum = new BoundingFrustum(camera.View * camera.Projection);
             //  Model model = Content.Load<Model>("Models/stone2");
              //  this.model = new LoadModel(model, Vector3.One, Vector3.Up, new Vector3(1), device);
            this.textures = textures;
            effect = Content.Load<Effect>("Effects/MultiTextured");
            effect2 = Content.Load<Effect>("Effects/Shadows");
            Device = device;

            _position = position;
            _topNodeSize = textures[4].Width - 1;

            _vertices = new MapRender(textures[4],scale);
            _buffers = new BufferManager(_vertices.Vertices, device);
            _rootNode = new QuadNode(NodeType.FullNode, _topNodeSize, 1, null, this, 0);

            //Construct an array large enough to hold all of the indices we'll need.
            Indices = _vertices.indices;

            envBilbList.Add(new EnvBilb(textures[6], textures[5], device, Content, scale));
             foreach (EnvBilb pass in envBilbList)
            {
                pass.GenerateObjPositions(_vertices.Vertices, _vertices.TerrainWidth, _vertices.TerrainLength, _vertices.heightData);
                pass.CreateBillboardVerticesFromList();
            }

            /*
            envModelList.Add(new EnvModel(textures[6], model, device, Content, scale));

               foreach (EnvModel pass1 in envModelList)
            {
                pass1.GenerateObjPositions(_vertices.Vertices, _vertices.TerrainWidth, _vertices.TerrainLength, _vertices.heightData);
                pass1.CreateModelFromList();
            }
             * */

               effect.Parameters["xTexture0"].SetValue(textures[1]);
               effect.Parameters["xTexture1"].SetValue(textures[0]);
               effect.Parameters["xTexture2"].SetValue(textures[2]);
               effect.Parameters["xTexture3"].SetValue(textures[3]);
               effect.Parameters["xTexture5"].SetValue(textures[7]);
               Matrix worldMatrix = Matrix.Identity;
               effect.Parameters["xWorld"].SetValue(worldMatrix);
               effect.Parameters["xEnableLighting"].SetValue(true);
               effect.Parameters["xAmbient"].SetValue(light.Ambient);
               effect.Parameters["xLightPower"].SetValue(light.LightPower);

               effect.Parameters["Ground"].SetValue(textures[7]);
               effect.Parameters["GroundText0"].SetValue(textures[8]);
               effect.Parameters["GroundText1"].SetValue(textures[9]);
               effect.Parameters["GroundText2"].SetValue(textures[10]);

               _rootNode.EnforceMinimumDepth();
        }
Exemple #2
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            #region KURSORY i okno
            StaticHelpers.StaticHelper.DeviceManager = graphics;
            WindowController.window = (Form)Form.FromHandle(this.Window.Handle);
            MouseCursorController.LoadCustomCursor(@"Content/Cursors/TronNormal.ani");
            MouseCursorController.LoadCustomCursor(@"Content/Cursors/TronBusy.ani");
            MouseCursorController.LoadCustomCursor(@"Content/Cursors/TronAlternate.ani");
            MouseCursorController.LoadCustomCursor(@"Content/Cursors/gam1232.ani");

            MouseCursorController.stage = Controlers.CursorEnum.CursorStage.Normal;
            #endregion

            #region Light Shadow
            light = new LightsAndShadows.Light(0.7f, 0.4f, new Vector3(-2800, 4000, -2800));
            shadow = new LightsAndShadows.Shadow();
            LoadModelsFromFile._light = light;
            #endregion
            #region PresentationParameters
            PresentationParameters pp = graphics.GraphicsDevice.PresentationParameters;
            pp.DepthStencilFormat = DepthFormat.Depth24Stencil8;

            #endregion
            #region PointsForLaser
            pointsForLasers.Add(new List<PointInTime>());
            pointsForLasers[0].Add(new PointInTime(new Vector3(100, 40, 100), 0));
            pointsForLasers[0].Add(new PointInTime(new Vector3(1600, 40, 300), 20000));
            pointsForLasers[0].Add(new PointInTime(new Vector3(3000, 40, 260), 40000));
            pointsForLasers[0].Add(new PointInTime(new Vector3(1300, 40, 900), 60000));
            pointsForLasers[0].Add(new PointInTime(new Vector3(400, 40, 1500), 80000));
            pointsForLasers[0].Add(new PointInTime(new Vector3(1299, 40, 1900), 100000));
            pointsForLasers[0].Add(new PointInTime(new Vector3(100, 40, 3000), 120000));

            #endregion
            #region Curve
            curvesForLaser.Add(new Curve3D(pointsForLasers[0],CurveLoopType.Oscillate));
            #endregion
            #region Laser

            #endregion

            hiDefShadowEffect = Content.Load<Effect>("Effects/Shadows");
            animHiDefShadowEffect = Content.Load<Effect>("Effects/AnimatedShadow");
            device = GraphicsDevice;
            device.DepthStencilState = DepthStencilState.Default;
            shadow.RenderTarget = new RenderTarget2D(device, 4096, 4096, false, pp.BackBufferFormat, DepthFormat.Depth24Stencil8);

            spriteBatch = new SpriteBatch(GraphicsDevice);
            StaticHelpers.StaticHelper._spr_font = Content.Load<SpriteFont>("Fonts/FPS");// you have on your project

            StaticHelpers.StaticHelper.Content = Content;
            StaticHelpers.StaticHelper.Device = device;
            endGamePicture = Content.Load<Texture2D>("Textures/t³okoñcowe");
            #region Tekstury
            List<Texture2D> texture = new List<Texture2D>();
            //alphy do terenu
            texture.Add(Content.Load<Texture2D>("HeighMaps/texturemap_grass")); // alpha pomiedzy trawa 0 i trawa1
            texture.Add(Content.Load<Texture2D>("HeighMaps/texturemap_grass1")); // alpha pomiedzy 1 2
            texture.Add(Content.Load<Texture2D>("HeighMaps/texturemap_sand"));
            texture.Add(Content.Load<Texture2D>("HeighMaps/texturemap_forest_cover"));
            texture.Add(Content.Load<Texture2D>("HeighMaps/texturemap_stone")); // alpha pomiedzy 4 5
            texture.Add(Content.Load<Texture2D>("HeighMaps/texturemap_grass1")); // alpha pomiedzy 5 6
            texture.Add(Content.Load<Texture2D>("HeighMaps/texturemap_snow")); // alpha pomiedzy ciemne7 i jasne 8
            //0 - 6

            //tekstury terenu
            texture.Add(Content.Load<Texture2D>("Textures/Ground/grass0")); //
            texture.Add(Content.Load<Texture2D>("Textures/Ground/grass"));  // to mo¿na wyci¹æ
            texture.Add(Content.Load<Texture2D>("Textures/Ground/grass1")); // to mo¿na wyci¹æ
            texture.Add(Content.Load<Texture2D>("Textures/Ground/sand"));  //
            texture.Add(Content.Load<Texture2D>("Textures/Ground/forest_cover")); //
            texture.Add(Content.Load<Texture2D>("Textures/Ground/rock"));  //
            texture.Add(Content.Load<Texture2D>("Textures/Ground/dirt"));  // to mo¿na wyci¹æ
            texture.Add(Content.Load<Texture2D>("Textures/Ground/rock"));  // to mo¿na wyci¹æ
            //7 - 14
            //heighmapa terenu
            texture.Add(Content.Load<Texture2D>("HeighMaps/terrain"));
            //15
            //tekstura od zaznaczenia
            texture.Add(Content.Load<Texture2D>("Textures/select2"));
            //16
            //mapy rozmieszczenia obiektow i bilboardow (w zaleznosci ile czego bedzie to sobie pododajesz)
            texture.Add(Content.Load<Texture2D>("HeighMaps/grassMap"));
            texture.Add(Content.Load<Texture2D>("Textures/Bilboard/tree"));
            texture.Add(Content.Load<Texture2D>("HeighMaps/iguyMap"));
            texture.Add(Content.Load<Texture2D>("Textures/Bilboard/igua"));
            texture.Add(Content.Load<Texture2D>("HeighMaps/szuwaryMap"));
            texture.Add(Content.Load<Texture2D>("Textures/Bilboard/szuwary"));
            //17 - 22

            //mapy rozmieszczenia obiektow (w zaleznosci ile czego bedzie to sobie pododajesz)
            texture.Add(Content.Load<Texture2D>("HeighMaps/koamienMap"));
            texture.Add(Content.Load<Texture2D>("HeighMaps/trawaMap"));
            texture.Add(Content.Load<Texture2D>("HeighMaps/kzak1Map"));
            //23 - 25
            texture.Add(Content.Load<Texture2D>("Textures/circle"));
            #endregion

            camera = new FreeCamera(
            new Vector3(texture[4].Width * 1 / 2, texture[4].Width * 1 / 20, texture[4].Width * 1 / 2),
            MathHelper.ToRadians(0), // Turned around 153 degrees
            MathHelper.ToRadians(-45), // Pitched up 13 degrees
            GraphicsDevice);

            quadTree.Add(new QuadTree(Vector2.Zero, texture, device, 3, Content, (FreeCamera)camera));

            water = new Water(device, Content, texture[4].Width, 3);
            foreach (QuadTree q in quadTree)
            {
                q.Cull = true;
            }
            StaticHelpers.StaticHelper.heights = quadTree[0].Vertices.heightDataToControl;
            StaticHelpers.StaticHelper.width = (int)Math.Sqrt(quadTree[0].Vertices.heightDataToControl.Length);
            StaticHelpers.StaticHelper.length = (int)Math.Sqrt(quadTree[0].Vertices.heightDataToControl.Length);

            PathFinderManager.PathFinderManagerInitialize(128);

            #region loadFromFile

            Controlers.LoadModelsFromFile.Load();
            foreach (InteractiveModel i in LoadModelsFromFile.listOfAllInteractiveModelsFromFile)
            {

                // Console.WriteLine(models.GetType().BaseType.Name);
                if (i.GetType().BaseType == typeof(Building) || i.GetType().BaseType == typeof(Material) || i.GetType().BaseType == typeof(EnviroModels) || i.GetType().BaseType==typeof(AllieBuilding))
                {

                    IModel.Add(i);
                }
                else
                {
                    if (i.GetType() == typeof(Beetle))
                    {
                        ((Beetle)i).Ants = models;
                        ((Beetle)i).removeMyself();
                    }
                    else if (i.GetType() == typeof(Spider))
                    {
                        ((Spider)i).Ants = models;
                        ((Spider)i).removeMyself();

                    }
                    models.Add(i);
                }
            }
            #endregion
            PathFinderManager.blockAllNodes(IModel);
            //for (int i = 0; i < PathFinderManager.GridSize; i += 1)
            //{
            //    for (int J = 0; J < PathFinderManager.GridSize; J += 1)
            //    {
            //        if (PathFinderManager.tileList[i, J].walkable == false || PathFinderManager.tileList[i, J].haveMineral == true || PathFinderManager.tileList[i, J].haveBuilding == true)
            //        {
            //            inter.Add(new InteractiveModel(new LoadModel(Content.Load<Model>("Models/log2"),new Vector3(PathFinderManager.tileList[i,J].centerPosition.X,StaticHelpers.StaticHelper.GetHeightAt(PathFinderManager.tileList[i,J].centerPosition.X,PathFinderManager.tileList[i,J].centerPosition.Y),PathFinderManager.tileList[i,J].centerPosition.Y),Vector3.Zero,new Vector3(1f,0.3f,1f),device,light)));
            //        }
            //    }
            //}

            /////////////// nie wiem czy to powinno byæ czy nie wiêc zakomentowa³em tylko
            //
            //            mapR = new MapRender(texture[15], 3);
            //            Console.WriteLine(GraphicsDevice.Viewport.Bounds);

            //e.Ant = models[0];
            // e.Enemy = spider;
            //  e.Ants = Enemys;

            WindowController.setWindowSize(1366, 768, false);
            //models.Add(new AntPeasant(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models/mrowka_01"), Vector3.Zero, Vector3.Zero, new Vector3(0.3f), StaticHelpers.StaticHelper.Device, light)));
            // models.Add(new TownCenter(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models/domek"), Vector3.Zero, Vector3.Zero, new Vector3(0.23f), StaticHelpers.StaticHelper.Device, light)));
            ////models.Add(new Queen(new LoadModel(StaticHelpers.StaticHelper.Content.Load<Model>("Models/grasshopper"), new Vector3(300,40,300), Vector3.Zero, new Vector3(0.23f), StaticHelpers.StaticHelper.Device, StaticHelpers.StaticHelper.Content,light)));
            ////models[models.Count - 1].Model.switchAnimation("Idle");

            List<String> aa = new List<string>();
            aa.Add("s1");
            aa.Add("s2");
            aa.Add("Gater");
            SoundController.SoundController.content = Content;
            SoundController.SoundController.Initialize(aa);

            List<String> PlayList = new List<string>();
            PlayList.Add("Kwai");
            PlayList.Add("MarketGarden");
            PlayList.Add("Escape");
            SoundController.SoundController.InitializeBackground(PlayList);

            // models[models.Count - 1].Model.switchAnimation("Idle");

            // models.Add(new Cancer(new LoadModel(Content.Load<Model>("Models/crab"), new Vector3(0, 40, 0), new Vector3(0), new Vector3(0.4f), GraphicsDevice,  light), models));

              models.Add(new Cancer(new LoadModel(Content.Load<Model>("Models/crab"), new Vector3(1375, 40, 2500), new Vector3(0), new Vector3(0.4f), GraphicsDevice, Content, light), models));

              models[models.Count - 1].Model.switchAnimation("Idle");

             models.Add(new SunDew(new LoadModel(Content.Load<Model>("Models/rosiczka"), new Vector3(1574, 40, 2100), new Vector3(0), new Vector3(0.8f), GraphicsDevice, Content, light), models));
            models[models.Count - 1].Model.switchAnimation("Idle");
            models.Add(new SunDew(new LoadModel(Content.Load<Model>("Models/rosiczka"), new Vector3(2400, 40, 805), new Vector3(0), new Vector3(0.8f), GraphicsDevice, Content, light), models));
            models[models.Count - 1].Model.switchAnimation("Idle");
            models.Add(new SunDew(new LoadModel(Content.Load<Model>("Models/rosiczka"), new Vector3(1700, 40, 1111), new Vector3(0), new Vector3(0.8f), GraphicsDevice, Content, light), models));
            models[models.Count - 1].Model.switchAnimation("Idle");
            // models.Add(new Spider(new LoadModel(Content.Load<Model>("Models/spider"), new Vector3(250, 40, 250), new Vector3(0), new Vector3(0.4f), GraphicsDevice, Content, light), models));
            // models[models.Count - 1].Model.switchAnimation("Idle");

            ////models.Add(new Grasshopper(new LoadModel(Content.Load<Model>("Models/grasshopper"), new Vector3(50, 40, 50), new Vector3(0), new Vector3(0.4f), GraphicsDevice, Content, light), models));
            ////models[models.Count - 1].Model.switchAnimation("Idle");

            // models.Add(new StrongAnt(new LoadModel(Content.Load<Model>("Models/strongAnt"),new Vector3(120,40,20),new Vector3(0),new Vector3(0.4f),GraphicsDevice,Content,light)));
            //// models[models.Count - 1].Model.switchAnimation("Idle");

            // models.Add(new AntPeasant(new LoadModel(Content.Load<Model>("Models/ant"), new Vector3(100, 40, 10), new Vector3(0), new Vector3(0.4f), GraphicsDevice, Content, light)));

               // Console.WriteLine("QuadNode: " + QuadNodeController.QuadNodeList.Count);

            BBoxRender.InitializeBBoxDebuger(device);

               // IModel.Add(new BeetleBuilding(new LoadModel(Content.Load<Model>("Models/h4"), new Vector3(700, 60, 900), new Vector3(0), new Vector3(0.4f), GraphicsDevice, light)));
              //  IModel.Add(new GrassHopperBuilding(new LoadModel(Content.Load<Model>("Models/h3"), new Vector3(900, 40, 1100), new Vector3(0), new Vector3(0.4f), GraphicsDevice, light)));

            Console.WriteLine(QuadNodeController.QuadNodeList2.Count);

            #region trigger end game
            theEnd = new Trigger((new LoadModel(Content.Load<Model>("Models/endNode"), new Vector3(1375, 40, 2500), new Vector3(0), new Vector3(4f), GraphicsDevice, light)));
            IModel.Add(theEnd);
            #endregion

            IModel.Add(new Laser((new LoadModel(Content.Load<Model>("Models/laser"), new Vector3(0, 40, 0), new Vector3(0), new Vector3(2f), GraphicsDevice, light)), curvesForLaser[0]));
            timeTriggers.Add(new LaserTrigger((Laser)IModel[IModel.Count - 1], 100));

            control = new Logic.Control(texture[11], quadTree[0]);
            gui = new MainGUI(StaticHelpers.StaticHelper.Content, control,models);

            control.Models_Colision = IModel;

            Player.addMaterial(new Wood(),200);
            Player.addMaterial(new Stone(), 200);
            Player.addMaterial(new Hyacynt(), 200);
            Player.addMaterial(new Dicentra(), 200);
            Player.addMaterial(new Chelidonium(), 200);

            miniMap = new MiniMap(models);
            foreach(InteractiveModel m in IModel) {
                if (m is Laser || m is GrassHopperBuilding || m is BeetleBuilding)
                    miniMap.addObjects(m);
                }
            intro = new List<Texture2D>();
            intro.Add( Content.Load<Texture2D>("Textures/1"));
            intro.Add(Content.Load<Texture2D>("Textures/2"));
            intro.Add(Content.Load<Texture2D>("Textures/3"));
            intro.Add(Content.Load<Texture2D>("Textures/4"));

            _intro = intro[0];
        }