예제 #1
0
 public InstantiateObjectInfo(GameObject gameObject, Vector3 position, Quaternion rotation, int id, OnlinePlayerId playerOwner)
 {
     GameObject  = gameObject;
     Position    = position;
     Rotation    = rotation;
     Id          = id;
     PlayerOwner = playerOwner;
 }
예제 #2
0
 public InstantiateObjectInfo()
 {
     GameObject  = null;
     Position    = Vector3.zero;
     Rotation    = Quaternion.identity;
     Id          = -1;
     PlayerOwner = OnlinePlayerId.None;
 }
예제 #3
0
    public InstantiateObjectInfo(byte[] bytes)
    {
        var ms = new MemoryStream(bytes);
        var br = new BinaryReader(ms);

        GameObject  = OnlinePrefabs.GetPrefabBy(br.ReadString());
        Position    = new Vector3(br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
        Rotation    = new Quaternion(br.ReadSingle(), br.ReadSingle(), br.ReadSingle(), br.ReadSingle());
        Id          = br.ReadInt32();
        PlayerOwner = (OnlinePlayerId)br.ReadInt32();

        br.Close();
        ms.Close();
    }
예제 #4
0
    public static void OnlineInstantiate(this UnityEngine.Object obj, GameObject gameObject, Vector3 position, Quaternion rotation, OnlinePlayerId playerOwner)
    {
        InstantiateObjectInfo info = null;

        if (OnlineManager.IsHost())
        {
            info = new InstantiateObjectInfo(gameObject, position, rotation, OnlineObjectManager.GenerateId(), playerOwner);
        }
        else
        {
            info = new InstantiateObjectInfo(gameObject, position, rotation, -1, playerOwner);
        }

        var bytes = BitConverter.GetBytes((int)MsgProtocol.InstantiateObject).Concat(info.Serialize()).ToArray();

        OnlineManager.SendMsg(bytes);

        if (OnlineManager.IsHost())
        {
            OnlineManager.Instantiate(info);
        }
    }
예제 #5
0
 public void Set(int objectId, OnlinePlayerId playerOwner)
 {
     ObjectId    = objectId;
     PlayerOwner = playerOwner;
 }