예제 #1
0
 /// <summary>
 /// Send to the message networked (to all other connected clients) to this board's sepecific box entry.
 /// </summary>
 public static void SendToNet(EventType message, string entry, bool varified = false)
 {
     if (activeGlobal && activeLocal)
     {
         FFMessageSystem.SendMessageToNet <EventType>(message, entry, varified);
     }
 }
예제 #2
0
    /// <summary>
    /// Registers the Game Object to other clients. If this is called on the game object it will be created
    /// on all other connected clients. This should be called on Awake in order for OwnGameObject to work.
    /// </summary>
    public static bool RegisterNetGameObject(GameObject go, string prefabName)
    {
        if (go == null)
        {
            throw new ArgumentNullException();
        }

        FFSystem.GetReady();
        FFPrivate.FFMessageSystem.GetReady();

        // object registered/created by another client, or already registered once on this client
        GameObjectData localGoData;
        int            id = go.GetInstanceID();

        if (singleton._GameObjecttRegistryIsLocked || singleton._localIdToGameObjectData.TryGetValue(id, out localGoData))
        {
            return(false);
        }

        if (FFClient.isReady)
        {
            int instanceId = go.GetInstanceID();
            singleton._localIdToGameObjectData.Add(instanceId, new GameObjectData(go, FFClient.clientId, -1, id));

            NetObjectCreatedEvent NOCE;

            NOCE.pos   = go.transform.position;
            NOCE.rot   = go.transform.rotation;
            NOCE.scale = go.transform.localScale;

            NOCE.creationTime         = FFClient.clientTime;
            NOCE.gameObjectInstanceId = instanceId;
            NOCE.clientOwnerNetId     = FFClient.clientId;

            NOCE.gameObjectNetId = -1; // Set by server, -1 == Not Uninitialized

            // Strip (clone)
            int cloneBegin = prefabName.IndexOf("(Clone)");
            if (cloneBegin == -1)
            {
                NOCE.prefabName = prefabName;
            }
            else
            {
                NOCE.prefabName = prefabName.Substring(0, cloneBegin);
            }

            //Debug.Log("NewObjectCreatedEvent!"); // debug
            FFMessageSystem.SendMessageToNet <NetObjectCreatedEvent>(NOCE, true);
        }
        else
        {
            GameObjectPreFabPair goPre;
            goPre.go     = go;
            goPre.prefab = prefabName;
            singleton._gameObjectsToRegisterToServer.Enqueue(goPre);
        }

        return(true);
    }
예제 #3
0
    /// <summary>
    /// Send to the message networked (to all other connected clients) to this board's sepecific box entry.
    /// </summary>
    private static void SendToNet(EventType message, string entry, bool varified = false)
    {
        Debug.Assert(false, "this codepath probably doens't work");

        if (activeGlobal && activeLocal)
        {
            FFMessageSystem.SendMessageToNet <EventType>(message, entry, varified);
        }
    }
예제 #4
0
    private static void SendClientConnectedEvent(string clientName)
    {
        singleton._clientData.clientGuid = Guid.NewGuid();
        ClientConnectedEvent e = new ClientConnectedEvent();

        e.clientId        = -1;
        e.serverTime      = -1;
        e.serverStartTime = new DateTime();
        e.serverName      = null;
        e.clientName      = clientName;
        e.clientGuid      = singleton._clientData.clientGuid;
        e.clientSendTime  = (float)FFSystem.clientWatchTime;

        FFMessageSystem.SendMessageToNet <ClientConnectedEvent>(e, true);
    }
예제 #5
0
 /// <summary>
 /// Send the message networked (to all other connected clients) to other clients' go (GameObject) and everything connected. go (GameObject) must be a registered Object on other clients
 /// and anything connected does not need to be registered
 /// </summary>
 public static void SendToNetToAllConnected(EventType message, GameObject go, bool varifiedpacket = false)
 {
     FFMessageSystem.SendMessageToNet <EventType>(message, go.GetInstanceID(),
                                                  FFPacketInstructionFlags.MessageBoardGameObjectSendToAllConnected, varifiedpacket);
 }
예제 #6
0
 /// <summary>
 /// Send the message networked (to all other connected clients) to other clients' go (GameObject) and its childeren. go (GameObject) must be a registered Object on other clients
 /// and its childeren do not need to be registered to recieve the message
 /// </summary>
 private static void SendToNetDown(EventType message, GameObject go, bool varifiedPacket = false)
 {
     FFMessageSystem.SendMessageToNet <EventType>(message, go.GetInstanceID(),
                                                  FFPacketInstructionFlags.MessageBoardGameObjectSendDown, varifiedPacket);
 }