本文整理汇总了C#中System.UInt16.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# UInt16.CopyTo方法的具体用法?C# UInt16.CopyTo怎么用?C# UInt16.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.UInt16
的用法示例。
在下文中一共展示了UInt16.CopyTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: packGameDefinition
//Entirely untested
public static UInt16[] packGameDefinition(
HostGun.CommandCode game_type,
UInt16 game_id,
int game_time_minutes,
int tags,
int reloads,
int sheild,
int mega,
bool extended_tagging,
bool unlimited_ammo,
bool unlimited_mega,
bool friendly_fire,
bool medic_mode,
bool rapid_tags,
bool hunters_hunted,
bool hunters_hunted_direction,
bool zones,
bool bases_are_teams,
bool tagged_players_are_disabled,
bool base_areas_revive_players,
bool base_areas_are_hospitals,
bool base_areas_fire_at_players,
int number_of_teams_in_game,
char[] game_type_name)
{
//assert(game_type_name.Length == 4);
Debug.Assert(number_of_teams_in_game >= 0 && number_of_teams_in_game <= 3);
byte flags =
(byte)((extended_tagging ? 1 : 0) << 7
| (unlimited_ammo ? 1 : 1) << 6
| (unlimited_mega ? 1 : 1) << 5
| (friendly_fire ? 1 : 0) << 4
| (medic_mode ? 1 : 0) << 3
| (rapid_tags ? 1 : 0) << 2
| (hunters_hunted ? 1 : 0) << 1
| (hunters_hunted_direction ? 1 : 0) << 0);
byte flags2 =
(byte)((zones ? 1 : 0) << 7
| (bases_are_teams ? 1 : 0) << 6
| (tagged_players_are_disabled ? 1 : 0) << 5
| (base_areas_revive_players ? 1 : 0) << 4
| (base_areas_are_hospitals ? 1 : 0) << 3
| (base_areas_fire_at_players ? 1 : 0) << 2
| (number_of_teams_in_game & 0x03));
String flags_string = String.Format("{0:x}{1:x}",flags,flags2);
Console.WriteLine(flags_string);
/*flags = 0x78;
flags2 = 0xA3;
flags_string = String.Format("{0:x}{1:x}",flags,flags2);
Console.WriteLine(flags_string);*/
UInt16[] values = new UInt16[] {
(UInt16)game_type,
game_id,//Game ID
DecimalToDecimalHex((byte)game_time_minutes), //game time minutes
DecimalToDecimalHex((byte)tags), //tags
DecimalToDecimalHex((byte)reloads), //reloads
DecimalToDecimalHex((byte)sheild), //sheild
DecimalToDecimalHex((byte)mega), //mega
flags,
flags2,
};
if (game_type_name != null && game_type_name.Length > 0) {
UInt16[] values2 = new UInt16[values.Length + game_type_name.Length];
values.CopyTo(values2,0);
game_type_name.CopyTo(values2,values.Length);
}
return values;
}