Exemplo n.º 1
0
        private void CheckExcludeButton(RoomAuthoring otherRoomAuthoring)
        {
            var previousColor = GUI.backgroundColor;

            GUI.backgroundColor = Color.red;
            if (GUILayout.Button("x", GUILayout.MaxWidth(20)))
            {
                var networkAuthoring = authoring.GetComponentInParent <RoomNetworkAuthoring>();
                var parent           = networkAuthoring.transform;

                var gameObject = new GameObject("New Exclude Portal", typeof(RoomExcludePortalAuthoring));
                Undo.RegisterCreatedObjectUndo(gameObject, "Create Exclude Portal");
                gameObject.transform.SetParent(parent, false);

                var exclude = gameObject.GetComponent <RoomExcludePortalAuthoring>();
                var excludeSerializedObject = new SerializedObject(exclude);

                excludeSerializedObject.FindProperty("roomAuthoringA").objectReferenceValue = authoring;
                excludeSerializedObject.FindProperty("roomAuthoringB").objectReferenceValue = otherRoomAuthoring;

                excludeSerializedObject.ApplyModifiedProperties();

                GameObjectEditorIconHelper.SetIcon(gameObject, GameObjectEditorIconHelper.LabelIcon.Red);

                gameObject.name = exclude.GetPortalName();
            }
            GUI.backgroundColor = previousColor;
        }
Exemplo n.º 2
0
        void OnEnable()
        {
            authoring = (RoomAuthoring)target;

            var gameObject = authoring.gameObject;

            if (!GameObjectEditorIconHelper.GetHasIcon(gameObject))
            {
                GameObjectEditorIconHelper.SetIcon(gameObject, GameObjectEditorIconHelper.LabelIcon.Green);
            }
        }
        private void LinkToOtherPortals(RoomAuthoring roomAuthoring,
                                        DynamicBuffer <RoomPortalReference> portalReferences, int currentIndex)
        {
            var length = portalReferences.Length;

            if (currentIndex + 1 >= length)
            {
                return;
            }

            var portalReferenceA = portalReferences[currentIndex];
            var portalEntityA    = portalReferenceA.PortalEntity;

            if (!GetIsChainable(portalEntityA))
            {
                return;
            }

            for (int i = currentIndex + 1; i < length; i++)
            {
                var portalReferenceB = portalReferences[i];
                var portalEntityB    = portalReferenceB.PortalEntity;

                if (!GetIsChainable(portalEntityB))
                {
                    return;
                }

                var element = new PortalChainElement
                {
                    RoomAuthoring = roomAuthoring,
                    RoomA         = portalReferenceA.LinkedRoomEntity,
                    RoomB         = portalReferenceB.LinkedRoomEntity,
                    PortalA       = portalEntityA,
                    PortalB       = portalEntityB,
                };

                chainElements.Add(element);
            }
        }
Exemplo n.º 4
0
        private IEnumerable <LinkedRoomData> AddRoomsLinkedBySeeThrough(RoomAuthoring otherRoomAuthoring, RoomPortalAuthoring[] allPortals)
        {
            if (!otherRoomAuthoring.SeeThrough)
            {
                yield break;
            }

            foreach (var portal in allPortals)
            {
                if (GetIsContainedInPortal(portal, otherRoomAuthoring))
                {
                    var thirdRoom = GetOtherRoomInPortal(portal, otherRoomAuthoring);
                    if (thirdRoom != authoring)
                    {
                        yield return(new LinkedRoomData
                        {
                            OtherRoom = thirdRoom,
                            SeeThroughRoom = otherRoomAuthoring,
                        });
                    }
                }
            }
        }
Exemplo n.º 5
0
        private RoomAuthoring GetOtherRoomInPortal(RoomPortalAuthoring portalAuthoring, RoomAuthoring roomAuthoring)
        {
            if (portalAuthoring.RoomAuthoringA == roomAuthoring)
            {
                return(portalAuthoring.RoomAuthoringB);
            }

            if (portalAuthoring.RoomAuthoringB == roomAuthoring)
            {
                return(portalAuthoring.RoomAuthoringA);
            }

            throw new ArgumentException("Room not contained in portal");
        }
Exemplo n.º 6
0
 private bool GetIsContainedInExclude(RoomExcludePortalAuthoring excludeAuthoring, RoomAuthoring roomAuthoring)
 {
     return(excludeAuthoring.RoomAuthoringA == roomAuthoring || excludeAuthoring.RoomAuthoringB == roomAuthoring);
 }
Exemplo n.º 7
0
 private bool GetIsContainedInPortal(RoomPortalAuthoring portalAuthoring, RoomAuthoring roomAuthoring)
 {
     return(portalAuthoring.RoomAuthoringA == roomAuthoring || portalAuthoring.RoomAuthoringB == roomAuthoring);
 }