Пример #1
0
 public void BottoneGioca()
 {
     if (Statici.nomePersonaggio != string.Empty && Statici.datiPersonaggio.Dati.nomePersonaggio != string.Empty)
     {
         if (inputNomePartita.text.Replace(" ", "") != string.Empty)
         {
             ResettaErrore();
             BloccaSbloccaCanvas(false);
             RoomSettings settings = new RoomSettings(inputNomePartita.text.Replace(" ", "").Trim());
             settings.GroupId = "games";
             settings.IsGame = true;
             settings.MaxUsers = numeroMaxDecisoDaOwner;
             settings.MaxSpectators = 0;
             SFSRoomVariable roomVariableStart = new SFSRoomVariable("gameStarted", false);
             roomVariableStart.IsPersistent = true;
             settings.Variables.Add(roomVariableStart);
             settings.Extension = new RoomExtension(EXTENSION_ID, EXTENSION_CLASS);
             sfs.Send(new CreateRoomRequest(settings, true, sfs.LastJoinedRoom));
         }
         else
             erroreText.text = "Assegnare un nome alla partita";
     }
     else
         erroreText.text = "Inserire un nome e scegliere una classe";
 }
Пример #2
0
    private void CreateRoom()
    {
        var room = new RoomSettings("room 1");
        room.IsGame = true;
        room.MaxUsers = 6;
        room.GroupId = "groupid";

        SmartFoxConnector.Instance.CreateRoom(room);
    }
Пример #3
0
    public void OnStartNewGameButtonClick()
    {
        // Configure Game Room
        RoomSettings settings = new RoomSettings(sfs.MySelf.Name + "'s game");
        settings.GroupId = "games";
        settings.IsGame = true;
        settings.MaxUsers = 2;
        settings.MaxSpectators = 0;
        settings.Extension = new RoomExtension(EXTENSION_ID, EXTENSION_CLASS);

        // Request Game Room creation to server
        sfs.Send(new CreateRoomRequest(settings, true, sfs.LastJoinedRoom));
    }
Пример #4
0
    // Use this for initialization
    void Start() {
        // Habitación a la que afecta
        if (isNext)
        {
            affectedRoomSettings = way.nextRoom;
        }
        else {
            affectedRoomSettings = way.prevRoom;
        }
        if (affectedRoomSettings == null)
        {
            Destroy(gameObject);
        }
        else {
            affectedRoom = affectedRoomSettings.gameObject;
        }

    }
Пример #5
0
    public void createRoom()
    {
        // Configure Game Room
        RoomSettings settings = new RoomSettings(sfs.MySelf.Name + "'s Room");
        settings.GroupId = "games";
        settings.IsGame = true;

        //Settings for maximun player in game is 2
        settings.MaxUsers = 4;

        //Settings for maximun of spectators is no limit
        settings.MaxSpectators = 0;
        //settings.MaxSpectators = 0;

        settings.Extension = new RoomExtension(EXTENSION_ID, EXTENSION_CLASS);

        // Request Game Room creation to server
        sfs.Send(new CreateRoomRequest(settings, true, sfs.LastJoinedRoom));

        Debug.Log("Created Room");
    }
Пример #6
0
 public AppSettings AddGallery(RoomSettings gallery)
 {
     galleries[gallery.GalleryName] = gallery;
     return(this);
 }
Пример #7
0
 public override void OnStartClient()
 {
     base.OnStartClient();
     Instance = this;
 }
Пример #8
0
 protected void BaseOnLevelLoad()
 {
     if (gameIsOver)
     {
         return;
     }
     CameraFade.StartAlphaFade(Color.black, true, true, GlobalConsts.SCENE_TRANSITION_TIME);
     if (teleportTag == "" || teleportTarget == null)
         return;
     GameObject teleportGO = GameObject.FindGameObjectWithTag(teleportTag);
     GameObject[] targetGOs = GameObject.FindGameObjectsWithTag(teleportTarget.tag);
     if (targetGOs != null)
     {
         if (targetGOs.Length == 1)
         {
             GameObject go = targetGOs[0];
             if (go != teleportTarget)
             {
                 Destroy(teleportTarget);
                 teleportTarget = go;
             }
         }
         else if (targetGOs.Length > 0)
         {
             foreach (GameObject go in targetGOs)
             {
                 if (go.transform.position != teleportTarget.transform.position)
                 {
                     Destroy(go);
                 }
             }
         }
     }
     if (teleportGO == null)
         return;
     float z = teleportTarget.transform.position.z;
     Vector3 position = teleportGO.transform.position;
     position.z = z;
     position.y -= GlobalConsts.PLAYER_SPAWN_DEPRESSION;
     if (Physics2D.Raycast(position + Vector3.left, Vector3.down))
     {
         position = position + Vector3.left;
     }
     else if (Physics2D.Raycast(position + Vector3.right, Vector3.down))
     {
         position = position + Vector3.right;
     }
     teleportTarget.transform.position = position;
     roomSettings = null;
     GameObject roomGlobals = GameObject.FindGameObjectWithTag("Room Settings");
     if (roomGlobals != null)
     {
         roomSettings = roomGlobals.GetComponent<RoomSettings>();
     }
     AutoSave();
 }
Пример #9
0
	public void OnUdpInit(BaseEvent evt) {
		if (evt.Params.ContainsKey("success") && !(bool)evt.Params["success"]) {
			loginErrorMessage = (string)evt.Params["errorMessage"];
			Debug.Log("UDP error: "+loginErrorMessage);
		} else {
			Debug.Log("UDP ok");
		
			// On to the lobby
			loginErrorMessage = "";
			
			
			var numMaxUsers = 5;
			var roomName = "My Room";
			RoomSettings settings = new RoomSettings(roomName);
			//settings.GroupId = "game";
			//settings.IsGame = true;
			//settings.MaxUsers = (short)numMaxUsers;
			//settings.MaxSpectators = 0;
			smartFox.Send(new CreateRoomRequest(settings));
			smartFox.Send( new JoinRoomRequest(roomName) );
			
			
		}
	}
