当前位置: 首页>>代码示例>>C#>>正文


C# Direction.GetOpposite方法代码示例

本文整理汇总了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);
    }
开发者ID:upsky,项目名称:domru,代码行数:33,代码来源:RoomContentGenerator_GenerationMethods.cs

示例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;
    }
开发者ID:upsky,项目名称:domru,代码行数:25,代码来源:RoomContentGenerator_GenerationMethods.cs

示例3: GetOutDirection

        public override Direction GetOutDirection(Direction prevOutDirection)
        {
            if (!HasConnection(prevOutDirection))
                return Direction.None;

            // т.к. _currentDirection совпадает с `последней` стороной данной фигуры, то нужно вернуть либо текущую сторону, либо следующую:
            return prevOutDirection.GetOpposite() == _currentDirection ? _currentDirection.GetNext() : _currentDirection;
        }
开发者ID:upsky,项目名称:domru,代码行数:8,代码来源:CornerShape.cs

示例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;
        }
开发者ID:upsky,项目名称:domru,代码行数:18,代码来源:CornerShape.cs

示例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; //для двух остальных случаев возвращается центральная сторона
        }
开发者ID:upsky,项目名称:domru,代码行数:15,代码来源:TeeShape.cs

示例6: GetOutDirection

        public override Direction GetOutDirection(Direction prevOutDirection)
        {
            if (!HasConnection(prevOutDirection))
                return Direction.None;

            //_currentDirection равна центральной стороне

            if (prevOutDirection.GetOpposite() == _currentDirection) //если входная сторона - центральнная
                return _currentDirection.GetPrev();
            return prevOutDirection; //для двух остальных случаев возвращается сторона, противоположная входной стороне текущего элемента, как и в случае линии.
        }
开发者ID:upsky,项目名称:domru,代码行数:11,代码来源:TeeShape.cs

示例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;
        }
开发者ID:upsky,项目名称:domru,代码行数:24,代码来源:TeeShape.cs

示例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;
        }
开发者ID:upsky,项目名称:domru,代码行数:16,代码来源:LineShape.cs

示例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;
        }
开发者ID:upsky,项目名称:domru,代码行数:16,代码来源:LineShape.cs

示例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);
        }
    }
开发者ID:Mojopon,项目名称:ThreeSeven,代码行数:32,代码来源:Grid.cs

示例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;
        }
开发者ID:upsky,项目名称:domru,代码行数:18,代码来源:TeeShape.cs

示例12: HasConnection

 /// <summary>
 /// Проверка наличия соединения
 /// </summary>
 /// <param name="prevOutDirection">Направление выхода предыдущего элемента. Противоположно проверяемой стороне текущего элемента</param>
 public bool HasConnection(Direction prevOutDirection)
 {
     return Sides[(byte)prevOutDirection.GetOpposite()];
 }
开发者ID:upsky,项目名称:domru,代码行数:8,代码来源:Shape.cs

示例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);
        }
    }
开发者ID:upsky,项目名称:domru,代码行数:45,代码来源:RoomContentGenerator_GenerationMethods.cs

示例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
 }
开发者ID:DarkCookies,项目名称:The-Life-Breaker,代码行数:7,代码来源:Maze.cs

示例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

        }
    }
开发者ID:DarkCookies,项目名称:The-Life-Breaker,代码行数:11,代码来源:Maze.cs


注:本文中的Direction.GetOpposite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。