예제 #1
0
        protected void updateKeys(GameTime time)
        {
            // TODO: Add your update logic here

            var KeyBoardState = Keyboard.GetState();

            ScreenOrSelection = KeyBoardState.IsKeyDown(Keys.A);

            if (KeyBoardState.IsKeyDown(Keys.Z))
            {
                OnRequestedSceneChanged(this, SceneType.LevelSelect, null);
            }

            if (KeyBoardState.IsKeyDown(Keys.Y) && IslandMovement <= 0)
            {
                PlantTile[,] newTiles = new PlantTile[++GSV.PlantTileCountX, ++GSV.PlantTileCountY];
                for (int i = 0; i < GSV.PlantTileCountX; i++)
                {
                    for (int j = 0; j < GSV.PlantTileCountY; j++)
                    {
                        if (i < GSV.PlantTileCountX - 1 && j < GSV.PlantTileCountY - 1)
                        {
                            newTiles[i, j]             = Tiles[i, j];
                            newTiles[i, j].OldPosition = newTiles[i, j].Position;
                            newTiles[i, j].NewPosition = new Vector3((((i) * GSV.spacingX)) - (GSV.spacingX * 0.5f * GSV.PlantTileCountX), 0, (((j) * GSV.spacingY)) - (GSV.spacingY * 0.5f * GSV.PlantTileCountY));
                        }
                        else
                        {
                            newTiles[i, j]             = new PlantTile();
                            newTiles[i, j].OldPosition = new Vector3((((i - 0.5f) * GSV.spacingX)) - (GSV.spacingX * 0.5f * GSV.PlantTileCountX), 0, (((j - 0.5f) * GSV.spacingY)) - (GSV.spacingY * 0.5f * GSV.PlantTileCountY));
                            newTiles[i, j].NewPosition = new Vector3((((i) * GSV.spacingX)) - (GSV.spacingX * 0.5f * GSV.PlantTileCountX), 0, (((j) * GSV.spacingY)) - (GSV.spacingY * 0.5f * GSV.PlantTileCountY));
                            newTiles[i, j].Position    = newTiles[i, j].OldPosition;
                            Entities.Bush shrub = new Entities.Bush(ref OrderedModels);
                            //bush.Position = new Vector3(Utils.RNG.Next((int)(0.2f * Consts.spacing), (int)(0.8f * Consts.spacing)), 0, Utils.RNG.Next((int)(0.2f * Consts.spacing), (int)(0.8f * Consts.spacing)));
                            shrub.Position = newTiles[i, j].GenPositionForEntity(shrub, GSV, ref OrderedModels);

                            for (int k = 0; k != 10; k++)
                            {
                                Entities.Flower flower = new Entities.Flower(ref OrderedModels);
                                flower.Position = newTiles[i, j].GenPositionForEntity(flower, GSV, ref OrderedModels);
                                flower.ScaleObject(new Vector3(1f));
                                newTiles[i, j].EntityList.Add(flower);
                            }

                            newTiles[i, j].EntityList.Add(shrub);

                            newTiles[i, j].Terrain = new Terrain.DirtPatch();

                            newTiles[i, j].Terrain.Generate(GSV.TerrainDepth, GSV.TerrainWidth, GSV.TerrainPointSpacing, Graphics.GraphicsDevice);
                        }
                    }
                }
                IslandMovement = IslandMovingTime;
                Tiles          = newTiles;
            }
            else if (IslandMovement > 0)
            {
                IslandMovement -= (float)time.ElapsedGameTime.TotalMilliseconds;
                foreach (var b in Tiles)
                {
                    b.Position = Vector3.Lerp(b.NewPosition, b.OldPosition, IslandMovement / IslandMovingTime);
                }
            }


            if (!KeyBoardState.IsKeyDown(Keys.F) && PrevKBS.IsKeyDown(Keys.F))
            {
                Selector        = new SwingingSelector(Entities.Flower.Sprite);
                Selector.Entity = new Entities.Flower(ref OrderedModels);
            }
            if (!KeyBoardState.IsKeyDown(Keys.B) && PrevKBS.IsKeyDown(Keys.B))
            {
                Selector        = new SwingingSelector(Entities.Bush.Sprite);
                Selector.Entity = new Entities.Bush(ref OrderedModels);
            }
            if (!KeyBoardState.IsKeyDown(Keys.R) && PrevKBS.IsKeyDown(Keys.R))
            {
                Selector        = new SwingingSelector(Entities.Reed.Sprite);
                Selector.Entity = new Entities.Reed(ref OrderedModels);
            }
            if (!KeyBoardState.IsKeyDown(Keys.U) && PrevKBS.IsKeyDown(Keys.U))
            {
                Selector        = new SwingingSelector(Entities.FlowerBush.Sprite);
                Selector.Entity = new Entities.FlowerBush(ref OrderedModels);
            }
            if (!KeyBoardState.IsKeyDown(Keys.S) && PrevKBS.IsKeyDown(Keys.S))
            {
                Selector        = new SwingingSelector(Entities.Shrub.Sprite);
                Selector.Entity = new Entities.Shrub(ref OrderedModels);
            }


            if (KeyBoardState.IsKeyDown(Keys.X))
            {
                for (int i = 1; i != 100000; i++)
                {
                    var b = Math.Log10(Math.Tan(Math.Tanh(Math.Sqrt(i)))) / Math.Log10(Math.E);
                }
            }

            PrevKBS = KeyBoardState;
        }
