Exemple #1
0
 // Update is called once per frame
 private void Update()
 {
     if (m_IsPlayerNear && InputControlManager.Instance.IsCanUseSubmitButton())
     {
         //if current ui interaction button is ArrowUp
         if (m_InteractionType == InteractionType.ArrowUp)
         {
             //if ArrowUp button pressed
             if (InputControlManager.Instance.IsUpperButtonsPressed())
             {
                 //call attached method
                 PressInteractionButton?.Invoke();
             }
         }
         //if current ui interaction button is PickUp
         else if (m_InteractionType == InteractionType.PickUp)
         {
             //if PickUp button pressed
             if (InputControlManager.Instance.IsPickupPressed())
             {
                 //call attached method
                 PressInteractionButton?.Invoke();
             }
         }
     }
 }
Exemple #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="eventData"></param>
 public void OnMove(AxisEventData eventData)
 {
     if (onMove != null)
     {
         onMove.Invoke(gameObject);
     }
 }
Exemple #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="eventData"></param>
 public void OnDrop(PointerEventData eventData)
 {
     if (onDrop != null)
     {
         onDrop.Invoke(gameObject);
     }
 }
Exemple #4
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="eventData"></param>
 public void OnScroll(PointerEventData eventData)
 {
     if (onScroll != null)
     {
         onScroll.Invoke(gameObject);
     }
 }
Exemple #5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="eventData"></param>
        public void OnDrag(PointerEventData eventData)
        {
            switch (eventData.button)
            {
            case PointerEventData.InputButton.Left:
                if (onDragLeft != null)
                {
                    onDragLeft.Invoke(gameObject);
                }
                break;

            case PointerEventData.InputButton.Right:
                if (onDragRight != null)
                {
                    onDragRight.Invoke(gameObject);
                }
                break;

            case PointerEventData.InputButton.Middle:
                if (onDragMiddle != null)
                {
                    onDragMiddle.Invoke(gameObject);
                }
                break;

            default:
                break;
            }
        }
        internal static bool Read(string filename, ReadHandler handler, VoidDelegate onFail = null)
        {
            if (!File.Exists(filename))
            {
                return(false);
            }

            try
            {
                using (Stream stream = File.Open(filename, FileMode.Open, FileAccess.Read, FileShare.Read))
                    using (SerializationReader reader = new SerializationReader(stream))
                    {
                        handler(reader);
                        return(true);
                    }
            }
            catch (Exception e)
            {
                onFail?.Invoke();

                try
                {
                    GeneralHelper.CreateBackup(filename);
                }
                catch { }

                ErrorSubmission.Submit(new OsuError(e)
                {
                    Feedback = "database-corrupt"
                });
                return(false);
            }
        }
 public void OnPointerEnter(PointerEventData eventData)
 {
     if (onEnter != null)
     {
         onEnter.Invoke(gameObject);
     }
 }
Exemple #8
0
        //run scheduled events
        public void Update()
        {
            VoidDelegate[] runnable;

            lock (schedulerQueue)
            {
                long currentTime = timer.ElapsedMilliseconds;

                while (timedQueue.Count > 0 && timedQueue[0].ExecuteTime <= currentTime)
                {
                    schedulerQueue.Enqueue(timedQueue[0].Task);
                    timedQueue.RemoveAt(0);
                }

                int c = schedulerQueue.Count;
                if (c == 0)
                {
                    return;
                }
                runnable = new VoidDelegate[c];
                schedulerQueue.CopyTo(runnable, 0);
                schedulerQueue.Clear();
            }

            foreach (VoidDelegate v in runnable)
            {
                VoidDelegate mi = v;
                mi.Invoke();
            }
        }
Exemple #9
0
        public void OnPointerUp(PointerEventData eventData)
        {
            PointerEventData = eventData;

            if (onUp != null)
            {
                onUp(go);
            }

            if (onUpAndState != null)
            {
                onUpAndState(go, eventData.pointerCurrentRaycast.gameObject == eventData.pointerPressRaycast.gameObject);
            }
            if (this.m_onPressing)
            {
                if (OnLongPressEnd != null && this.m_onPressEventTriggered)
                {
                    OnLongPressEnd.Invoke(go);
                }

                if (Time.time - m_pressStartTime < DURATION_THRESHOLD && !eventData.dragging)
                {
                    OnClick();
                }
            }
            this.m_onPressing            = false;
            this.m_onPressEventTriggered = false;
        }
Exemple #10
0
 public static void InvokeIfRequired(Control c, VoidDelegate d)
 {
     if (c.InvokeRequired)
         c.Invoke(d);
     else
         d.Invoke();
 }
Exemple #11
0
 public override void OnPointerUp(PointerEventData eventData)
 {
     if (onUp != null)
     {
         onUp.Invoke(gameObject);
     }
 }
