コード例 #1
0
        public override void Load()
        {
            SelectableImage videoSettings = new SelectableImage(Assets.GetTexture("HUDVideoSettingsBase"), Assets.GetTexture("HUDVideoSettingsSelected"), new Vector2(150, 150), scale: 0.25f);

            videoSettings.OnClick = () =>
            {
                SceneManager.StartScene("VideoSettings");
            };

            SelectableImage audioSettings = new SelectableImage(Assets.GetTexture("HUDAudioSettingsBase"), Assets.GetTexture("HUDAudioSettingsSelected"), new Vector2(150, 200), scale: 0.25f);

            audioSettings.OnClick = () =>
            {
                SceneManager.StartScene("AudioSettings");
            };

            SelectableImage back = new SelectableImage(Assets.GetTexture("HUDBackBase"), Assets.GetTexture("HUDBackSelected"), new Vector2(150, 250), scale: 0.25f);

            back.OnClick = () =>
            {
                if (LD48Game.WasGameStarted)
                {
                    SceneManager.StartScene("PauseMenu");
                }
                else
                {
                    SceneManager.StartScene("MainMenu");
                }
            };

            UI.AddUIElement(videoSettings);
            //UI.AddUIElement(audioSettings);
            UI.AddUIElement(back);
        }
コード例 #2
0
        public override void Load()
        {
            Image newGame = new Image(Assets.GetTexture("HUDWinningBase"), new Vector2(250, 150), scale: 0.25f);

            SelectableImage quit = new SelectableImage(Assets.GetTexture("HUDQuitBase"), Assets.GetTexture("HUDQuitSelected"), new Vector2(450, 300), scale: 0.25f);

            quit.OnClick = Config.ExitAction;

            UI.AddUIElement(newGame);
            UI.AddUIElement(quit);

            UI.AddUIElement(newGame);
        }
コード例 #3
0
        public override void Load()
        {
            Image lostMessage = new Image(Assets.GetTexture("HUDLost"), new Vector2(250, 150), scale: 0.25f);

            SelectableImage restart = new SelectableImage(Assets.GetTexture("HUDRestartBase"), Assets.GetTexture("HUDWRestartSelected"), new Vector2(250, 250), scale: 0.25f);

            restart.OnClick = () =>
            {
                SceneManager.LoadScene("Level_1");
            };

            SelectableImage quit = new SelectableImage(Assets.GetTexture("HUDQuitBase"), Assets.GetTexture("HUDQuitSelected"), new Vector2(250, 350), scale: 0.25f);

            quit.OnClick = Config.ExitAction;

            UI.AddUIElement(lostMessage);
            //UI.AddUIElement(restart);
            UI.AddUIElement(quit);
        }
コード例 #4
0
ファイル: StarSystemScene.cs プロジェクト: weshec/Stareater
        public StarSystemScene(Action systemClosedHandler)
        {
            this.systemClosedHandler = systemClosedHandler;

            this.siteView = new ConstructionSiteView();
            this.siteView.Position.ParentRelative(0, -1);

            this.emptyPlanetView = new EmptyPlanetView(this.setupColonizationMarkers);
            this.emptyPlanetView.Position.ParentRelative(0, -1);

            this.starSelector = new SelectableImage <int>(StarSystemController.StarIndex)
            {
                ForgroundImage = GalaxyTextures.Get.SystemStar,
                SelectorImage  = GalaxyTextures.Get.SelectedStar,
                SelectCallback = select,
                Padding        = 24,
            };
            starSelector.Position.FixedSize(400, 400).RelativeTo(this.StarAnchor);
            this.AddElement(starSelector);
        }