Пример #10
0
    // Changed
    // A window to use for room creation
    private void onCreateWindow(int windowID)
    {
        GUI.skin = createRoomSkin;
        GUI.DragWindow(new Rect(0, 0, createRoom.width, 60));

        if (createRoom.x + createRoom.width > Screen.width)
        {
            createRoom.x = Screen.width - createRoom.width;
        }
        else if (createRoom.x < 0)
        {
            createRoom.x = 0;
        }

        if (createRoom.y + createRoom.height > Screen.height)
        {
            createRoom.y = Screen.height - createRoom.height;
        }
        else if (createRoom.y <0)
        {
            createRoom.y = 0;
        }

        newRoomName = GUI.TextField(new Rect(20, 70, 200, 30), newRoomName, 20);
        newRoomPlayers = GUI.TextField(new Rect(20, 130, 200, 30), newRoomPlayers, 20);
        newRoomType = GUI.TextField(new Rect(20, 190, 200, 30), newRoomType, 20);

        GUI.TextArea(new Rect(20, 40, 200, 30), "New Room Name:");
        GUI.TextArea(new Rect(20, 100, 200, 30), "Max Players:");
        GUI.TextArea(new Rect(20, 160, 200, 30), "Room Stage:");

        if (GUI.Button(new Rect(createRoom.width/2 - 110, 240, 100, 30), "Create!") ||
            (Event.current.type == EventType.keyDown && Event.current.character == '\n'))
        {
            short numMaxPlayers = 0;

            if (Int16.TryParse(newRoomPlayers, out numMaxPlayers))
            {
                RoomSettings settings = new RoomSettings(newRoomName);
                settings.MaxUsers = numMaxPlayers;

                List<RoomVariable> variablesArray = new List<RoomVariable>();
                RoomVariable newRoomVariable = new SFSRoomVariable(newRoomType, null);
                variablesArray.Add(newRoomVariable);
                //settings.Variables = variablesArray;

                smartFox.Send(new CreateRoomRequest(settings));

                newRoomName = "";
                newRoomPlayers = "";
                newRoomType = "";
                showCreateRoom = false;
            }
            else
            {
                newRoomPlayers = "";
            }
        }

        if (GUI.Button(new Rect(createRoom.width/2 + 10, 240, 100, 30), "Cancel"))
        {
            newRoomName = "";
            newRoomPlayers = "";
            newRoomType = "";
            showCreateRoom = false;
        }
    }
    private static Noeud[] PlaceDoor(Noeud[] graph)
    {
        foreach (Noeud node in graph)
        {
            RoomSettings roomSettings = node.sallePrefab.GetComponent <RoomSettings>();
            foreach (int key in node.liens.Keys)
            {
                if (graph[key].position.x < node.position.x)
                {
                    switch (node.liens[key])
                    {
                    case Noeud.TYPE_DE_LIEN.CLOSE:
                        roomSettings.doorLeft.SetState(Door.STATE.CLOSED);
                        break;

                    case Noeud.TYPE_DE_LIEN.OPEN:
                        roomSettings.doorLeft.SetState(Door.STATE.OPEN);
                        break;

                    case Noeud.TYPE_DE_LIEN.SECRET:
                        roomSettings.doorLeft.SetState(Door.STATE.SECRET);
                        break;
                    }
                }

                if (graph[key].position.x > node.position.x)
                {
                    switch (node.liens[key])
                    {
                    case Noeud.TYPE_DE_LIEN.CLOSE:
                        roomSettings.doorRight.SetState(Door.STATE.CLOSED);
                        break;

                    case Noeud.TYPE_DE_LIEN.OPEN:
                        roomSettings.doorRight.SetState(Door.STATE.OPEN);
                        break;

                    case Noeud.TYPE_DE_LIEN.SECRET:
                        roomSettings.doorRight.SetState(Door.STATE.SECRET);
                        break;
                    }
                }

                if (graph[key].position.y > node.position.y)
                {
                    switch (node.liens[key])
                    {
                    case Noeud.TYPE_DE_LIEN.CLOSE:
                        roomSettings.doorUp.SetState(Door.STATE.CLOSED);
                        break;

                    case Noeud.TYPE_DE_LIEN.OPEN:
                        roomSettings.doorUp.SetState(Door.STATE.OPEN);
                        break;

                    case Noeud.TYPE_DE_LIEN.SECRET:
                        roomSettings.doorUp.SetState(Door.STATE.SECRET);
                        break;
                    }
                }

                if (graph[key].position.y < node.position.y)
                {
                    switch (node.liens[key])
                    {
                    case Noeud.TYPE_DE_LIEN.CLOSE:
                        roomSettings.doorDown.SetState(Door.STATE.CLOSED);
                        break;

                    case Noeud.TYPE_DE_LIEN.OPEN:
                        roomSettings.doorDown.SetState(Door.STATE.OPEN);
                        break;

                    case Noeud.TYPE_DE_LIEN.SECRET:
                        roomSettings.doorDown.SetState(Door.STATE.SECRET);
                        break;
                    }
                }
            }
        }
        return(graph);
    }
Пример #12
0
 private GameObject CheckIsGoodRoom(Node node, RoomSettings roomS, RoomTag roomTag)
 {
     return(node.RoomTags.HasFlag(roomTag) ? roomS.Room : null);
 }
Пример #13
0
    public static RoomInstance PlaceRoom(RoomInstance prefab, bool isBossRoom, FloorSettings floorSettings, RoomSettings roomSettings, Vector3Int location, Vector3Int extents, RoomConnections connection)
    {
        RoomInstance instance = Instantiate(prefab, location, Quaternion.identity);

        instance.m_Connections   = connection;
        instance.m_IsBossRoom    = isBossRoom;
        instance.m_RoomSettings  = roomSettings;
        instance.m_FloorSettings = floorSettings;

        RoomGeneratorHelper generator = new RoomGeneratorHelper(roomSettings, extents, connection);

        instance.SetupRoom(generator, extents);
        return(instance);
    }
Пример #14
0
 private RoomSettings()
 {
     I = this;
 }
Пример #15
0
 private void SetupRoomList()
 {
     List<Room> allRooms = smartFox.RoomManager.GetRoomList();
     foreach (Room room in allRooms) {
         if (!room.IsGame)
             continue;
         roomName = room.Name;
         break;
     }
     if (roomName=="") {
         roomName = smartFox.MySelf.Name + " game";
         short numMaxUsers = 100;
         RoomSettings settings = new RoomSettings(roomName);
         settings.GroupId = "default";
         settings.IsGame = true;
         settings.MaxUsers = numMaxUsers;
         settings.MaxSpectators = 0;
         settings.Extension = new RoomExtension("Snow", "Extension.SnowExtension");
         smartFox.Send(new CreateRoomRequest(settings, true, smartFox.LastJoinedRoom));
     }
     else {
         smartFox.Send(new JoinRoomRequest(roomName));
     }
 }
Пример #16
0
 public void CreateRoom(RoomSettings settings)
 {
     sfs.Send(new CreateRoomRequest(settings, true));
 }
Пример #17
0
 // TODO: Take settings as a parameter, or take no parameters
 //       and find the room settings somewhere?
 // Invoked locally on master client from OnJoinedRoom.
 // Distribute full art manifest for the room to all visitors.
 // Perform RPC on all clients when they connect (targeting OthersBuffered).
 public void ExportArt(RoomSettings room)
 {
     DistributeManifest(room.GetManifest());
     room.Slots.ForEachValue(DisplayArt);  // TODO: should definitely do this, but maybe somewhere else?
 }
Пример #18
0
    private void DrawRoomsGUI()
    {
        if (GameValues.isHost)
        {
            //start game button event listener
            if (GUILayout.Button("Start Game") && startGameTime <= 0)
            {

                // ****** Create the actual game ******* //
                String[] nameParts = this.currentActiveRoom.Name.Split('-');
                String gameName = nameParts[0].Trim() + " - Game";
                Debug.Log("Host created game named: " + gameName);

                RoomSettings settings = new RoomSettings(gameName);
                settings.MaxUsers = (short)currentActiveRoom.MaxUsers; // how many players allowed: 12
                settings.Extension = new RoomExtension(GameManager.ExtName, GameManager.ExtClass);
                settings.IsGame = true;
                settings.MaxVariables = 15;

                //get the variables set up from the lobby
                List<RoomVariable> lobbyVars = currentActiveRoom.GetVariables();
                SFSObject lobbyGameInfo = (SFSObject)((RoomVariable)lobbyVars[1]).GetSFSObjectValue();
                //lobbyGameInfo.GetSFSArray("
                //FORMAT BY INDEX
                //0 = (bool)        gameStarted
                //1 = (SFSObject)   gameInfo
                //      -(string)   the host username               key: "host"
                //      -(IntArray) playerIds                       key: "playerIDs"
                //      -(int)      number of Teams                 key: "numTeams"
                //      -(SFSArray) teams                           key: "teams"
                //      -(int)      length of the game in seconds   key: "gameLength"

                SFSRoomVariable gameInfo = new SFSRoomVariable("gameInfo", lobbyGameInfo);
                settings.Variables.Add(gameInfo);

                SFSRoomVariable userCountVar = new SFSRoomVariable("numberOfPlayers", currentActiveRoom.UserCount);
                settings.Variables.Add(userCountVar);

                SFSArray joinedPlayers = new SFSArray();
                SFSRoomVariable joinedVar = new SFSRoomVariable("playersJoined", joinedPlayers);
                settings.Variables.Add(joinedVar);

                //get the values from the appropriate fields to populate the gameInfo
                smartFox.Send(new CreateRoomRequest(settings));

                //start timer
                startGameTime = Time.time + 5.0f;
                Debug.Log("Start the countdown");

                List<RoomVariable> roomVars = new List<RoomVariable>();

                SFSRoomVariable startCountdown = new SFSRoomVariable("startCountdown", true);
                roomVars.Add(startCountdown);
                smartFox.Send(new SetRoomVariablesRequest(roomVars));
            }
        }
        else
        {
            //start game button event listener
            if (GUILayout.Button("Waiting..."))
            {
            }
        }
    }
