本文整理汇总了C#中Location.ToVector3方法的典型用法代码示例。如果您正苦于以下问题:C# Location.ToVector3方法的具体用法?C# Location.ToVector3怎么用?C# Location.ToVector3使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Location
的用法示例。
在下文中一共展示了Location.ToVector3方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DrawLine
public static void DrawLine(Location from, Location to, Color4 color)
{
var vertices = new PositionColored[2];
vertices[0] = new PositionColored(from.ToVector3(), color.ToArgb());
vertices[1] = new PositionColored(to.ToVector3(), color.ToArgb());
Device.DrawUserPrimitives(PrimitiveType.LineList, 1, vertices);
}
示例2: DrawCircle
public static unsafe void DrawCircle(Location center, float radius, Color innerColor, Color outerColor, int complexity = 24, bool isFilled = true)
{
var vertices = new List<PositionColored>();
if (isFilled)
vertices.Add(new PositionColored(Vector3.Zero, innerColor.ToArgb()));
double stepAngle = (Math.PI * 2) / complexity;
for (int i = 0; i <= complexity; i++)
{
double angle = (Math.PI * 2) - (i * stepAngle);
float x = (float)(radius * Math.Cos(angle));
float y = (float)(-radius * Math.Sin(angle));
vertices.Add(new PositionColored(new Vector3(x, y, 0), outerColor.ToArgb()));
}
var buffer = vertices.ToArray();
InternalRender(center.ToVector3() + new Vector3(0, 0, 0.3f));
if (isFilled)
Device.DrawUserPrimitives(PrimitiveType.TriangleFan, buffer.Length - 2, buffer);
else
Device.DrawUserPrimitives(PrimitiveType.LineStrip, buffer.Length - 1, buffer);
}
示例3: GetRandomPosition
private Vector3 GetRandomPosition(int groupId)
{
GameObject group = cubeCreator.groups[groupId];
// キューブの位置をリスト化
var positions = Enumerable
.Range(0, group.transform.childCount)
.Select(index => group.transform.GetChild(index))
.Select(child => child.position)
.ToList();
// Pivot Cube Position
positions.Insert(0, Vector3.zero);
// 生成可能範囲を取得
int xCanPutMin = xMin - positions.Min(p => (int)p.x);
int xCanPutMax = xMax - positions.Max(p => (int)p.x);
int zCanPutMin = zMin - positions.Min(p => (int)p.z);
int zCanPutMax = zMax - positions.Max(p => (int)p.z);
// 突然変異
float probabilityOfMutation = GetProbabilityOfMutation();
if (Random.value < probabilityOfMutation)
{
Debug.Log("mutatoin!!");
var playerLocation = new Location(player.transform.position);
playerLocation.x = Mathf.Clamp(playerLocation.x, xCanPutMin, xCanPutMax);
playerLocation.z = Mathf.Clamp(playerLocation.z, zCanPutMin, zCanPutMax);
return playerLocation.ToVector3();
}
// 生成可能範囲を配列化
Location[] canPutLocations =
(from x in Enumerable.Range(xCanPutMin, xCanPutMax - xCanPutMin + 1)
from z in Enumerable.Range(zCanPutMin, zCanPutMax - zCanPutMin + 1)
select new Location(x, z))
.ToArray();
// 評価の取得
Dictionary<Location, int> cubeLengths = GetCubeLengths(positions);
Dictionary<Location, int> heightMap = GetHeightMap();
Dictionary<Location, int> scores = GetScores(canPutLocations, cubeLengths, heightMap);
var scoreMin = scores.Min(score => score.Value);
var threshold = GetScoreThreshold();
var candidates =
scores
.Where(score => score.Value >= scoreMin && score.Value <= scoreMin + threshold)
.Select(score => score.Key)
.ToArray();
var randomPosition = candidates[Random.Range(0, candidates.Length)].ToVector3();
return randomPosition;
}
示例4: DrawLine
public static void DrawLine(Location from, Location to, Color color)
{
var vertices = new PositionColored[2];
vertices[0] = new PositionColored(Vector3.Zero, color.ToArgb());
vertices[1] = new PositionColored(to.ToVector3() - from.ToVector3(), color.ToArgb());
InternalRender(from.ToVector3());
Device.DrawUserPrimitives(PrimitiveType.LineList, vertices.Length / 2, vertices);
}