void Start()
    {
        //Enable Background Running
        Application.runInBackground = true;

        //Enable custom log
        CustomLogger.LogIt("Start Logging");
        //Application.dataPath
        Debug.Log(Application.dataPath);

        //Connect to the DarkRift Server using the Ip specified (will hang until connected or timeout)
        DarkRiftAPI.Connect(serverIP, serverPort);
        //Setup a receiver so we can create players when told to.
        DarkRiftAPI.onDataDetailed += ReceiveData;

        //Tell others that we've entered the game and to instantiate a player object for us.
        if (DarkRiftAPI.isConnected)
        {
            Debug.Log("Connected to the Server!");

            //Get everyone else to tell us to spawn them a player (this doesn't need the data field so just put whatever)
            DarkRiftAPI.SendMessageToOthers(TagIndex.Controller, TagIndex.ControllerSubjects.JoinMessage, "hi");
            //Then tell them to spawn us a player! (this time the data is the spawn position)
            DarkRiftAPI.SendMessageToAll(TagIndex.Controller, TagIndex.ControllerSubjects.SpawnPlayer, new Vector3(0f, 0f, 0f));
        }
        else
        {
            Debug.LogError("Failed to connect to DarkRift Server!");
        }
    }
 /// <summary
 /// Start this instance.
 /// </summary>
 void Start()
 {
     CustomLogger.LogIt("--- Starting Logging ---");
     Debug.Log("Network idle.");
     StartClient(ipAddress);
     Debug.Log("Network Started.");
     //serverConn.SendBytes(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, SendOption.Reliable); //DEBUG
     SendMessageToServer((sbyte)CommandType.LOGIN);
     //Add PLAYER_JOIN MESSAGE (SENDTOOTHER) NOT HERE TIMER/THREAD PROBLEM
     //SendMessage(SendType.SENDTOOTHER, PacketId.PLAYER_JOIN, 0, this.UID, true, PlayerME.transform.position, PlayerME.transform.rotation);
     lastPosition = PlayerME.transform.position;
     lastRotation = PlayerME.transform.rotation;
     Debug.Log("Network Trasmitted.");
 }
Пример #3
0
    /// <summary
    /// Start this instance.
    /// </summary>
    void Start()
    {
        CustomLogger.LogIt("--- Starting Logging ---");
        //Enable Background Running
        //Application.runInBackground = true;
        INIParser ini = new INIParser();

        // Open the save file. If the save file does not exist, INIParser automatically create
        // one
        ini.Open(Application.dataPath + "/MayaVerse.ini");
        if (ini.IsKeyExists("NetworkConfig", "ServerIP"))
        {
            ipAddress = ini.ReadValue("NetworkConfig", "ServerIP", "127.0.0.1");
            Debug.Log("ServerIP: " + ipAddress);
        }
        else
        {
            ini.WriteValue("NetworkConfig", "ServerIP", "127.0.0.1");
            Debug.Log("ServerIP: " + ipAddress);
        }
        if (ini.IsKeyExists("NetworkConfig", "ServerPort"))
        {
            portNumber = ini.ReadValue("NetworkConfig", "ServerPort", 4296);
            Debug.Log("ServerPort: " + portNumber.ToString());
        }
        else
        {
            ini.WriteValue("NetworkConfig", "ServerPort", 4296);
            Debug.Log("ServerPort: " + portNumber.ToString());
        }
        if (ini.IsKeyExists("AvatarConfig", "AvatarName"))
        {
            AvatarName = ini.ReadValue("AvatarConfig", "AvatarName", "Vytek75");
            Debug.Log("AvatarName: " + this.AvatarName);
        }
        else
        {
            ini.WriteValue("AvatarConfig", "AvatarName", "Vytek75");
            Debug.Log("AvatarName: " + this.AvatarName);
        }
        if (ini.IsKeyExists("AvatarConfig", "AvatarPassword"))
        {
            AvatarPassword = ini.ReadValue("AvatarConfig", "AvatarPassword", "test1234!");
            Debug.Log("AvatarPassword: "******"AvatarConfig", "AvatarPassword", "test1234!");
            Debug.Log("AvatarPassword: "******"Network idle.");
        StartClient(ipAddress);
        Debug.Log("Network Started.");
        //serverConn.SendBytes(new byte[] { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }, SendOption.Reliable); //DEBUG
        SendMessageToServer((sbyte)CommandType.LOGIN);
        //Add PLAYER_JOIN MESSAGE (SENDTOOTHER) NOT HERE TIMER/THREAD PROBLEM
        //SendMessage(SendType.SENDTOOTHER, PacketId.PLAYER_JOIN, 0, this.UID, true, PlayerME.transform.position, PlayerME.transform.rotation);
        lastPosition = PlayerME.transform.position;
        lastRotation = PlayerME.transform.rotation;
        Debug.Log("Network Trasmitted.");
        //START POOL MANAGER FOR NETWORKOBJECTS
        Debug.Log("Pool Manager started.");
        poolObj = PoolsManager.Instance;
    }