コード例 #5
0
        public StarSystemScene(Action systemClosedHandler)
        {
            this.systemClosedHandler = systemClosedHandler;

            this.siteView = new ConstructionSiteView();
            this.siteView.Position.ParentRelative(0, -1);

            this.emptyPlanetView = new EmptyPlanetView(this.setupColonizationMarkers);
            this.emptyPlanetView.Position.ParentRelative(0, -1);

            var context      = LocalizationManifest.Get.CurrentLanguage["FormMain"];
            var returnButton = new GuiButton
            {
                ClickCallback    = systemClosedHandler,
                BackgroundHover  = new BackgroundTexture(GalaxyTextures.Get.ButtonHover, 9),
                BackgroundNormal = new BackgroundTexture(GalaxyTextures.Get.ButtonNormal, 9),
                Padding          = 12,
                Text             = context["Return"].Text(),
                TextColor        = Color.Black,
                TextHeight       = 20
            };

            returnButton.Position.WrapContent().Then.ParentRelative(1, 1).WithMargins(10, 5);
            this.AddElement(returnButton);

            var starAnchor = new GuiAnchor(0, 0);

            this.AddAnchor(starAnchor);

            this.starSelector = new SelectableImage <int>(StarSystemController.StarIndex)
            {
                ForgroundImage = GalaxyTextures.Get.SystemStar,
                SelectorImage  = GalaxyTextures.Get.SelectedStar,
                SelectCallback = select,
                Padding        = 24,
            };
            starSelector.Position.FixedSize(400, 400).RelativeTo(starAnchor);
            this.AddElement(starSelector);
        }
コード例 #6
0
        protected void Page_LoadComplete(object obj, EventArgs e)
        {
            string root = Server.MapPath("~");
            string dir  = Request.QueryString["album"];

            divImages.Controls.Clear();
            if (dir != null)
            {
                string[] images = Directory.GetFiles(root + "Albums/" + dir);
                for (int i = 0; i < images.Length; i++)
                {
                    SelectableImage si = LoadControl("~/User Control/SelectableImage.ascx") as SelectableImage;
                    si.WidthClass    = "col-md-6";
                    si.SelectorClass = "selectorClass";
                    si.FilePath      = images[i];
                    images[i]        = "~/" + images[i].Substring(root.Length);
                    images[i]        = images[i].Replace('\\', '/');
                    si.ImageUrL      = images[i];
                    si.Name          = images[i].Split('/').Last();
                    divImages.Controls.Add(si);
                }
            }
        }
コード例 #7
0
        public override void Load()
        {
            SelectableImage continueGame = new SelectableImage(Assets.GetTexture("HUDContinueBase"), Assets.GetTexture("HUDContinueSelected"), new Vector2(150, 150), scale: 0.25f);

            continueGame.OnClick = () =>
            {
                SceneManager.StartScene("Level_1");
            };

            SelectableImage settings = new SelectableImage(Assets.GetTexture("HUDSettingsBase"), Assets.GetTexture("HUDSettingsSelected"), new Vector2(150, 200), scale: 0.25f);

            settings.OnClick = () =>
            {
                SceneManager.StartScene("Settings");
            };

            SelectableImage quit = new SelectableImage(Assets.GetTexture("HUDQuitBase"), Assets.GetTexture("HUDQuitSelected"), new Vector2(150, 250), scale: 0.25f);

            quit.OnClick = Config.ExitAction;

            UI.AddUIElement(quit);
            UI.AddUIElement(continueGame);
            UI.AddUIElement(settings);
        }
