private void OnEnable()
 {
     netGO = GetComponent <NetGO>();
     //подписываемся на входящие сообщения
     netGO.OnMessageGo += OnMessageGo;
     //подписываемся на сетевой апдейт
     netGO.OnGoFrameUpdate += OnGoFrameUpdate;
     InvokeRepeating("RandHeal", 1, 1);
     lastData = new GoMessPlayerData();
 }
示例#2
0
    public void NetInstantiate(NetGO netGO)
    {
        MessageInstantiate message = new MessageInstantiate();

        message.name     = netGO.name;
        message.localId  = GetNewLocalId();
        message.position = netGO.transform.position.NetworkVector3();
        message.rotation = netGO.transform.rotation.NetworkQuaternion();
        netGO.localId    = message.localId;
        GalaxyApi.send.SendMessageToServer((byte)CommandType.goInstantiate, message, GalaxyCoreCommon.GalaxyDeliveryType.reliable);
        netGOsNoSync.Add(netGO);
    }
示例#3
0
        /// <summary>
        /// Обработчик создания новых объектов
        /// </summary>
        /// <param name="message"></param>
        /// <param name="clientConnection"></param>
        void InstantiateGO(MessageInstantiate message, ClientConnection clientConnection)
        {
            Client client = Server.clientManager.GetClientByConnection(clientConnection);
            NetGO  netGO  = new NetGO();

            netGO.name     = message.name;
            netGO.netID    = GetNewID();
            netGO.owner    = client.id;
            netGO.position = message.position;
            netGO.rotation = message.rotation;
            message.netID  = netGO.netID;
            message.owner  = client.id;
            netObjects.Add(netGO.netID, netGO);
            SendMessageToAll((byte)CommandType.goInstantiate, message, GalaxyDeliveryType.reliable);
            Console.WriteLine("Был создан NetGO id:" + netGO.netID);
        }
示例#4
0
    private void OnMessTransform(MessageTransform message)
    {
        if (!netGOs.ContainsKey(message.netID))
        {
            return;
        }
        NetGO go = netGOs[message.netID];

        if (go.isMy)
        {
            return;
        }
        if (message.position != null)
        {
            go.transform.position = message.position.Vector3();
        }
        if (message.rotation != null)
        {
            go.transform.rotation = message.rotation.Quaternion();
        }
    }