Пример #19
0
        private static void RoomSettings_FindParent(On.RoomSettings.orig_FindParent orig, RoomSettings self, Region region)
        {
            if (self.isTemplate)
            {
                string filePath = "World" + Path.DirectorySeparatorChar + "Regions" + Path.DirectorySeparatorChar + region.name + Path.DirectorySeparatorChar + self.name + ".txt";

                /*
                 * if (!File.Exists(Custom.RootFolderDirectory() + filePath))
                 * {
                 * }
                 */
                //CustomWorldMod.CustomWorldLog($"Custom Regions: Finding custom room settings template [{filePath}]");
                bool foundTemplate = false;
                foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks)
                {
                    string newPath = Custom.RootFolderDirectory() + CustomWorldMod.resourcePath + keyValues.Value + Path.DirectorySeparatorChar + filePath;

                    if (File.Exists(newPath))
                    {
                        foundTemplate = true;
                        self.filePath = newPath;
                        CustomWorldMod.Log($"Found template at [{newPath}]");
                        break;
                    }
                }
                if (!foundTemplate && File.Exists(Custom.RootFolderDirectory() + filePath))
                {
                    self.filePath = Custom.RootFolderDirectory() + filePath;
                    CustomWorldMod.Log($"Using vanilla template at [{self.filePath}] since custom was not found", false, CustomWorldMod.DebugLevel.FULL);
                }
            }
            else
            {
                // Mod didn't include Settings file
                if (!File.Exists(self.filePath))
                {
                    string regularRoomPath = Custom.RootFolderDirectory() + "World" + Path.DirectorySeparatorChar + "Regions" + Path.DirectorySeparatorChar + Regex.Split(self.name, "_")[0];
                    regularRoomPath += Path.DirectorySeparatorChar + "Rooms" + Path.DirectorySeparatorChar + self.name + "_Settings.txt";
                    if (File.Exists(regularRoomPath))
                    {
                        self.filePath = regularRoomPath;
                    }
                    else
                    {
                        CustomWorldMod.Log($"Missing settings file for [{self.name}] - [{regularRoomPath}]", false, CustomWorldMod.DebugLevel.FULL);
                    }

                    /*
                     * try
                     * {
                     *  // Call vanilla FindRoomDirectory
                     *  // I copied this from Warp :flushed:
                     *  MethodInfo _WorldLoader_FindRoomFileDirectory = typeof(WorldLoader).GetMethod("FindRoomFileDirectory", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
                     *  object returnValue = _WorldLoader_FindRoomFileDirectory.Invoke(null, new object[] { self.name, false });
                     *  //
                     *  var method = typeof(WorldLoader).GetMethod("FindRoomFileDirectory");
                     *  var ftn = method.MethodHandle.GetFunctionPointer();
                     *  var func = (Func<string, bool, string>)Activator.CreateInstance(typeof(Func<string, bool, string>), null, ftn);
                     *  object returnValue = func(self.name, false);
                     *
                     *  if (returnValue != null && returnValue is string s && File.Exists(s + "_Settings.txt"))
                     *  {
                     *      self.filePath = s + "_Settings.txt";
                     *  }
                     *  else
                     *  {
                     *      CustomWorldMod.Log($"Error loading settings file for [{self.name}] - [{returnValue}]");
                     *  }
                     *
                     * } catch (Exception e) { CustomWorldMod.Log($"Error invoking method [{e}]", true); }
                     */
                }
            }


            /*
             * else
             * {
             *  //CustomWorldMod.Log($"Custom Regions: RoomSettings, room [{self.name}] is not template. FilePath [{self.filePath}]");
             *  Calling FindRoomFileDirectory will find the custom one
             *  self.filePath = FindVanillaRoom(self.name, false) + "_Settings.txt";
             * }
             */

            try
            {
                orig(self, region);
            }
            catch (Exception e)
            {
                CustomWorldMod.Log("Found illegal characters in a room settings file." + e, true);
                throw e;
            }
        }
 RoomSettings GetRoomSetting()
 {
     roomSetting = new RoomSettings ("TestRoom");
     roomSetting.Extension = new RoomExtension (EXTENSION_ID, EXTENSION_CLASS);
     roomSetting.IsGame = true;
     Debug.Log (roomSetting.Extension);
     return roomSetting;
 }
    void OnGUI()
    {
        if (!started) return;

        //GUI.skin = gSkin;
        int screenW = Screen.width;
        int screenH = Screen.height;

        Room currentActiveRoom = smartFox.LastJoinedRoom;

        if ( currentActiveRoom == null ) {
            // Wait until active room has been set up in the API before drawing anything
            return;
        }

        // User list
        GUI.Box(new Rect(screenW-200, 80, 180, 170), "Users");
        GUILayout.BeginArea(new Rect(screenW-190, 110, 150, 160));
        userScrollPosition = GUILayout.BeginScrollView(userScrollPosition, GUILayout.Width(150), GUILayout.Height(130));
        GUILayout.BeginVertical();

        foreach ( User user in currentActiveRoom.UserList ) {
            GUILayout.Label(user.Name);
        }

        GUILayout.EndVertical();
        GUILayout.EndScrollView();
        GUILayout.EndArea();

        // Game room list
        GUI.Box(new Rect(screenW-200, 260, 180, 200), "Game List");
        if (smartFox.RoomList.Count != 1 ) {
            GUILayout.BeginArea(new Rect(screenW-190, 290, 150, 130));
            gameScrollPosition = GUILayout.BeginScrollView(gameScrollPosition, GUILayout.Width(150), GUILayout.Height(160));

            roomSelection = GUILayout.SelectionGrid(roomSelection, roomStrings, 1, "RoomListButton");
            if (roomSelection>=0 && roomStrings[roomSelection] != currentActiveRoom.Name)
            {
                smartFox.Send(new JoinRoomRequest(roomStrings[roomSelection], null, smartFox.LastJoinedRoom.Id));
            }

            if ( smartFox.RoomList.Count == 1 ) { // We always have 1 non-game room - Main Lobby
                GUILayout.Label("No games available to join");
            }

            GUILayout.EndScrollView();
            GUILayout.EndArea();
        }

        if ( GUI.Button(new Rect(screenW-200, 480, 85, 24), "New game") ) {
            RoomSettings settings = new RoomSettings(smartFox.MySelf.Name + "'s game");
            //settings.GroupId = "game";
            settings.IsGame = true;
            settings.MaxUsers = 2;
            settings.MaxSpectators = 0;
            settings.Extension = new RoomExtension(extensionId, extensionClass);
            smartFox.Send(new CreateRoomRequest(settings, true, smartFox.LastJoinedRoom));

        /*
            SFSGameSettings settings = new SFSGameSettings("TestGame");
            settings.IsPublic = true;
            settings.MaxUsers = 4;
            settings.MaxSpectators = 0;
            settings.MinPlayersToStartGame = 2;
            settings.PlayerMatchExpression = new MatchExpression("BestScore", NumberMatch.GREATER_THAN, 100);
            settings.NotifyGameStarted = true;
            settings.LeaveLastJoinedRoom = true;

            smartFox.Send( new CreateSFSGameRequest(settings) );
            */
        }

        // Standard view
        if ( GUI.Button(new Rect(screenW-105, 480, 85, 24), "Logout") ) {
            smartFox.Send(new LogoutRequest());
        }

        // Room chat window
        GUI.Box(new Rect(10, 80, screenW-230, screenH-100), "Chat");
        chatWindow.Draw();
    }