コード例 #8
0
        public void SetStarSystem(StarSystemController controller, PlayerController playerController)
        {
            this.controller    = controller;
            this.currentPlayer = playerController;

            this.maxOffset = (controller.Planets.Count() + 1) * OrbitStep + OrbitOffset;

            var bestColony = controller.Planets.
                             Select(x => controller.PlanetsColony(x)).
                             Aggregate(
                (ColonyInfo)null,
                (prev, next) => next == null || (prev != null && prev.Population >= next.Population) ? prev : next
                );

            this.originOffset      = bestColony != null ? bestColony.Location.Position * OrbitStep + OrbitOffset : 0.5f;
            this.lastMousePosition = null;

            this.starSelector.ForgroundImageColor = controller.HostStar.Color;
            this.starSelector.Select();

            foreach (var anchor in this.planetAnchors)
            {
                this.RemoveAnchor(anchor);
            }
            this.planetAnchors.Clear();

            foreach (var element in this.planetSelectors.Values.Concat(this.colonizationMarkers.Values).Concat(this.otherPlanetElements))
            {
                this.RemoveElement(element);
            }
            this.planetSelectors.Clear();
            this.colonizationMarkers.Clear();
            this.otherPlanetElements.Clear();

            var traitGridBuilder = new GridPositionBuilder(2, 20, 20, 3);

            foreach (var trait in controller.HostStar.Traits)
            {
                var traitImage = new GuiImage
                {
                    Below   = this.starSelector,
                    Image   = GalaxyTextures.Get.Sprite(trait.ImagePath),
                    Tooltip = new SimpleTooltip("Traits", trait.LangCode)
                };
                traitImage.Position.FixedSize(20, 20).RelativeTo(this.starSelector, 0.8f, -0.8f, -1, 1).WithMargins(3, 0);
                traitGridBuilder.Add(traitImage.Position);
                this.addPlanetElement(traitImage);
            }

            foreach (var planet in this.controller.Planets)
            {
                var anchor = new GuiAnchor(planet.Position * OrbitStep + OrbitOffset, 0);
                this.AddAnchor(anchor);
                this.planetAnchors.Add(anchor);

                var planetSelector = new SelectableImage <int>(planet.Position)
                {
                    ForgroundImage = GalaxyTextures.Get.PlanetSprite(planet.Type),
                    SelectorImage  = GalaxyTextures.Get.SelectedStar,
                    SelectCallback = select,
                    Padding        = 16,
                };
                planetSelector.Position.FixedSize(100, 100).RelativeTo(anchor);
                planetSelector.GroupWith(starSelector);
                this.planetSelectors[planet.Position] = planetSelector;
                this.AddElement(planetSelector);

                var popInfo = new GuiText {
                    TextHeight = 20
                };
                popInfo.Position.WrapContent().Then.RelativeTo(planetSelector, 0, -1, 0, 1).WithMargins(0, 20);

                var formatter = new ThousandsFormatter();
                var colony    = this.controller.PlanetsColony(planet);
                if (colony != null)
                {
                    popInfo.Text      = formatter.Format(colony.Population) + " / " + formatter.Format(colony.PopulationMax);
                    popInfo.TextColor = colony.Owner.Color;
                }
                else
                {
                    popInfo.Text      = formatter.Format(planet.PopulationMax);
                    popInfo.TextColor = Color.Gray;
                }
                this.addPlanetElement(popInfo);

                traitGridBuilder = new GridPositionBuilder(4, 20, 20, 3);
                foreach (var trait in planet.Traits)
                {
                    var traitImage = new GuiImage
                    {
                        Image   = GalaxyTextures.Get.Sprite(trait.ImagePath),
                        Tooltip = new SimpleTooltip("Traits", trait.LangCode)
                    };
                    traitImage.Position.FixedSize(20, 20).RelativeTo(popInfo, 0, -1, 0, 1).WithMargins(0, 10).Offset(-40, 0);
                    traitGridBuilder.Add(traitImage.Position);
                    this.addPlanetElement(traitImage);
                }
            }

            this.setupColonizationMarkers();
        }
