Пример #1
0
 /// <summary>
 /// Build the CPPN activation functions.
 /// </summary>
 /// <param name="activationFunctions">The activation functions collection to add to.</param>
 public static void BuildCPPNActivationFunctions(
     ChooseObject <IActivationFunction> activationFunctions)
 {
     activationFunctions.Add(0.25, new ActivationClippedLinear());
     activationFunctions.Add(0.25, new ActivationBipolarSteepenedSigmoid());
     activationFunctions.Add(0.25, new ActivationGaussian());
     activationFunctions.Add(0.25, new ActivationSIN());
     activationFunctions.FinalizeStructure();
 }
 /// <summary>
 /// Build the CPPN activation functions.
 /// </summary>
 /// <param name="activationFunctions">The activation functions collection to add to.</param>
 public static void BuildCPPNActivationFunctions(
         ChooseObject<IActivationFunction> activationFunctions)
 {
     activationFunctions.Add(0.25, new ActivationClippedLinear());
     activationFunctions.Add(0.25, new ActivationBipolarSteepenedSigmoid());
     activationFunctions.Add(0.25, new ActivationGaussian());
     activationFunctions.Add(0.25, new ActivationSIN());
     activationFunctions.FinalizeStructure();
 }
Пример #3
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            KeyMouseReader.Update();
            if (KeyMouseReader.RightClick())
            {
                camera.Update(new Vector2(KeyMouseReader.mouseState.X - camera.CameraPos.X, KeyMouseReader.mouseState.Y - camera.CameraPos.Y));
            }
            grid.Update(new Vector2(KeyMouseReader.mouseState.X, KeyMouseReader.mouseState.Y));
            if (navigateTabs == NavigationTabs.ChooseObject)
            {
                if (chooseObject == ChooseObject.Player)
                {
                    grid.tileType = TileGrid.TileType.AddPlayer;
                }
                else if (chooseObject == ChooseObject.Wall)
                {
                    grid.tileType = TileGrid.TileType.AddWall;
                }
                else if (chooseObject == ChooseObject.Teleport)
                {
                    grid.tileType = TileGrid.TileType.AddTeleport;
                }
                else if (chooseObject == ChooseObject.EnemySpawner)
                {
                    grid.tileType = TileGrid.TileType.AddSpawner;
                }
                else if (chooseObject == ChooseObject.Pistol)
                {
                    grid.tileType = TileGrid.TileType.AddPistol;
                }
            }
            hud.Update(camera.CameraPos);

            if (navigateTabs == NavigationTabs.SetGrid)
            {
                SetGrid();
            }
            else if (navigateTabs == NavigationTabs.ChooseTool && chooseTool == ChooseTools.SaveLevel)
            {
                grid.SaveToJsonFile();
                Console.WriteLine("SAVED");
                chooseTool   = ChooseTools.AddTiles;
                hud.selected = 0;
            }

            switch (navigateTabs)
            {
            case NavigationTabs.ChooseTool:
                if (KeyMouseReader.KeyPressed(Keys.Escape))
                {
                    navigateTabs = NavigationTabs.SetGrid;
                }

                if (KeyMouseReader.KeyPressed(Keys.Enter))
                {
                    if (hud.selected == 0)
                    {
                        chooseTool   = ChooseTools.AddTiles;
                        navigateTabs = NavigationTabs.ChooseCategory;
                    }
                    else if (hud.selected == 1)
                    {
                        chooseTool = ChooseTools.RemoveTiles;
                    }
                    else if (hud.selected == 2)
                    {
                        chooseTool = ChooseTools.SaveLevel;
                    }
                    hud.selected = 0;
                }
                break;

            case NavigationTabs.ChooseCategory:
                if (KeyMouseReader.KeyPressed(Keys.Escape))
                {
                    navigateTabs = NavigationTabs.ChooseTool;
                }

                if (KeyMouseReader.KeyPressed(Keys.Enter))
                {
                    if (hud.selected == 0)
                    {
                        chooseCategory = ChooseCategory.Characters;
                    }
                    else if (hud.selected == 1)
                    {
                        chooseCategory = ChooseCategory.Environment;
                    }
                    else if (hud.selected == 2)
                    {
                        chooseCategory = ChooseCategory.Weapons;
                    }
                    hud.selected = 0;
                    navigateTabs = NavigationTabs.ChooseObject;
                }
                break;

            case NavigationTabs.ChooseObject:
                if (KeyMouseReader.KeyPressed(Keys.Escape))
                {
                    navigateTabs = NavigationTabs.ChooseCategory;
                }

                if (KeyMouseReader.KeyPressed(Keys.Enter))
                {
                    if (chooseCategory == ChooseCategory.Characters)
                    {
                        if (hud.selected == 0)
                        {
                            chooseObject = ChooseObject.Player;
                        }
                        else if (hud.selected == 1)
                        {
                            chooseObject = ChooseObject.EnemySpawner;
                        }
                        else if (hud.selected == 2)
                        {
                            chooseObject = ChooseObject.Enemy;
                        }
                    }
                    else if (chooseCategory == ChooseCategory.Environment)
                    {
                        if (hud.selected == 0)
                        {
                            chooseObject = ChooseObject.Wall;
                        }
                        else if (hud.selected == 1)
                        {
                            chooseObject = ChooseObject.Teleport;
                        }
                    }
                    else if (chooseCategory == ChooseCategory.Weapons)
                    {
                        if (hud.selected == 0)
                        {
                            chooseObject = ChooseObject.Pistol;
                        }
                    }
                }
                break;
            }

            // TODO: Add your update logic here

            base.Update(gameTime);
        }