Пример #22
0
 public void CreateRoom(RoomSettings settings, Action complete = null)
 {
     _smartFox.Send(new CreateRoomRequest(settings));
 }
Пример #23
0
    /// <summary>
    /// Actualiza los contadores de etiquetas ya aparecidas con las de la ultima room seleccionada
    /// Actualiza contadores de personajes necesarios y de tags de puzzles aparecidos hasta el momento
    /// </summary>
    /// <param name="selectedRoom">Hacitacion seleccionada cuyos tags se añaden al conjunto</param>
    void UpdateActualTags(RoomSettings selectedRoom)
    {
        if(selectedRoom!=null)
        {
            //Añade al total de apariciones las etiquetas de personajes necesarios
            foreach(CharacterName character in selectedRoom.requiredCharacters)
            {
                actualCharacterTags[character]++;
            }

            //Añade al total de apariciones las etiquetas de puzzle, agregandolas al diccionario
            //si aparecen por primera vez

            foreach (PuzzleTags tag in selectedRoom.tags)
            {
                    actualTagsCount[tag]++;
            }
        }
    }
Пример #24
0
 public Task NotifyRoomSettingsChange(string roomId, RoomSettings settings)
 {
     return(GetRoomMembers(roomId)
            .SendAsync(RoomHub.Notifications.UpdateRoomSettings, settings));
 }
Пример #25
0
 public BaseRoom(uint id, RoomSettings settings, PlayerInfo host)
 {
     roomId       = id;
     roomSettings = settings;
     roomHost     = host;
 }
Пример #26
0
    public RoomGeneratorHelper(RoomSettings settings, Vector3Int targetExtent, RoomConnections connections)
    {
        m_Settings    = settings;
        m_Connections = connections;
        m_NoiseMap    = new PerlinNoise(Random.Range(int.MinValue, int.MaxValue));

        // Decide room size
        m_TraversableExtent = new Vector3Int(
            targetExtent.x - settings.m_Padding.x * 2,
            targetExtent.y,
            targetExtent.z - settings.m_Padding.z * 2
            );

        // Populate voxel data
        Vector3Int fullExtent = FullExtent;
        VoxelData  voxelData  = VoxelData.New(fullExtent.x, fullExtent.y, fullExtent.z);

        m_DoorCentre = new Vector2Int(fullExtent.x / 2, fullExtent.z / 2);

        for (int x = 0; x < fullExtent.x; ++x)
        {
            for (int z = 0; z < fullExtent.z; ++z)
            {
                int height = GetHeight(x, z);

                // Try to create a placement spot here
                if (x % m_Settings.m_PlacementFrequency == 0 && z % m_Settings.m_PlacementFrequency == 0)
                {
                    if (height == m_Settings.m_FloorHeight)
                    {
                        m_AccessibleSpots.Add(new Vector3Int(x, height, z));
                    }
                    else if (height == m_TraversableExtent.y)
                    {
                        m_InaccessibleSpots.Add(new Vector3Int(x, height, z));
                    }
                }


                for (int y = 0; y <= height; ++y)
                {
                    uint[] coloursTable = m_Settings.m_ColourIndices;

                    float rawNoise = GetRawNoise(x, z, m_Settings.m_TextureHeightFrequency, m_Settings.m_TextureNoiseScale);

                    if (rawNoise <= 0.3f && m_Settings.m_LowNoiseColourIndices.Length != 0)
                    {
                        coloursTable = m_Settings.m_LowNoiseColourIndices;
                    }
                    else if (rawNoise >= 0.6f && m_Settings.m_HighNoiseColourIndices.Length != 0)
                    {
                        coloursTable = m_Settings.m_HighNoiseColourIndices;
                    }

                    int  colourLookupIdx = Mathf.Clamp(height - y, 0, coloursTable.Length - 1);
                    uint colour          = coloursTable[colourLookupIdx];

                    voxelData.SetVoxel(new Voxel(colour), x, y, z);
                }
            }
        }

        m_Mesh      = voxelData.GenerateMesh(Vector3.zero, settings.m_Scale);
        m_Mesh.name = "GeneratedMesh";
    }
Пример #27
0
    private void DrawLobbyGUI()
    {
        Room currentActiveRoom = smartFox.LastJoinedRoom;
        if ( currentActiveRoom == null ) {
            // Wait until active room has been set up in the API before drawing anything
            return;
        }

        float chatPanelWidth = Screen.width * 3/4 - 10;
        float chatPanelHeight = Screen.height - 80;
        float chatPanelPosX = 10;
        float chatPanelPosY = 10;

        float roomPanelWidth = Screen.width * 1/4 - 10;
        float roomPanelHeight = Screen.height / 2 - 40 - 5;
        float roomPanelPosX = chatPanelPosX + chatPanelWidth;
        float roomPanelPosY = chatPanelPosY;

        float userPanelWidth = roomPanelWidth;
        float userPanelHeight = roomPanelHeight;
        float userPanelPosX = chatPanelPosX + chatPanelWidth;
        float userPanelPosY = chatPanelPosY + roomPanelHeight + 10;

        // Room list
        GUILayout.BeginArea(new Rect(roomPanelPosX, roomPanelPosY, roomPanelWidth, roomPanelHeight));
        GUILayout.Box ("Game List", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));

        if (smartFox.RoomList.Count != 1 ) {
            GUILayout.BeginVertical();
            GUILayout.BeginArea(new Rect(20, 25, roomPanelWidth-40, roomPanelHeight-80), GUI.skin.customStyles[0]);
            // We want some padding between buttons in the grid selection
            GUIStyle selectionStyle = new GUIStyle(GUI.skin.button);
            selectionStyle.margin = new RectOffset(4,4,4,4);
            gameScrollPosition = GUILayout.BeginScrollView (gameScrollPosition);
            roomSelection = GUILayout.SelectionGrid (roomSelection, roomStrings, 1, selectionStyle);

            if (roomSelection>=0 && roomStrings[roomSelection] != currentActiveRoom.Name) {
                smartFox.Send(new JoinRoomRequest(roomStrings[roomSelection], null, smartFox.LastJoinedRoom.Id));
            }
            GUILayout.EndScrollView();
            GUILayout.EndArea ();
            GUILayout.EndVertical();
        }
        else {
            GUILayout.BeginVertical();
            GUILayout.BeginArea(new Rect(20, 25, roomPanelWidth-40, roomPanelHeight-80), GUI.skin.customStyles[0]);
            // We always have 1 non-game room - Main Lobby
            GUILayout.Label("No games available to join");
            GUILayout.EndArea ();
            GUILayout.EndVertical();
        }

        GUILayout.BeginHorizontal();
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("New game") ) {
            RoomSettings settings = new RoomSettings(smartFox.MySelf.Name + "'s game");
            settings.GroupId = "games";
            settings.IsGame = true;
            settings.MaxUsers = 4;
            settings.MaxSpectators = 0;
            settings.Extension = new RoomExtension(SFSNetworkManager.ExtName, SFSNetworkManager.ExtClass);
            smartFox.Send(new CreateRoomRequest(settings, true, smartFox.LastJoinedRoom));
        }
        GUILayout.FlexibleSpace();
        GUILayout.EndHorizontal();

        GUILayout.EndArea();

        // User list
        GUILayout.BeginArea(new Rect(userPanelPosX, userPanelPosY, userPanelWidth, userPanelHeight));
        GUILayout.Box ("Users", GUILayout.ExpandWidth(true), GUILayout.ExpandHeight(true));
        GUILayout.BeginVertical();
        GUILayout.BeginArea(new Rect(20, 25, userPanelWidth-40, userPanelHeight-80), GUI.skin.customStyles[0]);

        userScrollPosition = GUILayout.BeginScrollView (userScrollPosition, GUILayout.Width (150), GUILayout.Height (160));
        foreach (User user in currentActiveRoom.UserList) {
            GUILayout.Label(user.Name);
        }
        GUILayout.EndScrollView ();

        GUILayout.EndArea ();

        // Current user info
        GUILayout.BeginArea(new Rect(20, 25 + userPanelHeight - 70, userPanelWidth-40, 40));
        GUILayout.BeginHorizontal();
        GUILayout.Label("Logged in as " + smartFox.MySelf.Name);
        GUILayout.FlexibleSpace();
        if (GUILayout.Button("Logout")) {
            smartFox.Send( new LogoutRequest() );
        }
        GUILayout.EndHorizontal();

        GUILayout.EndArea ();
        GUILayout.EndVertical();
        GUILayout.EndArea ();

        // Room chat window
        chatWindow.Draw(chatPanelPosX, chatPanelPosY, chatPanelWidth, chatPanelHeight);
    }