コード例 #9
0
        public override void Load()
        {
            Image resolutionLabel = new Image(Assets.GetTexture("HUDResolutionLabel"), new Vector2(150, 50), scale: 0.25f);

            resolutionSelect.AddOption("720p", Assets.GetTexture("HUD720p"));
            resolutionSelect.AddOption("1080p", Assets.GetTexture("HUD1080p"));
            resolutionSelect.AddOption("1440p", Assets.GetTexture("HUD1440p"));
            resolutionSelect.AddOption("4K", Assets.GetTexture("HUD4K"));
            SelectableImage resolutionRight = new SelectableImage(Assets.GetTexture("HUDArrowRightBase"), Assets.GetTexture("HUDArrowRightSelected"), new Vector2(485, 100), scale: 0.02f);

            resolutionRight.OnClick = () =>
            {
                resolutionSelect.Next();
            };
            SelectableImage resolutionLeft = new SelectableImage(Assets.GetTexture("HUDArrowLeftBase"), Assets.GetTexture("HUDArrowLeftSelected"), new Vector2(265, 100), scale: 0.02f);

            resolutionLeft.OnClick = () =>
            {
                resolutionSelect.Previous();
            };


            Image frameLimiterLabel = new Image(Assets.GetTexture("HUDFPSLimitLabel"), new Vector2(150, 150), scale: 0.25f);

            frameLimitSelect.AddOption("30", Assets.GetTexture("HUD30"));
            frameLimitSelect.AddOption("60", Assets.GetTexture("HUD60"));
            frameLimitSelect.AddOption("120", Assets.GetTexture("HUD120"));
            frameLimitSelect.AddOption("Unlimited", Assets.GetTexture("HUDUnlimited"));

            SelectableImage fpsRight = new SelectableImage(Assets.GetTexture("HUDArrowRightBase"), Assets.GetTexture("HUDArrowRightSelected"), new Vector2(485, 200), scale: 0.02f);

            fpsRight.OnClick = () =>
            {
                frameLimitSelect.Next();
            };
            SelectableImage fpsLeft = new SelectableImage(Assets.GetTexture("HUDArrowLeftBase"), Assets.GetTexture("HUDArrowLeftSelected"), new Vector2(265, 200), scale: 0.02f);

            fpsLeft.OnClick = () =>
            {
                frameLimitSelect.Previous();
            };

            Image vsyncLabel = new Image(Assets.GetTexture("HUDVsyncLabel"), new Vector2(150, 250), scale: 0.25f);

            vsyncSelect.AddOption("On", Assets.GetTexture("HUDOn"));
            vsyncSelect.AddOption("Off", Assets.GetTexture("HUDOff"));

            SelectableImage vsyncRight = new SelectableImage(Assets.GetTexture("HUDArrowRightBase"), Assets.GetTexture("HUDArrowRightSelected"), new Vector2(485, 300), scale: 0.02f);

            vsyncRight.OnClick = () =>
            {
                vsyncSelect.Next();
            };
            SelectableImage vsyncLeft = new SelectableImage(Assets.GetTexture("HUDArrowLeftBase"), Assets.GetTexture("HUDArrowLeftSelected"), new Vector2(265, 300), scale: 0.02f);

            vsyncLeft.OnClick = () =>
            {
                vsyncSelect.Previous();
            };

            Image windowModeLabel = new Image(Assets.GetTexture("HUDWindowModeLabel"), new Vector2(150, 350), scale: 0.25f);

            windowModeSelect.AddOption("Fullscreen", Assets.GetTexture("HUDFullscreen"));
            windowModeSelect.AddOption("Windowed", Assets.GetTexture("HUDWindowed"));

            SelectableImage windowModeRight = new SelectableImage(Assets.GetTexture("HUDArrowRightBase"), Assets.GetTexture("HUDArrowRightSelected"), new Vector2(485, 400), scale: 0.02f);

            windowModeRight.OnClick = () =>
            {
                windowModeSelect.Next();
            };
            SelectableImage windowModeLeft = new SelectableImage(Assets.GetTexture("HUDArrowLeftBase"), Assets.GetTexture("HUDArrowLeftSelected"), new Vector2(265, 400), scale: 0.02f);

            windowModeLeft.OnClick = () =>
            {
                windowModeSelect.Previous();
            };

            SelectableImage cancel = new SelectableImage(Assets.GetTexture("HUDCancelBase"), Assets.GetTexture("HUDCancelSelected"), new Vector2(150, 500), scale: 0.25f);

            cancel.OnClick = () =>
            {
                SceneManager.StartScene("Settings");
            };

            SelectableImage apply = new SelectableImage(Assets.GetTexture("HUDApplyBase"), Assets.GetTexture("HUDApplySelected"), new Vector2(450, 500), scale: 0.25f);

            apply.OnClick = ApplyConfiguration;

            UI.AddUIElement(resolutionLabel);
            UI.AddUIElement(frameLimiterLabel);
            UI.AddUIElement(vsyncLabel);
            UI.AddUIElement(windowModeLabel);
            UI.AddUIElement(resolutionSelect);
            UI.AddUIElement(frameLimitSelect);
            UI.AddUIElement(vsyncSelect);
            UI.AddUIElement(windowModeSelect);
            UI.AddUIElement(resolutionRight);
            UI.AddUIElement(resolutionLeft);
            UI.AddUIElement(fpsLeft);
            UI.AddUIElement(fpsRight);
            UI.AddUIElement(vsyncLeft);
            UI.AddUIElement(vsyncRight);
            UI.AddUIElement(windowModeRight);
            UI.AddUIElement(windowModeLeft);
            UI.AddUIElement(apply);
            UI.AddUIElement(cancel);

            SetCurrentVideoSettings();
        }