Exemple #12
0
 public override void OnPointerDown(PointerEventData eventData)
 {
     if (onDown != null)
     {
         onDown.Invoke(gameObject);
     }
 }
Exemple #13
0
 public override void OnPointerClick(PointerEventData eventData)
 {
     if (onClick != null)
     {
         onClick.Invoke(gameObject);
     }
 }
Exemple #14
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="eventData"></param>
 public void OnDeselect(BaseEventData eventData)
 {
     if (onDeselect != null)
     {
         onDeselect.Invoke(gameObject);
     }
 }
Exemple #15
0
 public void OnClick()
 {
     if (onClick != null)
     {
         onClick.Invoke(go);
     }
 }
Exemple #16
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="eventData"></param>
 public void OnUpdateSelected(BaseEventData eventData)
 {
     if (onUpdateselect != null)
     {
         onUpdateselect.Invoke(gameObject);
     }
 }
Exemple #17
0
    private void Update()
    {
        if (destination)
        {
            destinationPos = destination.position;
        }
        Vector2 dirVec = destinationPos - origin;

        foreach (Animator anim in anims)
        {
            if (dirVec.magnitude > 0.1f)
            {
                anim.SetFloat("Horizontal", dirVec.x);
                anim.SetFloat("Vertical", dirVec.y);
            }
        }
        t += Time.deltaTime;
        Vector2 res = Vector3.Lerp(origin, destinationPos, t / hoverTime);

        res += (-tangent / hoverTime * t * t + tangent * t) * Vector2.up;
        transform.position = res;
        if (t >= hoverTime)
        {
            if (destination)
            {
                grounded?.Invoke();
            }
            foreach (Animator anim in anims)
            {
                anim.SetBool("Grounded", true);
            }
        }
    }
Exemple #18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="eventData"></param>
 public void OnCancel(BaseEventData eventData)
 {
     if (onCancel != null)
     {
         onCancel.Invoke(gameObject);
     }
 }
Exemple #19
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="eventData"></param>
        public void OnPointerClick(PointerEventData eventData)
        {
            EventSystem.current.SetSelectedGameObject(gameObject);
            switch (eventData.button)
            {
            case PointerEventData.InputButton.Left:
                if (onClickLeft != null)
                {
                    onClickLeft.Invoke(gameObject);
                }
                break;

            case PointerEventData.InputButton.Right:
                if (onClickRight != null)
                {
                    onClickRight.Invoke(gameObject);
                }
                break;

            case PointerEventData.InputButton.Middle:
                if (onClickMiddle != null)
                {
                    onClickMiddle.Invoke(gameObject);
                }
                break;

            default:
                break;
            }
            if (Time.time - clickTime < doubleClickTime)
            {
                switch (eventData.button)
                {
                case PointerEventData.InputButton.Left:
                    if (onDoubleClickLeft != null)
                    {
                        onDoubleClickLeft.Invoke(gameObject);
                    }
                    break;

                case PointerEventData.InputButton.Right:
                    if (onDoubleClickRight != null)
                    {
                        onDoubleClickRight.Invoke(gameObject);
                    }
                    break;

                case PointerEventData.InputButton.Middle:
                    if (onDoubleClickMiddle != null)
                    {
                        onDoubleClickMiddle.Invoke(gameObject);
                    }
                    break;

                default:
                    break;
                }
            }
            clickTime = Time.time;
        }
 public void OnPointerExit(PointerEventData eventData)
 {
     if (onExit != null)
     {
         onExit.Invoke(gameObject);
     }
 }
Exemple #21
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="eventData"></param>
 public void OnSubmit(BaseEventData eventData)
 {
     if (onSumit != null)
     {
         onSumit.Invoke(gameObject);
     }
 }
    private void Update()
    {
        foreach (Animator anim in anims)
        {
            if (dirVec.magnitude > 0.1f)
            {
                anim.SetFloat("Horizontal", dirVec.x);
                anim.SetFloat("Vertical", dirVec.y);
            }
        }
        Vector3 res = new Vector3();

        res  = Vector3.Lerp(origin, targetPos, timer / travelTime);
        res += (-tangent / travelTime * timer * timer + tangent * timer) * Vector3.up;
        transform.position = res;

        if (timer < travelTime)
        {
            timer += Time.deltaTime;
            if (timer >= travelTime)
            {
                grounded?.Invoke();
                foreach (Animator anim in anims)
                {
                    anim.SetBool("Grounded", true);
                }
            }
        }
    }
    protected override IEnumerator AnimateWorkshop(float duration, VoidDelegate onFinish)
    {
        m_previewObject.SetActive(true);

        Hologram holo         = CreateHologram(m_previewObject);
        Vector3  rotationAxis = (m_dropzone.transform.position - Camera.main.transform.position).normalized;

        for (float t = 0; t < 2; t += Time.deltaTime / duration)
        {
            // o - 1 - 1
            m_previewObject.transform.localScale = holo.transform.localScale = Vector3.one * 40 * Mathf.Lerp(0, 1, Mathf.PingPong(t, 1));

            m_previewObject.transform.RotateAround(m_dropzone.transform.position, -rotationAxis, Time.deltaTime * 20);
            DrawHologram(holo, m_previewObject.transform);
            yield return(new WaitForEndOfFrame());
        }

        Destroy(holo.gameObject);

        m_previewObject.SetActive(false);
        m_previewObject.transform.position = previewInitPos;
        m_previewObject.transform.rotation = previewInitRos;

        m_placingEnabled = true;

        onFinish.Invoke();
    }