Пример #28
0
    public void CreateRoomRequest(string roomName = "")
    {
        RoomSettings roomSettings = GetRoomSettings(roomName);

        SmartFox.Send(new CreateRoomRequest(roomSettings, true, SmartFox.LastJoinedRoom));
    }
Пример #29
0
 protected void BaseInit()
 {
     DontDestroy(this.gameObject);
     inputController = gameObject.GetComponent<InputController>();
     if (inputController == null)
     {
         inputController = gameObject.AddComponent<InputController>();
     }
     Screen.orientation = ScreenOrientation.LandscapeLeft;
     Screen.sleepTimeout = (int)SleepTimeout.NeverSleep;
     GameObject roomGlobals = GameObject.FindGameObjectWithTag("Room Settings");
     if (roomGlobals != null)
     {
         roomSettings = roomGlobals.GetComponent<RoomSettings>();
     }
 }
Пример #30
0
 private static void RoomSettings_Save(On.RoomSettings.orig_Save orig, RoomSettings self)
 {
     CustomWorldMod.Log($"[RoomSettings] Custom Regions: Saving room settings at [{self.filePath}]");
     orig(self);
 }
Пример #31
0
    private void DrawUsersGUI(Rect screenPos)
    {
        GUILayout.BeginArea(screenPos);
        GUI.Box(new Rect(0, 0, screenPos.width, screenPos.height), "");
        GUILayout.BeginVertical();
        GUILayout.Label("Users");
        userScrollPosition = GUILayout.BeginScrollView(userScrollPosition, false, true, GUILayout.Width(screenPos.width));
        GUILayout.BeginVertical();
        List<User> userList = currentActiveRoom.UserList;
        foreach (User user in userList)
        {
            GUILayout.Label(user.Name);
        }
        GUILayout.EndVertical();
        GUILayout.EndScrollView();
        GUILayout.BeginHorizontal();
        // Logout button
        if (GUILayout.Button("Logout"))
        {
            smartFox.Send(new LogoutRequest());
        }
        // Game Room button
        if (currentActiveRoom.Name == "The Lobby")
        {
            if (GUILayout.Button("Make Game"))
            {
                Debug.Log("Make Game Button clicked");

                // ****** Create new room ******* //
                int gameLength = 120; //time in seconds

                //let smartfox take care of error if duplicate name
                RoomSettings settings = new RoomSettings(username + " - Room");
                // how many players allowed
                settings.MaxUsers = (short)maxPlayers;
                //settings.GroupId = "create";
                //settings.IsGame = true;

                List<RoomVariable> roomVariables = new List<RoomVariable>();
                //roomVariables.Add(new SFSRoomVariable("host", username));
                roomVariables.Add(new SFSRoomVariable("gameStarted", false));   //a game started bool
                // set up arrays of colors
                //SFSArray nums = new SFSArray();
                //for (int i = 0; i < 5; i++)
                //{
                //    nums.AddInt(i);
                //}
                //roomVariables.Add(new SFSRoomVariable("colorNums", nums));

                SFSObject gameInfo = new SFSObject();
                gameInfo.PutUtfString("host", username);                        //the host
                SFSArray playerIDs = new SFSArray(); //[maxPlayers];
                for (int i = 0; i < maxPlayers; i++)
                {
                    playerIDs.AddInt(i);
                }

                gameInfo.PutSFSArray("playerIDs", playerIDs);                   //the player IDs
                gameInfo.PutInt("numTeams", numTeams);                          //the number of teams

                SFSArray teams = new SFSArray();								//ASSIGN WHICH PLAYERS GO ON WHICH TEAMS
                int counter = 0;
                int[] teamPlayerIndices;										// numTeams = 8, maxPlayers = 16
                for (int i = 0; i < numTeams; i++)								// i = 0, j = 0, j = 1, index = 0, index = 8
                {																// i = 1, j = 0, j = 1, index = 1, index = 9
                    teamPlayerIndices = new int[maxPlayers / numTeams];			// i = 2, j = 0, j = 1, index = 2, index = 10
                    for (int j = 0; j < maxPlayers / numTeams; j++)				// i = 3, j = 0, j = 1, index = 3, index = 11
                    { 															// ...
                        int index = i + (j * numTeams);
                        teamPlayerIndices[j] = index;							// i = 7, j = 0, j = 1, index = 7, index = 15
                    }

                    teams.AddIntArray(teamPlayerIndices);
                }
                gameInfo.PutSFSArray("teams", teams);                           //an array of possible values to be grabbed
                gameInfo.PutInt("gameLength", gameLength);                      //the length of the game

                roomVariables.Add(new SFSRoomVariable("gameInfo", gameInfo));

                settings.Variables = roomVariables;
                smartFox.Send(new CreateRoomRequest(settings, true, CurrentActiveRoom));           // Contains: maxUsers, and roomVariables
                Debug.Log("new room " + username + "- Room");
            }
        }
        GUILayout.EndHorizontal();
        GUILayout.EndVertical();
        GUILayout.EndArea();
    }