コード例 #10
0
ファイル: Game1.cs プロジェクト: griffinfujioka/BASEketball
        /// <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)
        {
            #region Label U1: use Touch Location to check for selection

            //obtain all of the devices TouchLocations
            TouchCollection touchCollection = TouchPanel.GetState();
            //check each of the devices TouchLocations;
            foreach (TouchLocation tl in touchCollection)
            {
                /*
                    * Utilize the touch location state.
                    *   -TouchLocationState.Invalid is when the location's position is invalid. Could be when a new
                    *   touch location attempts to get the previous location of itself.
                    *   -TouchLocationState.Moved is when the touch location position was updated or pressed in the same position.
                    *   -TouchLocationState.Pressed is when the touch location position is new.
                    *   -TouchLocationState.Released is when the location position was released.
                */
                switch (tl.State)
                {
                    case TouchLocationState.Pressed:
                        // Priotize the selction
                        // System.Diagnostics.Debug.WriteLine("Pressed: TouchID=" + tl.Id);
                        mCurrentSelected = null;
                        if (mBall.Selected(tl.Position))
                            mCurrentSelected = mBall;
                        break;

                    case TouchLocationState.Moved:
                        // with TouchID, will not "drop" the image when movement is very fast!
                        // if (null != mCurrentSelected)
                        //    mCurrentSelected.DragTo(tl.Id, tl.Position);
                        //
                        // One should not mix touch.Move with gesture.
                        //   here we are working with Gesture, so, check for FreeDrag
                        break;

                    case TouchLocationState.Released:
                        if (null != mCurrentSelected)
                            mCurrentSelected.UnSelect();

                        mCurrentSelected = null;
                        break;
                }
            }
            #endregion

            #region Label U2: Working with gesture: on selected image
            while (TouchPanel.IsGestureAvailable)
            {
                //detect any gestures that were performed
                GestureSample gesture = TouchPanel.ReadGesture();
                //do code depending on which gesture was detected
                switch (gesture.GestureType)
                {
                    case GestureType.Pinch:
                        // Only work with mBg image.
                        // Sets the markers to be visible and at pinch position
                        mMarker1.IsVisible = true;
                        mMarker2.IsVisible = true;
                        mMarker1.SetPositionTo(gesture.Position);
                        mMarker2.SetPositionTo(gesture.Position2);
                        break;
                    case GestureType.PinchComplete:
                        // now hid the markers
                        mMarker1.IsVisible = false;
                        mMarker2.IsVisible = false;
                        break;

                    case GestureType.FreeDrag:
                        // drags which the selected image
                        if (null != mCurrentSelected)
                            mCurrentSelected.SetPositionTo(gesture.Position);
                        break;

                    case GestureType.DoubleTap:
                        break;

                    case GestureType.Tap:
                        // Always reposition the ball
                        mBall.SetPositionTo(gesture.Position);
                        mBall.SetVelocity(Vector2.Zero);
                        mBeep.Play();
                        break;

                    case GestureType.Hold:
                        // Always reposition the ball
                        mBall.SetPositionTo(gesture.Position);
                        mBall.SetVelocity(Vector2.Zero);
                        mBeep.Play();
                        break;

                    case GestureType.Flick:
                        // Transfer the flick-delta to the ball,
                        //         scale down the veocity to have
                        //         a resonable speed for the ball
                        if (mBall == mCurrentSelected)
                            mBall.SetVelocity(gesture.Delta * 0.2f);
                        break;
                }
            }
            #endregion

            #region Label U3: In case the ball is kicked
            mBall.Update();
            #endregion

            #region Label U4: Usual XNA stuff: Allows the game to exit and base.Update
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            base.Update(gameTime);
            #endregion

            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed)
                this.Exit();

            // TODO: Add your update logic here

            base.Update(gameTime);
        }
