示例#1
0
    public void RotateTillConnect()
    {
        float degrees = 0;
        List <BuildingType.ExitsPosition> updatedPos = new List <BuildingType.ExitsPosition>();

        for (int i = 0; i < 4; i++)
        {
            if (CanConnect(myExits))
            {
                break;
            }
            foreach (BuildingType.ExitsPosition pos in myExits)
            {
                switch (pos)
                {
                case BuildingType.ExitsPosition.LEFT:
                    updatedPos.Add(BuildingType.ExitsPosition.TOP);
                    break;

                case BuildingType.ExitsPosition.RIGHT:
                    updatedPos.Add(BuildingType.ExitsPosition.BOTTOM);
                    break;

                case BuildingType.ExitsPosition.TOP:
                    updatedPos.Add(BuildingType.ExitsPosition.RIGHT);
                    break;

                case BuildingType.ExitsPosition.BOTTOM:
                    updatedPos.Add(BuildingType.ExitsPosition.LEFT);
                    break;
                }
            }
            myExits.Clear();
            foreach (BuildingType.ExitsPosition pos in updatedPos)
            {
                if (!myExits.Contains(pos))
                {
                    myExits.Add(pos);
                }
            }
            updatedPos.Clear();
            degrees = (degrees - 90) % 360;
            UpdateExitsTransforms(true);
        }
        transform.Rotate(0, 0, degrees);
        myType.UpdateExits(myExits, anchorPointTop, anchorPointBottom, anchorPointLeft, anchorPointRight);
        myNodeManager.UpdateNodeDistance(myNode);
    }