Пример #32
0
        private static void RoomSettings_Reset(On.RoomSettings.orig_Reset orig, RoomSettings self)
        {
            if (regionName == null)
            {
                // Reset() was called not from RoomSettings ctor
                orig(self);
                return;
            }

            if (self.isTemplate)
            {
                string filePath = "World" + Path.DirectorySeparatorChar + "Regions" + Path.DirectorySeparatorChar + regionName +
                                  Path.DirectorySeparatorChar + self.name + ".txt";

                bool foundTemplate = false;
                foreach (KeyValuePair <string, string> keyValues in CustomWorldMod.activatedPacks)
                {
                    string newPath = Custom.RootFolderDirectory() +
                                     CustomWorldMod.resourcePath + keyValues.Value + Path.DirectorySeparatorChar + filePath;
                    CustomWorldMod.Log($"[RoomSettings] Finding custom room settings template [{newPath}]", false, CustomWorldMod.DebugLevel.FULL);

                    if (File.Exists(newPath))
                    {
                        foundTemplate = true;
                        self.filePath = newPath;
                        CustomWorldMod.Log($"[RoomSettings] Found template at [{newPath}]");
                        break;
                    }
                }

                if (!foundTemplate && File.Exists(Custom.RootFolderDirectory() + filePath))
                {
                    self.filePath = Custom.RootFolderDirectory() + filePath;
                    CustomWorldMod.Log($"[RoomSettings] Using vanilla template at [{self.filePath}] since custom was not found", false, CustomWorldMod.DebugLevel.FULL);
                }
            }
            else
            {
                // Mod didn't include Settings file
                if (!File.Exists(self.filePath))
                {
                    CustomWorldMod.Log($"[RoomSettings] Room is not template, but could not find settings file at " +
                                       $"[{self.filePath}]", false, CustomWorldMod.DebugLevel.FULL);

                    string regularRoomPath = Custom.RootFolderDirectory() +
                                             "World" + Path.DirectorySeparatorChar + "Regions" + Path.DirectorySeparatorChar + Regex.Split(self.name, "_")[0];

                    regularRoomPath += Path.DirectorySeparatorChar + "Rooms" + Path.DirectorySeparatorChar + self.name + "_Settings.txt";
                    if (File.Exists(regularRoomPath))
                    {
                        self.filePath = regularRoomPath;
                    }
                    else
                    {
                        CustomWorldMod.Log($"[RoomSettings] Missing settings file for [{self.name}] - [{regularRoomPath}]", false, CustomWorldMod.DebugLevel.FULL);
                    }
                }
            }
            regionName = null;
            orig(self);
        }
Пример #33
0
        /**
         * ルーム作成設定.
         */
        private void OnGUI_CreateOrJoinRoom()
        {
            // 値の入力
            GUILayout.BeginHorizontal();
            GUILayout.Label("Your Numeric Value(" + baseValueLow + "-" + baseValueHigh + ") : ", GUILayout.Width(200));
            baseValue = Convert.ToInt32(GUILayout.TextField(baseValue.ToString(), GUILayout.Width(50)));
            GUILayout.EndHorizontal();

            // ルーム最大人数の入力
            GUILayout.BeginHorizontal();
            GUILayout.Label("Room Max Players : ", GUILayout.Width(200));
            maxPlayers = Convert.ToByte(GUILayout.TextField(maxPlayers.ToString(), GUILayout.Width(50)));
            GUILayout.EndHorizontal();

            // ルームの作成
            if (GUILayout.Button("Create Room", GUILayout.Width(250)))
            {
                // 入力した値が範囲外の場合、入力を無視する
                if (baseValue < baseValueLow || baseValue > baseValueHigh)
                {
                    Debug.LogWarning("Your value must between" + baseValueLow + " and " + baseValueHigh);
                }
                else
                {
                    // 自身の値をクエリーパラメータとして代入
                    customRoomParam["Value"] = baseValue;

                    // ロビー抽出バラメータの設定
                    string[] customRoomParametersForLobby = { "Value" };

                    // ルームの作成
                    RoomSettings roomSettings = new RoomSettings()
                    {
                        isVisible       = true,
                        isOpen          = true,
                        maxPlayers      = this.maxPlayers,
                        roomParameters  = this.customRoomParam,
                        lobbyParameters = customRoomParametersForLobby
                    };
                    MonobitNetwork.CreateRoom(null, roomSettings, null);
                }
            }

            // ルームへの入室
            if (GUILayout.Button("Join Room", GUILayout.Width(250)))
            {
                // 入力した値が範囲外の場合、入力を無視する
                if (baseValue < baseValueLow || baseValue > baseValueHigh)
                {
                    Debug.LogWarning("Your value must between" + baseValueLow + " and " + baseValueHigh);
                }
                else
                {
                    // 自身の値に対し、検索範囲の最初の閾値を設定する
                    baseValueMin = (baseValue - baseValueIncrease < baseValueLow) ? baseValueLow : baseValue - baseValueIncrease;
                    baseValueMax = (baseValue + baseValueIncrease > baseValueHigh) ? baseValueHigh : baseValue + baseValueIncrease;

                    // 閾値から、クエリー検索のためのWHERE句を生成する
                    string queryLobbyFilter = "Value>=" + baseValueMin + " AND Value<=" + baseValueMax;

                    // ルームへの入室
                    MonobitNetwork.JoinRandomRoom(null, this.maxPlayers, Definitions.MatchmakingMode.SerialMatching, new LobbyInfo()
                    {
                        Kind = LobbyKind.Query, Name = "QueryLobby"
                    }, queryLobbyFilter);
                }
            }
        }
Пример #34
0
 private void SendRoomRequest( object data )
 {
     RoomSettings settings = new RoomSettings ( SFSInstance.MySelf.Name + "'s game." );
     settings.Extension = new RoomExtension ( "StarboundAcesExtension", "com.gspteama.main.StarboundAcesExtension" );
     settings.MaxUsers = 8;
     settings.IsGame = true;
     SFSInstance.Send ( new CreateRoomRequest ( settings, true, SFSInstance.LastJoinedRoom ) );
 }
Пример #35
0
    private void DrawButtonsGUI(Rect screenPos, int userBoxWidth, int gameBoxWidth)
    {
        GUILayout.BeginArea(screenPos);
        GUILayout.BeginHorizontal();
        // Logout button
         	if (GUILayout.Button("Logout", buttonStyle, GUILayout.MaxWidth(userBoxWidth + 50)))
        {
            smartFox.Send(new LogoutRequest());
        }

        GUILayout.Space(screenPos.width - (userBoxWidth + gameBoxWidth + 125));

        // Game Room button
        if (GUILayout.Button("Make Game", buttonStyle, GUILayout.MaxWidth(gameBoxWidth + 125)))
        {
            if (currentActiveRoom.Name == "The Lobby")
            {

                Debug.Log("Make Game Button clicked");

                if (createdMyRoom)
                {
                    smartFox.Send(new JoinRoomRequest(username + " - Room", "", CurrentActiveRoom.Id));
                    return;
                }

                // ****** Create new room ******* //
                int gameLength = 120; //time in seconds

                //let smartfox take care of error if duplicate name
                RoomSettings settings = new RoomSettings(username + " - Room");
                // how many players allowed
                settings.MaxUsers = (short)maxPlayers;
                //settings.GroupId = "create";
                //settings.IsGame = true;

                List<RoomVariable> roomVariables = new List<RoomVariable>();
                //roomVariables.Add(new SFSRoomVariable("host", username));
                roomVariables.Add(new SFSRoomVariable("gameStarted", false));   //a game started bool

                SFSObject gameInfo = new SFSObject();
                gameInfo.PutUtfString("host", username);                        //the host
                SFSArray playerIDs = new SFSArray(); //[maxPlayers];

                gameInfo.PutSFSArray("playerIDs", playerIDs);                   //the player IDs
                gameInfo.PutInt("numTeams", numTeams);                          //the number of teams

                //hmmmmm
                SFSArray teams = new SFSArray();								//ASSIGN WHICH PLAYERS GO ON WHICH TEAMS
                int[] teamPlayerIndices;										// numTeams = 8, maxPlayers = 16
                for (int i = 0; i < numTeams; i++)								// i = 0, j = 0, j = 1, index = 0, index = 8
                {																// i = 1, j = 0, j = 1, index = 1, index = 9
                    teamPlayerIndices = new int[maxPlayers / numTeams];			// i = 2, j = 0, j = 1, index = 2, index = 10
                    for (int j = 0; j < maxPlayers / numTeams; j++)				// i = 3, j = 0, j = 1, index = 3, index = 11
                    { 															// ...
                        int index = i + (j * numTeams);
                        teamPlayerIndices[j] = index;							// i = 7, j = 0, j = 1, index = 7, index = 15
                    }

                    teams.AddIntArray(teamPlayerIndices);
                }
                gameInfo.PutSFSArray("teams", teams);                           //an array of possible values to be grabbed
                gameInfo.PutInt("gameLength", gameLength);                      //the length of the game

                roomVariables.Add(new SFSRoomVariable("gameInfo", gameInfo));

                settings.Variables = roomVariables;
                smartFox.Send(new CreateRoomRequest(settings, true, CurrentActiveRoom));           // Contains: maxUsers, and roomVariables
                createdMyRoom = true;
                Debug.Log("new room " + username + " - Room ");
            }
        }

        GUILayout.EndHorizontal();
        GUILayout.EndArea();
    }
