本文整理汇总了C#中fCraft.Map类的典型用法代码示例。如果您正苦于以下问题:C# Map类的具体用法?C# Map怎么用?C# Map使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Map类属于fCraft命名空间,在下文中一共展示了Map类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteLevelEnd
internal void WriteLevelEnd( Map map ) {
if( map == null ) throw new ArgumentNullException( "map" );
Write( OpCode.MapEnd );
Write( (short)map.WidthX );
Write( (short)map.Height );
Write( (short)map.WidthY );
}
示例2: LoadMap
public void LoadMap() {
lock( WorldLock ) {
if( Map != null ) return;
try {
Map = MapUtility.Load( GetMapName() );
} catch( Exception ex ) {
Logger.Log( "World.LoadMap: Failed to load map ({0}): {1}", LogType.Error,
GetMapName(), ex );
}
// or generate a default one
if( Map != null ) {
Map.World = this;
} else {
Logger.Log( "World.LoadMap: Generating default flatgrass level.", LogType.SystemActivity );
Map = new Map( this, 64, 64, 64, true );
MapGenerator.GenerateFlatgrass( Map );
Map.ResetSpawn();
}
StartTasks();
if( OnLoaded != null ) OnLoaded();
}
}
示例3: GenerateFlatgrass
public static Map GenerateFlatgrass( int width, int length, int height ) {
Map map = new Map( null, width, length, height, true );
map.Blocks.MemSet( (byte)Block.Stone, 0, width * length * (height / 2 - FlatgrassDirtLevel) );
map.Blocks.MemSet( (byte)Block.Dirt, width * length * (height / 2 - FlatgrassDirtLevel), width * length * (FlatgrassDirtLevel - 1) );
map.Blocks.MemSet( (byte)Block.Grass, width * length * (height / 2 - 1), width * length );
return map;
}
示例4: Deserialize
public void Deserialize( string group, string key, string value, Map map )
{
try {
WorldVariableLoader data = World.Deserialize( key, value, map );
data.LoadWorldVariables( map.World );
} catch ( Exception ex ) {
Logger.Log( LogType.Error, "WorldV.Deserialize: Error deserializing key {0}: {1}", key, ex );
}
}
示例5: Serialize
public int Serialize( Map map, Stream stream, IMapConverterEx converter )
{
BinaryWriter writer = new BinaryWriter( stream );
int count = 0;
foreach ( World world in WorldManager.Worlds ) {
converter.WriteMetadataEntry( _group[0], world.Name, world.Serialize(), writer );
++count;
}
return count;
}
示例6: MapGenerator
public MapGenerator( Random _rand, Map _map, Player _player, string _filename, double _roughness, double _smoothingOver, double _smoothingUnder, double _water, double _midpoint, double _sides, bool _hollow ) {
rand = _rand;
map = _map;
player = _player;
filename = _filename;
roughness = _roughness;
smoothingOver = _smoothingOver;
smoothingUnder = _smoothingUnder;
midpoint = _midpoint;
sides = _sides;
water = _water;
hollow = _hollow;
}
示例7: Serialize
public int Serialize( Map map, Stream stream, IMapConverterEx converter )
{
BinaryWriter writer = new BinaryWriter( stream );
int count = 0;
if ( map.MessageBlocks != null ) {
if ( map.MessageBlocks.Count >= 1 ) {
foreach ( MessageBlock MessageBlock in map.MessageBlocks ) {
converter.WriteMetadataEntry( _group[0], MessageBlock.Name, MessageBlock.Serialize(), writer );
++count;
}
}
}
return count;
}
示例8: Deserialize
public void Deserialize( string group, string key, string value, Map map )
{
try {
MessageBlock MessageBlock = MessageBlock.Deserialize( key, value, map );
if ( map.MessageBlocks == null ) map.MessageBlocks = new ArrayList();
if ( map.MessageBlocks.Count >= 1 ) {
if ( map.MessageBlocks.Contains( key ) ) {
Logger.Log( LogType.Error, "Map loading warning: duplicate MessageBlock name found: " + key + ", ignored" );
return;
}
}
map.MessageBlocks.Add( MessageBlock );
} catch ( Exception ex ) {
Logger.Log( LogType.Error, "MessageBlock.Deserialize: Error deserializing MessageBlock {0}: {1}", key, ex );
}
}
示例9: Deserialize
public void Deserialize(string group, string key, string value, Map map)
{
try
{
Life2DZone life = Life2DZone.Deserialize(key, value, map);
if (map.LifeZones.ContainsKey(key.ToLower()))
{
Logger.Log(LogType.Error, "Map loading warning: duplicate life name found: " + key+", ignored");
return;
}
map.LifeZones.Add(key.ToLower(), life);
}
catch (Exception ex)
{
Logger.Log(LogType.Error, "LifeSerialization.Deserialize: Error deserializing life {0}: {1}", key, ex);
}
}
示例10: Serialize
public int Serialize(Map map, Stream stream, IMapConverterEx converter)
{
BinaryWriter writer = new BinaryWriter(stream);
int count = 0;
World w = map.World;
Object lockObj = null == w ? new object() : w.SyncRoot;
IEnumerable<Life2DZone> lifes;
lock (lockObj)
{
lifes = map.LifeZones.Values.ToList(); //copies the current life list under a lock
}
foreach (Life2DZone life in lifes)
{
converter.WriteMetadataEntry(_group[0], life.Name, life.Serialize(), writer);
++count;
}
return count;
}
示例11: SealLiquids
static void SealLiquids(Map map, byte sealantType)
{
for (int x = 1; x < map.Width - 1; x++)
{
for (int z = 1; z < map.Height; z++)
{
for (int y = 1; y < map.Length - 1; y++)
{
int index = map.Index(x, y, z);
if ((map.Blocks[index] == 10 || map.Blocks[index] == 11 || map.Blocks[index] == 8 || map.Blocks[index] == 9) &&
(map.GetBlock(x - 1, y, z) == Block.Air || map.GetBlock(x + 1, y, z) == Block.Air ||
map.GetBlock(x, y - 1, z) == Block.Air || map.GetBlock(x, y + 1, z) == Block.Air ||
map.GetBlock(x, y, z - 1) == Block.Air))
{
map.Blocks[index] = sealantType;
}
}
}
}
}
示例12: AddSingleVein
static void AddSingleVein(Random rand, Map map, byte bedrockType, byte fillingType, int k, double maxDiameter, int l, int i1)
{
int j1 = rand.Next(0, map.Width);
int k1 = rand.Next(0, map.Height);
int l1 = rand.Next(0, map.Length);
double thirteenOverK = 1 / (double)k;
for (int i2 = 0; i2 < i1; i2++)
{
int j2 = j1 + (int)(.5 * (rand.NextDouble() - .5) * map.Width);
int k2 = k1 + (int)(.5 * (rand.NextDouble() - .5) * map.Height);
int l2 = l1 + (int)(.5 * (rand.NextDouble() - .5) * map.Length);
for (int l3 = 0; l3 < k; l3++)
{
int diameter = (int)(maxDiameter * rand.NextDouble() * map.Width);
if (diameter < 1) diameter = 2;
int radius = diameter / 2;
if (radius == 0) radius = 1;
int i3 = (int)((1 - thirteenOverK) * j1 + thirteenOverK * j2 + (l * radius) * (rand.NextDouble() - .5));
int j3 = (int)((1 - thirteenOverK) * k1 + thirteenOverK * k2 + (l * radius) * (rand.NextDouble() - .5));
int k3 = (int)((1 - thirteenOverK) * l1 + thirteenOverK * l2 + (l * radius) * (rand.NextDouble() - .5));
for (int k4 = 0; k4 < diameter; k4++)
{
for (int l4 = 0; l4 < diameter; l4++)
{
for (int i5 = 0; i5 < diameter; i5++)
{
if ((k4 - radius) * (k4 - radius) + (l4 - radius) * (l4 - radius) + (i5 - radius) * (i5 - radius) < radius * radius &&
i3 + k4 < map.Width && j3 + l4 < map.Height && k3 + i5 < map.Length &&
i3 + k4 >= 0 && j3 + l4 >= 0 && k3 + i5 >= 0)
{
int index = i3 + k4 + map.Width * map.Length * (map.Height - 1 - (j3 + l4)) + map.Width * (k3 + i5);
if (map.Blocks[index] == bedrockType)
{
map.Blocks[index] = fillingType;
}
}
}
}
}
}
j1 = j2;
k1 = k2;
l1 = l2;
}
}
示例13: removal
public static void removal(ConcurrentDictionary<String, Vector3I> bullets, Map map)
{
foreach (Vector3I bp in bullets.Values)
{
map.QueueUpdate(new BlockUpdate(null,
(short)bp.X,
(short)bp.Y,
(short)bp.Z,
Block.Air));
Vector3I removed;
bullets.TryRemove(bp.ToString(), out removed);
}
}
示例14: AddWorld
public static World AddWorld( string name, Map map, bool neverUnload )
{
lock( worldListLock ) {
if( worlds.ContainsKey( name ) ) return null;
if( !Player.IsValidName( name ) ) return null;
World newWorld = new World( name );
newWorld.neverUnload = neverUnload;
if( map != null ) {
// if a map is given
newWorld.map = map;
if( !neverUnload ) {
newWorld.UnloadMap();// UnloadMap also saves the map
} else {
newWorld.SaveMap( null );
}
} else {
// generate default map
if( neverUnload ) newWorld.LoadMap();
}
worlds.Add( name, newWorld );
newWorld.updateTaskId = AddTask( UpdateBlocks, Config.GetInt( ConfigKey.TickInterval ), newWorld );
if( Config.GetInt( ConfigKey.SaveInterval ) > 0 ) {
int saveInterval = Config.GetInt( ConfigKey.SaveInterval ) * 1000;
newWorld.saveTaskId = AddTask( SaveMap, saveInterval, newWorld, saveInterval );
}
if( Config.GetInt( ConfigKey.BackupInterval ) > 0 ) {
int backupInterval = Config.GetInt( ConfigKey.BackupInterval ) * 1000 * 60;
newWorld.backupTaskId = AddTask( AutoBackup, backupInterval, newWorld, (Config.GetBool( ConfigKey.BackupOnStartup ) ? 0 : backupInterval) );
}
newWorld.UpdatePlayerList();
return newWorld;
}
}
示例15: RaisePlayerPlacedBlockEvent
internal static void RaisePlayerPlacedBlockEvent( Player player, Map map, Vector3I coords,
Block oldBlock, Block newBlock, BlockChangeContext context ) {
var handler = PlacedBlock;
if( handler != null ) {
handler( null, new PlayerPlacedBlockEventArgs( player, map, coords, oldBlock, newBlock, context ) );
}
}