本文整理汇总了C#中Direction.GetOpposite方法的典型用法代码示例。如果您正苦于以下问题:C# Direction.GetOpposite方法的具体用法?C# Direction.GetOpposite怎么用?C# Direction.GetOpposite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Direction
的用法示例。
在下文中一共展示了Direction.GetOpposite方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreatePlasmaConnector
private void CreatePlasmaConnector(Vector3 plasmaPos, Direction sofaDir)
{
Vector3 position = plasmaPos;
position.y = _connectorPrefab.position.y + 10f;
Direction dir = sofaDir.GetOpposite();
int secondNodeOffsetIndexX = 0;
int secondNodeOffsetIndexY = 0;
switch (dir)
{
case Direction.Up:
case Direction.Down:
position.x -= 0.5f;
secondNodeOffsetIndexX = 1;
break;
case Direction.Right:
case Direction.Left:
position.z -= 0.5f;
secondNodeOffsetIndexY = 1;
break;
}
var plasmaConnector = (Transform)Instantiate(_connectorPrefab, position, DirectionUtils.DirectionToQuaternion(dir));
plasmaConnector.parent = SceneContainers.Connectors;
var nearNode = plasmaConnector.GetComponent<Connector>().NearestNode;
var plasmaConnectorSpawnNode = _emptyNodes.Find(c => c.GridNode == NodesGrid.Grid[nearNode.X, nearNode.Y]);
RemoveNodeFromEmptyNodes(plasmaConnectorSpawnNode, SpawnNodeType.Connector);
var secondNode = _emptyNodes.Find(c => c.GridNode == NodesGrid.Grid[nearNode.X + secondNodeOffsetIndexX, nearNode.Y + secondNodeOffsetIndexY]);
RemoveNodeFromEmptyNodes(secondNode, SpawnNodeType.Device);
}
示例2: CreatePlasma
private void CreatePlasma(Vector3 sofaPos, Direction sofaDir, out Vector3 plasmaPos)
{
Vector3 position = sofaPos;
position.y = _plasmaTVPrefab.transform.position.y + 10f;
Direction dir = sofaDir.GetOpposite();
switch (dir)
{
case Direction.Up:
case Direction.Down:
position.z -= 100f * dir.CreateSign();
position.x += 0.5f;
break;
case Direction.Right:
case Direction.Left:
position.z += 0.5f;
position.x -= 100f * dir.CreateSign();
break;
}
var plasmaTV_pos = plasmaPos = RoomClamp(position);
var plasmaTV = (Transform)Instantiate(_plasmaTVPrefab, plasmaTV_pos, DirectionUtils.DirectionToQuaternion(dir));
plasmaTV.parent = _devices;
}
示例3: GetOutDirection
public override Direction GetOutDirection(Direction prevOutDirection)
{
if (!HasConnection(prevOutDirection))
return Direction.None;
// т.к. _currentDirection совпадает с `последней` стороной данной фигуры, то нужно вернуть либо текущую сторону, либо следующую:
return prevOutDirection.GetOpposite() == _currentDirection ? _currentDirection.GetNext() : _currentDirection;
}
示例4: GetPath
public override List<Vector3> GetPath(Direction prevOutDirection)
{
List<Vector3> path = new List<Vector3>();
if (prevOutDirection.GetOpposite() == _currentDirection)
{
path.AddRange(_signalPoints.Select(tr=>tr.position));
}
else if (prevOutDirection.GetOpposite() == _currentDirection.GetNext()) //(prevOutDirection == _currentDirection.GetPrev())
{
//foreach (var p in _reversedSignalPoints)
//{
// Debug.LogWarning(p.name);
//}
path.AddRange(_reversedSignalPoints.Select(tr => tr.position));
}
return path;
}
示例5: GetSecondOutDirection
/// <summary>
/// Вторая сторона выхода. Например, для ипользования в клонировании сигнала.
/// </summary>
/// <param name="prevOutDirection">Направление выхода предыдущего элемента. Противоположно проверяемой стороне текущего элемента</param>
public Direction GetSecondOutDirection(Direction prevOutDirection)
{
if (!HasConnection(prevOutDirection))
return Direction.None;
//_currentDirection равна центральной стороне
if (prevOutDirection.GetOpposite() == _currentDirection) //если входная сторона - центральнная
return _currentDirection.GetNext();
return _currentDirection; //для двух остальных случаев возвращается центральная сторона
}
示例6: GetOutDirection
public override Direction GetOutDirection(Direction prevOutDirection)
{
if (!HasConnection(prevOutDirection))
return Direction.None;
//_currentDirection равна центральной стороне
if (prevOutDirection.GetOpposite() == _currentDirection) //если входная сторона - центральнная
return _currentDirection.GetPrev();
return prevOutDirection; //для двух остальных случаев возвращается сторона, противоположная входной стороне текущего элемента, как и в случае линии.
}
示例7: GetPath
public override List<Vector3> GetPath(Direction prevOutDirection)
{
List<Vector3> path = new List<Vector3>();
if (prevOutDirection.GetOpposite() == _currentDirection) //если входная сторона - центральнная
{
path.Add(UpSignalPoint);
path.Add(CenterSignalPoint);
path.Add(LeftSignalPoint);
}
else if (prevOutDirection.GetOpposite() == _currentDirection.GetPrev())
{
path.Add(LeftSignalPoint);
path.Add(CenterSignalPoint);
path.Add(RightSignalPoint);
}
else if (prevOutDirection.GetOpposite() == _currentDirection.GetNext())
{
path.Add(RightSignalPoint);
path.Add(CenterSignalPoint);
path.Add(LeftSignalPoint);
}
return path;
}
示例8: TestPath
public override List<string> TestPath(Direction prevOutDirection)
{
List<string> path = new List<string>();
if (prevOutDirection == _currentDirection)
{
path.Add("Down");
path.Add("Up");
}
else if (prevOutDirection.GetOpposite() == _currentDirection)
{
path.Add("Up");
path.Add("Down");
}
return path;
}
示例9: GetPath
public override List<Vector3> GetPath(Direction prevOutDirection)
{
List<Vector3> path = new List<Vector3>();
if (prevOutDirection == _currentDirection)
{
path.Add(DownSignalPoint);
path.Add(UpSignalPoint);
}
else if (prevOutDirection.GetOpposite() == _currentDirection)
{
path.Add(UpSignalPoint);
path.Add(DownSignalPoint);
}
return path;
}
示例10: OnArrowKeyInput
public void OnArrowKeyInput(Direction direction)
{
if (_currentGroup == null || ControllingGroup != true || direction == Direction.None) return;
if (direction == Direction.Up)
{
RotateCurrentGroup();
return;
}
bool bumpedOnTheGround = false;
_currentGroup.Move(direction);
foreach (Coord coord in _currentGroup.ChildrenLocation)
{
if (!IsAvailable(coord.X, coord.Y))
{
_currentGroup.Move(direction.GetOpposite());
if (direction == Direction.Down)
{
bumpedOnTheGround = true;
}
break;
}
}
if (bumpedOnTheGround)
{
ControllingGroup = false;
_currentGroup.PlaySound(SoundName.BumpOnTheGround);
}
}
示例11: GetSecondPath
/// <summary>
/// Вовзращает точки пути для клонированного сигнала, учитывая с какой стороны пришел оригинальный сигнал.
/// </summary>
/// <param name="inDirection">Направление выхода предыдущего элемента. Противоположно проверяемой стороне текущего элемента</param>
public List<Vector3> GetSecondPath(Direction inDirection)
{
List<Vector3> path = new List<Vector3> {CenterSignalPoint};
if (inDirection.GetOpposite() == _currentDirection) //если входная сторона - центральнная
{
path.Add(RightSignalPoint);
}
else if (inDirection.GetOpposite() == _currentDirection.GetPrev() || inDirection.GetOpposite() == _currentDirection.GetNext())
{
path.Add(UpSignalPoint);
}
return path;
}
示例12: HasConnection
/// <summary>
/// Проверка наличия соединения
/// </summary>
/// <param name="prevOutDirection">Направление выхода предыдущего элемента. Противоположно проверяемой стороне текущего элемента</param>
public bool HasConnection(Direction prevOutDirection)
{
return Sides[(byte)prevOutDirection.GetOpposite()];
}
示例13: CreateWindows
private void CreateWindows(Direction sofaDir)
{
var prefab = RandomUtils.GetRandomItem(_windowPrefabs);
int winCount = (Random.Range(1, 4) == 3) ? 1 : 2;
//winCount = 2;//Test only
int prevDir = -1;
for (int i = 0; i < winCount; i++)
{
Direction dir = (Direction)RandomUtils.RangeWithExclude(0, 4, (int)sofaDir.GetOpposite(), prevDir);
prevDir = (int) dir;
Vector3 pos = new Vector3(0f, prefab.position.y + 10f, 0f);
switch (dir)
{
case Direction.Up:
pos.x = localOffset - 0.5f;//0.65f;
pos.z = -100f;
break;
case Direction.Down:
pos.x = localOffset - 0.5f + Random.Range(0, 2);
pos.z = 100f;
break;
case Direction.Right:
case Direction.Left:
pos.x = -100 * dir.CreateSign();
pos.z = localOffset - 0.5f + Random.Range(0, 2);
break;
}
pos = RoomClamp(pos);
var window = (Transform)Instantiate(prefab, pos, DirectionUtils.DirectionToQuaternion(dir));
window.parent = _windows;
var nearNode = AstarPath.active.astarData.gridGraph.GetNearest(pos - new Vector3(0.1f, 0, 0.1f)).node;
var spawnNode = _emptyNodes.Find(c => c.GridNode.AstarNode == nearNode);
RemoveNodeFromEmptyNodes(spawnNode, SpawnNodeType.Busy);
var nearNode2 = AstarPath.active.astarData.gridGraph.GetNearest(pos + new Vector3(0.1f, 0, 0.1f)).node;
var spawnNode2 = _emptyNodes.Find(c => c.GridNode.AstarNode == nearNode2);
RemoveNodeFromEmptyNodes(spawnNode2, SpawnNodeType.Busy);
}
}
示例14: CreatePassage
private void CreatePassage(Cell cell, Cell nextCell, Direction direction)
{
Passage passage = Instantiate(passagePrefab) as Passage;
passage.Instance(cell, nextCell, direction);// Instance the passage (void) ...
passage = Instantiate(passagePrefab) as Passage;
passage.Instance(nextCell, cell, direction.GetOpposite());// from one cell to the other, in the two directions
}
示例15: CreateWall
private void CreateWall(Cell cell, Cell nextCell, Direction direction)
{
Wall wall = Instantiate(wallPrefab) as Wall;
wall.Instance(cell, nextCell, direction); //instance a wall between the next cell
if (nextCell != null) //if next cell is existing
{
wall = Instantiate(wallPrefab) as Wall;
wall.Instance(nextCell, cell, direction.GetOpposite());//instance a wall in the other direction
}
}