本文整理汇总了C#中ClassicalSharp.Game类的典型用法代码示例。如果您正苦于以下问题:C# Game类的具体用法?C# Game怎么用?C# Game使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Game类属于ClassicalSharp命名空间,在下文中一共展示了Game类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Load
public override byte[] Load( Stream stream, Game game, out int width, out int height, out int length )
{
using( GZipStream wrapper = new GZipStream( stream, CompressionMode.Decompress ) ) {
reader = new BinaryReader( wrapper );
if( reader.ReadByte() != (byte)NbtTagType.Compound )
throw new InvalidDataException( "Nbt file must start with Tag_Compound" );
this.game = game;
map = game.Map;
invalid.TagId = NbtTagType.Invalid;
NbtTag root = ReadTag( (byte)NbtTagType.Compound, true );
Dictionary<string, NbtTag> children = (Dictionary<string, NbtTag>)root.Value;
if( children.ContainsKey( "Metadata" ) )
ParseMetadata( children );
Dictionary<string, NbtTag> spawn = (Dictionary<string, NbtTag>)children["Spawn"].Value;
LocalPlayer p = game.LocalPlayer;
p.SpawnPoint.X = (short)spawn["X"].Value / 32f;
p.SpawnPoint.Y = (short)spawn["Y"].Value / 32f;
p.SpawnPoint.Z = (short)spawn["Z"].Value / 32f;
map.Uuid = new Guid( (byte[])children["UUID"].Value );
width = (short)children["X"].Value;
height = (short)children["Y"].Value;
length = (short)children["Z"].Value;
return (byte[])children["BlockArray"].Value;
}
}
开发者ID:Cheesse,项目名称:ClassicalSharp,代码行数:28,代码来源:MapCw.Importer.cs
示例2: NetPlayer
public NetPlayer( string displayName, string skinName, Game game )
: base(game)
{
DisplayName = displayName;
SkinName = Utils.StripColours( skinName );
InitRenderingData();
}
开发者ID:Hetal728,项目名称:ClassicalSharp,代码行数:7,代码来源:NetPlayer.cs
示例3: Main
static void Main( string[] args )
{
ErrorHandler.InstallHandler( "client.log" );
Utils.LogDebug( "Starting " + AppName + ".." );
if( !File.Exists( "default.zip" ) ) {
Utils.LogDebug( "default.zip not found. Cannot start." );
return;
}
bool nullContext = true;
#if !USE_DX
nullContext = false;
#endif
int width, height;
SelectResolution( out width, out height );
if( args.Length == 0 || args.Length == 1 ) {
const string skinServer = "http://s3.amazonaws.com/MinecraftSkins/";
string pack = args.Length >= 1 ? args[0] : "default.zip";
using( Game game = new Game( "LocalPlayer", null, skinServer,
pack, nullContext, width, height ) )
game.Run();
} else if( args.Length < 4 ) {
Utils.LogDebug( "ClassicalSharp.exe is only the raw client. You must either use the launcher or"
+ " provide command line arguments to start the client." );
} else {
RunMultiplayer( args, nullContext, width, height );
}
}
开发者ID:Daribon,项目名称:ClassicalSharp,代码行数:30,代码来源:Program.cs
示例4: Map
public Map( Game game )
{
this.game = game;
info = game.BlockInfo;
SetSunlight( DefaultSunlight );
SetShadowlight( DefaultShadowlight );
}
开发者ID:Hetal728,项目名称:ClassicalSharp,代码行数:7,代码来源:Map.cs
示例5: FpsScreen
public FpsScreen( Game game )
: base(game)
{
font = new Font( "Arial", 13 );
posFont = new Font( "Arial", 12, FontStyle.Italic );
text = new StringBuffer( 96 );
}
开发者ID:umby24,项目名称:ClassicalSharp,代码行数:7,代码来源:FpsScreen.cs
示例6: Draw
public static void Draw( Game game, byte block, float size, float x, float y )
{
info = game.BlockInfo;
cache = game.ModelCache;
atlas = game.TerrainAtlas;
minBB = info.MinBB[block];
maxBB = info.MaxBB[block];
fullBright = info.FullBright[block];
if( info.IsSprite[block] ) {
minBB = Vector3.Zero; maxBB = Vector3.One;
}
if( info.IsAir[block] ) return;
index = 0;
// isometric coords size: cosY * -scale - sinY * scale
// we need to divide by (2 * cosY), as the calling function expects size to be in pixels.
scale = size / (2 * cosY);
// screen to isometric coords (cos(-x) = cos(x), sin(-x) = -sin(x))
pos.X = x; pos.Y = y; pos.Z = 0;
pos = Utils.RotateY( Utils.RotateX( pos, cosX, -sinX ), cosY, -sinY );
if( info.IsSprite[block] ) {
XQuad( block, 0f, TileSide.Right );
ZQuad( block, 0f, TileSide.Back );
} else {
XQuad( block, Make( maxBB.X ), TileSide.Left );
ZQuad( block, Make( minBB.Z ), TileSide.Back );
YQuad( block, Make( maxBB.Y ), TileSide.Top );
}
for( int i = 0; i < index; i++ )
TransformVertex( ref cache.vertices[i] );
game.Graphics.UpdateDynamicIndexedVb( DrawMode.Triangles, cache.vb,
cache.vertices, index, index * 6 / 4 );
}
开发者ID:Chameleonherman,项目名称:ClassicalSharp,代码行数:35,代码来源:IsometricBlockDrawer.cs
示例7: Load
public override byte[] Load( Stream stream, Game game, out int width, out int height, out int length )
{
byte[] map = null;
width = 0;
height = 0;
length = 0;
LocalPlayer p = game.LocalPlayer;
p.SpawnPoint = Vector3.Zero;
using( GZipStream gs = new GZipStream( stream, CompressionMode.Decompress ) ) {
reader = new BinaryReader( gs );
ClassDescription obj = ReadData();
for( int i = 0; i < obj.Fields.Length; i++ ) {
FieldDescription field = obj.Fields[i];
if( field.FieldName == "width" )
width = (int)field.Value;
else if( field.FieldName == "height" )
length = (int)field.Value;
else if( field.FieldName == "depth" )
height = (int)field.Value;
else if( field.FieldName == "blocks" )
map = (byte[])field.Value;
else if( field.FieldName == "xSpawn" )
p.SpawnPoint.X = (int)field.Value;
else if( field.FieldName == "ySpawn" )
p.SpawnPoint.Y = (int)field.Value;
else if( field.FieldName == "zSpawn" )
p.SpawnPoint.Z = (int)field.Value;
}
}
return map;
}
开发者ID:umby24,项目名称:ClassicalSharp,代码行数:32,代码来源:MapDat.Importer.cs
示例8: Main
static void Main( string[] args )
{
AppDirectory = AppDomain.CurrentDomain.BaseDirectory;
string logPath = Path.Combine( AppDirectory, "client.log" );
ErrorHandler.InstallHandler( logPath );
CleanupMainDirectory();
Utils.LogDebug( "Starting " + AppName + ".." );
string path = Path.Combine( Program.AppDirectory, TexturePackExtractor.Dir );
if( !File.Exists( Path.Combine( path, "default.zip" ) ) ) {
Utils.LogDebug( "default.zip not found. Cannot start." );
return;
}
bool nullContext = true;
#if !USE_DX
nullContext = false;
#endif
int width, height;
SelectResolution( out width, out height );
if( args.Length == 0 || args.Length == 1 ) {
const string skinServer = "http://static.classicube.net/skins/";
string user = args.Length > 0 ? args[0] : "Singleplayer";
using( Game game = new Game( user, null, skinServer, nullContext, width, height ) )
game.Run();
} else if( args.Length < 4 ) {
Utils.LogDebug( "ClassicalSharp.exe is only the raw client. You must either use the launcher or"
+ " provide command line arguments to start the client." );
} else {
RunMultiplayer( args, nullContext, width, height );
}
}
开发者ID:Chameleonherman,项目名称:ClassicalSharp,代码行数:33,代码来源:Program.cs
示例9: ChunkMeshBuilder
public ChunkMeshBuilder( Game game )
{
this.game = game;
graphics = game.Graphics;
info = game.BlockInfo;
game.Events.TerrainAtlasChanged += TerrainAtlasChanged;
}
开发者ID:Cheesse,项目名称:ClassicalSharp,代码行数:7,代码来源:ChunkMeshBuilder.cs
示例10: BlockHotbarWidget
public BlockHotbarWidget( Game game )
: base(game)
{
HorizontalDocking = Docking.Centre;
VerticalDocking = Docking.BottomOrRight;
game.Events.HeldBlockChanged += HeldBlockChanged;
}
开发者ID:Hetal728,项目名称:ClassicalSharp,代码行数:7,代码来源:BlockHotbarWidget.cs
示例11: LoadingMapScreen
public LoadingMapScreen( Game game, string name, string motd )
: base(game)
{
serverName = name;
serverMotd = motd;
font = new Font( "Arial", 14 );
}
开发者ID:Hetal728,项目名称:ClassicalSharp,代码行数:7,代码来源:LoadingMapScreen.cs
示例12: ClipCameraPos
public static void ClipCameraPos( Game game, Vector3 origin, Vector3 dir, float reach, PickedPos pickedPos )
{
if( !game.CameraClipping ) {
pickedPos.SetAsInvalid();
pickedPos.IntersectPoint = origin + dir * reach;
return;
}
tracer.SetRayData( origin, dir );
World map = game.World;
BlockInfo info = game.BlockInfo;
float reachSquared = reach * reach;
int iterations = 0;
Vector3I pOrigin = Vector3I.Floor( origin );
while( iterations < 10000 ) {
int x = tracer.X, y = tracer.Y, z = tracer.Z;
byte block = GetBlock( map, x, y, z, pOrigin );
Vector3 min = new Vector3( x, y, z ) + info.MinBB[block];
Vector3 max = new Vector3( x, y, z ) + info.MaxBB[block];
float dx = Math.Min( Math.Abs( origin.X - min.X ), Math.Abs( origin.X - max.X ) );
float dy = Math.Min( Math.Abs( origin.Y - min.Y ), Math.Abs( origin.Y - max.Y ) );
float dz = Math.Min( Math.Abs( origin.Z - min.Z ), Math.Abs( origin.Z - max.Z ) );
if( dx * dx + dy * dy + dz * dz > reachSquared ) {
pickedPos.SetAsInvalid();
pickedPos.IntersectPoint = origin + dir * reach;
return;
}
if( info.Collide[block] == CollideType.Solid && !info.IsAir[block] ) {
float t0, t1;
const float adjust = 0.1f;
if( Intersection.RayIntersectsBox( origin, dir, min, max, out t0, out t1 ) ) {
Vector3 intersect = origin + dir * t0;
pickedPos.SetAsValid( x, y, z, min, max, block, intersect );
switch( pickedPos.BlockFace) {
case CpeBlockFace.XMin:
pickedPos.IntersectPoint.X -= adjust; break;
case CpeBlockFace.XMax:
pickedPos.IntersectPoint.X += adjust; break;
case CpeBlockFace.YMin:
pickedPos.IntersectPoint.Y -= adjust; break;
case CpeBlockFace.YMax:
pickedPos.IntersectPoint.Y += adjust; break;
case CpeBlockFace.ZMin:
pickedPos.IntersectPoint.Z -= adjust; break;
case CpeBlockFace.ZMax:
pickedPos.IntersectPoint.Z += adjust; break;
}
return;
}
}
tracer.Step();
iterations++;
}
throw new InvalidOperationException( "did over 10000 iterations in ClipCameraPos(). " +
"Something has gone wrong. (dir: " + dir + ")" );
}
开发者ID:Retatta,项目名称:ClassicalSharp,代码行数:60,代码来源:Picking.cs
示例13: Draw
public static void Draw( Game game, byte block, float size, float x, float y )
{
info = game.BlockInfo;
cache = game.ModelCache;
atlas = game.TerrainAtlas;
blockHeight = info.Height[block];
index = 0;
scale = size;
// screen to isometric coords (cos(-x) = cos(x), sin(-x) = -sin(x))
pos.X = x; pos.Y = y; pos.Z = 0;
pos = Utils.RotateY( Utils.RotateX( pos, cosX, -sinX ), cosY, -sinY );
if( info.IsSprite[block] ) {
DrawXFace( block, 0f, TileSide.Right );
DrawZFace( block, 0f, TileSide.Back );
} else {
DrawXFace( block, scale, TileSide.Left );
DrawZFace( block, -scale, TileSide.Back );
DrawYFace( block, scale * blockHeight, TileSide.Top );
}
for( int i = 0; i < index; i++ )
TransformVertex( ref cache.vertices[i] );
game.Graphics.DrawDynamicIndexedVb( DrawMode.Triangles, cache.vb,
cache.vertices, index, index * 6 / 4 );
}
开发者ID:umby24,项目名称:ClassicalSharp,代码行数:27,代码来源:IsometricBlockDrawer.cs
示例14: BlockHotbarWidget
public BlockHotbarWidget( Game game )
: base(game)
{
HorizontalAnchor = Anchor.Centre;
VerticalAnchor = Anchor.BottomOrRight;
hotbarCount = game.Inventory.Hotbar.Length;
}
开发者ID:umby24,项目名称:ClassicalSharp,代码行数:7,代码来源:BlockHotbarWidget.cs
示例15: Load
public virtual byte[] Load( Stream stream, Game game, out int width, out int height, out int length )
{
width = 0;
height = 0;
length = 0;
return null;
}
开发者ID:umby24,项目名称:ClassicalSharp,代码行数:7,代码来源:IMapFile.cs
示例16: Main
public static void Main( string[] args )
{
if( !Debugger.IsAttached ) {
AppDomain.CurrentDomain.UnhandledException += UnhandledException;
}
Utils.Log( "Starting " + Utils.AppName + ".." );
if( !File.Exists( "default.zip" ) ) {
Fail( "default.zip not found. Cannot start." );
return;
}
if( args.Length == 0 || args.Length == 1 ) {
Utils.Log( "Starting singleplayer mode." );
const string skinServer = "http://s3.amazonaws.com/MinecraftSkins/";
using( Game game = new Game( "LocalPlayer", null, skinServer, "default.zip" ) ) {
game.Run();
}
} else if( args.Length < 4 ) {
Fail( "ClassicalSharp.exe is only the raw client. You must either use the launcher or"
+ " provide command line arguments to start the client." );
} else {
RunMultiplayer( args );
}
}
开发者ID:Hetal728,项目名称:ClassicalSharp,代码行数:25,代码来源:Program.cs
示例17: InputHandler
public InputHandler( Game game )
{
this.game = game;
RegisterInputHandlers();
LoadMouseToKeyMappings();
Keys = new KeyMap();
}
开发者ID:Cheesse,项目名称:ClassicalSharp,代码行数:7,代码来源:InputHandler.cs
示例18: TextGroupWidget
public TextGroupWidget( Game game, int elementsCount,
Font font, Font underlineFont )
: base(game)
{
ElementsCount = elementsCount;
this.font = font;
this.underlineFont = underlineFont;
}
开发者ID:andrewphorn,项目名称:ClassicalSharp,代码行数:8,代码来源:TextGroupWidget.cs
示例19: ErrorScreen
public ErrorScreen( Game game, string title, string message )
: base(game)
{
this.title = title;
this.message = message;
titleFont = new Font( "Arial", 16, FontStyle.Bold );
messageFont = new Font( "Arial", 14, FontStyle.Regular );
}
开发者ID:umby24,项目名称:ClassicalSharp,代码行数:8,代码来源:ErrorScreen.cs
示例20: WeatherRenderer
public WeatherRenderer( Game game )
{
this.game = game;
map = game.Map;
graphics = game.Graphics;
info = game.BlockInfo;
weatherVb = graphics.CreateDynamicVb( VertexFormat.Pos3fTex2fCol4b, 12 * 9 * 9 );
}
开发者ID:Cheesse,项目名称:ClassicalSharp,代码行数:8,代码来源:WeatherRenderer.cs
注:本文中的ClassicalSharp.Game类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论