本文整理汇总了C#中Game.GetKey方法的典型用法代码示例。如果您正苦于以下问题:C# Game.GetKey方法的具体用法?C# Game.GetKey怎么用?C# Game.GetKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Game
的用法示例。
在下文中一共展示了Game.GetKey方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnKeyDown
public override void OnKeyDown(Game game, KeyEventArgs args)
{
if (args.GetKeyCode() == game.GetKey(GlKeys.F12))
{
takeScreenshot = true;
args.SetHandled(true);
}
}
示例2: OnKeyDown
public override void OnKeyDown(Game game, KeyEventArgs args)
{
if (!(game.guistate == GuiState.Normal && game.GuiTyping == TypingState.None))
{
//Do nothing when in dialog or chat
return;
}
int eKey = args.GetKeyCode();
if (eKey == game.GetKey(GlKeys.R))
{
Packet_Item item = game.d_Inventory.RightHand[game.ActiveMaterial];
if (item != null && item.ItemClass == Packet_ItemClassEnum.Block
&& game.blocktypes[item.BlockId].IsPistol
&& game.reloadstartMilliseconds == 0)
{
int sound = game.rnd.Next() % game.blocktypes[item.BlockId].Sounds.ReloadCount;
game.AudioPlay(StringTools.StringAppend(game.platform, game.blocktypes[item.BlockId].Sounds.Reload[sound], ".ogg"));
game.reloadstartMilliseconds = game.platform.TimeMillisecondsFromStart();
game.reloadblock = item.BlockId;
game.SendPacketClient(ClientPackets.Reload());
}
}
}
示例3: OnNewFrameFixed
public override void OnNewFrameFixed(Game game, NewFrameEventArgs args)
{
float one = 1;
float dt = args.GetDt();
if (game.guistate == GuiState.MapLoading) { return; }
bool angleup = false;
bool angledown = false;
float overheadcameraanglemovearea = one * 5 / 100;
float overheadcameraspeed = 3;
game.controls.wantsjump = game.guistate == GuiState.Normal && game.GuiTyping == TypingState.None && game.keyboardState[game.GetKey(GlKeys.Space)];
game.controls.wantsjumphalf = false;
game.controls.shiftkeydown = game.guistate == GuiState.Normal && game.GuiTyping == TypingState.None && game.keyboardState[game.GetKey(GlKeys.ShiftLeft)];
game.controls.movedx = 0;
game.controls.movedy = 0;
game.controls.moveup = false;
game.controls.movedown = false;
if (game.guistate == GuiState.Normal)
{
if (game.GuiTyping == TypingState.None)
{
if (game.reachedwall_1blockhigh && (game.AutoJumpEnabled || (!game.platform.IsMousePointerLocked())))
{
game.controls.wantsjump = true;
}
if (game.reachedHalfBlock)
{
game.controls.wantsjumphalf = true;
}
if (game.overheadcamera)
{
CameraMove m = new CameraMove();
if (game.keyboardState[game.GetKey(GlKeys.A)]) { game.overheadcameraK.TurnRight(dt * overheadcameraspeed); }
if (game.keyboardState[game.GetKey(GlKeys.D)]) { game.overheadcameraK.TurnLeft(dt * overheadcameraspeed); }
if (game.keyboardState[game.GetKey(GlKeys.W)]) { angleup = true; }
if (game.keyboardState[game.GetKey(GlKeys.S)]) { angledown = true; }
game.overheadcameraK.Center.X = game.player.position.x;
game.overheadcameraK.Center.Y = game.player.position.y;
game.overheadcameraK.Center.Z = game.player.position.z;
m.Distance = game.overheadcameradistance;
m.AngleUp = angleup;
m.AngleDown = angledown;
game.overheadcameraK.Move(m, dt);
float toDest = game.Dist(game.player.position.x, game.player.position.y, game.player.position.z,
game.playerdestination.X + one / 2, game.playerdestination.Y - one / 2, game.playerdestination.Z + one / 2);
if (toDest >= 1)
{
game.controls.movedy += 1;
if (game.reachedwall)
{
game.controls.wantsjump = true;
}
//player orientation
float qX = game.playerdestination.X - game.player.position.x;
float qY = game.playerdestination.Y - game.player.position.y;
float qZ = game.playerdestination.Z - game.player.position.z;
float angle = game.VectorAngleGet(qX, qY, qZ);
game.player.position.roty = Game.GetPi() / 2 + angle;
game.player.position.rotx = Game.GetPi();
}
}
else if (game.enable_move)
{
if (game.keyboardState[game.GetKey(GlKeys.W)]) { game.controls.movedy += 1; }
if (game.keyboardState[game.GetKey(GlKeys.S)]) { game.controls.movedy += -1; }
if (game.keyboardState[game.GetKey(GlKeys.A)]) { game.controls.movedx += -1; game.localplayeranimationhint.leanleft = true; game.localstance = 1; }
else { game.localplayeranimationhint.leanleft = false; }
if (game.keyboardState[game.GetKey(GlKeys.D)]) { game.controls.movedx += 1; game.localplayeranimationhint.leanright = true; game.localstance = 2; }
else { game.localplayeranimationhint.leanright = false; }
if (!game.localplayeranimationhint.leanleft && !game.localplayeranimationhint.leanright) { game.localstance = 0; }
game.controls.movedx += game.touchMoveDx;
game.controls.movedy += game.touchMoveDy;
}
}
if (game.controls.freemove || game.SwimmingEyes())
{
if (game.GuiTyping == TypingState.None && game.keyboardState[game.GetKey(GlKeys.Space)])
{
game.controls.moveup = true;
}
if (game.GuiTyping == TypingState.None && game.keyboardState[game.GetKey(GlKeys.ControlLeft)])
{
game.controls.movedown = true;
}
}
}
}
示例4: OnKeyDown
public override void OnKeyDown(Game game, KeyEventArgs args)
{
for (int i = 0; i < game.dialogsCount; i++)
{
if (game.dialogs[i] == null) { continue; }
game.dialogs[i].screen.OnKeyDown(game, args);
}
if (game.guistate == GuiState.Normal)
{
if (args.GetKeyCode() == game.GetKey(GlKeys.Escape))
{
for (int i = 0; i < game.dialogsCount; i++)
{
if (game.dialogs[i] == null)
{
continue;
}
VisibleDialog d = game.dialogs[i];
if (d.value.IsModal != 0)
{
game.dialogs[i] = null;
return;
}
}
game.ShowEscapeMenu();
args.SetHandled(true);
return;
}
}
if (game.guistate == GuiState.ModalDialog)
{
// Close modal dialogs when pressing ESC key
if (args.GetKeyCode() == game.GetKey(GlKeys.Escape))
{
for (int i = 0; i < game.dialogsCount; i++)
{
if (game.dialogs[i] == null) { continue; }
if (game.dialogs[i].value.IsModal != 0)
{
game.dialogs[i] = null;
}
}
game.SendPacketClient(ClientPackets.DialogClick("Esc", new string[0], 0));
game.GuiStateBackToGame();
args.SetHandled(true);
}
// Handle TAB key
if (args.GetKeyCode() == game.GetKey(GlKeys.Tab))
{
game.SendPacketClient(ClientPackets.DialogClick("Tab", new string[0], 0));
args.SetHandled(true);
}
return;
}
}
示例5: RailOnNewFrame
internal void RailOnNewFrame(Game game, float dt)
{
if (localMinecart == null)
{
localMinecart = new Entity();
localMinecart.minecart = new Minecart();
game.EntityAddLocal(localMinecart);
}
localMinecart.minecart.enabled = railriding;
if (railriding)
{
Minecart m = localMinecart.minecart;
m.positionX = game.player.position.x;
m.positionY = game.player.position.y;
m.positionZ = game.player.position.z;
m.direction = currentdirection;
m.lastdirection = lastdirection;
m.progress = currentrailblockprogress;
}
game.localplayeranimationhint.InVehicle = railriding;
game.localplayeranimationhint.DrawFixX = 0;
game.localplayeranimationhint.DrawFixY = railriding ? (-one * 7 / 10) : 0;
game.localplayeranimationhint.DrawFixZ = 0;
bool turnright = game.keyboardState[game.GetKey(GlKeys.D)];
bool turnleft = game.keyboardState[game.GetKey(GlKeys.A)];
RailSound(game);
if (railriding)
{
game.controls.freemove = true;
game.enable_move = false;
Vector3Ref railPos = CurrentRailPos(game);
game.player.position.x = railPos.X;
game.player.position.y = railPos.Y;
game.player.position.z = railPos.Z;
currentrailblockprogress += currentvehiclespeed * dt;
if (currentrailblockprogress >= 1)
{
lastdirection = currentdirection;
currentrailblockprogress = 0;
TileEnterData newenter = new TileEnterData();
Vector3IntRef nexttile = NextTile(currentdirection, currentrailblockX, currentrailblockY, currentrailblockZ);
newenter.BlockPositionX = nexttile.X;
newenter.BlockPositionY = nexttile.Y;
newenter.BlockPositionZ = nexttile.Z;
//slope
if (GetUpDownMove(game, currentrailblockX, currentrailblockY, currentrailblockZ,
DirectionUtils.ResultEnter(DirectionUtils.ResultExit(currentdirection))) == UpDown.Up)
{
newenter.BlockPositionZ++;
}
if (GetUpDownMove(game, newenter.BlockPositionX,
newenter.BlockPositionY,
newenter.BlockPositionZ - 1,
DirectionUtils.ResultEnter(DirectionUtils.ResultExit(currentdirection))) == UpDown.Down)
{
newenter.BlockPositionZ--;
}
newenter.EnterDirection = DirectionUtils.ResultEnter(DirectionUtils.ResultExit(currentdirection));
BoolRef newdirFound = new BoolRef();
VehicleDirection12 newdir = BestNewDirection(PossibleRails(game, newenter), turnleft, turnright, newdirFound);
if (!newdirFound.value)
{
//end of rail
currentdirection = DirectionUtils.Reverse(currentdirection);
}
else
{
currentdirection = newdir;
currentrailblockX = game.platform.FloatToInt(newenter.BlockPositionX);
currentrailblockY = game.platform.FloatToInt(newenter.BlockPositionY);
currentrailblockZ = game.platform.FloatToInt(newenter.BlockPositionZ);
}
}
}
if (game.keyboardState[game.GetKey(GlKeys.W)] && game.GuiTyping != TypingState.Typing)
{
currentvehiclespeed += 1 * dt;
}
if (game.keyboardState[game.GetKey(GlKeys.S)] && game.GuiTyping != TypingState.Typing)
{
currentvehiclespeed -= 5 * dt;
}
if (currentvehiclespeed < 0)
{
currentvehiclespeed = 0;
}
//todo fix
//if (viewport.keypressed != null && viewport.keypressed.Key == GlKeys.Q)
if (!wasqpressed && game.keyboardState[game.GetKey(GlKeys.Q)] && game.GuiTyping != TypingState.Typing)
{
Reverse();
}
if (!wasepressed && game.keyboardState[game.GetKey(GlKeys.E)] && !railriding && !game.controls.freemove && game.GuiTyping != TypingState.Typing)
{
currentrailblockX = game.platform.FloatToInt(game.player.position.x);
currentrailblockY = game.platform.FloatToInt(game.player.position.z);
currentrailblockZ = game.platform.FloatToInt(game.player.position.y) - 1;
//.........这里部分代码省略.........
示例6: OnKeyDown
public override void OnKeyDown(Game game, KeyEventArgs args)
{
int eKey = args.GetKeyCode();
if (eKey == (game.GetKey(GlKeys.E)) && game.GuiTyping == TypingState.None)
{
if (!(game.SelectedBlockPositionX == -1 && game.SelectedBlockPositionY == -1 && game.SelectedBlockPositionZ == -1))
{
int posx = game.SelectedBlockPositionX;
int posy = game.SelectedBlockPositionZ;
int posz = game.SelectedBlockPositionY;
if (game.map.GetBlock(posx, posy, posz) == game.d_Data.BlockIdCraftingTable())
{
//draw crafting recipes list.
IntRef tableCount = new IntRef();
Vector3IntRef[] table = d_CraftingTableTool.GetTable(posx, posy, posz, tableCount);
IntRef onTableCount = new IntRef();
int[] onTable = d_CraftingTableTool.GetOnTable(table, tableCount.value, onTableCount);
CraftingRecipesStart(game, d_CraftingRecipes, d_CraftingRecipesCount, onTable, onTableCount.value, posx, posy, posz);
args.SetHandled(true);
}
}
}
}
示例7: OnMouseWheelChanged
public override void OnMouseWheelChanged(Game game_, MouseWheelEventArgs args)
{
float delta = args.GetDeltaPrecise();
if ((game_.guistate == GuiState.Normal || (game_.guistate == GuiState.Inventory && !IsMouseOverCells()))
&& (!game_.keyboardState[game_.GetKey(GlKeys.LShift)]))
{
game_.ActiveMaterial -= game_.platform.FloatToInt(delta);
game_.ActiveMaterial = game_.ActiveMaterial % 10;
while (game_.ActiveMaterial < 0)
{
game_.ActiveMaterial += 10;
}
}
if (IsMouseOverCells() && game.guistate == GuiState.Inventory)
{
if (delta > 0)
{
ScrollUp();
}
if (delta < 0)
{
ScrollDown();
}
}
}