예제 #1
0
            public Dialog(Pane pane, System system)
            {
                this.system = system;

                systemLabel     = AddChild("systemLabel", new TextAsset(system.Name));
                difficultyLabel = AddChild("difficultyLabel", new TextAsset(system.Difficulty.ToString()));
                planetInfoLabel = AddChild("difficultyLabel", new TextAsset());

                int planetIndex = 0;

                foreach (Planet planet in system.Planets)
                {
                    Func <bool> onClick = delegate()
                    {
                        if (pane.IsTopPane())
                        {
                            PaneStack.Instance.Push(new PlanetPane(planet));
                        }
                        return(true);
                    };
                    Func <bool, bool> onHover = delegate(bool hovered)
                    {
                        if (hovered)
                        {
                            planetInfoLabel.Text = "hovered over planet: " + planet.Name;
                        }
                        else
                        {
                            planetInfoLabel.Text = "";
                        }
                        return(true);
                    };

                    var planetButton = new ButtonAsset(planet.Name, onClick, onHover);
                    planetButton.Position = new Vector2(280 + (planetIndex * 160), 280);
                    AddChild("planetButton", planetButton);
                    planetIndex++;
                }

                if (system.Name == "Terragon")
                {
                    Func <bool> onClick = delegate()
                    {
                        if (pane.IsTopPane())
                        {
                            PaneStack.Instance.Push(new SpacePortPane());
                        }
                        return(true);
                    };
                    Func <bool, bool> onHover = delegate(bool hovered)
                    {
                        return(true);
                    };
                    var spacePortButton = new ButtonAsset("Space Port", onClick, onHover);
                    spacePortButton.Position = new Vector2(280, 380);
                    AddChild("spacePortButton", spacePortButton);
                }
            }
예제 #2
0
 public bool WasPressed()
 {
     if (prevPrevMs != null && prevMs != null && pane.IsTopPane())
     {
         return(prevPrevMs.Value.LeftButton == ButtonState.Released && prevMs.Value.LeftButton == ButtonState.Pressed);
     }
     return(false);
 }