예제 #2
0
        /// <summary>
        /// Allows the game to perform any initialization it needs to before starting to run.
        /// This is where it can query for any required services and load any non-graphic
        /// related content.  Calling base.Initialize will enumerate through any components
        /// and initialize them as well.
        /// </summary>
        public void Initialize(GraphicsDeviceManager GD)
        {
            /*//////////////////////////////////////////////////////////
             * Cam.Width = GraphicsDevice.PresentationParameters.BackBufferWidth;
             * Cam.Height = GraphicsDevice.PresentationParameters.BackBufferHeight;
             *///////////////////////////////////////////////////////////

            Tiles = new PlantTile[GSV.PlantTileCountX, GSV.PlantTileCountY];

            Graphics = GD;

            PrimitivesEffect = new BasicEffect(Graphics.GraphicsDevice);

            InitGraphics(true);

            LoadData();

            if (!CouldLoadFile)
            {
                for (int x = 0; x < GSV.PlantTileCountX; x++)
                {
                    for (int y = 0; y < GSV.PlantTileCountY; y++)
                    {
                        Tiles[x, y] = new PlantTile
                        {
                            Position = new Vector3(((x * GSV.spacingX)) - (GSV.spacingX * 0.5f * GSV.PlantTileCountX), 0, ((y * GSV.spacingY)) - (GSV.spacingY * 0.5f * GSV.PlantTileCountY))
                        };

                        Entities.Bush shrub = new Entities.Bush(ref OrderedModels);
                        //bush.Position = new Vector3(Utils.RNG.Next((int)(0.2f * Consts.spacing), (int)(0.8f * Consts.spacing)), 0, Utils.RNG.Next((int)(0.2f * Consts.spacing), (int)(0.8f * Consts.spacing)));
                        shrub.Position = Tiles[x, y].GenPositionForEntity(shrub, GSV, ref OrderedModels);

                        for (int i = 0; i != 10; i++)
                        {
                            Entities.Flower flower = new Entities.Flower(ref OrderedModels);
                            flower.Position = Tiles[x, y].GenPositionForEntity(flower, GSV, ref OrderedModels);
                            flower.ScaleObject(new Vector3(1f));
                            Tiles[x, y].EntityList.Add(flower);
                        }

                        Tiles[x, y].EntityList.Add(shrub);

                        Tiles[x, y].Terrain = new Terrain.DirtPatch();

                        Tiles[x, y].Terrain.Generate(GSV.TerrainDepth, GSV.TerrainWidth, GSV.TerrainPointSpacing, Graphics.GraphicsDevice);
                    }
                }
            }

            ////////////Water////////////


            Water = new Terrain.Water();

            Water.GenerateCircle(GSV.WaterSize, GSV.WaterSize, GSV.WaterPointSpacing, GSV.WaterRadius, Graphics.GraphicsDevice);

            Water.Update(Graphics.GraphicsDevice, GSV, null, null, null);

            //WaterWithEffect.Generate()

            HelpButton.Position = new Point(0);

            HelpButton.Scale = 1;

            EffectReloader = new EffectReloader(@"..\..\..\..\Content", @"PrimitivesEffect.fx", GD.GraphicsDevice);
            EffectReloader.OnEffectChanged += onPrimitivesEffectChanged;

            WEffect.InitShaders(@"Effects\WaterShader.fx", Graphics.GraphicsDevice);
            WaterWithEffect.GenerateCircle(GSV.WaterSize, GSV.WaterSize, GSV.WaterPointSpacing, GSV.WaterRadius, Graphics.GraphicsDevice);

            Initialized = true;
        }