Exemplo n.º 1
0
        public void SetTrigger(int hash)
        {
            var animMsg = new AnimationTriggerMessage();

            animMsg.netId = netId;
            animMsg.hash  = hash;

            if (hasAuthority && localPlayerAuthority)
            {
                if (NetworkClient.allClients.Count > 0)
                {
                    var client = ClientScene.readyConnection;
                    if (client != null)
                    {
                        client.Send((short)MsgType.AnimationTrigger, animMsg);
                    }
                }
                return;
            }

            if (isServer && !localPlayerAuthority)
            {
                NetworkServer.SendToReady(gameObject, (short)MsgType.AnimationTrigger, animMsg);
            }
        }
Exemplo n.º 2
0
        internal static void OnAnimationTriggerServerMessage(NetworkMessage netMsg)
        {
            AnimationTriggerMessage msg = new AnimationTriggerMessage();

            netMsg.ReadMessage(msg);
            if (LogFilter.logDev)
            {
                Debug.Log("OnAnimationTriggerMessage for netId=" + msg.netId + " conn=" + netMsg.conn);
            }

            GameObject go = NetworkServer.FindLocalObject(msg.netId);

            if (go == null)
            {
                return;
            }
            NetworkAnimator animSync = go.GetComponent <NetworkAnimator>();

            if (animSync != null)
            {
                animSync.HandleAnimTriggerMsg(msg.hash);

                NetworkServer.SendToReady(go, (short)MsgType.AnimationTrigger, msg);
            }
        }
Exemplo n.º 3
0
        internal static void OnAnimationTriggerClientMessage(NetworkMessage netMsg)
        {
            AnimationTriggerMessage msg = netMsg.ReadMessage <AnimationTriggerMessage>();

            GameObject go = ClientScene.FindLocalObject(msg.netId);

            if (go == null)
            {
                return;
            }
            var animSync = go.GetComponent <NetworkAnimator>();

            if (animSync != null)
            {
                animSync.HandleAnimTriggerMsg(msg.hash);
            }
        }