本文整理汇总了C#中Int2类的典型用法代码示例。如果您正苦于以下问题:C# Int2类的具体用法?C# Int2怎么用?C# Int2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Int2类属于命名空间,在下文中一共展示了Int2类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: UploadCharacterBitmap
/// <summary>
/// Upload a character's bitmap into the current cache.
/// </summary>
/// <param name="character">The character specifications corresponding to the bitmap</param>
public void UploadCharacterBitmap(CharacterSpecification character)
{
if(character.Bitmap == null)
throw new ArgumentNullException("character");
if(character.IsBitmapUploaded)
throw new InvalidOperationException("The character '"+character.Character+"' upload has been requested while its current glyph is valid.");
var targetSize = new Int2(character.Bitmap.Width, character.Bitmap.Rows);
if (!packer.Insert(targetSize.X, targetSize.Y, ref character.Glyph.Subrect))
{
// not enough space to place the new character -> remove less used characters and try again
RemoveLessUsedCharacters();
if (!packer.Insert(targetSize.X, targetSize.Y, ref character.Glyph.Subrect))
{
// memory is too fragmented in order to place the new character -> clear all the characters and restart.
ClearCache();
if (!packer.Insert(targetSize.X, targetSize.Y, ref character.Glyph.Subrect))
throw new InvalidOperationException("The rendered character is too big for the cache texture");
}
}
// updload the bitmap on the texture (if the size in the bitmap is not null)
if (character.Bitmap.Rows != 0 && character.Bitmap.Width != 0)
{
var dataBox = new DataBox(character.Bitmap.Buffer, character.Bitmap.Pitch, character.Bitmap.Pitch * character.Bitmap.Rows);
var region = new ResourceRegion(character.Glyph.Subrect.Left, character.Glyph.Subrect.Top, 0, character.Glyph.Subrect.Right, character.Glyph.Subrect.Bottom, 1);
system.GraphicsDevice.UpdateSubresource(cacheTextures[0], 0, dataBox, region);
}
// update the glyph data
character.IsBitmapUploaded = true;
character.Glyph.BitmapIndex = 0;
}
示例2: PlaneProceduralModel
/// <summary>
/// Initializes a new instance of geometric descriptor for a plane.
/// </summary>
public PlaneProceduralModel()
{
Normal = NormalDirection.UpY;
Size = new Vector2(1.0f);
Tessellation = new Int2(1);
UVScales = new Vector2(1);
}
示例3: getPath
public static Int2[] getPath(Int2 current, Int2 final, GridSystem grid)
{
int width = grid.gridSizeX;
int height = grid.gridSizeZ;
if (width <= current._x || width <= final._x) {
return null;
}
if (height <= current._z || height <= final._z) {
return null;
}
if (grid[current._x, current._z] == null || grid[final._x,final._z] == null)
{
return null;
}
int[,] distanceGrid = new int[width, height];
for (int i = 0; i < width; i++) {
for (int j = 0; j < height; j++) {
distanceGrid[i,j] = -1;
}
}
distanceGrid [current._x, current._z] = 0;
Int2[] path = DFS (current, final, grid, distanceGrid);
Debug.Log ("Path");
for (int i = 0; i < path.Length; i++) {
Debug.Log (path[i]);
}
return path;
}
示例4: RemoveBlock
public bool RemoveBlock(int x, int y)
{
Int2 coord = new Int2(x, y);
if (blocks.ContainsKey(coord))
{
blocks.Remove(coord);
return true;
}
return false;
}
示例5: PackingAttributes
/// <summary>
/// Creates a default instance of packing attributes.
/// </summary>
public PackingAttributes()
{
Enabled = true;
PackingAlgorithm = TexturePackingMethod.Best;
AllowMultipacking = true;
AllowRotations = true;
AtlasMaximumSize = new Int2(2048);
BorderSize = 2;
}
示例6: DrawCore
protected override void DrawCore(RenderContext context)
{
var output = PrefilteredRadiance;
if(output == null || (output.Dimension != TextureDimension.Texture2D && output.Dimension != TextureDimension.TextureCube) || output.ArraySize != 6)
throw new NotSupportedException("Only array of 2D textures are currently supported as output");
var input = RadianceMap;
if(input == null || input.Dimension != TextureDimension.TextureCube)
throw new NotSupportedException("Only cubemaps are currently supported as input");
var roughness = 0f;
var faceCount = output.ArraySize;
var levelSize = new Int2(output.Width, output.Height);
var mipCount = MipmapGenerationCount == 0 ? output.MipLevels : MipmapGenerationCount;
for (int l = 0; l < mipCount; l++)
{
if (l == 0 && DoNotFilterHighestLevel && input.Width >= output.Width)
{
var inputLevel = MathUtil.Log2(input.Width / output.Width);
for (int f = 0; f < 6; f++)
{
var inputSubresource = inputLevel + f * input.MipLevels;
var outputSubresource = 0 + f * output.MipLevels;
GraphicsDevice.CopyRegion(input, inputSubresource, null, output, outputSubresource);
}
}
else
{
var outputView = output.ToTextureView(ViewType.MipBand, 0, l);
computeShader.ThreadGroupCounts = new Int3(levelSize.X, levelSize.Y, faceCount);
computeShader.ThreadNumbers = new Int3(SamplingsCount, 1, 1);
computeShader.Parameters.Set(RadiancePrefilteringGGXShaderKeys.Roughness, roughness);
computeShader.Parameters.Set(RadiancePrefilteringGGXShaderKeys.MipmapCount, input.MipLevels - 1);
computeShader.Parameters.Set(RadiancePrefilteringGGXShaderKeys.RadianceMap, input);
computeShader.Parameters.Set(RadiancePrefilteringGGXShaderKeys.RadianceMapSize, input.Width);
computeShader.Parameters.Set(RadiancePrefilteringGGXShaderKeys.FilteredRadiance, outputView);
computeShader.Parameters.Set(RadiancePrefilteringGGXParams.NbOfSamplings, SamplingsCount);
computeShader.Draw(context);
outputView.Dispose();
}
if (mipCount > 1)
{
roughness += 1f / (mipCount - 1);
levelSize /= 2;
}
}
}
示例7: BackgroundSection
public BackgroundSection(Sprite backgroundSprite, Vector3 screenVirtualResolution, float scrollSpeed, float depth, Vector2 startPos = default(Vector2))
{
screenResolution = new Int2((int)screenVirtualResolution.X, (int)screenVirtualResolution.Y);
screenCenter = new Vector2(screenVirtualResolution.X / 2, screenVirtualResolution.Y /2);
this.depth = depth;
firstQuadPos = startPos;
secondQuadPos = startPos;
ScrollSpeed = scrollSpeed;
ScrollPos = 0;
CreateBackground(backgroundSprite.Texture, backgroundSprite.Region);
}
示例8: DrawTo
/// <summary>
/// Draws to the specified cube at the specified position.
/// </summary>
/// <param name='position'>
/// Position (from bottom left).
/// </param>
/// <param name='cube'>
/// Cube.
/// </param>
public override void DrawTo(Int2 position, Cube cube)
{
base.DrawTo(position, cube);
switch (id)
{
case 0:
cube.FillRect(new Color(128,128,255), Cube.SCREEN_WIDTH/2, Cube.SCREEN_HEIGHT/2-10, 1, 20);
break;
case 1:
cube.FillRect(new Color(128,128,255), Cube.SCREEN_WIDTH/2-4, Cube.SCREEN_HEIGHT/2-10, 1, 20);
cube.FillRect(new Color(128,128,255), Cube.SCREEN_WIDTH/2+4, Cube.SCREEN_HEIGHT/2-10, 1, 20);
break;
}
}
示例9: BeadSelectorDlg
public BeadSelectorDlg(FloatImg image, int ROI, Int2[] positions)
{
InitializeComponent();
if (!DesignMode)
{
dispImage = image.ToImage();
this.image = image;
pictureBox.Image = dispImage;
roiPositions = positions.ToList();
}
DialogResult = System.Windows.Forms.DialogResult.Cancel;
textBoxROI.Text = ROI.ToString();
}
示例10: FixedUpdate
void FixedUpdate() {
mousePos = Input.mousePosition;
foreach (var town in Towns)
{
Int2 mousePosInt = new Int2();
Tile.ScreenToMapPosition(mousePos, out mousePosInt);
if (Vector2.Distance(town.location.ToVector2(), mousePosInt.ToVector2()) < .32f)
{
selectedTownPos = Tile.MapToWorldPosition(town.location);
selectedTownName = town.name;
print(town.name);
}
}
}
示例11: Update
// Update is called once per frame
void Update () {
// Calculate the tile the target is standing on
Int2 p = new Int2 ( Mathf.RoundToInt ((target.position.x - tileSize*0.5f) / tileSize), Mathf.RoundToInt ((target.position.z - tileSize*0.5f) / tileSize) );
// Clamp range
range = range < 1 ? 1 : range;
// Remove tiles which are out of range
bool changed = true;
while ( changed ) {
changed = false;
foreach (KeyValuePair<Int2,ProceduralTile> pair in tiles ) {
if ( Mathf.Abs (pair.Key.x-p.x) > range || Mathf.Abs (pair.Key.y-p.y) > range ) {
pair.Value.Destroy ();
tiles.Remove ( pair.Key );
changed = true;
break;
}
}
}
// Add tiles which have come in range
// and start calculating them
for ( int x = p.x-range; x <= p.x+range; x++ ) {
for ( int z = p.y-range; z <= p.y+range; z++ ) {
if ( !tiles.ContainsKey ( new Int2(x,z) ) ) {
ProceduralTile tile = new ProceduralTile ( this, x, z );
var generator = tile.Generate ();
// Tick it one step forward
generator.MoveNext ();
// Calculate the rest later
tileGenerationQueue.Enqueue (generator);
tiles.Add ( new Int2(x,z), tile );
}
}
}
// The ones directly adjacent to the current one
// should always be completely calculated
// make sure they are
for ( int x = p.x-1; x <= p.x+1; x++ ) {
for ( int z = p.y-1; z <= p.y+1; z++ ) {
tiles[new Int2(x,z)].ForceFinish();
}
}
}
示例12: SetUp
public void SetUp()
{
var x = 50;
var y = 75;
var width = 100;
var height = 125;
_aabb = new AABB(x, y, width, height);
_top = y;
_left = x;
_right = x + width;
_bottom = y + height;
_topLeft = new Int2(_left, _top);
_topRight = new Int2(_right, _top);
_bottomLeft = new Int2(_left, _bottom);
_bottomRight = new Int2(_right, _bottom);
}
示例13: Combine
public static PlatformGroup Combine(PlatformGroup lhs, PlatformGroup rhs, Int2 playerIdx)
{
GameObject output = new GameObject("PlatformGroup");
PlatformGroup outputGroup = output.AddComponent<PlatformGroup>();
outputGroup.container = new HashSet<Platform>();
//outputGroup.OnGroupMoved += robot.replanPath;
//transfer ownership
outputGroup.container.UnionWith(lhs.container);
outputGroup.container.UnionWith(rhs.container);
//transfer childObjs
List<Transform> children = new List<Transform>();
for (int i = 0; i < lhs.gameObject.transform.childCount; i++)
children.Add(lhs.gameObject.transform.GetChild(i));
foreach (Transform child in children)
child.transform.parent = output.transform;
children.Clear();
for (int i = 0; i < rhs.gameObject.transform.childCount; i++)
children.Add(rhs.gameObject.transform.GetChild(i));
foreach (Transform child in children)
child.transform.parent = output.transform;
//Vector2 robotPos2d = new Vector2(robot.transform.position.x, robot.transform.position.z);
if (ReferenceEquals(lhs, gridSystem.ComputeGroup(playerIdx)) ||
ReferenceEquals(rhs, gridSystem.ComputeGroup(playerIdx)) ||
ReferenceEquals(lhs, gridSystem.ComputeGroup(gridSystem.goal)) ||
ReferenceEquals(rhs, gridSystem.ComputeGroup(gridSystem.goal)))
{
foreach (Transform child in output.transform)
child.gameObject.layer = Utility.ToLayerNumber(gridSystem.lockedPfLayer);//?
}
foreach (Platform pf in outputGroup.container)
pf.group = outputGroup;
lhs.container.Clear();
rhs.container.Clear();
Destroy(lhs.gameObject);
Destroy(rhs.gameObject);
return outputGroup;
}
示例14: CharacterBitmap
/// <summary>
/// Initializes a new instance of the <see cref="CharacterBitmap"/> class from a data array.
/// </summary>
/// <param name="pixelMode">The data format of the bitmap data</param>
/// <param name="data">The bitmap data</param>
/// <param name="borderSize">The size of the border around the image</param>
/// <param name="width">The width of the bitmap </param>
/// <param name="rows">The height of the bitmap</param>
/// <param name="pitch">The pitch of the bitmap</param>
/// <param name="grayLevels">The number of gray levels of the bitmap</param>
public CharacterBitmap(IntPtr data, ref Int2 borderSize, int width, int rows, int pitch, int grayLevels, PixelMode pixelMode)
{
// add one empty border to each side of the bitmap
width += 2 * borderSize.X;
rows += 2 * borderSize.Y;
buffer = Utilities.AllocateMemory(width * rows, 1);
if (pixelMode == PixelMode.Mono)
CopyAndAddBordersFromMono(data, buffer, ref borderSize, width, rows, pitch);
else
CopyAndAddBordersFromGrays(data, buffer, ref borderSize, width, rows);
this.width = width;
this.rows = rows;
this.pitch = width;
this.grayLevels = grayLevels;
this.pixelMode = pixelMode;
}
示例15: ExecuteAlgorithm
public int[,] ExecuteAlgorithm(int numTiles, out List<Vector2> openPositions, out Vector3 playerSpawn)
{
openPositions = new List<Vector2>();
int[,] level = new int[numTiles * 2, numTiles * 2];
set2DArrayDefaults(level, 2);
int startingX = numTiles, startingY = numTiles;
Int2 current = new Int2(startingX, startingY);
Int2 directionLastMoved = new Int2(0, 0);
int numTilesPlaced = 0;
// For resizing the level
int leftX = current.x;
int rightX = current.x;
int topY = current.y;
int bottomY = current.y;
while (numTilesPlaced < numTiles)
{
leftX = current.x < leftX ? current.x : leftX;
rightX = current.x > rightX ? current.x : rightX;
topY = current.y > topY ? current.y : topY;
bottomY = current.y < bottomY ? current.y : bottomY;
if (level[current.x, current.y] == 2)
{
level[current.x, current.y] = 1;
numTilesPlaced++;
}
current += getRandomDirection(new int[] { 25, 25, 25, 25 });
}
playerSpawn = new Vector3((startingY - bottomY + 1) * LoadLevel.TileSize, (startingX - leftX + 1) * LoadLevel.TileSize, 0);
return cropLevel(level, leftX, rightX, topY, bottomY, openPositions);
}