Пример #1
0
    bool MatchDoors(GameObject roomPrefab, Node node)
    {
        /*if (node.roomType != Node.ROOM_TYPE.START && node.roomType != Node.ROOM_TYPE.END)
         * { // (patch now)*/
        if (node.roomType != roomPrefab.GetComponent <Room>().roomType)    // check if room matches node type
        {
            return(false);
        }
        //}

        var roomDoors = roomPrefab.GetComponent <Room>().connectedDoors;

        Utils.ORIENTATION orientation = Utils.ORIENTATION.NONE;
        for (int i = 0; i < 4; i++)
        {
            switch (i)
            {
            case 0:
                orientation = Utils.ORIENTATION.NORTH;
                break;

            case 1:
                orientation = Utils.ORIENTATION.SOUTH;
                break;

            case 2:
                orientation = Utils.ORIENTATION.EAST;
                break;

            case 3:
                orientation = Utils.ORIENTATION.WEST;
                break;
            }

            var  edge   = node.adjacents.SingleOrDefault(y => y.orientation == Utils.OrientationToDir(orientation));
            var  door   = roomDoors.SingleOrDefault(y => y.Orientation == orientation);
            bool isDoor = door != null && door.State != Door.STATE.WALL;
            bool isEdge = edge != null && edge.doorState != Door.STATE.WALL;

            // a strict room needs all the corresponding doors for the edges
            if (node.roomType != Node.ROOM_TYPE.DEFAULT)
            {
                if (isEdge)
                {
                    if (!isDoor)
                    {
                        return(false);
                    }
                }
            }
            else if (/*node.roomType == Node.ROOM_TYPE.DEFAULT && */ isDoor != isEdge)
            {
                return(false);
            }
        }
        return(true);
    }
Пример #2
0
 public void Start()
 {
     _orientation = Utils.AngleToOrientation(-transform.eulerAngles.z);
     if (closedGo.gameObject.activeSelf)
     {
         SetState(STATE.CLOSED);
     }
     else if (openGo.gameObject.activeSelf)
     {
         SetState(STATE.OPEN);
     }
     else if (wallGo.gameObject.activeSelf)
     {
         SetState(STATE.WALL);
     }
     else if (secretGo.gameObject.activeSelf)
     {
         SetState(STATE.SECRET);
     }
 }
Пример #3
0
 public void Awake()
 {
     _room        = GetComponentInParent <Room>();
     _orientation = Utils.AngleToOrientation(-transform.eulerAngles.z);
 }
Пример #4
0
 public void SetOrientation()
 {
     _orientation = Utils.AngleToOrientation(-transform.eulerAngles.z);
 }