Exemple #1
0
    static protected void NotifyOnEvent(CNetworkPlayer _cNetworkPlayer, CDUIElement _DUIElement, EElementNotificationType _NotificationType, object[] _Arguments)
    {
        ulong ignorePlayer = _cNetworkPlayer.PlayerId;

        foreach (ulong playerId in CNetwork.Server.FindNetworkPlayers().Keys)
        {
            if (playerId != ignorePlayer)
            {
                _DUIElement.InvokeRpc(playerId, "Invoke" + _NotificationType.ToString(), _Arguments);
            }
        }
    }
Exemple #2
0
    static public void UnserializeElementEvents(CNetworkPlayer _cNetworkPlayer, CNetworkStream _cStream)
    {
        while (_cStream.HasUnreadData)
        {
            // Get the DUIElement and its network view
            CDUIElement duiElement = CNetwork.Factory.FindObject(_cStream.ReadNetworkViewId()).GetComponent <CDUIElement>();

            // Get the interaction notification
            EElementNotificationType notification = (EElementNotificationType)_cStream.ReadByte();

            // Based on the notification type, update the clients of the event
            switch (notification)
            {
            case EElementNotificationType.OnClick:
                int click = _cStream.ReadInt();
                NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { click });
                break;

            case EElementNotificationType.OnDoubleClick:
                int dClick = _cStream.ReadInt();
                NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { dClick });
                break;

            case EElementNotificationType.OnPress:
                bool isPressed = _cStream.ReadByte() == 1 ? true : false;
                NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { isPressed });
                break;

            case EElementNotificationType.OnSelect:
                bool isSelected = _cStream.ReadByte() == 1 ? true : false;
                NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { isSelected });
                break;

            case EElementNotificationType.OnHover:
                bool isHovered = _cStream.ReadByte() == 1 ? true : false;
                NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { isHovered });
                break;

            case EElementNotificationType.OnDrag:
                float deltaX = _cStream.ReadFloat();
                float deltaY = _cStream.ReadFloat();
                NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { deltaX, deltaY });
                break;

            case EElementNotificationType.OnDragStart:
                NotifyOnEvent(_cNetworkPlayer, duiElement, notification, null);
                break;

            case EElementNotificationType.OnDragEnd:
                NotifyOnEvent(_cNetworkPlayer, duiElement, notification, null);
                break;

            case EElementNotificationType.OnScroll:
                float delta = _cStream.ReadFloat();
                NotifyOnEvent(_cNetworkPlayer, duiElement, notification, new object[] { delta });
                break;

            default:
                break;
            }
        }
    }