本文整理汇总了C#中Button.SetAction方法的典型用法代码示例。如果您正苦于以下问题:C# Button.SetAction方法的具体用法?C# Button.SetAction怎么用?C# Button.SetAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Button
的用法示例。
在下文中一共展示了Button.SetAction方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Enter
public override void Enter(Dictionary<string, object> data)
{
_label = new Label(Game, Game.BaseScreenSize.X / 2, Game.BaseScreenSize.Y / 2, "", "Calibri120Bold")
{ PositionGravity = Gravity.Center };
var readyButtonRect = new Rectangle(0, 0, 200, 50);
readyButtonRect.X = (int)Game.BaseScreenSize.X - readyButtonRect.Width - 50;
readyButtonRect.Y = (int)Game.BaseScreenSize.Y - readyButtonRect.Height - 50;
_readyButton = new Button(Game, readyButtonRect, "Ready", new Color(0.1f, 0.7f, 0.1f));
_readyButton.SetAction((a, userInfo) => Continue(), null);
Game.Components.Add(_readyButton);
Game.Components.Add(_label);
foreach (var gamer in Storage.NetworkSession.AllGamers)
{
Game.Components.Remove(gamer.Tag as Player);
if (gamer.IsLocal)
{
gamer.Tag = new LocalPlayer(Game, gamer);
}
else
{
gamer.Tag = new RemotePlayer(Game, gamer);
}
}
Storage.SandParticles.Particles.Clear();
Storage.AnimationController.Clear();
Storage.Game.Effect.CurrentTechnique = Storage.Game.Effect.Techniques["None"];
}
示例2: Enter
public override void Enter(Dictionary<string, object> data)
{
_sandLogo = data["SandLogo"] as Billboard;
var readyButtonRect = new Rectangle(0, 0, 200, 50);
readyButtonRect.X = (int)Game.BaseScreenSize.X - readyButtonRect.Width - 50;
readyButtonRect.Y = (int)Game.BaseScreenSize.Y - readyButtonRect.Height - 50;
_readyButton = new Button(Game, readyButtonRect, "Ready", new Color(0.1f, 0.7f, 0.1f));
_readyButton.SetAction((a, userInfo) => Game.TransitionState(States.Loadout), null);
_mapChooser = new MapChooserButton(Game, new Vector2(50, 450));
Game.Components.Add(_sandLogo);
Game.Components.Add(_readyButton);
Game.Components.Add(_mapChooser);
}
示例3: Enter
public override void Enter(Dictionary<string, object> data)
{
Storage.NetworkSession.GamerJoined += GamerJoined;
Storage.NetworkSession.GamerLeft += GamerLeft;
var netPlayer = Storage.NetworkSession.LocalGamers[0];
var player = netPlayer.Tag as Player;
if(player == null)
{
throw new Exception("Player not inited!?");
}
var logoSprite = Storage.Sprite("SandLogo");
var sandLogoOrigin = new Vector2(Game.BaseScreenSize.X * 0.5f - (logoSprite.Width * 0.5f), 30);
_sandLogo = data.ContainsKey("SandLogo")
? data["SandLogo"] as Billboard
: new Billboard(Game, sandLogoOrigin, logoSprite);
Storage.AnimationController.Add(new Animation(_sandLogo, "Y", sandLogoOrigin.Y), 750);
var readyButtonRect = new Rectangle(0, 0, 200, 50);
readyButtonRect.X = (int)Game.BaseScreenSize.X - readyButtonRect.Width - 50;
readyButtonRect.Y = (int)Game.BaseScreenSize.Y - readyButtonRect.Height - 50;
_readyButton = new Button(Game, readyButtonRect, "Ready", new Color(0.1f, 0.7f, 0.1f));
_readyButton.SetAction(ReadyButtonAction,
null);
var playerClassOrigin = new Vector2((Game.BaseScreenSize.X / 2.0f) - 128,
sandLogoOrigin.Y + logoSprite.Height + 32);
// TODO: this code needs to be cleaned up a lot
// TODO: make sure we aren't clicking on a taken combination
_redDefenseButton = new PlayerClassButton(Game, new Vector2(playerClassOrigin.X - 256, playerClassOrigin.Y),
Class.Defense, Team.Red);
_redDefenseButton.Button.SetAction((a, userInfo) =>
{
player.Team = Team.Red;
player.Class = Class.Defense;
Sound.OneShot(AddRandomSuffix("DefenseClass"), false);
}, null);
Game.Components.Add(_redDefenseButton);
_redOffenseButton = new PlayerClassButton(Game,
new Vector2(playerClassOrigin.X - 256,
playerClassOrigin.Y + 256 + 64), Class.Offense,
Team.Red);
_redOffenseButton.Button.SetAction((a, userInfo) =>
{
player.Team = Team.Red;
player.Class = Class.Offense;
Sound.OneShot(AddRandomSuffix("OffenseClass"), false);
}, null);
Game.Components.Add(_redOffenseButton);
_redSupportButton = new PlayerClassButton(Game,
new Vector2(playerClassOrigin.X - 256,
playerClassOrigin.Y + 512 + 128), Class.Support,
Team.Red);
_redSupportButton.Button.SetAction((a, userInfo) =>
{
player.Team = Team.Red;
player.Class = Class.Support;
Sound.OneShot(AddRandomSuffix("SupportClass"), false);
}, null);
Game.Components.Add(_redSupportButton);
_blueDefenseButton = new PlayerClassButton(Game, new Vector2(playerClassOrigin.X + 256, playerClassOrigin.Y),
Class.Defense, Team.Blue);
_blueDefenseButton.Button.SetAction((a, userInfo) =>
{
player.Team = Team.Blue;
player.Class = Class.Defense;
Sound.OneShot(AddRandomSuffix("DefenseClass"), false);
}, null);
Game.Components.Add(_blueDefenseButton);
_blueOffenseButton = new PlayerClassButton(Game,
new Vector2(playerClassOrigin.X + 256,
playerClassOrigin.Y + 256 + 64), Class.Offense,
Team.Blue);
_blueOffenseButton.Button.SetAction((a, userInfo) =>
{
player.Team = Team.Blue;
player.Class = Class.Offense;
Sound.OneShot(AddRandomSuffix("OffenseClass"), false);
}, null);
Game.Components.Add(_blueOffenseButton);
_blueSupportButton = new PlayerClassButton(Game,
new Vector2(playerClassOrigin.X + 256,
playerClassOrigin.Y + 512 + 128), Class.Support,
Team.Blue);
_blueSupportButton.Button.SetAction((a, userInfo) =>
{
player.Team = Team.Blue;
player.Class = Class.Support;
Sound.OneShot(AddRandomSuffix("SupportClass"), false);
}, null);
Game.Components.Add(_blueSupportButton);
_classDescriptions = new ClassDescription[3];
//.........这里部分代码省略.........
示例4: Enter
public override void Enter(Dictionary<string, object> data)
{
_sandLogo = data["SandLogo"] as Billboard;
var readyButtonRect = new Rectangle(0, 0, 200, 50);
readyButtonRect.X = (int)Game.BaseScreenSize.X - readyButtonRect.Width - 50;
readyButtonRect.Y = (int)Game.BaseScreenSize.Y - readyButtonRect.Height - 50;
_readyButton = new Button(Game, readyButtonRect, "Ready", new Color(0.1f, 0.7f, 0.1f));
_readyButton.SetAction((a, userInfo) => Game.TransitionState(States.ReadyWait), null);
var weapons = new List<Type> { typeof(Cannon), typeof(EMP) };
var utilities = new List<Type> { typeof(Shield), typeof(Ground) };
var mobilities = new List<Type> { typeof(BoostDrive), typeof(WinkDrive), typeof(BlinkDrive) };
var primaries = new List<Type>();
switch((Storage.NetworkSession.LocalGamers[0].Tag as Player).Class)
{
case Class.None:
break;
case Class.Defense:
primaries.Add(typeof(Jet));
primaries.Add(typeof(SandCharge));
break;
case Class.Offense:
primaries.Add(typeof(Laser));
primaries.Add(typeof(FlameCharge));
break;
case Class.Support:
primaries.Add(typeof(Plow));
primaries.Add(typeof(PressureCharge));
break;
default:
throw new ArgumentOutOfRangeException();
}
_primaryAToolChooser = new ToolChooserButton(Game, new Vector2(300, _sandLogo.Y + 220), "Primary 1",
primaries);
_primaryBToolChooser = new ToolChooserButton(Game, new Vector2(300, _sandLogo.Y + 420), "Primary 2",
primaries);
_primaryBToolChooser.ChooseTool(null, primaries[1], false); // TODO: this is all a hack
_weaponsToolChooser = new ToolChooserButton(Game, new Vector2(300, _sandLogo.Y + 620), "Weapon", weapons);
_utilitiesToolChooser = new ToolChooserButton(Game, new Vector2(300, _sandLogo.Y + 820), "Utility",
utilities);
_mobilitiesToolChooser = new ToolChooserButton(Game, new Vector2(300, _sandLogo.Y + 1020), "Mobility",
mobilities);
var origin = 50;
var offset = 17;
_primaryButtonA = new Billboard(Game, new Vector2(origin + 30, _primaryAToolChooser.Y - offset), Storage.Sprite("lmouse"))
{ PositionGravity = Gravity.Center };
_primaryButtonB = new Billboard(Game, new Vector2(origin + 30, _primaryBToolChooser.Y - offset), Storage.Sprite("lmouse")) { PositionGravity = Gravity.Center };
_weaponButton = new Billboard(Game, new Vector2(origin + 30, _weaponsToolChooser.Y - offset), Storage.Sprite("rmouse")) { PositionGravity = Gravity.Center };
_utilityButton = new Billboard(Game, new Vector2(origin, _utilitiesToolChooser.Y - offset), Storage.Sprite("shift")) { PositionGravity = Gravity.Center };
_mobilityButton = new Billboard(Game, new Vector2(origin, _mobilitiesToolChooser.Y - offset), Storage.Sprite("space")) { PositionGravity = Gravity.Center };
Game.Components.Add(_sandLogo);
Game.Components.Add(_readyButton);
Game.Components.Add(_weaponsToolChooser);
Game.Components.Add(_utilitiesToolChooser);
Game.Components.Add(_mobilitiesToolChooser);
Game.Components.Add(_primaryAToolChooser);
Game.Components.Add(_primaryBToolChooser);
Game.Components.Add(_primaryButtonA);
Game.Components.Add(_primaryButtonB);
Game.Components.Add(_weaponButton);
Game.Components.Add(_utilityButton);
Game.Components.Add(_mobilityButton);
}