Ejemplo n.º 1
0
        public override void HandleInput(InputHelper input, Microsoft.Xna.Framework.GameTime gameTime)
        {
            supers.Clear();
#if WINDOWS
            var surfacetouches = input.SurfaceTouches;
            if (surfacetouches.Count > 0)
            {
                //Surface
                for (int i = 0; i < surfacetouches.Count; i++)
                {
                    Vector2 position = Camera.ConvertScreenToWorldAndDisplayUnits(new Vector2(surfacetouches[i].X, surfacetouches[i].Y));

                    supers[i] = new Individual(i, ((double)position.X),
                                               ((double)position.Y),
                                               0.0, 0.0, new Parameters());
                }
            }
            else
#endif
            if (input.Touches.Count > 0)
            {
                //Everthing else touch
                for (int i = 0; i < input.Touches.Count; i++)
                {
                    Vector2 position = Camera.ConvertScreenToWorldAndDisplayUnits(new Vector2(input.Touches[i].Position.X, input.Touches[i].Position.Y));

                    supers[i] = new Individual(i, ((double)position.X),
                                               ((double)position.Y),
                                               0.0, 0.0, new SuperParameters());
                }
            }
            else if (supers.Count <= 0 &&
                     (input.Cursor != Vector2.Zero) &&
                     input.MouseState.LeftButton == ButtonState.Pressed)
            {
                //Mouse
                supers.Add(0, new Individual());
                for (int i = 0; i < supers.Count; i++)
                {
                    Vector2 position = Camera.ConvertScreenToWorldAndDisplayUnits(input.Cursor);

                    supers[i] = new Individual(i, ((double)position.X),
                                               ((double)position.Y),
                                               0, 0, new SuperParameters());
                }
            }

            if (input.IsNewKeyPress(Keys.A))
            {
                controlClient.ToggleAnalyze();
            }

            if (input.IsNewKeyPress(Keys.C))
            {
                debugComponent.SetVisiblity();
            }

            ButtonSection.HandleInput(input, gameTime);
            base.HandleInput(input, gameTime);
        }
Ejemplo n.º 2
0
        public void HandleInput(ScreenSystem.ScreenSystem.InputHelper input, GameTime gameTime)
        {
            // Mouse or touch on a menu item
            int hoverIndex = GetMenuEntryAt(input.Cursor);

            if (hoverIndex >= 0)
            {
                selectedEntry = hoverIndex;
                //debugScreen.AddDebugItem("BUTTON HOVER", "Index " + hoverIndex, XnaSwarmsData.Debug.DebugFlagType.Important);
            }
            else
            {
                selectedEntry = -1;
            }

            // Accept or cancel the menu?
            if (input.IsMenuSelect() && selectedEntry != -1)
            {
                if (menuEntries[selectedEntry].IsStable())
                {
                    controlClient.CreateStableSwarm();
                }
                else if (menuEntries[selectedEntry].IsMutationGame())
                {
                    controlClient.CreateMutationSwarm();
                }
                else if (menuEntries[selectedEntry].IsZoomIn())
                {
                    controlClient.ZoomIn();
                }
                else if (menuEntries[selectedEntry].IsZoomOut())
                {
                    controlClient.ZoomOut();
                }
                else if (menuEntries[selectedEntry].IsDebugger())
                {
                    debugScreen.SetVisiblity();
                }
                else if (menuEntries[selectedEntry].IsSave())
                {
                    SaveSwarm(controlClient.SaveWorld());
                    UpdateLikedItemsUI();
                }
                else if (menuEntries[selectedEntry].IsRecall1())
                {
                    allLikedItems[0].SaveWorldParameters = controlClient.SaveWorld();
                    controlClient.UpdatePopulation(allLikedItems[0], false);
                }
                else if (menuEntries[selectedEntry].IsRecall2())
                {
                    allLikedItems[1].SaveWorldParameters = controlClient.SaveWorld();
                    controlClient.UpdatePopulation(allLikedItems[1], false);
                }
                else if (menuEntries[selectedEntry].IsRecall3())
                {
                    allLikedItems[2].SaveWorldParameters = controlClient.SaveWorld();
                    controlClient.UpdatePopulation(allLikedItems[2], false);
                }
                else if (menuEntries[selectedEntry].IsRecall4())
                {
                    allLikedItems[3].SaveWorldParameters = controlClient.SaveWorld();
                    controlClient.UpdatePopulation(allLikedItems[3], false);
                }
                else if (menuEntries[selectedEntry].IsRecall5())
                {
                    allLikedItems[4].SaveWorldParameters = controlClient.SaveWorld();
                    controlClient.UpdatePopulation(allLikedItems[4], false);
                }
                else if (menuEntries[selectedEntry].IsRecall6())
                {
                    allLikedItems[5].SaveWorldParameters = controlClient.SaveWorld();
                    controlClient.UpdatePopulation(allLikedItems[5], false);
                }
                else if (menuEntries[selectedEntry].IsAudioPlay())
                {
                    controlClient.StartSoundEngine();
                }
                else if (menuEntries[selectedEntry].IsAudioPause())
                {
                    controlClient.StopSoundEngine();
                }
                else if (menuEntries[selectedEntry].IsAnalyze())
                {
                    controlClient.ToggleAnalyze();
                }

#if NETFX_CORE
                else if (menuEntries[selectedEntry].IsImportLikes())
                {
                    ImportSwarmSaveData();
                }
                else if (menuEntries[selectedEntry].IsExportLikes())
                {
                    ExportSwarmSaveData();
                }
#endif
            }
        }