コード例 #11
0
ファイル: StarSystemScene.cs プロジェクト: weshec/Stareater
        public void SetStarSystem(StarSystemController controller, PlayerController playerController)
        {
            this.setupSystem(controller.Planets.ToList(), controller.PlanetsColony);
            this.controller    = controller;
            this.currentPlayer = playerController;

            var colonies = controller.Planets.Select(x => controller.PlanetsColony(x)).Where(x => x != null);

            if (colonies.Any())
            {
                this.panTo(Methods.FindBest(colonies, x => x.Population).Location);
            }
            else
            {
                this.panToStar();
            }

            this.starSelector.ForgroundImageColor = controller.HostStar.Color;
            this.starSelector.Select();

            foreach (var element in this.planetSelectors.Values.Concat(this.colonizationMarkers.Values).Concat(this.otherPlanetElements))
            {
                this.RemoveElement(element);
            }
            this.planetSelectors.Clear();
            this.colonizationMarkers.Clear();
            this.otherPlanetElements.Clear();

            var traitGridBuilder = new GridPositionBuilder(2, 20, 20, 3);

            foreach (var trait in controller.HostStar.Traits)
            {
                var traitImage = new GuiImage
                {
                    Below   = this.starSelector,
                    Margins = new Vector2(3, 0),
                    Image   = GalaxyTextures.Get.Sprite(trait.ImagePath),
                    Tooltip = new SimpleTooltip("Traits", trait.LangCode)
                };
                traitImage.Position.FixedSize(20, 20).RelativeTo(this.starSelector, 0.8f, -0.8f, -1, 1).UseMargins();
                traitGridBuilder.Add(traitImage.Position);
                this.addPlanetElement(traitImage);
            }

            foreach (var planet in this.controller.Planets)
            {
                var planetSelector = new SelectableImage <int>(planet.Position)
                {
                    ForgroundImage = GalaxyTextures.Get.PlanetSprite(planet.Type),
                    SelectorImage  = GalaxyTextures.Get.SelectedStar,
                    SelectCallback = select,
                    Padding        = 16,
                };
                planetSelector.Position.FixedSize(100, 100).RelativeTo(this.planetAnchor(planet));
                planetSelector.GroupWith(starSelector);
                this.planetSelectors[planet.Position] = planetSelector;
                this.AddElement(planetSelector);

                var popInfo = new GuiText
                {
                    Margins    = new Vector2(0, 20),
                    TextHeight = 20
                };
                popInfo.Position.WrapContent().Then.RelativeTo(planetSelector, 0, -1, 0, 1).UseMargins();

                var formatter = new ThousandsFormatter();
                var colony    = this.controller.PlanetsColony(planet);
                if (colony != null)
                {
                    popInfo.Text      = formatter.Format(colony.Population) + " / " + formatter.Format(colony.PopulationMax);
                    popInfo.TextColor = colony.Owner.Color;
                }
                else
                {
                    popInfo.Text      = formatter.Format(planet.PopulationMax);
                    popInfo.TextColor = Color.Gray;
                }
                this.addPlanetElement(popInfo);

                traitGridBuilder = new GridPositionBuilder(4, 20, 20, 3);
                foreach (var trait in planet.Traits)
                {
                    var traitImage = new GuiImage
                    {
                        Margins = new Vector2(0, 10),
                        Image   = GalaxyTextures.Get.Sprite(trait.ImagePath),
                        Tooltip = new SimpleTooltip("Traits", trait.LangCode)
                    };
                    traitImage.Position.FixedSize(20, 20).RelativeTo(popInfo, 0, -1, 0, 1).UseMargins().Offset(-40, 0);
                    traitGridBuilder.Add(traitImage.Position);
                    this.addPlanetElement(traitImage);
                }
            }

            this.setupColonizationMarkers();
        }