// Use this for initialization
    void Start()
    {
        if (FailureScene == null)
        {
            Logs.Error("Failure scene is not set");
        }

        if (!Msf.Client.Connection.IsConnected)
        {
            // If we're not connected to master, jump back to maion screen
            SceneManager.LoadScene(FailureScene.SceneName);
            return;
        }

        // Get access to the zone we are supposed to be in.
        Msf.Client.Connection.SendMessage(WorldDemoOpCodes.GetCurrentZoneAccess, (status, response) =>
        {
            if (status != ResponseStatus.Success)
            {
                // If we've failed to request a teleport
                Logs.Warn("Teleport request failed. Reason: " + response.AsString() + "." +
                          "This might be intentional(when quitting a game)");
                SceneManager.LoadScene(FailureScene.SceneName);
                return;
            }

            var access = response.Deserialize(new RoomAccessPacket());

            // Make sure that we won't try to start a game server
            // on the game scene
            Msf.Client.Rooms.ForceClientMode = true;

            RoomConnector.Connect(access);
        });
    }
Beispiel #2
0
 public virtual void OnRoomAccessReceived(RoomAccessPacket access)
 {
     // Connect via room connector
     if (RoomConnector.Instance != null)
     {
         RoomConnector.Connect(access);
     }
 }
Beispiel #3
0
        private static Room BuildDungeonInUnitySpaceRecur(RoomPrototype actualElement, Transform parent)
        {
            var instantiatedRoom = Object.Instantiate(actualElement.RoomResource, actualElement.GlobalPosition, actualElement.Rotation, parent);

            actualElement.ActualGraphElement.Room = instantiatedRoom;
            instantiatedRoom.DungeonStructureNode = actualElement.ActualGraphElement;

            foreach (var prototypeConnection in actualElement.ChildRoomConnections)
            {
                var parentConn = instantiatedRoom.GetConnections().Single(c =>
                                                                          c.name == prototypeConnection.ParentConnection.name &&
                                                                          c.transform.localPosition == prototypeConnection.ParentConnection.transform.localPosition);

                if (prototypeConnection.State == PrototypeConnectionState.CONNECTED)
                {
                    var nextRoom  = BuildDungeonInUnitySpaceRecur(prototypeConnection.ChildRoomPrototype, parent);
                    var childConn = nextRoom.GetConnections().Single(c => c.name == prototypeConnection.ChildConnection.name &&
                                                                     c.transform.localPosition == prototypeConnection.ChildConnection.transform.localPosition);
                    RoomConnector.Connect(parentConn, childConn);

                    CreateOpenReplacement(parentConn);
                    CreateOpenReplacement(childConn);
                }
                else if (prototypeConnection.State == PrototypeConnectionState.CLOSED)
                {
                    parentConn.Close();
                    CreateClosedReplacement(parentConn);
                }
                else
                {
                    throw new Exception("No other state should be possible");
                }
            }

            return(instantiatedRoom);
        }