Example #1
0
    private void InvokeWithinComponents(EElementNotificationType _Notification, object[] _Arguments)
    {
        // Get all of the components that are not this component within the element
        var targets =
            from component in GetComponents <Component>()
            where component != this
            select component;

        // Invoke the correct callback method on all other components
        s_IsSyncingNetworkCallbacks = true;
        foreach (Component component in targets)
        {
            Type       type       = component.GetType();
            string     methodName = _Notification.ToString();
            MethodInfo mi         = type.GetMethod(methodName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

            if (mi != null)
            {
                mi.Invoke(component, _Arguments);
            }
        }
        s_IsSyncingNetworkCallbacks = false;

        // Debug...
        // Commented out by Nathan to avoid extraneous debug information.
        // Feel free to uncomment for debugging purposes when required.
        //Debug.Log("Recieved Notification: " + _Notification.ToString() + " [" + gameObject.name + "]");
    }
Example #2
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);
            }
        }
    }
Example #3
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;
            }
        }
    }