Beispiel #1
0
        private Touch[] GetCurrentMouseTouches()
        {
            Touch[] mouseTouches = null;
            bool    isDown       = AppInput.GetKeyDown(KCode.Mouse0);  //Input.GetMouseButtonDown(0);
            bool    isButton     = AppInput.GetKey(KCode.Mouse0);      //Input.GetMouseButton(0);

            if (isButton && (_currentTouches == null || _currentTouches.Length == 0))
            {
                isDown = true;
            }
            if (isButton || isDown)
            {
                if (isDown)
                {
                    mousePosition = AppInput.MousePosition;
                }
                bool isStationary = mousePosition == AppInput.MousePosition;
                mouseTouches = new Touch[] { new Touch {
                                                 fingerId      = 0, rawPosition = AppInput.MousePosition, position = AppInput.MousePosition,
                                                 deltaPosition = AppInput.MousePosition - mousePosition,
                                                 phase         = (isDown) ? TouchPhase.Began : ((isStationary) ? TouchPhase.Stationary : TouchPhase.Moved),
                                             } };
                mousePosition = AppInput.MousePosition;
            }
            return(mouseTouches);
        }
 private void Start()
 {
     if (EventSystem.current == null)
     {
         AppInput.GetEventSystem();
     }
     if (GetComponent <Image>() == null)
     {
         Debug.LogError("There is no joystick image attached to this script.");
     }
     if (transform.GetChild(0).GetComponent <TouchGuiDrag>() == null)
     {
         Debug.LogError("There is no joystick handle image attached to this script.");
     }
     if (GetComponent <Image>() != null && transform.GetChild(0).GetComponent <TouchGuiDrag>() != null)
     {
         bgImage      = GetComponent <Image>();
         joystickKnob = transform.GetChild(0).GetComponent <TouchGuiDrag>();
         bgImage.rectTransform.SetAsLastSibling();                 // ensures that this joystick will always render on top of other UI elements
         Vector2 idealPivot      = new Vector2(0.5f, 0.5f);
         Vector2 offsetFromIdeal = (idealPivot - bgImage.rectTransform.pivot);
         offsetFromIdeal.Scale(bgImage.rectTransform.sizeDelta);
         bgImage.rectTransform.pivot             = idealPivot;
         bgImage.rectTransform.anchoredPosition += offsetFromIdeal;
         joystickKnob.onDragBegin   += () => dragging = true;
         joystickKnob.onDrag        += OnDrag;
         joystickKnob.onDragRelease += () => {
             dragging    = false;
             inputVector = Vector3.zero;
         };
     }
 }
Beispiel #3
0
    void Start()
    {
        KBind keyMap = new KBind(KCode.F, () => { Debug.Log("RESPECT"); return(true); }, "pay respects");

        AppInput.AddListener(keyMap);
        AppInput.AddListener(this.keyMap);
    }
Beispiel #4
0
        public PhiddleView(CGRect frame, PhiddleCore phiddle, ISettingsService <AppInputMac> settingsService, ILogService log) : base(frame)
        {
            this.log     = log;
            this.phiddle = phiddle;

            appInput = settingsService.Settings;

            if (!settingsService.Loaded)
            {
                log.Warning("PhiddleView", "Could not load settings for App Input, using defaults");
            }
        }
Beispiel #5
0
 private void Update()
 {
     if (follower == null && characterToMove.Target != null)
     {
         SetFollower(characterToMove.Target.move);
     }
     if (follower == null)
     {
         return;
     }
     if (AppInput.GetKey(key))
     {
         RaycastClick(rh => ClickFor(follower, rh));
     }
     if (prefab_waypoint != null && AppInput.GetKeyUp(key))
     {
         follower.ShowCurrentWaypoint();
     }
 }
Beispiel #6
0
        private void InitializePhiddleCore()
        {
            // Create the Core, add our services and initialize Core with it
            phiddle = new PhiddleCore();
            phiddle.Services.AddSingleton(screen);
            phiddle.Services.AddSingleton <LoggingService>();
            phiddle.Services.AddSingleton <SettingsService <AppInputWin> >();
            phiddle.Initialize();

            // Get the services we need right away
            Log = PhiddleCore.ServiceProvider.GetRequiredService <LoggingService>();
            var settingsService = PhiddleCore.ServiceProvider.GetRequiredService <SettingsService <AppInputWin> >();

            appInput = settingsService.Settings;

            if (!settingsService.Loaded & settingsService.IsDefault)
            {
                Log.Warning("InitializePhiddleCore", "Could not load settings for App Input, using defaults");
            }
        }
 private void Update()
 {
     if (selection.Count == 0 && c2m.characterToMove.Target != null)
     {
         SetSelection(c2m.characterToMove.Target);
     }
     if (AppInput.GetKey(c2m.key))
     {
         c2m.RaycastClick(rh => {
             if (selection.Count == 0)
             {
                 return;
             }
             for (int i = 0; i < selection.Count; ++i)
             {
                 if (selection[i] == null)
                 {
                     selection.RemoveAt(i--);
                     continue;
                 }
                 c2m.ClickFor(selection[i], rh);
             }
         });
     }
     if (c2m.prefab_waypoint != null && AppInput.GetKeyUp(c2m.key))
     {
         //if (follower != null) { follower.ShowCurrentWaypoint(); }
         if (selection.Count > 0)
         {
             for (int i = 0; i < selection.Count; ++i)
             {
                 selection[i].ShowCurrentWaypoint();
             }
         }
     }
 }
Beispiel #8
0
 private static void UpdateEditor(FrameEventArgs e)
 {
     AppInput.SetFrameInput(new InputState(mainWindow.KeyboardState, mainWindow.MouseState));
     EntygineApp.UpdateFrame(e);
 }