Ejemplo n.º 1
0
        /// <summary>
        /// Differentiates the mouse button for an event type
        /// </summary>
        /// <param name="button"></param>
        /// <param name="left"></param>
        /// <param name="right"></param>
        /// <param name="middle"></param>
        /// <returns></returns>
        public static Signal DifferentiateMouseButton(int button, Signal left, Signal right, Signal middle)
        {
            Signal signal = null;
            switch (button)
            {
                case 0:
                    signal = left;
                    break;
                case 1:
                    signal = right;
                    break;
                case 2:
                    signal = middle;
                    break;
                default:
                    Debug.Log("Unknown mouse button");
                    break;
            }

            return signal;
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Returns Signal type
 /// </summary>
 /// <param name="signal"></param>
 /// <returns></returns>
 public static string DescribeSignal(Signal signal)
 {
     return string.Format("Signal: {0}", signal.GetType());
 }
Ejemplo n.º 3
0
        private void SignalStateChangedHandler(Signal signal, bool connected)
        {
            //Debug.Log(string.Format("SignalStateChangedHandler: {0} [{1}]", signal, connected));
            if (connected && !_activeSignals.Contains(signal))
            {
                _activeSignals.Add(signal);
                //Debug.Log(string.Format("SignalStateChangedHandler: added {0} [{1}]", signal, connected));
            }
            else if (!connected && _activeSignals.Contains(signal))
            {
                _activeSignals.Remove(signal);
                //Debug.Log(string.Format("SignalStateChangedHandler: removed {0} [{1}]", signal, connected));
            }

            HandleOnGuiInvokerEnabledState();
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Initialization routine
        /// </summary>
        private void Initialize()
        {
            #if DEBUG
            if (DebugMode)
                Debug.Log(string.Format("Initializing system manager"));
            #endif
            /**
             * 1.a) Instantiate signals
             * */
            FixedUpdateSignal = new Signal();
            UpdateSignal = new Signal();
            LateUpdateSignal = new Signal();
            ResizeSignal = new Signal();
            DisposingSignal = new Signal();
            LevelInitSignal = new Signal();
            LevelLoadedSignal = new Signal();
            SceneChangeSignal = new Signal();
            GizmoSignal = new Signal();
            TouchSignal = new Signal();

            /**
             * 1.b) Instantiate signals requiring OnGUI processing
             * */

            PreRenderSignal = new StateHandlingSignal(SignalStateChangedHandler);
            RenderSignal = new StateHandlingSignal(SignalStateChangedHandler);

            MouseDownSignal = new StateHandlingSignal(SignalStateChangedHandler);
            MouseUpSignal = new StateHandlingSignal(SignalStateChangedHandler);

            MiddleMouseDownSignal = new StateHandlingSignal(SignalStateChangedHandler);
            MiddleMouseUpSignal = new StateHandlingSignal(SignalStateChangedHandler);

            RightMouseDownSignal = new StateHandlingSignal(SignalStateChangedHandler);
            RightMouseUpSignal = new StateHandlingSignal(SignalStateChangedHandler);

            MouseMoveSignal = new StateHandlingSignal(SignalStateChangedHandler);
            MouseDragSignal = new StateHandlingSignal(SignalStateChangedHandler);
            MouseWheelSignal = new StateHandlingSignal(SignalStateChangedHandler);

            KeyDownSignal = new StateHandlingSignal(SignalStateChangedHandler);
            KeyUpSignal = new StateHandlingSignal(SignalStateChangedHandler);

            /**
             * 2) Instantiate processors
             * */
            _keyboardProcessor = new KeyboardProcessor(this);
            _mouseProcessor = new MouseProcessor(this);
            _mousePositionProcessor = new MousePositionProcessor(this);
            _touchProcessor = new TouchProcessor(this);
            _screenSizeProcessor = new ScreenSizeProcessor(this);

            /**
             * 3.a) Instantiate SystemManagerInvoker
             * */
            Framework.CreateComponent<SystemManagerInvoker>(true); // exclusive, i.e. allow single instance only

            /**
             * 3.b) Instantiate SystemManagerOnGuiInvoker
             * Keeping reference to it so we could disable it when OnGUI processing not needed
             * */
            _onGuiInvoker = (SystemManagerOnGuiInvoker)Framework.CreateComponent<SystemManagerOnGuiInvoker>(true); // exclusive, i.e. allow single instance only
            _onGuiInvoker.enabled = false; // disable it by default
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initialization routine
        /// </summary>
        private void Initialize()
        {
            #if DEBUG
            if (DebugMode)
                Debug.Log(string.Format("Initializing system manager"));
            #endif

            /**
             * 1) Instantiate SystemManagerInvoker
             * */
            Framework.CreateComponent(typeof(SystemManagerInvoker), true); // exclusive, i.e. allow single instance only

            /**
             * 2) Instantiate signals
             * */
            FixedUpdateSignal = new Signal();
            UpdateSignal = new Signal();
            LateUpdateSignal = new Signal();
            PreRenderSignal = new Signal();
            RenderSignal = new Signal();
            ResizeSignal = new Signal();
            DisposingSignal = new Signal();
            LevelLoadedSignal = new Signal();
            SceneChangeSignal = new Signal();

            MouseDownSignal = new Signal();
            MouseUpSignal = new Signal();

            MiddleMouseDownSignal = new Signal();
            MiddleMouseUpSignal = new Signal();

            RightMouseDownSignal = new Signal();
            RightMouseUpSignal = new Signal();

            MouseMoveSignal = new Signal();
            MouseDragSignal = new Signal();
            MouseWheelSignal = new Signal();

            KeyDownSignal = new Signal();
            KeyUpSignal = new Signal();

            TouchSignal = new Signal();

            /**
             * 3) Instantiate processors
             * */
            _keyboardProcessor = new KeyboardProcessor(this);
            _mouseProcessor = new MouseProcessor(this);
            _mousePositionProcessor = new MousePositionProcessor(this);
            _touchProcessor = new TouchProcessor(this);
            _screenSizeProcessor = new ScreenSizeProcessor(this);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Returns Signal type
 /// </summary>
 /// <param name="signal"></param>
 /// <returns></returns>
 public static string DescribeSignal(Signal signal)
 {
     return(string.Format("Signal: {0}", signal.GetType()));
 }