Пример #36
0
        private static void RoomSettings_LoadPlacedObjects(On.RoomSettings.orig_LoadPlacedObjects orig, RoomSettings self, string[] s, int playerChar)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            orig(self, s, playerChar);
            watch.Stop();
            var elapsedMs = watch.ElapsedTicks;

            CustomWorldMod.Log($"Vanilla Room Settings time [{elapsedMs}]");
        }
Пример #37
0
        private static void RoomSettings_FindParent(On.RoomSettings.orig_FindParent orig, RoomSettings self, Region region)
        {
            CustomWorldMod.Log($"[RoomSettings] Finding parent... filePath [{self.filePath}]", false, CustomWorldMod.DebugLevel.FULL);

            try
            {
                orig(self, region);
            }
            catch (Exception e)
            {
                CustomWorldMod.Log($"[RoomSettings] Found illegal characters in a room settings file [{self.name}]. \nException: {e}", true);
                throw e;
            }
        }
Пример #38
0
 public void CreateRoom(RoomSettings settings, Action complete = null)
 {
     _smartFox.Send(new CreateRoomRequest(settings));
 }
Пример #39
0
        private static void RoomSettings_LoadPlacedObjects(On.RoomSettings.orig_LoadPlacedObjects orig, RoomSettings self, string[] s, int playerChar)
        {
            var watch = System.Diagnostics.Stopwatch.StartNew();

            orig(self, s, playerChar);
            watch.Stop();
            DateTime date = new DateTime(watch.ElapsedTicks);

            CustomWorldMod.Log($"[RoomSettings] Loading placedObjects [{self.name}]. Elapsed time [{date.ToString("s.ffff")}s]");
        }
Пример #40
0
    public RoomSettings CreateRoomSettings(string roomName,short numMaxUsers = 100)
    {
        //записываем все настройки нашей новой комнаты
          RoomSettings settings = new RoomSettings(roomName);

          settings.MaxUsers = numMaxUsers;
          settings.GroupId = "game";
          settings.IsGame = true;
          settings.MaxUsers = (short)numMaxUsers;
          settings.MaxSpectators = 0;
        return settings;
    }
Пример #41
0
    /*
     * Handle login event
     */
    public void OnLogin(BaseEvent evt)
    {
        try {
            if (evt.Params.ContainsKey("success") && !(bool)evt.Params["success"]) {
                Debug.Log("Login error");
            }
            else
            {

                //Startup UDP
                smartFox.InitUDP(serverName, serverPort);
             	RoomSettings rs = new RoomSettings("Test_room");
                smartFox.Send(new CreateRoomRequest(rs,true));

            }
        }
        catch (Exception ex)
        {
            Debug.Log("Exception handling login request: "+ex.Message+" "+ex.StackTrace);
        }
    }
Пример #42
0
        /**
         * ルーム作成設定.
         */
        private void OnGUI_CreateRoom()
        {
            // 表題
            GUILayout.Label("Create Room", new GUIStyle()
            {
                normal = new GUIStyleState()
                {
                    textColor = Color.white
                }, fontStyle = FontStyle.Bold
            });
            GUILayout.BeginHorizontal();
            GUILayout.Space(25);
            GUILayout.BeginVertical();
            GUILayout.Label("Custom Parameters");

            // ルームのカスタムパラメータの値入力
            if (this.customRoomParam.Count > 0)
            {
                Hashtable tmp = new Hashtable(this.customRoomParam);
                foreach (string key in this.customRoomParam.Keys)
                {
                    GUILayout.BeginHorizontal();
                    GUILayout.Label("Key : " + key + ", Value : ", GUILayout.Width(125));
                    tmp[key] = GUILayout.TextField(this.customRoomParam[key].ToString(), GUILayout.Width(200));
                    if (GUILayout.Button("Remove", GUILayout.Width(75)))
                    {
                        tmp.Remove(key);
                    }
                    GUILayout.EndHorizontal();
                }
                this.customRoomParam = tmp;
            }

            // ルームのカスタムパラメータのキー追加
            GUILayout.BeginHorizontal();
            GUILayout.Label("New Key : ", GUILayout.Width(100));
            customRoomKey = GUILayout.TextField(customRoomKey, GUILayout.Width(200));
            if (GUILayout.Button("Add", GUILayout.Width(75)))
            {
                if (!string.IsNullOrEmpty(customRoomKey))
                {
                    this.customRoomParam[customRoomKey] = "" as object;
                    customRoomKey = "";
                }
            }
            GUILayout.EndHorizontal();

            // 自分の作成するルーム名を公開設定にするかどうかのフラグ
            this.isVisible = GUILayout.Toggle(this.isVisible, "Visible room");

            // 自分のルームに入室可能な収容人数の設定
            GUILayout.BeginHorizontal(new GUIStyle()
            {
                alignment = TextAnchor.MiddleLeft
            });
            GUILayout.Label("Max Players : ", GUILayout.Width(100));
            string tmpInput = GUILayout.TextField(this.maxPlayers.ToString(), GUILayout.Width(50));

            byte.TryParse(tmpInput, out this.maxPlayers);

            // 任意の名称を持つルームを作成する
            if (GUILayout.Button("Create Room", GUILayout.Width(150)))
            {
                // カスタムルームパラメータから、ロビー送信パラメータを抽出(とりあえず全部送信するようにする)
                string[] customRoomParametersForLobby = new string[this.customRoomParam.Keys.Count];
                int      keyIndex = 0;
                foreach (string key in this.customRoomParam.Keys)
                {
                    customRoomParametersForLobby[keyIndex] = key;
                    keyIndex++;
                }

                RoomSettings roomSettings = new RoomSettings()
                {
                    isVisible       = this.isVisible,
                    isOpen          = true,
                    maxPlayers      = this.maxPlayers,
                    roomParameters  = this.customRoomParam,
                    lobbyParameters = customRoomParametersForLobby
                };

                MonobitNetwork.CreateRoom(null, roomSettings, null);
            }

            GUILayout.EndHorizontal();
            GUILayout.EndVertical();
            GUILayout.EndHorizontal();
        }
