本文整理汇总了C#中IntVector2类的典型用法代码示例。如果您正苦于以下问题:C# IntVector2类的具体用法?C# IntVector2怎么用?C# IntVector2使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IntVector2类属于命名空间,在下文中一共展示了IntVector2类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: paintObstacle
// Paints the obstacle tiles in green
public void paintObstacle(IntVector2 index)
{
GameObject t = TileGenerator.tiles[index.x,index.y];
if(t.tag == "Tile")
{
if(t.renderer)
{
t.renderer.material = green;
}
else
{
t.GetComponentsInChildren<Renderer>()[1].material = green;
}
t.tag = "Obstacle";
}
else
{
if(t.renderer)
{
t.renderer.material = grey;
}
else
{
t.GetComponentsInChildren<Renderer>()[1].material = grey;
}
t.tag = "Tile";
}
}
开发者ID:noahdayan,项目名称:Modern-Computer-Games-Projects,代码行数:32,代码来源:TilePainter.cs
示例2: Calculate
public static void Calculate(IntVector2 viewerLocation, int visionRange, Grid2D<bool> visibilityMap, IntSize2 mapSize,
Func<IntVector2, bool> blockerDelegate)
{
visibilityMap.Clear();
if (blockerDelegate(viewerLocation) == true)
return;
for (int y = -visionRange; y <= visionRange; ++y)
{
for (int x = -visionRange; x <= visionRange; ++x)
{
var dst = viewerLocation + new IntVector2(x, y);
if (mapSize.Contains(dst) == false)
{
visibilityMap[x, y] = false;
continue;
}
bool vis = FindLos(viewerLocation, dst, blockerDelegate);
visibilityMap[x, y] = vis;
}
}
}
开发者ID:tomba,项目名称:dwarrowdelf,代码行数:25,代码来源:RayCastBresenhams.cs
示例3: MakeTunnel
List<DungeonArea> MakeTunnel( IntVector2 pointA, IntVector2 pointB )
{
var roomsColor = SUtil.SRandom.SRandom.GetRandomColor();
foreach (var r in dunArea_)
r.color_ = roomsColor;
IntRect[] areas = dunArea_.Select(r => r.area_).ToArray();
IntVector2[] points = new IntVector2[]
{
pointA,
pointB,
};
var diffArea = IntRect.BLTRRect( points[0], points[1] );
DungeonArea[] halls = new DungeonArea[]
{
new DungeonArea( diffArea ),
//new DungeonArea( points[0]),
//new DungeonArea( points[1]),
};
var hallcolors = new Color[]
{
Color.green, Color.red, Color.red
};
for (int i = 0; i < halls.Length; ++i)
halls[i].color_ = hallcolors[i];
return halls.ToList();
}
开发者ID:sarkahn,项目名称:unityroguetest,代码行数:34,代码来源:DungeonTestingCornerCase.cs
示例4: applyTextureToAnotherTexture
public static void applyTextureToAnotherTexture(ref TextureColorArray source, ref TextureColorArray destination, IntVector2 centerInDestination)
{
_leftX = centerInDestination.x - source.width / 2;
_rightX = _leftX + source.width;
_downY = centerInDestination.y - source.height / 2;
_topY = _downY + source.height;
_srcLeftX = _leftX < 0 ? -_leftX : 0;
_srcDownY = _downY < 0 ? -_downY : 0;
_leftX = _leftX < 0 ? 0 : _leftX ;
_rightX = _rightX >= destination.width ? destination.width : _rightX;
_downY = _downY < 0 ? 0 : _downY ;
_topY = _topY >= destination.height ? destination.height : _topY ;
_srcY = _srcDownY * source.width;
_destY = _downY * destination.width;
for (_y = _downY; _y < _topY; _y++) {
_srcX = _srcLeftX;
for (int _x = _leftX; _x < _rightX; _x++) {
if (source.Colors [_srcY + _srcX].a > destination.Colors [_destY + _x].a)
destination.Colors [_destY + _x] = source.Colors [_srcY + _srcX];
_srcX ++;
}
_srcY += source.width;
_destY += destination.width;
}
}
开发者ID:happyjiahan,项目名称:colorus,代码行数:29,代码来源:TextureUtil.cs
示例5: ReplacePosition
public Entity ReplacePosition(IntVector2 newValue)
{
var component = CreateComponent<PositionComponent>(ComponentIds.Position);
component.value = newValue;
ReplaceComponent(ComponentIds.Position, component);
return this;
}
开发者ID:sschmid,项目名称:Entitas-CSharp,代码行数:7,代码来源:PositionComponentGeneratedExtension.cs
示例6: applyColors
public void applyColors(Color32[] colors, bool sendEvents = true, bool radialAnimate = false, IntVector2 center = null)
{
for (int i = 0; i < colors.Length; i++) {
if (colors[i].a !=0){
_r = _actualColors[i].r;
_actualColors[i].r = colors[i].r;
colors[i].r = _r;
_g = _actualColors[i].g;
_actualColors[i].g = colors[i].g;
colors[i].g = _g;
_b = _actualColors[i].b;
_actualColors[i].b = colors[i].b;
colors[i].b = _b;
}
}
if (radialAnimate){
IntVector2 point;
if (center == null){
point = new IntVector2( config.canvasSize.x/2, config.canvasSize.y/2);
} else {
point = center;
}
StartCoroutine(radialLayer.updateColorsAndAnimate(colors,point));
}
StartCoroutine( backLayer.updateColors(_actualColors, radialAnimate));
if (sendEvents && events.onActiveReceiveNewColors != null)
events.onActiveReceiveNewColors();
}
开发者ID:happyjiahan,项目名称:colorus,代码行数:32,代码来源:CanvasController.cs
示例7: ReplaceVelocity
public Entity ReplaceVelocity(IntVector2 newValue)
{
var component = CreateComponent<VelocityComponent>(ComponentIds.Velocity);
component.value = newValue;
ReplaceComponent(ComponentIds.Velocity, component);
return this;
}
开发者ID:sschmid,项目名称:Entitas-CSharp,代码行数:7,代码来源:VelocityComponentGeneratedExtension.cs
示例8: MoveByVector
public void MoveByVector(IntVector2 offset)
{
IntVector2 newPos = Map.BoundPos(pos+offset);
if (mode == CATCH) {
IntVector2 totemNewPos = Map.BoundPos (pos + dir + offset);
if (offset == dir) { // forward
if (Map.mainMap [totemNewPos.x, totemNewPos.y].Count != 0) {
return;
}
} else if (offset == -dir) { // backward
if (Map.mainMap [newPos.x, newPos.y].Count != 0)
return;
} else { // 平移
if (Map.mainMap [totemNewPos.x, totemNewPos.y].Count != 0 ||
Map.mainMap [newPos.x, newPos.y].Count != 0)
return;
}
// Update the pos of the caught totem
IntVector2 totemPre = new IntVector2(caughtTotem.pos.x, caughtTotem.pos.y);
caughtTotem.pos = totemNewPos;
Map.UpdatePos (caughtTotem, totemPre);
} else if (Map.mainMap [newPos.x, newPos.y].Count != 0) {
return;
}
base.MoveByVector (offset);
}
开发者ID:roy200514,项目名称:TotemGame,代码行数:29,代码来源:Player.cs
示例9: OnSerializeNetworkView
void OnSerializeNetworkView(BitStream stream, NetworkMessageInfo info)
{
BoardLocation newLocation= new BoardLocation(new IntVector2(0,0), new IntVector2(0,0));
int maxSpeed = 0;
IntVector2 direction = new IntVector2(0,0);
BoardLocation lastBoardLocation = new BoardLocation(new IntVector2( 0, 0), new IntVector2(0,0));
if (stream.isWriting)
{
newLocation = this.boardLocation;
maxSpeed = this.maxSpeed;
direction = this.direction;
lastBoardLocation = this.lastBoardLocation;
newLocation.Serialize( stream );
stream.Serialize( ref maxSpeed );
direction.Serialize( stream );
lastBoardLocation.Serialize( stream );
}
else
{
newLocation.DeSerialize( stream );
stream.Serialize( ref maxSpeed );
direction.DeSerialize( stream );
lastBoardLocation.DeSerialize( stream );
this.boardLocation = newLocation;
this.maxSpeed = maxSpeed;
this.direction = direction;
this.lastBoardLocation = lastBoardLocation;
}
}
开发者ID:pmlamotte,项目名称:2Pac,代码行数:32,代码来源:BoardObject.cs
示例10: onMouseOverWithButtonDone
void onMouseOverWithButtonDone(IntVector2 obj)
{
Profiler.BeginSample("onMouseOverWithButtonDone");
Profiler.BeginSample("init start");
points.Add(obj);
InterpolateContext ic = new InterpolateContext (new LinearInterpolationStrategy());
Profiler.EndSample();
Profiler.BeginSample("interpolation");
if (interpolatedPath==null)
interpolatedPath= new List<IntVector2>();
else
interpolatedPath.Clear();
ic.interpolate(points, interpolatedPath);
Profiler.EndSample();
Profiler.BeginSample("fetch colors");
Color32[] workingColors= canvas.fetchColors();
Profiler.EndSample();
Profiler.BeginSample("apply points with cache");
TextureUtil.generateTexturePath(canvasTool, ColorUtil.getRandomColor(),interpolatedPath,workingColors,canvasConfig.canvasSize.x, canvasConfig.canvasSize.y);
Profiler.EndSample();
Profiler.BeginSample("update back layer");
Debug.Log("change color and use aply method");
//canvas.applyColors(workingColors, ColorUtil.getRandomColor());
Profiler.EndSample();
Profiler.EndSample();
}
开发者ID:happyjiahan,项目名称:colorus,代码行数:29,代码来源:CanvasTest.cs
示例11: OnControllerColliderHit
void OnControllerColliderHit(ControllerColliderHit hit)
{
Rigidbody body = hit.collider.attachedRigidbody;
MazeCell cell = hit.gameObject.GetComponentInParent<MazeCell>();
if (cell == null)
return;
if(cell != currentCell)
{
if(currentCell != null)
currentCell.OnPlayerExit();
cell.OnPlayerEnter();
}
currentCell = cell;
Vector3 transformDirection = new Vector3(Mathf.Round(transform.forward.x), 0f, Mathf.Round(transform.forward.z));
IntVector2 direction = new IntVector2((int) transformDirection.x, (int) transformDirection.z);
if(direction.x != 0 && direction.z != 0)
{
if (Random.Range(0, 1) == 1)
direction.x = 0;
else
direction.z = 0;
}
MazeDirection mazeDirection = MazeDirections.FromIntVector2(direction);
faceDirection = mazeDirection;
}
开发者ID:thmundal,项目名称:Blendertest,代码行数:31,代码来源:Player.cs
示例12: PlaceAtLocation
public virtual bool PlaceAtLocation(IntVector2 location)
{
Location = location;
if (location != null)
{
hexCell = GridManager.instance.GetHexCell(location);
if (hexCell != null)
{
transform.position = hexCell.transform.position;
hexCell.placedPlaceable = this;
return true;
}
}
else
{
if (hexCell != null)
{
if (hexCell.placedPlaceable == this)
{
hexCell.placedPlaceable = null;
}
hexCell = null;
}
}
return false;
}
开发者ID:raxter,项目名称:6-Fold-Mass-Production,代码行数:26,代码来源:HexCellPlaceable.cs
示例13: DoMove
GameAction DoMove(Direction dir)
{
IntVector2 ov = new IntVector2(dir);
if (ov.IsNull)
return new WaitAction(1);
var env = this.Worker.Environment;
for (int i = 0; i < 7; ++i)
{
var v = ov.FastRotate(((i + 1) >> 1) * (((i % 2) << 1) - 1));
var d = EnvironmentHelpers.AdjustMoveDir(env, this.Worker.Location, v.ToDirection());
if (d != Direction.None)
return new MoveAction(d);
}
if (EnvironmentHelpers.CanMoveFromTo(this.Worker, Direction.Up))
return new MoveAction(Direction.Up);
if (EnvironmentHelpers.CanMoveFromTo(this.Worker, Direction.Down))
return new MoveAction(Direction.Down);
return new WaitAction(1);
}
开发者ID:Fulborg,项目名称:dwarrowdelf,代码行数:26,代码来源:FleeMoveAssignment.cs
示例14: DrawRoom
void DrawRoom( IntVector2 pos, IntVector2 size )
{
// char count = '0';
var yMax = size.y - 1;
var xMax = size.x - 1;
for( int x = 0; x < size.x; ++x )
{
for( int y = 0; y < size.y; ++y )
{
RLTile t = baseTiles_.GetRandomFloor();
if( (x == 0 || x == xMax ) && y != 0 )
t = baseTiles_.walls_.doubleVert_;
if( (y == 0 || y == yMax ) && x != 0 )
t = baseTiles_.walls_.doubleHor_;
if (x == 0 && y == 0)
t = baseTiles_.walls_.doubleBLCorner_;
if ( x == 0 && y == yMax )
t = baseTiles_.walls_.doubleTLCorner_;
if( x == xMax && y == yMax )
t = baseTiles_.walls_.doubleTRCorner_;
if( x == xMax && y == 0 )
t = baseTiles_.walls_.doubleBRCorner_;
SetTile(x + pos.y, y + pos.y, t.ch_, t.color_ );
}
}
}
开发者ID:sarkahn,项目名称:unityroguetest,代码行数:33,代码来源:RLMap.cs
示例15: Decode
public virtual bool Decode (Encoding encoding)
{
IntVector2 newLocation = new IntVector2(encoding.Int(0)-31, encoding.Int (1)-31);
Mechanism placedMechanism = GridManager.instance.GetHexCell(newLocation).placedMechanism;
bool didReplacedPart = false;
if (placedMechanism != null) // we are replacing a part
{
if (placedMechanism.MechanismType == MechanismType && // we are replacing the same type of part
placedMechanism.Location.IsEqualTo(newLocation) && // the location of the old part is the same as this new one (important for multicell mechanisms e.g. weldingRig)
!placedMechanism.isSolutionMechanism) // is a level mechanism (not part of the solution, part of the problem ;p)
{
ObjectPoolManager.DestroyObject(placedMechanism);
PlaceAtLocation(newLocation);
isSolutionMechanism = false; // we use the already on board's movable (i.e. immovable)
}
else
{
// something went wrong, we are loading a mechanism on top of one that is different, or a solution mechanism
Debug.LogError("Something went wrong, we are loading a mechanism on top of one that is different, or a solution mechanism");
return false;
}
}
else // this is a new part
{
PlaceAtLocation(newLocation);
isSolutionMechanism = (int)encoding.Int(2) == 1;
}
return true;
}
开发者ID:raxter,项目名称:6-Fold-Mass-Production,代码行数:32,代码来源:Mechanism.cs
示例16: Distance
public float Distance(IntVector2 v)
{
float r1 = x - v.x;
float r2 = y - v.y;
return (float)Math.Sqrt(r1 * r1 + r2 * r2);
}
开发者ID:mafiesto4,项目名称:GoogleHashCode2016,代码行数:7,代码来源:IntVector2.cs
示例17: InstantiateSquare
/// <summary>
/// Instantiate a given square prefab with the given coordinates. Set all the right
/// properties and add it to the board.
/// </summary>
/// <param name="squarePrefab">Square prefab.</param>
/// <param name="boardPosition">The position on the board to instantiate to.</param>
private void InstantiateSquare(GameObject squarePrefab, IntVector2 boardPosition) {
// instantiate the square and size it correctly
GameObject square = Instantiate<GameObject>(squarePrefab);
square.transform.SetParent(transform, false);
RectTransform squareRectTransform = square.transform as RectTransform;
squareRectTransform.sizeDelta = cellSize;
// assign collider properties
BoxCollider2D collider = square.GetComponent<BoxCollider2D>();
if (collider == null) {
Debug.LogErrorFormat("Generated square at {0} does not have a box collider 2d component.", boardPosition);
return;
}
collider.size = cellSize;
// assign tile properties
Tile tile = square.GetComponent<Tile>();
if (tile == null) {
Debug.LogErrorFormat("Generated square at {0} does not have a tile component.", boardPosition);
return;
}
tile.Coordinates = boardPosition;
tile.SetParentBoard(this);
// add to the board
board[boardPosition.x, boardPosition.y] = square;
}
开发者ID:BigVikingGames,项目名称:checkers-starter,代码行数:33,代码来源:Board.cs
示例18: Diamond
static void Diamond(Context ctx, IntVector2 middle, int radius)
{
double v1, v2, v3, v4;
IntVector2 p1, p2, p3, p4;
p1 = middle.Offset(0, -radius);
v1 = GetGridValue(ctx, p1);
p2 = middle.Offset(-radius, 0);
v2 = GetGridValue(ctx, p2);
p3 = middle.Offset(0, radius);
v3 = GetGridValue(ctx, p3);
p4 = middle.Offset(radius, 0);
v4 = GetGridValue(ctx, p4);
var avg = (v1 + v2 + v3 + v4) / 4;
var val = avg + GetRandom(ctx, ctx.Range);
ctx.Grid[middle] = val;
if (val < ctx.Min)
ctx.Min = val;
if (val > ctx.Max)
ctx.Max = val;
}
开发者ID:tomba,项目名称:dwarrowdelf,代码行数:27,代码来源:DiamondSquare.cs
示例19: Start
private void Start() {
//init communcation channels
textCommChannel = CommunicationChannelFactory.Make2WayTextChannel() as TextCommunicationChannel;
oneWayCommChannel = CommunicationChannelFactory.MakeOneWayTextChannel() as OneWayTextCommunication;
roomExitCommChannel = CommunicationChannelFactory.MakeRoomExitPathChannel() as RoomExitPathCommChannel;
oneWayTimedComm = CommunicationChannelFactory.MakeOneWayTimedChannel() as OneWayTimedCommChannel;
stillnessTimedComm = CommunicationChannelFactory.MakeTimedStillnessChannel() as StillnessTimedCommChannel;
//init object mover
objectMover = ObjectMover.CreateObjectMover();
playerCurrentCoords = player.MazeCellCoords;
//start out not in communcation
aiCommState = AICommunicationState.NotInCommuncation;
aiAlignmentState = AIAlignmentState.Neutral;
//initialize list of possible actions (for each state)
InitializeActionLists();
roomsRequestedIn = new Dictionary<IntVector2, bool>();
rng = new System.Random();
}
开发者ID:iangonzalez,项目名称:mouse-in-a-maze-game,代码行数:25,代码来源:GameAI.cs
示例20: PlotLine
/// <summary>
/// Line using linear interpolation
/// </summary>
public static IEnumerable<IntVector2> PlotLine(IntVector2 p0, IntVector2 p1)
{
const int MUL = 1 << 16;
IntVector2 v = p1 - p0;
int N = Math.Max(Math.Abs(v.X), Math.Abs(v.Y));
int dx, dy;
if (N == 0)
{
dx = dy = 0;
}
else
{
dx = (v.X * MUL) / N;
dy = (v.Y * MUL) / N;
}
int x = 0;
int y = 0;
for (int step = 0; step <= N; step++)
{
var p = new IntVector2(p0.X + MyMath.DivRoundNearest(x, MUL), p0.Y + MyMath.DivRoundNearest(y, MUL));
yield return p;
x += dx;
y += dy;
}
}
开发者ID:tomba,项目名称:dwarrowdelf,代码行数:36,代码来源:LerpLine.cs
注:本文中的IntVector2类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论