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); } }
public void TestButtonClick(ButtonClickEventArgs args) { ButtonAsset button = args.Sender as ButtonAsset; Demo1VirtualizedContext context = (Demo1VirtualizedContext)button.VirtualizedDataContext; Debug.WriteLine("OH HAI THERE!"); context.TestText = context.TestText + "!"; }
private ButtonAsset makeButton(string s, bool less, int index) { Func <bool> onClick = delegate() { int price = Int32.Parse(lines[index].Price.Text.Replace("$", "")); int playerMoney = Int32.Parse(yourMoney.Text.Replace("$", "")); int merchantMoney = Int32.Parse(theirMoney.Text.Replace("$", "")); int yours = Int32.Parse(lines[index].Yours.Text); int theirs = Int32.Parse(lines[index].Theirs.Text); if (less && theirs > 0 && price <= playerMoney) { yours += 1; theirs -= 1; playerMoney -= price; merchantMoney += price; tickSound.Play(); } else if (!less && yours > 0 && price <= merchantMoney) { yours -= 1; theirs += 1; playerMoney += price; merchantMoney += price; tickSound.Play(); } lines[index].Yours.Text = yours.ToString(); lines[index].Theirs.Text = theirs.ToString(); yourMoney.Text = "$" + playerMoney.ToString(); theirMoney.Text = "$" + merchantMoney.ToString(); return(true); }; Func <bool, bool> onHover = delegate(bool hovered) { return(true); }; var asset = new ButtonAsset(s, onClick, onHover); return(AddChild(s, asset)); }