Пример #43
0
    private void DrawRoomsGUI()
    {
        GUILayout.BeginArea(new Rect(screenW - 190, 290, 180, 150));

        if (GameValues.isHost)
        {
            //start game button event listener
            if (GUI.Button(new Rect(80, 110, 85, 24), "Start Game"))
            {

                // ****** Create the actual game ******* //
                String[] nameParts = this.currentActiveRoom.Name.Split('-');
                String gameName = nameParts[0] + " - Game";

                RoomSettings settings = new RoomSettings(gameName);
                settings.MaxUsers = (short)currentActiveRoom.MaxUsers; // how many players allowed: 12
                settings.Extension = new RoomExtension(GameManager.ExtName, GameManager.ExtClass);
                settings.IsGame = true;

                //get the variables set up from the lobby
                List<RoomVariable> lobbyVars = currentActiveRoom.GetVariables();
                SFSObject lobbyGameInfo = (SFSObject)((RoomVariable)lobbyVars[1]).GetSFSObjectValue();
                //lobbyGameInfo.GetSFSArray("
                //FORMAT BY INDEX
                //0 = (bool)        gameStarted
                //1 = (SFSObject)   gameInfo
                //      -(string)   the host username               key: "host"
                //      -(IntArray) playerIds                       key: "playerIDs"
                //      -(int)      number of Teams                 key: "numTeams"
                //      -(SFSArray) teams                           key: "teams"
                //      -(int)      length of the game in seconds   key: "gameLength"

                SFSRoomVariable gameInfo = new SFSRoomVariable("gameInfo", lobbyGameInfo);
                settings.Variables.Add(gameInfo);

                Debug.Log("numberOfPlayers: " + currentActiveRoom.UserCount);
                SFSRoomVariable userCountVar = new SFSRoomVariable("numberOfPlayers", currentActiveRoom.UserCount);
                settings.Variables.Add(userCountVar);

                SFSArray joinedPlayers = new SFSArray();
                SFSRoomVariable joinedVar = new SFSRoomVariable("playersJoined", joinedPlayers);
                settings.Variables.Add(joinedVar);

                //get the values from the appropriate fields to populate the gameInfo
                smartFox.Send(new CreateRoomRequest(settings, true));

                //let other players know to switch rooms
                List<RoomVariable> roomVars = new List<RoomVariable>();
                roomVars.Add(new SFSRoomVariable("gameStarted", true));
                smartFox.Send(new SetRoomVariablesRequest(roomVars));

            }
        }
        GUILayout.EndArea();
    }
Пример #44
0
    IEnumerator CreateRoom(List <Chunk> RoomChunks)
    {
        List <Chunk> Chunks   = new List <Chunk>(RoomChunks);
        RoomSettings Settings = new RoomSettings(3, 40, 4, roomSize.Tiny, roomType.None, roomClass.Neutral);

        while (true)
        {
            Room room = new Room(map.nextRoomID, Chunks, Settings);
            map.AddRoom(room);
            while (true)
            {
                room.SetSeed(new Seed(GlobalPrng));
                if (!BlacklistedSeeds.ContainsKey(room.Seed.GetHashCode()))
                {
                    break;
                }
                else
                {
                    Debug.Log("Found Blacklisted Seed: " + room.Seed.ToString());
                }
            }

            room.GenerateTiles();
            map.ApplyChunks(room.GetChunkList());
            if (SeeProgress)
            {
                yield return(new WaitForSeconds(0.3f));
            }

            for (int s = 0; s < room.SmoothingMultiplier; s++)
            {
                room.SmoothChunks();
                map.ApplyChunks(room.GetChunkList());
                if (SeeProgress)
                {
                    yield return(new WaitForSeconds(0.15f));
                }
            }

            float check = room.Chunks.Count * Mathf.Pow(room.GetChunkSize(), 2) * TilePercentageFilled;

            room.GetRegions();
            if (SeeProgress)
            {
                yield return(new WaitForSeconds(0.15f));
            }

            Debug.Log("Room has Tiles " + room.GetTilesByType(tileType.Floor).Count + " >= " + check);
            if (room.GetTilesByType(tileType.Floor).Count >= check)
            {
                room.SetColor();
                if (room.Regions.Count > 1)
                {
                    room.SetConnections();
                }
                map.ApplyChunks(room.GetChunkList());
                if (SeeProgress)
                {
                    yield return(new WaitForSeconds(0.3f));
                }
                FinishRoom(room);
                break;
            }
            else
            {
                if (Settings.RandomFillPercent < 90)
                {
                    Settings.RandomFillPercent += 5;
                }
                else if (Settings.SmoothingMultiplier > 1)
                {
                    Settings.RandomFillPercent = 40;
                    Settings.SmoothingMultiplier--;
                }
                else
                {
                    foreach (Chunk c in Chunks)
                    {
                        map.Chunks[c.Coordinates].RegenerateTiles();
                    }
                    int FloorAmount = room.GetTilesByType(tileType.Floor).Count;
                    LogHandler.BlacklistSeed("\n" + room.Seed.ToString() + " Generated " + FloorAmount + " Tiles for " + room.Chunks.Count + " Chunks of size " + room.GetChunkSize()
                                             + ". Expected at least " + (TilePercentageFilled * 100) + "% filled, got " + (room.Chunks.Count * Mathf.Pow(room.GetChunkSize(), 2) / (float)FloorAmount) + "%.");
                }
                continue;
            }
        }
    }
Пример #45
0
    /// <summary>
    /// Reduce en uno la duracion de las salas baneadas
    /// Si el tiempo de una sala llega a 0, se elimina del diccionario
    /// </summary>
    void UpdateBans(RoomSettings selectedRoom)
    {
        //Se disminuye en uno el contador de bans de las rooms
        foreach (RoomSettings entry in bannedRooms.Keys.ToList())
        {
            if(bannedRooms[entry]>1)
            {
                bannedRooms[entry] -= 1;
            }
            else
            {
                bannedRooms.Remove(entry);
            }
        }

        if (selectedRoom != null)
        {
            //Se añade/actualiza el ban de la nueva room
            if (!bannedRooms.ContainsKey(selectedRoom))
            {
                bannedRooms.Add(selectedRoom, banTime);
            }
            else
            {
                bannedRooms[selectedRoom] = banTime;
            }
        }
    }
Пример #46
0
 private static void RoomSettings_LoadAmbientSounds(On.RoomSettings.orig_LoadAmbientSounds orig, RoomSettings self, string[] s)
 {
     orig.Invoke(self, s);
     if (Downpour.debug)
     {
         for (int i = 0; i < s.Length; i++)
         {
             string[] array = Regex.Split(s[i], "><");
             if (array[0] == "OMNI")
             {
                 Debug.Log("SOUND: " + array[1]);
             }
         }
     }
 }
Пример #47
0
    private void DrawRoomsGUI()
    {
        GUI.Box (new Rect (screenW - 200, 260, 180, 130), "Room List");
        GUILayout.BeginArea (new Rect (screenW - 190, 290, 180, 150));
        if (smartFox.RoomList.Count > 1) {
            roomScrollPosition = GUILayout.BeginScrollView (roomScrollPosition, GUILayout.Width (150), GUILayout.Height (160));
            roomSelection = GUILayout.SelectionGrid (roomSelection, roomFullStrings, 1, "RoomListButton");

            if (roomSelection >= 0 && roomNameStrings[roomSelection] != currentActiveRoom.Name) {
                smartFox.Send(new JoinRoomRequest(roomNameStrings[roomSelection]));
            }
            GUILayout.EndScrollView ();

        } else {
            GUILayout.Label ("No rooms available to join");
        }
        // Game Room button

        if (GUI.Button (new Rect (80, 110, 85, 24), "Make Game")) {
            // ****** Create new room ******* //
            //Debug.Log("new room "+username + "'s Room");

            RoomSettings settings = new RoomSettings(username + "'s Room");
            settings.Name = username + "'s Room";
            settings.MaxUsers = 32;
            settings.IsGame = true;
            smartFox.Send(new CreateRoomRequest(settings));
        }

        /*if (GUI.Button (new Rect (80, 130, 85, 24), "Make Test 1")) {
            //Debug.Log("new room ");

            RoomSettings settings = new RoomSettings("Test Room");
            settings.MaxUsers = 32;
            settings.Name = "Test Room";
            settings.IsGame = true;
            smartFox.Send(new CreateRoomRequest(settings));
        }*/

        GUILayout.EndArea ();
    }
Пример #48
0
 // RoomSettings
 private static void RoomSettings_ctor(On.RoomSettings.orig_ctor orig, RoomSettings self, string name, Region region, bool template, bool firstTemplate, int playerChar)
 {
     // Copy filters from another character
     orig(self, name, region, template, firstTemplate, PlayerManager.CurrentCharacter?.useSpawns ?? playerChar);
 }