本文整理汇总了C#中World.GetNextEntityId方法的典型用法代码示例。如果您正苦于以下问题:C# World.GetNextEntityId方法的具体用法?C# World.GetNextEntityId怎么用?C# World.GetNextEntityId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类World
的用法示例。
在下文中一共展示了World.GetNextEntityId方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderSetPiece
public void RenderSetPiece(World world, IntPoint pos)
{
var radius = rand.Next(Size - 5, Size + 1)/2;
var border = new List<IntPoint>();
var t = new int[Size, Size];
for (var y = 0; y < Size; y++)
for (var x = 0; x < Size; x++)
{
var dx = x - (Size/2.0);
var dy = y - (Size/2.0);
var r = Math.Sqrt(dx*dx + dy*dy);
if (r <= radius)
{
t[x, y] = 1;
if (radius - r < 1.5)
border.Add(new IntPoint(x, y));
}
}
var trees = new HashSet<IntPoint>();
while (trees.Count < border.Count*0.5)
trees.Add(border[rand.Next(0, border.Count)]);
foreach (var i in trees)
t[i.X, i.Y] = 2;
for (var x = 0; x < Size; x++)
for (var y = 0; y < Size; y++)
{
if (t[x, y] == 1)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor;
tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 2)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor;
tile.ObjType = Tree;
tile.Name = "size:" + (rand.Next()%2 == 0 ? 120 : 140);
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Obstacles[x + pos.X, y + pos.Y] = 2;
world.Map[x + pos.X, y + pos.Y] = tile;
}
}
var ent = Entity.Resolve(0x091f);
ent.Size = 140;
ent.Move(pos.X + Size/2 + 1, pos.Y + Size/2 + 1);
world.EnterWorld(ent);
}
示例2: RenderSetPiece
public void RenderSetPiece(World world, IntPoint pos)
{
int radius = rand.Next(Size - 5, Size + 1) / 2;
List<IntPoint> border = new List<IntPoint>();
int[,] t = new int[Size, Size];
for (int y = 0; y < Size; y++)
for (int x = 0; x < Size; x++)
{
double dx = x - (Size / 2.0);
double dy = y - (Size / 2.0);
double r = Math.Sqrt(dx * dx + dy * dy);
if (r <= radius)
{
t[x, y] = 1;
if (radius - r < 1.5)
border.Add(new IntPoint(x, y));
}
}
HashSet<IntPoint> trees = new HashSet<IntPoint>();
while (trees.Count < border.Count * 0.5)
trees.Add(border[rand.Next(0, border.Count)]);
foreach (IntPoint i in trees)
t[i.X, i.Y] = 2;
XmlData dat = world.Manager.GameData;
for (int x = 0; x < Size; x++)
for (int y = 0; y < Size; y++)
{
if (t[x, y] == 1)
{
WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = dat.IdToTileType[Floor];
tile.ObjType = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 2)
{
WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = dat.IdToTileType[Floor];
tile.ObjType = dat.IdToObjectType[Tree];
tile.Name = "size:" + (rand.Next() % 2 == 0 ? 120 : 140);
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Map[x + pos.X, y + pos.Y] = tile;
}
}
Entity ent = Entity.Resolve(world.Manager, "Ent Ancient");
ent.Size = 140;
ent.Move(pos.X + Size / 2 + 1, pos.Y + Size / 2 + 1);
world.EnterWorld(ent);
}
示例3: RenderSetPiece
public void RenderSetPiece(World world, IntPoint pos)
{
var p = new int[Size, Size];
const double SCALE = 5.5;
for (var x = 0; x < Size; x++) //Lava
{
var t = (double) x/Size*Math.PI;
var x_ = t/Math.Sqrt(2) - Math.Sin(t)/(SCALE*Math.Sqrt(2));
var y1 = t/Math.Sqrt(2) - 2*Math.Sin(t)/(SCALE*Math.Sqrt(2));
var y2 = t/Math.Sqrt(2) + Math.Sin(t)/(SCALE*Math.Sqrt(2));
y1 /= Math.PI/Math.Sqrt(2);
y2 /= Math.PI/Math.Sqrt(2);
var y1_ = (int) Math.Ceiling(y1*Size);
var y2_ = (int) Math.Floor(y2*Size);
for (var i = y1_; i < y2_; i++)
p[x, i] = 1;
}
for (var x = 0; x < Size; x++) //Floor
for (var y = 0; y < Size; y++)
{
if (p[x, y] == 1 && rand.Next()%5 == 0)
p[x, y] = 2;
}
var r = rand.Next(0, 4); //Rotation
for (var i = 0; i < r; i++)
p = SetPieces.rotateCW(p);
p[20, 20] = 2;
for (var x = 0; x < Size; x++) //Rendering
for (var y = 0; y < Size; y++)
{
if (p[x, y] == 1)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Lava;
tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (p[x, y] == 2)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Lava;
tile.ObjType = Floor;
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
}
var demon = Entity.Resolve(0x668);
demon.Move(pos.X + 20.5f, pos.Y + 20.5f);
world.EnterWorld(demon);
var container = new Container(0x0501, null, false);
var count = rand.Next(5, 8);
var items = new List<Item>();
while (items.Count < count)
{
var item = chest.GetRandomLoot(rand);
if (item != null) items.Add(item);
}
for (var i = 0; i < items.Count; i++)
container.Inventory[i] = items[i];
container.Move(pos.X + 20.5f, pos.Y + 20.5f);
world.EnterWorld(container);
}
示例4: RenderSetPiece
public void RenderSetPiece(World world, IntPoint pos)
{
int[,] t = new int[81, 81];
for (int x = 0; x < Size; x++)
for (int y = 0; y < Size; y++)
{
double dx = x - (Size / 2.0);
double dy = y - (Size / 2.0);
double r = Math.Sqrt(dx * dx + dy * dy) + rand.NextDouble() * 4 - 2;
if (r <= 35)
t[x, y] = 1;
}
for (int x = 0; x < 17; x++)
for (int y = 0; y < 17; y++)
{
if (Center[x, y] != 0)
t[32 + x, 32 + y] = 2;
}
t[36, 36] = t[44, 36] = t[36, 44] = t[44, 44] = 3; //Pillars (Solo Standing)
t[30, 30] = t[50, 30] = t[30, 50] = t[50, 50] = 5; //Pillars (Outer Shape)
t[29, 33] = t[47, 29] = t[51, 47] = t[33, 51] = 5;
t[32, 29] = t[48, 51] = t[51, 32] = t[29, 48] = 5; // messy
t[29, 31] = t[49, 29] = t[51, 49] = t[31, 51] = 5;
t[30, 31] = t[49, 30] = t[50, 49] = t[31, 50] = 5;
t[33, 29] = t[51, 33] = t[47, 51] = t[29, 47] = 5;
t[29, 32] = t[51, 48] = t[48, 29] = t[32, 51] = 5; // messy
t[31, 29] = t[51, 31] = t[49, 51] = t[29, 49] = 5;
t[31, 30] = t[50, 31] = t[49, 50] = t[30, 49] = 5;
t[40, 26] = t[40, 27] = t[39, 27] = t[41, 27] = 4; //Pillars (T Shape)
t[40, 54] = t[40, 53] = t[39, 53] = t[41, 53] = 4;
t[26, 40] = t[27, 40] = t[27, 39] = t[27, 41] = 4;
t[54, 40] = t[53, 40] = t[53, 39] = t[53, 41] = 4;
for (int x = 0; x < Size; x++) //Rendering
for (int y = 0; y < Size; y++)
if (t[x, y] == 1)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor; tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 2)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Central; tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 3)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Central;
tile.ObjType = Pillar;
tile.Name = ConnectionComputer.GetConnString((_x, _y) => t[x + _x, y + _y] == 3);
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Obstacles[x + pos.X, y + pos.Y] = 2;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 4)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor;
tile.ObjType = Pillar;
tile.Name = ConnectionComputer.GetConnString((_x, _y) => t[x + _x, y + _y] == 4);
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Obstacles[x + pos.X, y + pos.Y] = 2;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 5)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor;
tile.ObjType = Pillar;
tile.Name = ConnectionComputer.GetConnString((_x, _y) => t[x + _x, y + _y] == 5);
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Obstacles[x + pos.X, y + pos.Y] = 2;
world.Map[x + pos.X, y + pos.Y] = tile;
}
Entity unknown = Entity.Resolve(0x0f02);
unknown.Move(pos.X + 40.5f, pos.Y + 40.5f);
world.EnterWorld(unknown);
}
示例5: RenderSetPiece
public void RenderSetPiece(World world, IntPoint pos)
{
var t = new int[27, 27];
var q = (int[,]) quarter.Clone();
for (var y = 0; y < 14; y++) //Top left
for (var x = 0; x < 14; x++)
t[x, y] = q[x, y];
q = SetPieces.reflectHori(q); //Top right
for (var y = 0; y < 14; y++)
for (var x = 0; x < 14; x++)
t[13 + x, y] = q[x, y];
q = SetPieces.reflectVert(q); //Bottom right
for (var y = 0; y < 14; y++)
for (var x = 0; x < 14; x++)
t[13 + x, 13 + y] = q[x, y];
q = SetPieces.reflectHori(q); //Bottom left
for (var y = 0; y < 14; y++)
for (var x = 0; x < 14; x++)
t[x, 13 + y] = q[x, y];
for (var y = 1; y < 4; y++) //Opening
for (var x = 8; x < 19; x++)
t[x, y] = 2;
t[12, 0] = t[13, 0] = t[14, 0] = 2;
var r = rand.Next(0, 4); //Rotation
for (var i = 0; i < r; i++)
t = SetPieces.rotateCW(t);
t[13 + 6, 13] = 3;
for (var x = 0; x < 27; x++) //Rendering
for (var y = 0; y < 27; y++)
{
if (t[x, y] == 1)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor;
tile.ObjType = Wall;
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Obstacles[x + pos.X, y + pos.Y] = 2;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 2)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor;
tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 3)
{
var cyclops = Entity.Resolve(0x0928);
cyclops.Move(pos.X + x, pos.Y + y);
world.EnterWorld(cyclops);
}
}
}
示例6: RenderSetPiece
public void RenderSetPiece(World world, IntPoint pos)
{
int[,] t = new int[81, 81];
for (int x = 0; x < Size; x++) //Flooring
for (int y = 0; y < Size; y++)
{
double dx = x - (Size / 2.0);
double dy = y - (Size / 2.0);
double r = Math.Sqrt(dx * dx + dy * dy) + rand.NextDouble() * 4 - 2;
if (r <= 35)
t[x, y] = 1;
}
for (int x = 0; x < 17; x++) //Center
for (int y = 0; y < 17; y++)
{
if (Center[x, y] != 0)
t[32 + x, 32 + y] = 2;
}
t[36, 36] = t[44, 36] = t[36, 44] = t[44, 44] = 3; //Pillars
t[30, 30] = t[50, 30] = t[30, 50] = t[50, 50] = 4;
t[40, 26] = t[40, 27] = t[39, 27] = t[41, 27] = 4;
t[40, 54] = t[40, 53] = t[39, 53] = t[41, 53] = 4;
t[26, 40] = t[27, 40] = t[27, 39] = t[27, 41] = 4;
t[54, 40] = t[53, 40] = t[53, 39] = t[53, 41] = 4;
var dat = world.Manager.GameData;
for (int x = 0; x < Size; x++) //Rendering
for (int y = 0; y < Size; y++)
if (t[x, y] == 1)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 2)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = dat.IdToTileType[Central]; tile.ObjType = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 3)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = dat.IdToTileType[Central];
tile.ObjType = dat.IdToObjectType[Pillar];
tile.Name = ConnectionComputer.GetConnString((_x, _y) => t[x + _x, y + _y] == 3);
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 4)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = dat.IdToTileType[Floor];
tile.ObjType = dat.IdToObjectType[Pillar];
tile.Name = ConnectionComputer.GetConnString((_x, _y) => t[x + _x, y + _y] == 4);
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Map[x + pos.X, y + pos.Y] = tile;
}
Entity sphinx = Entity.Resolve(world.Manager, "Grand Sphinx");
sphinx.Move(pos.X + 40.5f, pos.Y + 40.5f);
world.EnterWorld(sphinx);
}
示例7: RenderSetPiece
public void RenderSetPiece(World world, IntPoint pos)
{
int[,] t = new int[27, 27];
int[,] q = (int[,]) quarter.Clone();
for (int y = 0; y < 14; y++) //Top left
for (int x = 0; x < 14; x++)
t[x, y] = q[x, y];
q = SetPieces.reflectHori(q); //Top right
for (int y = 0; y < 14; y++)
for (int x = 0; x < 14; x++)
t[13 + x, y] = q[x, y];
q = SetPieces.reflectVert(q); //Bottom right
for (int y = 0; y < 14; y++)
for (int x = 0; x < 14; x++)
t[13 + x, 13 + y] = q[x, y];
q = SetPieces.reflectHori(q); //Bottom left
for (int y = 0; y < 14; y++)
for (int x = 0; x < 14; x++)
t[x, 13 + y] = q[x, y];
for (int y = 1; y < 4; y++) //Opening
for (int x = 8; x < 19; x++)
t[x, y] = 2;
t[12, 0] = t[13, 0] = t[14, 0] = 2;
int r = rand.Next(0, 4); //Rotation
for (int i = 0; i < r; i++)
t = SetPieces.rotateCW(t);
t[13 + 6, 13] = 3;
XmlData dat = world.Manager.GameData;
for (int x = 0; x < 27; x++) //Rendering
for (int y = 0; y < 27; y++)
{
if (t[x, y] == 1)
{
WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = dat.IdToTileType[Floor];
tile.ObjType = dat.IdToObjectType[Wall];
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 2)
{
WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = dat.IdToTileType[Floor];
tile.ObjType = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 3)
{
Entity cyclops = Entity.Resolve(world.Manager, 0x0928);
cyclops.Move(pos.X + x, pos.Y + y);
world.EnterWorld(cyclops);
}
}
}
示例8: RenderSetPiece
public void RenderSetPiece(World world, IntPoint pos)
{
int w = rand.Next(19, 22), h = rand.Next(19, 22);
int[,] t = new int[w, h];
for (int x = 0; x < w; x++) //Perimeter
{
t[x, 0] = 1;
t[x, h - 1] = 1;
}
for (int y = 0; y < h; y++)
{
t[0, y] = 1;
t[w - 1, y] = 1;
}
int midPtH = h / 2 + rand.Next(-2, 3); //Mid hori wall
int sepH = rand.Next(2, 4);
if (rand.Next() % 2 == 0)
{
for (int x = sepH; x < w; x++)
t[x, midPtH] = 1;
}
else
{
for (int x = 0; x < w - sepH; x++)
t[x, midPtH] = 1;
}
int begin, end;
if (rand.Next() % 2 == 0)
{
begin = 0; end = midPtH;
}
else
{
begin = midPtH; end = h;
}
int midPtV = w / 2 + rand.Next(-2, 3); //Mid vert wall
int sepW = rand.Next(2, 4);
if (rand.Next() % 2 == 0)
{
for (int y = begin + sepW; y < end; y++)
t[midPtV, y] = 1;
}
else
{
for (int y = begin; y < end - sepW; y++)
t[midPtV, y] = 1;
}
for (int x = 0; x < w; x++) //Flooring
for (int y = 0; y < h; y++)
if (t[x, y] == 0)
t[x, y] = 2;
for (int x = 0; x < w; x++) //Corruption
for (int y = 0; y < h; y++)
if (rand.Next() % 2 == 0)
t[x, y] = 0;
int rotation = rand.Next(0, 4); //Rotation
for (int i = 0; i < rotation; i++)
t = SetPieces.rotateCW(t);
w = t.GetLength(0); h = t.GetLength(1);
for (int x = 0; x < w; x++) //Rendering
for (int y = 0; y < h; y++)
{
if (t[x, y] == 1)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.ObjType = Wall;
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Obstacles[x + pos.X, y + pos.Y] = 2;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 2)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor; tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
}
}
示例9: RenderSetPiece
public void RenderSetPiece(World world, IntPoint pos)
{
int outerRadius = 13;
int waterRadius = 5;
int islandRadius = 8;
var border = new List<IntPoint>();
var t = new int[Size, Size];
for (int y = 0; y < Size; y++) //Outer
for (int x = 0; x < Size; x++)
{
double dx = x - (Size/2.0);
double dy = y - (Size/2.0);
double r = Math.Sqrt(dx*dx + dy*dy);
if (r <= outerRadius)
t[x, y] = 1;
}
for (int y = 0; y < Size; y++) //Water
for (int x = 0; x < Size; x++)
{
double dx = x - (Size/2.0);
double dy = y - (Size/2.0);
double r = Math.Sqrt(dx*dx + dy*dy);
if (r <= waterRadius)
{
t[x, y] = 2;
if (waterRadius - r < 1)
border.Add(new IntPoint(x, y));
}
}
for (int y = 0; y < Size; y++) //Island
for (int x = 0; x < Size; x++)
{
double dx = x - (Size/2.0);
double dy = y - (Size/2.0);
double r = Math.Sqrt(dx*dx + dy*dy);
if (r <= islandRadius)
{
t[x, y] = 1;
if (islandRadius - r < 1)
border.Add(new IntPoint(x, y));
}
}
var trees = new HashSet<IntPoint>();
while (trees.Count < border.Count*0.5)
trees.Add(border[rand.Next(0, border.Count)]);
foreach (IntPoint i in trees)
t[i.X, i.Y] = 3;
XmlData dat = world.Manager.GameData;
for (int x = 0; x < Size; x++)
for (int y = 0; y < Size; y++)
{
if (t[x, y] == 1)
{
WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = dat.IdToTileType[Floor];
tile.ObjType = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
//else if (t[x, y] == 2)
//{
// var tile = world.Map[x + pos.X, y + pos.Y].Clone();
// tile.TileId = dat.IdToTileType[Lava]; tile.ObjType = 0;
// world.Map[x + pos.X, y + pos.Y] = tile;
//}
else if (t[x, y] == 3)
{
WmapTile tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = dat.IdToTileType[Lava];
tile.ObjType = dat.IdToObjectType[Bush];
tile.Name = "size:" + (rand.Next()%2 == 0 ? 0 : 0);
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Map[x + pos.X, y + pos.Y] = tile;
}
}
Entity mage = Entity.Resolve(world.Manager, "Forgotten Archmage of Flame");
mage.Move(pos.X + 23.0f, pos.Y + 23.0f);
world.EnterWorld(mage);
}
示例10: RenderSetPiece
public void RenderSetPiece(World world, IntPoint pos)
{
int outerRadius = 13;
int waterRadius = 10;
int islandRadius = 3;
List<IntPoint> border = new List<IntPoint>();
int[,] t = new int[Size, Size];
for (int y = 0; y < Size; y++) //Outer
for (int x = 0; x < Size; x++)
{
double dx = x - (Size / 2.0);
double dy = y - (Size / 2.0);
double r = Math.Sqrt(dx * dx + dy * dy);
if (r <= outerRadius)
t[x, y] = 1;
}
for (int y = 0; y < Size; y++) //Water
for (int x = 0; x < Size; x++)
{
double dx = x - (Size / 2.0);
double dy = y - (Size / 2.0);
double r = Math.Sqrt(dx * dx + dy * dy);
if (r <= waterRadius)
{
t[x, y] = 2;
if (waterRadius - r < 1)
border.Add(new IntPoint(x, y));
}
}
for (int y = 0; y < Size; y++) //Island
for (int x = 0; x < Size; x++)
{
double dx = x - (Size / 2.0);
double dy = y - (Size / 2.0);
double r = Math.Sqrt(dx * dx + dy * dy);
if (r <= islandRadius)
{
t[x, y] = 1;
if (islandRadius - r < 1)
border.Add(new IntPoint(x, y));
}
}
HashSet<IntPoint> trees = new HashSet<IntPoint>();
while (trees.Count < border.Count * 0.5)
trees.Add(border[rand.Next(0, border.Count)]);
foreach (var i in trees)
t[i.X, i.Y] = 3;
var dat = world.Manager.GameData;
for (int x = 0; x < Size; x++)
for (int y = 0; y < Size; y++)
{
if (t[x, y] == 1)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = dat.IdToTileType[Floor]; tile.ObjType = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 2)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = dat.IdToTileType[Water]; tile.ObjType = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 3)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = dat.IdToTileType[Floor];
tile.ObjType = dat.IdToObjectType[Tree]; tile.Name = "size:" + (rand.Next() % 2 == 0 ? 120 : 140);
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Map[x + pos.X, y + pos.Y] = tile;
}
}
Entity giant = Entity.Resolve(world.Manager, "Oasis Giant");
giant.Move(pos.X + 15.5f, pos.Y + 15.5f);
world.EnterWorld(giant);
Container container = new Container(world.Manager, 0x0501, null, false);
Item[] items = chest.GetLoots(world.Manager, 5, 8).ToArray();
for (int i = 0; i < items.Length; i++)
container.Inventory[i] = items[i];
container.Move(pos.X + 15.5f, pos.Y + 15.5f);
world.EnterWorld(container);
}
示例11: RenderSetPiece
public void RenderSetPiece(World world, IntPoint pos)
{
int[,] t = new int[25, 26];
for (int x = 2; x < 23; x++) //Floor
for (int y = 1; y < 24; y++)
t[x, y] = rand.Next() % 10 == 0 ? 0 : 1;
for (int y = 1; y < 24; y++) //Perimeters
t[2, y] = t[22, y] = 2;
for (int x = 2; x < 23; x++)
t[x, 23] = 2;
for (int x = 0; x < 3; x++)
for (int y = 0; y < 3; y++)
t[x + 1, y] = t[x + 21, y] = 2;
for (int x = 0; x < 5; x++)
for (int y = 0; y < 5; y++)
{
if ((x == 0 && y == 0) ||
(x == 0 && y == 4) ||
(x == 4 && y == 0) ||
(x == 4 && y == 4)) continue;
t[x, y + 21] = t[x + 20, y + 21] = 2;
}
for (int y = 0; y < 6; y++) //Pillars
t[9, 4 + 3 * y] = t[15, 4 + 3 * y] = 4;
for (int x = 0; x < 25; x++) //Corruption
for (int y = 0; y < 26; y++)
{
if (t[x, y] == 1 || t[x, y] == 0) continue;
double p = rand.NextDouble();
if (p < 0.1)
t[x, y] = 1;
else if (p < 0.4)
t[x, y]++;
}
int r = rand.Next(0, 4);
for (int i = 0; i < r; i++) //Rotation
t = SetPieces.rotateCW(t);
int w = t.GetLength(0), h = t.GetLength(1);
for (int x = 0; x < w; x++) //Rendering
for (int y = 0; y < h; y++)
{
if (t[x, y] == 1)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor;
tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 2)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor;
tile.ObjType = WallA;
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Obstacles[x + pos.X, y + pos.Y] = 2;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 3)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor;
world.Obstacles[x + pos.X, y + pos.Y] = 2;
world.Map[x + pos.X, y + pos.Y] = tile;
Entity wall = Entity.Resolve(WallB);
wall.Move(x + pos.X + 0.5f, y + pos.Y + 0.5f);
world.EnterWorld(wall);
}
else if (t[x, y] == 4)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor;
tile.ObjType = PillarA;
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Obstacles[x + pos.X, y + pos.Y] = 2;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 5)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor;
tile.ObjType = PillarB;
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Obstacles[x + pos.X, y + pos.Y] = 2;
world.Map[x + pos.X, y + pos.Y] = tile;
}
}
//Boss
Entity lich = Entity.Resolve(0x091b);
lich.Move(pos.X + Size / 2, pos.Y + Size / 2);
world.EnterWorld(lich);
}
示例12: RenderSetPiece
public void RenderSetPiece(World world, IntPoint pos)
{
int outerRadius = 13;
int waterRadius = 10;
int islandRadius = 3;
List<IntPoint> border = new List<IntPoint>();
int[,] t = new int[Size, Size];
for (int y = 0; y < Size; y++) //Outer
for (int x = 0; x < Size; x++)
{
double dx = x - (Size / 2.0);
double dy = y - (Size / 2.0);
double r = Math.Sqrt(dx * dx + dy * dy);
if (r <= outerRadius)
t[x, y] = 1;
}
for (int y = 0; y < Size; y++) //Water
for (int x = 0; x < Size; x++)
{
double dx = x - (Size / 2.0);
double dy = y - (Size / 2.0);
double r = Math.Sqrt(dx * dx + dy * dy);
if (r <= waterRadius)
{
t[x, y] = 2;
if (waterRadius - r < 1)
border.Add(new IntPoint(x, y));
}
}
for (int y = 0; y < Size; y++) //Island
for (int x = 0; x < Size; x++)
{
double dx = x - (Size / 2.0);
double dy = y - (Size / 2.0);
double r = Math.Sqrt(dx * dx + dy * dy);
if (r <= islandRadius)
{
t[x, y] = 1;
if (islandRadius - r < 1)
border.Add(new IntPoint(x, y));
}
}
HashSet<IntPoint> trees = new HashSet<IntPoint>();
while (trees.Count < border.Count * 0.5)
trees.Add(border[rand.Next(0, border.Count)]);
foreach (var i in trees)
t[i.X, i.Y] = 3;
for (int x = 0; x < Size; x++)
for (int y = 0; y < Size; y++)
{
if (t[x, y] == 1)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor; tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 2)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Water; tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 3)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor;
tile.ObjType = Tree; tile.Name = "size:" + (rand.Next() % 2 == 0 ? 120 : 140);
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Obstacles[x + pos.X, y + pos.Y] = 2;
world.Map[x + pos.X, y + pos.Y] = tile;
}
}
Entity giant = Entity.Resolve(0x678);
giant.Move(pos.X + 15.5f, pos.Y + 15.5f);
world.EnterWorld(giant);
Container container = new Container(0x0501, null, false);
int count = rand.Next(5, 8);
List<Item> items = new List<Item>();
while (items.Count < count)
{
Item item = chest.GetRandomLoot(rand);
if (item != null) items.Add(item);
}
for (int i = 0; i < items.Count; i++)
container.Inventory[i] = items[i];
container.Move(pos.X + 15.5f, pos.Y + 15.5f);
world.EnterWorld(container);
}
示例13: RenderSetPiece
public void RenderSetPiece(World world, IntPoint pos)
{
const int waterRadius = 18;
const float islandRadius = 2.5f;
var TreeCount = 0;
var border = new List<IntPoint>();
var t = new int[Size, Size];
for (var y = 0; y < Size; y++) //Outer
for (var x = 0; x < Size; x++)
{
var dx = x - Size / 2.0;
var dy = y - Size / 2.0;
double sandRadius = 20 + rand.Next(0, 3);
var r = Math.Sqrt(dx * dx + dy * dy);
if (r <= sandRadius)
{
t[x, y] = 1;
}
}
for (var y = 0; y < Size; y++) //Water
for (var x = 0; x < Size; x++)
{
var dx = x - Size / 2.0;
var dy = y - Size / 2.0;
var r = Math.Sqrt(dx * dx + dy * dy);
if (r <= waterRadius)
{
t[x, y] = 2;
}
}
for (var y = 0; y < Size; y++) //Island
for (var x = 0; x < Size; x++)
{
var dx = x - Size / 2.0;
var dy = y - Size / 2.0;
var r = Math.Sqrt(dx * dx + dy * dy);
if (!(r <= islandRadius))
continue;
var Tree = rand.Next(1, 4);
t[x, y] = 3;
if (Tree != 1 || x == 21 || y == 21 || TreeCount >= 3)
continue;
t[x, y] = 4;
TreeCount++;
}
for (var x = 0; x < Size; x++)
for (var y = 0; y < Size; y++)
{
switch (t[x, y])
{
case 1:
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Outer;
tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
break;
case 2:
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Water;
tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
break;
case 3:
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Island;
tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
break;
case 4:
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Island;
tile.ObjType = Tree;
tile.Name = "size:" + (rand.Next() % 2 == 0 ? 120 : 140);
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Obstacles[x + pos.X, y + pos.Y] = 2;
world.Map[x + pos.X, y + pos.Y] = tile;
}
break;
}
}
var Bum = Entity.Resolve(0x0e55);
Bum.Move(pos.X + 21.5f, pos.Y + 21.5f);
world.EnterWorld(Bum);
}
示例14: RenderSetPiece
public void RenderSetPiece(World world, IntPoint pos)
{
var t = new int[81, 81];
for (var x = 0; x < Size; x++) //Flooring
for (var y = 0; y < Size; y++)
{
var dx = x - (Size/2.0);
var dy = y - (Size/2.0);
var r = Math.Sqrt(dx*dx + dy*dy) + rand.NextDouble()*4 - 2;
if (r <= 35)
t[x, y] = 1;
}
for (var x = 0; x < 17; x++) //Center
for (var y = 0; y < 17; y++)
{
if (Center[x, y] != 0)
t[32 + x, 32 + y] = 2;
}
t[36, 36] = t[44, 36] = t[36, 44] = t[44, 44] = 3; //Pillars
t[30, 30] = t[50, 30] = t[30, 50] = t[50, 50] = 4;
t[40, 26] = t[40, 27] = t[39, 27] = t[41, 27] = 4;
t[40, 54] = t[40, 53] = t[39, 53] = t[41, 53] = 4;
t[26, 40] = t[27, 40] = t[27, 39] = t[27, 41] = 4;
t[54, 40] = t[53, 40] = t[53, 39] = t[53, 41] = 4;
for (var x = 0; x < Size; x++) //Rendering
for (var y = 0; y < Size; y++)
if (t[x, y] == 1)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor;
tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 2)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Central;
tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 3)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Central;
tile.ObjType = Pillar;
tile.Name = ConnectionComputer.GetConnString((_x, _y) => t[x + _x, y + _y] == 3);
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Obstacles[x + pos.X, y + pos.Y] = 2;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 4)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Floor;
tile.ObjType = Pillar;
tile.Name = ConnectionComputer.GetConnString((_x, _y) => t[x + _x, y + _y] == 4);
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Obstacles[x + pos.X, y + pos.Y] = 2;
world.Map[x + pos.X, y + pos.Y] = tile;
}
var sphinx = Entity.Resolve(0x0d54);
sphinx.Move(pos.X + 40.5f, pos.Y + 40.5f);
world.EnterWorld(sphinx);
}
示例15: RenderSetPiece
//.........这里部分代码省略.........
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = DarkGrass;
tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 2)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Sand;
tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 3)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Water;
tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 4)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = WaterDeep;
tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (o[x, y] == 5)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.ObjType = Flower;
if (tile.ObjId == 0) tile.ObjId = world.GetNextEntityId();
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 6)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = BrokenPillar;
tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
else if (t[x, y] == 7)
{
var tile = world.Map[x + pos.X, y + pos.Y].Clone();
tile.TileId = Pillar;
tile.ObjType = 0;
world.Obstacles[x + pos.X, y + pos.Y] = 0;
world.Map[x + pos.X, y + pos.Y] = tile;
}
}
var hermit = Entity.Resolve(0x0d61);
var tentacle1 = Entity.Resolve(0x0d65);
var tentacle2 = Entity.Resolve(0x0d65);
var tentacle3 = Entity.Resolve(0x0d65);
var tentacle4 = Entity.Resolve(0x0d65);
var tentacle5 = Entity.Resolve(0x0d65);
var tentacle6 = Entity.Resolve(0x0d65);
var tentacle7 = Entity.Resolve(0x0d65);
var tentacle8 = Entity.Resolve(0x0d65);
hermit.Move(pos.X + 15.5f, pos.Y + 15.5f);
world.EnterWorld(hermit);
tentacle1.Move(pos.X + 9.5f, pos.Y + 15.5f);
world.EnterWorld(tentacle1);
tentacle2.Move(pos.X + 10.5f, pos.Y + 20.5f);
world.EnterWorld(tentacle2);
tentacle3.Move(pos.X + 15.5f, pos.Y + 21.5f);
world.EnterWorld(tentacle3);
tentacle4.Move(pos.X + 20.5f, pos.Y + 20.5f);
world.EnterWorld(tentacle4);
tentacle5.Move(pos.X + 21.5f, pos.Y + 15.5f);
world.EnterWorld(tentacle5);
tentacle6.Move(pos.X + 20.5f, pos.Y + 10.5f);
world.EnterWorld(tentacle6);
tentacle7.Move(pos.X + 15.5f, pos.Y + 9.5f);
world.EnterWorld(tentacle7);
tentacle8.Move(pos.X + 10.5f, pos.Y + 10.5f);
world.EnterWorld(tentacle8);
}