本文整理汇总了C#中IntVector3类的典型用法代码示例。如果您正苦于以下问题:C# IntVector3类的具体用法?C# IntVector3怎么用?C# IntVector3使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IntVector3类属于命名空间,在下文中一共展示了IntVector3类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Contains
// I/F
public bool Contains(IntVector3 eyePosition, IntVector3 point)
{
int distanceSquared;
IntVector3.DistanceSquared(ref eyePosition, ref point, out distanceSquared);
return distanceSquared <= radiusSquared;
}
示例2: TryGetSectorViewHighlightables
/// <summary>
/// Returns <c>true</c> if the sector indicated by sectorID contains one or more ISectorViewHighlightables, <c>false</c> otherwise.
/// </summary>
/// <param name="sectorID">ID of the sector.</param>
/// <param name="highlightablesInSector">The highlightables in sector.</param>
/// <returns></returns>
public bool TryGetSectorViewHighlightables(IntVector3 sectorID, out IEnumerable<ISectorViewHighlightable> highlightablesInSector) {
D.AssertNotDefault(sectorID);
List<ISectorViewHighlightable> sectorHighlightables = new List<ISectorViewHighlightable>();
ISystem_Ltd system;
if (TryGetSystem(sectorID, out system)) {
ISectorViewHighlightable sys = system as ISectorViewHighlightable;
D.AssertNotNull(sys);
sectorHighlightables.Add(sys);
}
IEnumerable<IStarbaseCmd_Ltd> starbases;
if (TryGetStarbases(sectorID, out starbases)) {
IEnumerable<ISectorViewHighlightable> highlightableStarbases = starbases.Cast<ISectorViewHighlightable>();
D.Assert(!highlightableStarbases.IsNullOrEmpty());
sectorHighlightables.AddRange(highlightableStarbases);
}
IEnumerable<IFleetCmd_Ltd> fleets;
if (TryGetFleets(sectorID, out fleets)) {
IEnumerable<ISectorViewHighlightable> highlightableFleets = fleets.Cast<ISectorViewHighlightable>();
D.Assert(!highlightableFleets.IsNullOrEmpty());
sectorHighlightables.AddRange(highlightableFleets);
}
if (sectorHighlightables.Any()) {
highlightablesInSector = sectorHighlightables;
return true;
}
highlightablesInSector = null;
return false;
}
示例3: AdjustRiver
public void AdjustRiver()
{
int minZ = m_riverPath.Min(p => m_terrain.GetSurfaceLevel(p));
var pos = DirectionSet.Cardinal | DirectionSet.Exact;
var coreLocs = new HashSet<IntVector2>(m_riverPath.SelectMany(p => pos.ToSurroundingPoints(p)));
foreach (var pp in coreLocs)
{
if (m_terrain.Size.Plane.Contains(pp) == false)
continue;
for (int z = m_terrain.Depth - 1; z >= minZ - 1; --z)
{
var p = new IntVector3(pp.X, pp.Y, z);
var td = TileData.EmptyTileData;
if (z == minZ - 1)
td.WaterLevel = TileData.MaxWaterLevel;
m_terrain.SetTileData(p, td);
}
}
}
示例4: GenerateVoxel
public override Voxel GenerateVoxel(IntVector3 pos)
{
var distance = pos.DistanceTo(IntVector3.Zero);
if (distance < half)
return new Voxel { Weight = 255 };
/*
var polarPos = SphericalPosition.FromCartesian(pos.X, pos.Y, pos.Z);
if (polarPos.Radius < half)
{
//var noiseVal = (float)gen.GetValue(polarPos.Azimuth, polarPos.Inclination, Seed);
//var radHere = (float)(noiseVal + 1f / 2f) * Size;
//if (radHere < half)
return new Voxel(1f);
}
// the easy way to generate a sphere
//if(pos.DistanceTo(IntVector3.Zero) < half)
// return new Voxel(1f);
*/
return Voxel.Empty;
}
示例5: Chunk
/// <summary>
/// Creates a new Chunk of size chunkSize x chunkSize x chunkSize, filled with null blocks.
/// This is for chunks that are part of the map.
/// It will assume that its north-west-bottom corner is at pos * chunkSize,
/// and (when implemented...) it will save its data to "pos.x,pos.y,pos.z".xml
/// </summary>
/// <param name="layers"></param>
/// <param name="pos"></param>
public Chunk(IntVector3 pos, GraphicsDevice graphics)
{
size = Sizes.ChunkSize;
blocks = new Block[Sizes.ChunkSize, Sizes.ChunkSize, Sizes.ChunkSize];
structures = new List<MapStructure>();
position = pos;
filename = MainGame.WorldFolder + position.X + "," + position.Y + "," + position.Z;
try
{
vBuff = new DynamicVertexBuffer(graphics, typeof(VertexPositionColorNormal), maxVerts, BufferUsage.WriteOnly);
//vBuff.ContentLost += new EventHandler<EventArgs>(verticesLostHandler);
iBuff = new DynamicIndexBuffer(graphics, IndexElementSize.SixteenBits, maxInds, BufferUsage.WriteOnly);
//iBuff.ContentLost += new EventHandler<EventArgs>(indicesLostHandler);
//so do I need to add a custom test for content lost before drawing?
}
catch(OpenTK.Graphics.GraphicsContextException e)
{
Logger.Log(e.ToString());
}
vertices = new VertexPositionColorNormal[0];
indices = new short[0];
}
示例6: findDetachedVoxels
public static ArrayList findDetachedVoxels(int [,,] mapData, int stopCode, IntVector3 point)
{
/*
where i,j,k is a recently destroyed block, returns a list of IntVector3s of all blocks that should
be detached, as well as the size of the blob that would contain them.
*/
ArrayList detachedVoxels = new ArrayList ();
allVisitedVoxels = new ArrayList ();
ArrayList seeds = MDView.getNeighbors (mapData, point);
for (int index=0; index<seeds.Count; index++) {
IntVector3 seedPoint = (IntVector3)seeds [index];
if (allVisitedVoxels.Contains (seedPoint)) {
seeds.Remove (seedPoint);
index--;
continue;
}
ArrayList newVoxels = getBlob (mapData, stopCode, seedPoint);
if (newVoxels.Count > 0) {
detachedVoxels.AddRange (newVoxels);
}
}
return detachedVoxels;
}
示例7: getCollisionArray
public static int[,] getCollisionArray(int[,,]mapData, IntVector3 direction)
{
/*
where direction is a unit vector, pointing in the direction mapData is travelling
the direction vector decides what the collision plane will be. for example the collision plane
of a moving car is vertical, like the surface of a brick wall, in front of the car.
the returned collisionArray is the heights of the nearest voxel lining up to each (x,y) of that
plane.
*/
//Debug.Log ("getCollisionArray " + direction.i + " " + direction.j + " " + direction.k);
if (! direction.isOrthogonalUnitVector ())
Debug.Log ("warning: getCollisionArray didn't get a unit vector.");
IntVector2 arraySize = getCollisionArraySize (mapData, direction);
int [,] collisionArray = new int [arraySize.x, arraySize.y];
for (int xOffset=0; xOffset<arraySize.x; xOffset++) {
for (int yOffset=0; yOffset<arraySize.y; yOffset++) {
int dist = getClosestVoxelDistance (mapData, xOffset, yOffset, direction);
collisionArray [xOffset, yOffset] = dist;
if (dist != -1) {
//Debug.Log ("xoffset: " + xOffset + " yoffset: " + yOffset + " dist: " + dist);
}
}
}
return collisionArray;
}
示例8: MoveBaseAssignment
protected MoveBaseAssignment(IJobObserver parent, IEnvironmentObject environment, IntVector3 location)
: base(parent)
{
this.Environment = environment;
this.Location = location;
m_state = 0;
}
示例9: Calculate3
public static void Calculate3(IntVector3 viewerLocation, int visionRange, VisionMap visibilityMap, IntSize3 mapSize,
Func<IntVector3, bool> blockerDelegate)
{
visibilityMap.Clear();
if (blockerDelegate(viewerLocation) == true)
return;
var g = new IntGrid3(new IntVector3(), mapSize);
g = g.Offset(-viewerLocation.X, -viewerLocation.Y, -viewerLocation.Z);
var vr = new IntVector3(visionRange, visionRange, visionRange);
g = g.Intersect(new IntGrid3(vr, -vr));
int visionRangeSquared = (visionRange + 1) * (visionRange + 1); // +1 to get a bit bigger view area
foreach (var dst in g.Range())
{
if (dst.LengthSquared > visionRangeSquared)
continue;
bool vis = FindLos3(viewerLocation, dst, blockerDelegate);
visibilityMap[dst] = vis;
// XXX Cheat a bit so that the floor will be visible
if (vis && dst.Z == 0 && viewerLocation.Z > 1)
{
visibilityMap[dst.SetZ(dst.Z - 1)] = true;
}
}
}
示例10: InitializeWorld
public void InitializeWorld(World world, IntSize3 size)
{
CreateTerrain(size);
IntVector3? stairs = null;
foreach (var p2 in m_terrainData.Size.Plane.Range())
{
var p = new IntVector3(p2, m_terrainData.Size.Depth - 1);
var td = m_terrainData.GetTileData(p.Down);
if (td.ID == TileID.Stairs)
{
stairs = p;
break;
}
}
if (stairs.HasValue == false)
throw new Exception();
m_env = EnvironmentObject.Create(world, m_terrainData, VisibilityMode.LivingLOS, stairs.Value);
CreateMonsters();
CreateDebugMonsterAtEntry();
}
示例11: EnvironmentObject
EnvironmentObject(Dwarrowdelf.TerrainGen.TerrainData terrain, VisibilityMode visMode, IntVector3 startLocation)
: base(ObjectType.Environment)
{
this.Version = 1;
this.VisibilityMode = visMode;
terrain.GetData(out m_tileGrid, out m_levelMap);
this.Size = terrain.Size;
this.StartLocation = startLocation;
InitFlags();
VerifyLevelMap();
m_contentArray = new KeyedObjectCollection[this.Depth];
for (int i = 0; i < this.Depth; ++i)
m_contentArray[i] = new KeyedObjectCollection();
m_originalNumTrees = ParallelEnumerable.Range(0, this.Size.Depth).Sum(z =>
{
int sum = 0;
for (int y = 0; y < this.Size.Height; ++y)
for (int x = 0; x < this.Size.Width; ++x)
if (GetTileData(x, y, z).HasTree)
sum++;
return sum;
});
}
示例12: CreateBallMap
public static TerrainData CreateBallMap(IntSize3 size, int innerSide = 0)
{
var map = new TerrainData(size);
int side = MyMath.Min(size.Width, size.Height, size.Depth);
int r = side / 2 - 1;
int ir = innerSide / 2 - 1;
Parallel.For(0, size.Depth, z =>
{
for (int y = 0; y < size.Height; ++y)
for (int x = 0; x < size.Width; ++x)
{
var pr = Math.Sqrt((x - r) * (x - r) + (y - r) * (y - r) + (z - r) * (z - r));
var p = new IntVector3(x, y, z);
if (pr < r && pr >= ir)
map.SetTileDataNoHeight(p, TileData.GetNaturalWall(MaterialID.Granite));
else
map.SetTileDataNoHeight(p, TileData.EmptyTileData);
}
});
map.RescanLevelMap();
return map;
}
示例13: Sees
public override bool Sees(IntVector3 p)
{
if (!m_environment.Contains(p))
return false;
return GetVisible(p);
}
示例14: MineAssignment
public MineAssignment(IJobObserver parent, IEnvironmentObject environment, IntVector3 location, MineActionType mineActionType)
: base(parent)
{
m_environment = environment;
m_location = location;
m_mineActionType = mineActionType;
}
示例15: genFootballPosts
public static int[,,] genFootballPosts(VoxelTheme voxelTheme, IntVector3 destination, int width, int addedHeight)
{
int cageHeight=5;
int[,,] newData = genMapDataFromPoint (destination, width,addedHeight+cageHeight);
int iSize = newData.GetLength (0);
int jSize = newData.GetLength (1);
if (iSize < 3 || width<3 || jSize/iSize>1)
return genBasic (voxelTheme, destination, width);
IntVector3 lastHopPoint = new IntVector3 (0, 0, -1);
int stepSpacing=5;
foreach (IntVector3 hopPoint in getHopArray(iSize,jSize-addedHeight,stepSpacing)) {
IntVector3 offset = new IntVector3 (hopPoint.x, hopPoint.y+addedHeight-1, 0);
int[,,] cageData=new int[1,cageHeight-1,width];
cageData=MDController.combine(cageData,GreebleGenerator.genCage(voxelTheme,1,cageHeight,width));
newData = MDController.combine (newData, cageData, offset);
if (lastHopPoint.z != -1) {
offset = new IntVector3 (lastHopPoint.x,0,width/2);
int underhangAddedHeight=Mathf.Min (hopPoint.y,lastHopPoint.y)+addedHeight;
int[,,] underhangData=ShapeGenerator.genUnderhang(voxelTheme, hopPoint,lastHopPoint,underhangAddedHeight);
newData = MDController.combine (newData, underhangData, offset);
}
lastHopPoint = hopPoint;
}
return rotateMapData (newData, destination);
}