本文整理汇总了C#中Vector2Int32类的典型用法代码示例。如果您正苦于以下问题:C# Vector2Int32类的具体用法?C# Vector2Int32怎么用?C# Vector2Int32使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector2Int32类属于命名空间,在下文中一共展示了Vector2Int32类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: CheckDirectionandDraw
private void CheckDirectionandDraw(Vector2Int32 tile)
{
Vector2Int32 p = tile;
Vector2Int32 p2 = tile;
if (_isRightDown)
{
if (_isLeftDown)
p.X = _startPoint.X;
else
p.Y = _startPoint.Y;
DrawLine(p);
_startPoint = p;
}
else if (_isLeftDown)
{
if ((Keyboard.IsKeyUp(Key.LeftShift)) && (Keyboard.IsKeyUp(Key.RightShift)))
{
DrawLine(p);
_startPoint = p;
_endPoint = p;
}
else if ((Keyboard.IsKeyDown(Key.LeftShift)) || (Keyboard.IsKeyDown(Key.RightShift)))
{
DrawLineP2P(p2);
_endPoint = p2;
}
}
}
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:29,代码来源:BrushTool.cs
示例2: DrawLine
public static IEnumerable<Vector2Int32> DrawLine(Vector2Int32 start, Vector2Int32 end)
{
// Distance start and end point
int dx = end.X - start.X;
int dy = end.Y - start.Y;
// Determine slope (absoulte value)
int len = dy >= 0 ? dy : -dy;
int lenx = dx >= 0 ? dx : -dx;
if (lenx > len)
{
len = lenx;
}
// Prevent divison by zero
if (len != 0)
{
// Init steps and start
float incx = dx / (float)len;
float incy = dy / (float)len;
float x = start.X;
float y = start.Y;
// Walk the line!
for (int i = 0; i < len; i++)
{
yield return new Vector2Int32((int)x, (int)y);
x += incx;
y += incy;
}
}
}
开发者ID:KeviinSkyline,项目名称:Terraria-Map-Editor,代码行数:34,代码来源:Shape.cs
示例3: PasteClipboard
private void PasteClipboard(Vector2Int32 anchor)
{
_wvm.Clipboard.PasteBufferIntoWorld(anchor);
_wvm.UpdateRenderRegion(new Rectangle(anchor.X, anchor.Y, _wvm.Clipboard.Buffer.Size.X, _wvm.Clipboard.Buffer.Size.Y));
/* Heathtech */
BlendRules.ResetUVCache(_wvm, anchor.X, anchor.Y, _wvm.Clipboard.Buffer.Size.X, _wvm.Clipboard.Buffer.Size.Y);
}
开发者ID:KeviinSkyline,项目名称:Terraria-Map-Editor,代码行数:8,代码来源:PasteTool.cs
示例4: FromHwndMouseEventArgs
public static TileMouseState FromHwndMouseEventArgs(HwndMouseEventArgs e, Vector2Int32 tile)
{
return new TileMouseState
{
LeftButton = e.LeftButton,
RightButton = e.RightButton,
MiddleButton = e.MiddleButton,
Location = tile
};
}
开发者ID:ThomasWDonnelly,项目名称:Terraria-Map-Editor,代码行数:10,代码来源:TileMouseState.cs
示例5: SetRectangle
public void SetRectangle(Vector2Int32 p1, Vector2Int32 p2)
{
int x1 = p1.X < p2.X ? p1.X : p2.X;
int y1 = p1.Y < p2.Y ? p1.Y : p2.Y;
int width = Math.Abs(p2.X - p1.X) + 1;
int height = Math.Abs(p2.Y - p1.Y) + 1;
SelectionArea = new Rectangle(x1, y1, width, height);
IsActive = true;
}
开发者ID:ThomasWDonnelly,项目名称:Terraria-Map-Editor,代码行数:10,代码来源:Selection.cs
示例6: FillRectangle
public static IEnumerable<Vector2Int32> FillRectangle(Vector2Int32 offset, Vector2Int32 size)
{
for (int y = offset.Y; y < offset.Y + size.Y; y++)
{
for (int x = offset.X; x < offset.X + size.X; x++)
{
yield return new Vector2Int32(x, y);
}
}
}
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:10,代码来源:Fill.cs
示例7: FillEllipse
public static IEnumerable<Vector2Int32> FillEllipse(Vector2Int32 offset, Vector2Int32 size)
{
// Calc center and radius
int xr = (size.X - offset.X) >> 1;
int yr = (size.Y - offset.Y) >> 1;
int xc = offset.X + xr;
int yc = offset.Y + yr;
var center = new Vector2Int32(xc, yc);
var radius = new Vector2Int32(xr, yr);
Debug.WriteLine(string.Format("Center: {0}, Radius: {1}", center, radius));
return FillEllipseCentered(center, radius);
}
开发者ID:Walkman-Mirror,项目名称:BCCL,代码行数:15,代码来源:Fill.cs
示例8: DrawLine
private void DrawLine(Vector2Int32 to)
{
foreach (Vector2Int32 pixel in Shape.DrawLineTool(_startPoint, to))
{
if (!_wvm.CurrentWorld.ValidTileLocation(pixel)) continue;
int index = pixel.X + pixel.Y * _wvm.CurrentWorld.TilesWide;
if (!_wvm.CheckTiles[index])
{
_wvm.CheckTiles[index] = true;
if (_wvm.Selection.IsValid(pixel))
{
_wvm.UndoManager.SaveTile(pixel);
_wvm.SetPixel(pixel.X, pixel.Y);
}
}
}
}
开发者ID:skulldownz,项目名称:Terraria-Map-Editor,代码行数:18,代码来源:PencilTool.cs
示例9: Add
public void Add(Vector2Int32 location, Tile tile)
{
var undoTile = new UndoTile(location, tile);
if (undoTile == null)
{
throw new Exception("Null undo?");
}
lock (UndoSaveLock)
{
UndoTiles.Add(undoTile);
LastTile = undoTile;
}
if (UndoTiles.Count > FlushSize)
{
Flush();
}
}
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:19,代码来源:UndoBuffer.cs
示例10: Flood
public void Flood(Vector2Int32 pt)
{
int bitmapWidth = _wvm.CurrentWorld.TilesWide;
int bitmapHeight = _wvm.CurrentWorld.TilesHigh;
int x = pt.X;
int y = pt.Y;
_wvm.CheckTiles = new bool[bitmapWidth * bitmapHeight];
var originTile = (Tile)_wvm.CurrentWorld.Tiles[x, y].Clone();
LinearFloodFill(ref x, ref y, ref originTile);
while (_ranges.Count > 0)
{
//**Get Next Range Off the Queue
FloodFillRange range = _ranges.Dequeue();
//**Check Above and Below Each Pixel in the Floodfill Range
int downPxIdx = (bitmapWidth * (range.Y + 1)) + range.StartX;//CoordsToPixelIndex(lFillLoc,y+1);
int upPxIdx = (bitmapWidth * (range.Y - 1)) + range.StartX;//CoordsToPixelIndex(lFillLoc, y - 1);
int upY = range.Y - 1;//so we can pass the y coord by ref
int downY = range.Y + 1;
for (int i = range.StartX; i <= range.EndX; i++)
{
//*Start Fill Upwards
//if we're not above the top of the bitmap and the pixel above this one is within the color tolerance
if (range.Y > 0 && (!_wvm.CheckTiles[upPxIdx]) && CheckTileMatch(ref originTile, ref _wvm.CurrentWorld.Tiles[i, upY]) && _wvm.Selection.IsValid(i, upY))
LinearFloodFill(ref i, ref upY, ref originTile);
//*Start Fill Downwards
//if we're not below the bottom of the bitmap and the pixel below this one is within the color tolerance
if (range.Y < (bitmapHeight - 1) && (!_wvm.CheckTiles[downPxIdx]) && CheckTileMatch(ref originTile, ref _wvm.CurrentWorld.Tiles[i, downY]) && _wvm.Selection.IsValid(i, downY))
LinearFloodFill(ref i, ref downY, ref originTile);
downPxIdx++;
upPxIdx++;
}
if (upY < _minY)
_minY = upY;
if (downY > _maxY)
_maxY = downY;
}
}
开发者ID:Ninlay,项目名称:Terraria-Map-Editor,代码行数:43,代码来源:FillTool.cs
示例11: CheckDirectionandDraw
private void CheckDirectionandDraw(Vector2Int32 tile)
{
Vector2Int32 p = tile;
if (_isRightDown)
{
if (_isLeftDown)
p.X = _startPoint.X;
else
p.Y = _startPoint.Y;
DrawLine(p);
_startPoint = p;
}
else if (_isLeftDown)
{
DrawLine(p);
_startPoint = p;
}
}
开发者ID:jiangzhonghui,项目名称:Terraria-Map-Editor,代码行数:19,代码来源:PencilTool.cs
示例12: AddNpc
private void AddNpc(int npcId)
{
if (CurrentWorld != null && World.NpcNames.ContainsKey(npcId))
{
string name = World.NpcNames[npcId];
if (CurrentWorld.NPCs.All(n => n.SpriteId != npcId))
{
var spawn = new Vector2Int32(CurrentWorld.SpawnX, CurrentWorld.SpawnY);
CurrentWorld.NPCs.Add(new NPC{Home = spawn, IsHomeless = true, DisplayName = name, Name = name, Position= new Vector2(spawn.X * 16, spawn.Y * 16), SpriteId = npcId});
Points.Add(name);
MessageBox.Show(string.Format("{0} added to spawn.", name), "NPC Added");
}
else
{
MessageBox.Show(string.Format("{0} is already on the map.", name), "NPC Exists");
}
}
else
{
MessageBox.Show(string.Format("Choose an NPC. NPC {0} not found.", npcId), "NPC Error");
}
}
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:22,代码来源:WorldViewModel.Commands.cs
示例13: AddNpc
private void AddNpc(NpcName npc)
{
if (CurrentWorld != null)
{
if (!CurrentWorld.NPCs.Any(n => n.Name == npc.Character))
{
var spawn = new Vector2Int32(CurrentWorld.SpawnX, CurrentWorld.SpawnY);
CurrentWorld.NPCs.Add(new NPC{Home = spawn, IsHomeless = true, Name = npc.Character, Position= new Vector2(spawn.X * 16, spawn.Y * 16), SpriteId = npc.Id});
Points.Add(npc.Character);
MessageBox.Show(string.Format("{1} ({0}) added to spawn.", npc.Character, npc.Name), "NPC Added");
}
else
{
MessageBox.Show(string.Format("{1} ({0}) is already on the map.", npc.Character, npc.Name), "NPC Exists");
}
}
}
开发者ID:nikitikitaki,项目名称:Terraria-Map-Editor,代码行数:17,代码来源:WorldViewModel.Commands.cs
示例14: FillEllipseCentered
public static IEnumerable<Vector2Int32> FillEllipseCentered(Vector2Int32 center, Vector2Int32 radius)
{
int xr = radius.X;
int yr = radius.Y;
int xc = center.X;
int yc = center.Y;
if (xr >= 1 && yr >= 1)
{
// Init vars
int uy, ly, lx, rx;
int x = xr;
int y = 0;
int xrSqTwo = (xr * xr) << 1;
int yrSqTwo = (yr * yr) << 1;
int xChg = yr * yr * (1 - (xr << 1));
int yChg = xr * xr;
int err = 0;
int xStopping = yrSqTwo * xr;
int yStopping = 0;
// Draw first set of points counter clockwise where tangent line slope > -1.
while (xStopping >= yStopping)
{
// Draw 4 quadrant points at once
uy = yc + y; // Upper half
ly = yc - y; // Lower half
//if (uy < 0) uy = 0; // Clip
//if (uy >= h) uy = h - 1; // ...
//if (ly < 0) ly = 0;
//if (ly >= h) ly = h - 1;
//uh = uy*w; // Upper half
//lh = ly*w; // Lower half
rx = xc + x;
lx = xc - x;
//if (rx < 0) rx = 0; // Clip
//if (rx >= w) rx = w - 1; // ...
//if (lx < 0) lx = 0;
//if (lx >= w) lx = w - 1;
// Draw line
for (int i = lx; i <= rx; i++)
{
yield return new Vector2Int32(i, uy); // Quadrant II to I (Actually two octants)
yield return new Vector2Int32(i, ly); // Quadrant III to IV
}
y++;
yStopping += xrSqTwo;
err += yChg;
yChg += xrSqTwo;
if ((xChg + (err << 1)) > 0)
{
x--;
xStopping -= yrSqTwo;
err += xChg;
xChg += yrSqTwo;
}
}
// ReInit vars
x = 0;
y = yr;
uy = yc + y; // Upper half
ly = yc - y; // Lower half
//if (uy < 0) uy = 0; // Clip
//if (uy >= h) uy = h - 1; // ...
//if (ly < 0) ly = 0;
//if (ly >= h) ly = h - 1;
//uh = uy*w; // Upper half
//lh = ly*w; // Lower half
xChg = yr * yr;
yChg = xr * xr * (1 - (yr << 1));
err = 0;
xStopping = 0;
yStopping = xrSqTwo * yr;
// Draw second set of points clockwise where tangent line slope < -1.
while (xStopping <= yStopping)
{
// Draw 4 quadrant points at once
rx = xc + x;
lx = xc - x;
//if (rx < 0) rx = 0; // Clip
//if (rx >= w) rx = w - 1; // ...
//if (lx < 0) lx = 0;
//if (lx >= w) lx = w - 1;
// Draw line
for (int i = lx; i <= rx; i++)
{
yield return new Vector2Int32(i, uy); // Quadrant II to I (Actually two octants)
yield return new Vector2Int32(i, ly); // Quadrant III to IV
}
x++;
xStopping += yrSqTwo;
err += xChg;
//.........这里部分代码省略.........
开发者ID:Walkman-Mirror,项目名称:BCCL,代码行数:101,代码来源:Fill.cs
示例15: LinearFloodFill
private static void LinearFloodFill(ref Vector2Int32 start, ref Vector2Int32 minBound, ref Vector2Int32 maxBound, Func<Vector2Int32, bool> validation, ref FloodFillRangeQueue ranges, ref HashSet<Vector2Int32> points)
{
//FIND LEFT EDGE OF COLOR AREA
int lFillLoc = start.X; //the location to check/fill on the left
int x = start.X;
int y = start.Y;
points.Add(start);
while (true)
{
points.Add(new Vector2Int32(lFillLoc, y));
// Preform validation for next point
lFillLoc--;
var curPoint = new Vector2Int32(lFillLoc, y);
if (lFillLoc <= minBound.X || !validation(curPoint) || points.Contains(curPoint))
break; //exit loop if we're at edge of bitmap or match area
}
lFillLoc++;
//FIND RIGHT EDGE OF COLOR AREA
int rFillLoc = x; //the location to check/fill on the left
while (true)
{
points.Add(new Vector2Int32(rFillLoc, y));
rFillLoc++;
var curPoint = new Vector2Int32(rFillLoc, y);
if (rFillLoc >= maxBound.X || !validation(curPoint) || points.Contains(curPoint))
break; //exit loop if we're at edge of bitmap or color area
}
rFillLoc--;
var r = new FloodFillRange(lFillLoc, rFillLoc, y);
ranges.Enqueue(ref r);
}
开发者ID:Walkman-Mirror,项目名称:BCCL,代码行数:39,代码来源:Fill.cs
示例16: Flood
public static void Flood(Vector2Int32 start, Vector2Int32 minBound, Vector2Int32 maxBound, Func<Vector2Int32, bool> validation)
{
var ranges = new FloodFillRangeQueue();
var points = new HashSet<Vector2Int32>();
LinearFloodFill(ref start, ref minBound, ref maxBound, validation, ref ranges, ref points);
while (ranges.Count > 0)
{
//**Get Next Range Off the Queue
FloodFillRange range = ranges.Dequeue();
//**Check Above and Below Each Pixel in the Floodfill Range
int upY = range.Y - 1;//so we can pass the y coord by ref
int downY = range.Y + 1;
var curPoint = new Vector2Int32();
for (int i = range.StartX; i <= range.EndX; i++)
{
//*Start Fill Upwards
//if we're not above the top of the bitmap and the pixel above this one is within the color tolerance
curPoint = new Vector2Int32(i, upY);
if (range.Y > 0 && (!points.Contains(curPoint) && validation(curPoint)))
LinearFloodFill(ref curPoint, ref minBound, ref maxBound, validation, ref ranges, ref points);
//*Start Fill Downwards
//if we're not below the bottom of the bitmap and the pixel below this one is within the color tolerance
curPoint = new Vector2Int32(i, downY);
if (range.Y < (maxBound.Y - 1) && (!points.Contains(curPoint) && validation(curPoint)))
LinearFloodFill(ref curPoint, ref minBound, ref maxBound, validation, ref ranges, ref points);
}
}
}
开发者ID:Walkman-Mirror,项目名称:BCCL,代码行数:32,代码来源:Fill.cs
示例17: UndoTile
public UndoTile(Vector2Int32 location, Tile tile)
{
Location = location;
Tile = tile;
}
开发者ID:ThomasWDonnelly,项目名称:Terraria-Map-Editor,代码行数:5,代码来源:UndoTile.cs
示例18: FillQuad
public static IEnumerable<Vector2Int32> FillQuad(Vector2Int32 v1, Vector2Int32 v2, Vector2Int32 v3, Vector2Int32 v4)
{
return FillPolygon(new[] { v1, v2, v3, v4 });
}
开发者ID:Walkman-Mirror,项目名称:BCCL,代码行数:4,代码来源:Fill.cs
示例19: DrawSprites
//.........这里部分代码省略.........
source.Y += ((y - 1 - (int)_wvm.CurrentWorld.TilesHigh + 327) % 18) * 16;
}
else if (y == (_wvm.CurrentWorld.TilesHigh - 200))
{
backTex = _textureDictionary.GetBackground(backstyle[backX, 6] + hellback);
source.X += (x % 8) * 16;
}
else
{
backTex = _textureDictionary.GetUnderworld(4);
source.Y += (y - (int)_wvm.CurrentWorld.TilesHigh + 200) * 16;
}
var dest = new Rectangle(1 + (int)((_scrollPosition.X + x) * _zoom), 1 + (int)((_scrollPosition.Y + y) * _zoom), (int)_zoom, (int)_zoom);
_spriteBatch.Draw(backTex, dest, source, Color.White, 0f, default(Vector2), SpriteEffects.None, LayerTileBackgroundTextures);
}
if (_wvm.ShowWalls)
{
if (curtile.Wall > 0)
{
var wallTex = _textureDictionary.GetWall(curtile.Wall);
if (wallTex != null)
{
if (curtile.uvWallCache == 0xFFFF)
{
int sameStyle = 0x00000000;
sameStyle |= (neighborTile[e] != null && neighborTile[e].Wall > 0) ? 0x0001 : 0x0000;
sameStyle |= (neighborTile[n] != null && neighborTile[n].Wall > 0) ? 0x0010 : 0x0000;
sameStyle |= (neighborTile[w] != null && neighborTile[w].Wall > 0) ? 0x0100 : 0x0000;
sameStyle |= (neighborTile[s] != null && neighborTile[s].Wall > 0) ? 0x1000 : 0x0000;
Vector2Int32 uvBlend = blendRules.GetUVForMasks((uint)sameStyle, 0x00000000, 0);
curtile.uvWallCache = (ushort)((uvBlend.Y << 8) + uvBlend.X);
}
var texsize = new Vector2Int32(32, 32);
var source = new Rectangle((curtile.uvWallCache & 0x00FF) * (texsize.X + 4), (curtile.uvWallCache >> 8) * (texsize.Y + 4), texsize.X, texsize.Y);
var dest = new Rectangle(1 + (int)((_scrollPosition.X + x - 0.5) * _zoom), 1 + (int)((_scrollPosition.Y + y - 0.5) * _zoom), (int)_zoom * 2, (int)_zoom * 2);
_spriteBatch.Draw(wallTex, dest, source, Color.White, 0f, default(Vector2), SpriteEffects.None, LayerTileWallTextures);
}
}
}
if (_wvm.ShowTiles)
{
if (curtile.IsActive)
{
if (tileprop.IsFramed)
{
Rectangle source = new Rectangle(), dest = new Rectangle();
var tileTex = _textureDictionary.GetTile(curtile.Type);
bool isTreeSpecial = false, isMushroom = false;
bool isLeft = false, isBase = false, isRight = false;
if (curtile.Type == (int)TileType.Tree)
{
int baseX = 0;
if (curtile.U == 66 && curtile.V <= 45)
++baseX;
if (curtile.U == 88 && curtile.V >= 66 && curtile.V <= 110)
--baseX;
if (curtile.U == 22 && curtile.V >= 132 && curtile.V < 198)
--baseX;
if (curtile.U == 44 && curtile.V >= 132 && curtile.V < 198)
开发者ID:TEdit,项目名称:Terraria-Map-Editor,代码行数:67,代码来源:WorldRenderXna.xaml.cs
示例20: TrackUV
private Vector2Int32 TrackUV(int num)
{
var uv = new Vector2Int32(0, 0);
switch (num)
{
case 0: uv.X = 0; uv.Y = 0; break;
case 1: uv.X = 1; uv.Y = 0; break;
case 2: uv.X = 2; uv.Y = 1; break;
case 3: uv.X = 3; uv.Y = 1; break;
case 4: uv.X = 0; uv.Y = 2; break;
case 5: uv.X = 1; uv.Y = 2; break;
case 6: uv.X = 0; uv.Y = 1; break;
case 7: uv.X = 1; uv.Y = 1; break;
case 8: uv.X = 0; uv.Y = 3; break;
case 9: uv.X = 1; uv.Y = 3; break;
case 10: uv.X = 4; uv.Y = 1; break;
case 11: uv.X = 5; uv.Y = 1; break;
case 12: uv.X = 6; uv.Y = 1; break;
case 13: uv.X = 7; uv.Y = 1; break;
case 14: uv.X = 2; uv.Y = 0; break;
case 15: uv.X = 3; uv.Y = 0; break;
case 16: uv.X = 4; uv.Y = 0; break;
case 17: uv.X = 5; uv.Y = 0; break;
case 18: uv.X = 6; uv.Y = 0; break;
case 19: uv.X = 7; uv.Y = 0; break;
case 20: uv.X = 0; uv.Y = 4; break;
case 21: uv.X = 1; uv.Y = 4; break;
case 22: uv.X = 0; uv.Y = 5; break;
case 23: uv.X = 1; uv.Y = 5; break;
case 24: uv.X = 2; uv.Y = 2; break;
case 25: uv.X = 3; uv.Y = 2; break;
case 26: uv.X = 4; uv.Y = 2; break;
case 27: uv.X = 5; uv.Y = 2; break;
case 28: uv.X = 6; uv.Y = 2; break;
case 29: uv.X = 7; uv.Y = 2; break;
case 30: uv.X = 2; uv.Y = 3; break;
case 31: uv.X = 3; uv.Y = 3; break;
case 32: uv.X = 4; uv.Y = 3; break;
case 33: uv.X = 5; uv.Y = 3; break;
case 34: uv.X = 6; uv.Y = 3; break;
case 35: uv.X = 7; uv.Y = 3; break;
case 36: uv.X = 0; uv.Y = 6; break;
case 37: uv.X = 1; uv.Y = 6; break;
case 38: uv.X = 0; uv.Y = 7; break;
case 39: uv.X = 1; uv.Y = 7; break;
}
return uv;
}
开发者ID:TEdit,项目名称:Terraria-Map-Editor,代码行数:48,代码来源:WorldRenderXna.xaml.cs
注:本文中的Vector2Int32类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论