本文整理汇总了C#中Vector2i类的典型用法代码示例。如果您正苦于以下问题:C# Vector2i类的具体用法?C# Vector2i怎么用?C# Vector2i使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Vector2i类属于命名空间,在下文中一共展示了Vector2i类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ControlNode
public ControlNode(Vector2i pos, float[,] map, Vector2 position, float size)
: base(position)
{
Active = map[pos.x, pos.y];
if (pos.x == map.GetLength(0))
{
Right = new Node(position + Vector2.right * size * 0.5f);
}
else
{
Right = new Node(position + Vector2.right * size * 0.5f);
}
if (pos.y == map.GetLength(1))
{
Up = new Node(position + Vector2.up * size * 0.5f);
}
else
{
Up = new Node(position + Vector2.up * size * 0.5f);
}
//float right = pos.x < ? map[pos.x + 1, pos.y] : Active;
//float up = map[pos.x, pos.y + 1];
}
示例2: GetActualPosition
private static Vector2i? GetActualPosition(Vector2 position)
{
NavigationField navigationField = NavigationField.Instance;
Vector2i pos = Vector2i.FromVector2Round(position);
if (!navigationField.fieldSize.ContainsAsSize(pos))
{
return null;
}
if (!float.IsPositiveInfinity(navigationField.Costs[pos.x, pos.y]))
{
return pos;
}
// Try to find a nice neighbour...
for (int y = -1; y <= 1; y++)
{
for (int x = -1; x <= 1; x++)
{
Vector2i test = new Vector2i(pos.x + x, pos.y + y);
if (!float.IsPositiveInfinity(navigationField.GetCost(test)))
{
return test;
}
}
}
return null;
}
示例3: Job_PlantSeed
public Job_PlantSeed(Vector2i plantPos, VoxelTypes seedType, IGrowPattern growPattern)
: base(Labors.Farm, "Plant Seed", "Planting seed")
{
PlantPos = plantPos;
SeedType = seedType;
GrowPattern = growPattern;
}
示例4: OnMouseButton
public static bool OnMouseButton(Controls.Control hoveredControl, int x, int y, bool down)
{
if (!down)
{
m_LastPressedControl = null;
// Not carrying anything, allow normal actions
if (CurrentPackage == null)
return false;
// We were carrying something, drop it.
onDrop(x, y);
return true;
}
if (hoveredControl == null)
return false;
if (!hoveredControl.DragAndDrop_Draggable())
return false;
// Store the last clicked on control. Don't do anything yet,
// we'll check it in OnMouseMoved, and if it moves further than
// x pixels with the mouse down, we'll start to drag.
m_LastPressedPos = new Vector2i(x, y);
m_LastPressedControl = hoveredControl;
return false;
}
示例5: Cannon
public Cannon(Direction2D direction, Vector2i index)
{
_direction = direction;
_worldIndex = index;
_readOnlyBullets = new ReadOnlyCollection<Bullet>(_bullets);
}
示例6: SetField
public override void SetField(Vector2i vect, char value)
{
if (IsEntryPointInTheSize(vect))
{
VarField[vect.X, vect.Y] = value;
}
}
示例7: Next
public static Vector2i Next(this Random random, Vector2i min, Vector2i max)
{
return new Vector2i(
random.Next(min.X, max.X + 1),
random.Next(min.Y, max.Y + 1)
);
}
示例8: SendVector
public void SendVector(Vector2i vect)
{
if (!(Player is Player.NetworkPlayer))
{
client.Send(string.Format("UniTTT!Vector:{0}", vect.ToString()));
}
}
示例9: ItemCollectedMessage
/// <summary>
/// Initializes a new instance of the <see cref="FreezingArcher.Messaging.ItemCollectedMessage"/> class.
/// </summary>
/// <param name="item">Item.</param>
/// <param name="inventoryPosition">Inventory position.</param>
/// <param name="entity">Entity.</param>
public ItemCollectedMessage(Entity entity, ItemComponent item, Vector2i inventoryPosition)
{
Entity = entity;
Item = item;
InventoryPosition = inventoryPosition;
MessageId = (int) Messaging.MessageId.ItemCollected;
}
示例10: DistanceEstimate
public double DistanceEstimate(Vector2i a, Vector2i b)
{
if (UseManhattanMetric)
return Math.Abs(b.X - a.X) + Math.Abs(b.Y - a.Y);
return Utils.Distance(new Vector2f(a.X, a.Y), new Vector2f(b.X, b.Y));
}
示例11: Exit
public Exit(Vector2i _pos)
: base(_pos)
{
CurrentTex = "exit";
Movable = false;
Open = false;
}
示例12: Setup
public void Setup(RL.Map _map, int[] _dir)
{
map = _map;
directions = _dir;
lineRenderers = new GameObject[directions.Length];
for (int i = 0; i < directions.Length; i++) {
lineRenderers [i] = new GameObject ();
lineRenderers [i].transform.parent = transform;
lineRenderers [i].transform.position = transform.position;
LineRenderer lr = lineRenderers [i].AddComponent<LineRenderer> ();
lr.renderer.sortingOrder = 2;
lr.renderer.sortingLayerName = "Default";
lr.SetColors(new Color(74/255f,63/255f,148/255f, 0.5f), new Color(113/255f,138/255f,145/255f, 0.5f));
lr.SetWidth (0.05f, 0.05f);
lr.material = (Material)Resources.Load ("trapParticle");
lr.useWorldSpace = false;
// move out on the direction until we hit a wall, this is our endpoint
Vector2i ndir = new Vector2i (RL.Map.nDir[directions[i],0], RL.Map.nDir[directions[i],1]);
Vector2i np = GetComponent<RLCharacter>().positionI;
int distanceCount = 1;
np += ndir;
while (map.IsOpenTile (np.x, np.y)) {
np += ndir;
}
// np -= ndir*0.5f;
lr.SetPosition (0, Vector3.zero);
lr.SetPosition (1, new Vector3(np.x-ndir.x*0.5f, np.y-ndir.y*0.5f, 0)-transform.position);
}
}
示例13: Window
/// <summary>
/// Initializes a new instance of the <see cref="FreezingArcher.Core.Window"/> class.
/// </summary>
/// <param name="size">Windowed size.</param>
/// <param name="resolution">Resolution of the framebuffer.</param>
/// <param name="title">Title.</param>
public Window (Vector2i size, Vector2i resolution, string title)
{
Logger.Log.AddLogEntry (LogLevel.Info, ClassName, "Creating new window '{0}'", title);
MSize = size;
MResolution = resolution;
MTitle = title;
}
示例14: Stop
public static void Stop(BHEntity mEntity, Vector2i mDirection, Rectangle mBounds, int mBoundsOffset)
{
if (mDirection.X == -1) mEntity.Position = new Vector2i(mBounds.X + mBoundsOffset, mEntity.Position.Y);
if (mDirection.X == 1) mEntity.Position = new Vector2i(mBounds.X + mBounds.Width - mBoundsOffset, mEntity.Position.Y);
if (mDirection.Y == -1) mEntity.Position = new Vector2i(mEntity.Position.X, mBounds.Y + mBoundsOffset);
if (mDirection.Y == 1) mEntity.Position = new Vector2i(mEntity.Position.X, mBounds.Y - mBoundsOffset + mBounds.Height);
}
示例15: Update
public override bool Update(Vector2i mouseS, IMapManager currentMap)
{
if (currentMap == null) return false;
spriteToDraw = GetDirectionalSprite(pManager.CurrentBaseSpriteKey);
mouseScreen = mouseS;
mouseWorld = CluwneLib.ScreenToWorld(mouseScreen);
var bounds = spriteToDraw.GetLocalBounds();
var spriteSize = CluwneLib.PixelToTile(new Vector2f(bounds.Width, bounds.Height));
var spriteRectWorld = new FloatRect(mouseWorld.X - (spriteSize.X / 2f),
mouseWorld.Y - (spriteSize.Y / 2f),
spriteSize.X, spriteSize.Y);
if (pManager.CurrentPermission.IsTile)
return false;
if (pManager.CollisionManager.IsColliding(spriteRectWorld))
return false;
//if (currentMap.IsSolidTile(mouseWorld)) return false;
var rangeSquared = pManager.CurrentPermission.Range * pManager.CurrentPermission.Range;
if (rangeSquared > 0)
if (
(pManager.PlayerManager.ControlledEntity.GetComponent<TransformComponent>(ComponentFamily.Transform)
.Position - mouseWorld).LengthSquared() > rangeSquared) return false;
currentTile = currentMap.GetTileRef(mouseWorld);
return true;
}