Exemple #24
0
        private void OnPacketRecieved(object sender, MavlinkPacket e)
        {
            uint           x = Mv.PacketsReceived;
            MavlinkMessage m = e.Message;

            if (m.GetType() == Hb.GetType())
            {
                Hb = (Msg_heartbeat)e.Message;
            }

            if (m.GetType() == Ss.GetType())
            {
                Ss = (Msg_sys_status)e.Message;
            }

            if (m.GetType() == Ps.GetType())
            {
                Ps = (Msg_power_status)e.Message;
            }

            if (m.GetType() == At.GetType())
            {
                At = (Msg_attitude)e.Message;
            }

            if (m.GetType() == Gps.GetType())
            {
                Gps = (Msg_gps_raw_int)e.Message;
            }

            if (m.GetType() == Vfr.GetType())
            {
                Vfr = (Msg_vfr_hud)e.Message;
            }

            if (m.GetType() == Rp.GetType())
            {
                Rp = (Msg_raw_pressure)e.Message;
            }

            if (m.GetType() == Sp.GetType())
            {
                Sp = (Msg_scaled_pressure)e.Message;
                PressureAbsolute   = (int)(Sp.press_abs * 1000f);
                Temperature        = Sp.temperature;
                PressureDifference = (int)(Sp.press_diff * 1000f);
                Total++;

                if (OnAtmosphericData != null)
                {
                    OnAtmosphericData.Invoke(PressureAbsolute, PressureDifference, Temperature, Total);
                }
            }

            if (x > 0 && OnPacketCountGreaterThanZero != null)
            {
                OnPacketCountGreaterThanZero.Invoke();
            }
        }
 public void OnPointerUp(PointerEventData eventData)
 {
     CancelInvoke("OnLongPress");
     if (onUp != null)
     {
         onUp.Invoke(eventData);
     }
 }
 public void OnPointerDown(PointerEventData eventData)
 {
     Invoke("OnLongPress", holdTime);
     if (onDown != null)
     {
         onDown.Invoke(eventData);
     }
 }
Exemple #27
0
 public override void OnPointerExit(PointerEventData eventData)
 {
     base.OnPointerExit(eventData);
     if (OnExit != null)
     {
         OnExit.Invoke(gameObject);
     }
 }
Exemple #28
0
 public override void OnPointerEnter(PointerEventData eventData)
 {
     base.OnPointerEnter(eventData);
     if (OnEnter != null)
     {
         OnEnter.Invoke(gameObject);
     }
 }
Exemple #29
0
 public override void OnPointerUp(PointerEventData eventData)
 {
     base.OnPointerUp(eventData);
     if (OnUp != null)
     {
         OnUp.Invoke(gameObject);
     }
 }
Exemple #30
0
 public override void OnPointerDown(PointerEventData eventData)
 {
     base.OnPointerDown(eventData);
     if (OnDown != null)
     {
         OnDown.Invoke(gameObject);
     }
 }
Exemple #31
0
 private static IEnumerator CallOnFixedFramesCoroutine(uint frames, VoidDelegate called)
 {
     for (uint i = 0; i < frames; i++)
     {
         yield return(new WaitForFixedUpdate());
     }
     called.Invoke();
 }
Exemple #32
0
 public void RunOnUiThread(Action act)
 {
     var d = new VoidDelegate(() => Invoke(new VoidDelegate(act)));  //SOME ADVANCED STUFF RIGHT HERR
     d.Invoke();
 }
Exemple #33
0
 public void RunOnUiThread(Action act)
 {
     VoidDelegate d = new VoidDelegate(delegate { Invoke(new VoidDelegate(act)); });  //SOME ADVANCED STUFF RIGHT HERR
     d.Invoke();
 }
Exemple #34
0
		public static Tween delayedCall (float aDelay, VoidDelegate onComplete)
		{
			return delayedCall (aDelay, (Tween Tween) => {
				onComplete.Invoke ();});
		}