Esempio n. 1
0
        private void releasedHandler(object sender, System.EventArgs e)
        {
            //Debug.Log("TouchPanel: released");

            ReleaseGesture gesture = (ReleaseGesture)sender;
            HitData        hit     = gesture.GetScreenPositionHitData();
            Vector3        point   = hit.Point + hit.Normal * .5f;

            if (recordingManager.IsRecording())
            {
                byte lane;
                if (point.x <= this.notesManager.lane_width * -3)
                {
                    lane = 0;
                }
                else if (point.x >= this.notesManager.lane_width * 3)
                {
                    lane = 6;
                }
                else
                {
                    lane = (byte)(Math.Round(point.x / this.notesManager.lane_width, MidpointRounding.AwayFromZero) + 3);
                }
                recordingManager.OnReleased(lane);
            }
        }
 public static IObservable <EventPattern <EventArgs> > ReleasedAsObservable(this ReleaseGesture gesture)
 {
     return(Observable.FromEventPattern <EventHandler <EventArgs>, EventArgs>(
                h => h.Invoke,
                h => gesture.Released += h,
                h => gesture.Released -= h));
 }
Esempio n. 3
0
 /// <summary>
 /// On destroy, disable some stuff
 /// </summary>
 private void OnDestroy()
 {
     // unsubscribe from gesture events
     foreach (GameObject go in GameObject.FindObjectsOfType <GameObject>())
     {
         TapGesture tg = go.GetComponent <TapGesture>();
         //unsubscribte from tap events
         if (tg != null)
         {
             tg.Tapped -= tappedHandler;
         }
         TransformGesture pg = go.GetComponent <TransformGesture>();
         if (pg != null)
         {
             // unsubscribe from pan events
             pg.TransformStarted   -= panStartedHandler;
             pg.Transformed        -= pannedHandler;
             pg.TransformCompleted -= panCompleteHandler;
         }
         PressGesture prg = go.GetComponent <PressGesture>();
         // unsubscribe from press events
         if (prg != null)
         {
             prg.Pressed -= pressedHandler;
         }
         ReleaseGesture rg = go.GetComponent <ReleaseGesture>();
         // unsubscribe to release events
         if (rg != null)
         {
             rg.Released -= releasedHandler;
         }
     }
 }
Esempio n. 4
0
        //<summary>
        // disable all gesture events
        //</summary>
        public void DisableGestures(GameObject go)
        {
            // disable tap events
            TapGesture tg = go.GetComponent <TapGesture>();

            if (tg != null)
            {
                tg.enabled = false;
            }
            // disable pan events
            TransformGesture pg = go.GetComponent <TransformGesture>();

            if (pg != null)
            {
                pg.enabled = false;
            }
            // disable press events
            PressGesture prg = go.GetComponent <PressGesture>();

            if (prg != null)
            {
                prg.enabled = false;
            }
            // disable release events
            ReleaseGesture rg = go.GetComponent <ReleaseGesture>();

            if (rg != null)
            {
                rg.enabled = false;
            }
            Debug.Log("Disabled gestures for " + go.name);
        }
Esempio n. 5
0
 protected override void onReleaseRunning(ReleaseGesture gesture)
 {
     if (rotatedDirty)
     {
         tempcSt.Execute(b);
     }
 }
Esempio n. 6
0
 private void HandleRelease(object sender, TouchScript.Events.GestureStateChangeEventArgs e)
 {
     if (e.State == Gesture.GestureState.Recognized)
     {
         ReleaseGesture gesture = sender as ReleaseGesture;
         ScaleDown(gesture.gameObject);
     }
 }
Esempio n. 7
0
    protected override void onReleaseRunning(ReleaseGesture gesture)
    {
        nextState = null;
        shouldPop = true;

        focusedObject.gameObject.GetComponent <Highlightable> ().highlighted = false;

        dismiss(nextState, shouldPop);
    }
Esempio n. 8
0
        private void Awake()
        {
            ScaleRange *= Camera.main.orthographicSize;

            HorizontalMoveGesture = GetComponent <ScreenTransformGesture>();
            ScaleGesture          = GetComponent <TransformGesture>();
            PressGesture          = GetComponent <PressGesture>();
            ReleaseGesture        = GetComponent <ReleaseGesture>();
            FlickGesture          = GetComponent <FlickGesture>();
        }
Esempio n. 9
0
        private void OnEnable()
        {
            tapGesture     = GetComponent <TapGesture>();
            pressGesture   = GetComponent <PressGesture>();
            releaseGesture = GetComponent <ReleaseGesture>();

            tapGesture.Tapped       += tappedHandler;
            pressGesture.Pressed    += pressedHandler;
            releaseGesture.Released += releasedHandler;
        }
Esempio n. 10
0
        private void OnEnable()
        {
            _PressGesture          = GetComponent <PressGesture>();
            _PressGesture.Pressed += PressHandler;

            _ReleaseGesture           = GetComponent <ReleaseGesture>();
            _ReleaseGesture.Released += ReleaseHandler;

            _TransformGesture              = GetComponent <TransformGesture>();
            _TransformGesture.Transformed += TransformHandler;
        }
 /// <summary>
 /// Initializes the components.
 /// </summary>
 private void InitializeComponents()
 {
     m_collider2D               = gameObject.AddDerivedIfNoBase <Collider2D, BoxCollider2D>();
     m_collider2D.isTrigger     = true;
     m_pressGesture             = gameObject.AddComponentNoDupe <PressGesture>();
     m_releaseGesture           = gameObject.AddComponentNoDupe <ReleaseGesture>();
     m_panGesture               = gameObject.AddComponentNoDupe <SimplePanGesture>();
     m_pressGesture.Pressed    += OnPlayerPress;
     m_releaseGesture.Released += OnPlayerRelease;
     m_panGesture.Panned       += OnPlayerSwipe;
 }
Esempio n. 12
0
        public override void OnEnter()
        {
            gesture = GestureUtils.GetGesture <ReleaseGesture>(Fsm, GameObject, Component, true);
            if (gesture == null)
            {
                LogError("Gesture is missing");
                return;
            }

            gesture.Released += gestureReleasedHandler;
        }
Esempio n. 13
0
 private void Awake()
 {
     gesture        = GetComponent <MetaGesture> ();
     releaseGesture = GetComponent <ReleaseGesture> ();
     trans          = iluminacao.GetComponent <Transform> ();
     areaTrans      = areaPoseidon.GetComponent <Transform> ();
     lightRender    = iluminacao.GetComponent <SpriteRenderer> ();
     luzPos         = new Vector2();
     unitPos        = new Vector2();
     lightColor     = new Color(1, 1, 1);
     unitVerificar  = new bool[13, 7];
 }
Esempio n. 14
0
        public void AddReleaseGesture(ReleaseGesture releaseGesture, int index)
        {
            if (_releaseGesture == null)
            {
                _releaseGesture           = releaseGesture;
                _releaseGesture.Released += Released;
            }
            else
            {
                if (_releaseGestures.Count == 0)
                {
                    _releaseGestures.Add(_releaseGesture);
                }

                var oldList = new List <ReleaseGesture>(_releaseGestures);

                if (index == 0)
                {
                    _releaseGestures = new List <ReleaseGesture>();
                    _releaseGestures.Add(releaseGesture);
                    for (int i = 0; i < oldList.Count; i++)
                    {
                        _releaseGestures.Add(oldList[i]);
                    }
                }
                else if (index < _releaseGestures.Count)
                {
                    var n = oldList.Count;
                    _releaseGestures = new List <ReleaseGesture>();
                    for (int i = 0; i < index; i++)
                    {
                        _releaseGestures.Add(oldList[i]);
                    }
                    _releaseGestures.Add(releaseGesture);
                    for (int i = index; i < n; i++)
                    {
                        _releaseGestures.Add(oldList[i]);
                    }
                }
                else
                {
                    _releaseGestures.Add(releaseGesture);
                }


                _releaseGestures.Add(releaseGesture);

                releaseGesture.Released += Released;
            }
            //_releaseGesture = releaseGesture;
            //_releaseGesture.Released += Released;
        }
Esempio n. 15
0
    // ----------------------------------------------------------------
    private void OnEnable()
    {
        // Setup Touchscript gestures
        tranGesture = GetComponent <ScreenTransformGesture>();
        tranGesture.TransformStarted += TransformStartHandler;
        tranGesture.Transformed      += TransformOngoingHandler;

        releaseGesture           = GetComponent <ReleaseGesture>();
        releaseGesture.Released += ReleaseHandler;

        pressGesture          = GetComponent <PressGesture>();
        pressGesture.Pressed += PressHandler;
    }
Esempio n. 16
0
    void ReleaseHandler(object sender, System.EventArgs e)
    {
        //print("Released");
        player.GetComponent <MonsterController>().RecieveMovmentImput(Vector2.zero);
        AnimationSetter.instance.SetMovement(false);
        flickReady = true;

        ReleaseGesture gesture = sender as ReleaseGesture;
        TouchHit       hitRelease;

        gesture.GetTargetHitResult(out hitRelease);
        releasePoint = hitRelease.Point;
    }
Esempio n. 17
0
        private void Awake()
        {
            tapGesture     = GetComponent <TapGesture> ();
            longPress      = GetComponent <LongPressGesture> ();
            releaseGesture = GetComponent <ReleaseGesture> ();

            trans     = GetComponent <Transform> ();
            cardImage = GetComponent <SpriteRenderer> ();

            toPos       = new Vector2(trans.localPosition.x, trans.localPosition.y);
            ActiveColor = new Color(1, 1, 1);

            cardName = this.name;
        }
Esempio n. 18
0
    private void buttonReleasedHandler(object sender, EventArgs e)
    {
        if (levelManager.loading)
        {
            return;
        }

        ReleaseGesture gesture = (ReleaseGesture)sender;
        GameObject     s       = gesture.gameObject;

        if (s.name.Equals(bottomCamCanvas.name))
        {
            PlacementUI.SetActive(false);

            if (activeKey != "" && database[activeKey].first.activeSelf)
            {
                if ((database[activeKey].first.tag != "PaintableBackground" || database[activeKey].first.tag == "PaintableBackground" && database[activeKey].first.GetComponent <SpriteRenderer>() != null))
                {
                    PlaceObject(lastTouchPosition);
                }

                database[activeKey].first.SetActive(false);
                database[activeKey].second.SetActive(false);
            }

            if (lastObjectSelected != null)
            {
                lastObjectSelected.first.transform.position = lastObjectSelected.second.transform.position + (new Vector3(0f, LevelManager.SCREEN_GAP, 0f));

                PathFollowing p = lastObjectSelected.first.GetComponent <PathFollowing>();
                if (p != null)
                {
                    p.setStateToIdle();
                }

                lastObjectSelected = null;
            }

            if (shouldResetKey)
            {
                activeKey      = keyToReset;
                keyToReset     = "";
                shouldResetKey = false;
            }

            draggingObject = null;
            removed        = false;
            dragging       = false;
        }
    }
 public void Awake()
 {
     trans                   = GetComponent <Transform>();
     timer                   = 0;
     pause                   = true;
     specialAttackOn         = false;
     waveInterval            = new WaitForSeconds(GameConstants.PLAYER_SPECIAL_INTERVAL);
     specialCoolDownInterval = new WaitForSeconds(GameConstants.PLAYER_SPECIAL_COOL_DOWN_INTERVAL);
     specialAttackWaveNumber = 0;
     tiroSom                 = GetComponent <AudioSource> ();
     tapGesture              = GetComponent <TapGesture>();
     pressGesture            = GetComponent <PressGesture> ();
     releaseGesture          = GetComponent <ReleaseGesture> ();
     numeroTiros             = 1;
 }
Esempio n. 20
0
        // subscribes an object to all relevant gestures, according to its tag
        public void AddAndSubscribeToGestures(GameObject go)
        {
            if (go.tag == "LevelIcon" || go.tag == "WordObject" || go.tag == "Button" || go.tag == "Kid" || go.tag == "Lock")
            {
                // add tap gesture component
                TapGesture tg = go.AddComponent <TapGesture> ();
                // subscribe to tap events
                tg.Tapped += tappedHandler;
                Debug.Log(go.name + " subscribed to tap events");
            }

            if (go.tag == "MovableLetter" || go.tag == "MovableBlank")
            {
                // add pan gesture component
                PanGesture pg = go.AddComponent <PanGesture> ();
                pg.CombineTouchesInterval = 0.2f;
                // subscribe to pan events
                pg.PanStarted   += panStartedHandler;
                pg.Panned       += pannedHandler;
                pg.PanCompleted += panCompleteHandler;
                Debug.Log(go.name + " subscribed to pan events");

                // add press gesture component
                PressGesture prg = go.AddComponent <PressGesture> ();
                // subscribe to press events
                prg.Pressed += pressedHandler;
                Debug.Log(go.name + " subscribed to press events");

                // add release gesture component
                ReleaseGesture rg = go.AddComponent <ReleaseGesture> ();
                // subscribe to release events
                rg.Released += releasedHandler;
                Debug.Log(go.name + " subscribed to release events");

                // add transformer component so object automatically moves on drag
                go.AddComponent <Transformer2D>();
            }

            if (go.tag == "TargetLetter" || go.tag == "TargetBlank")
            {
                // add press gesture component
                PressGesture prg = go.AddComponent <PressGesture> ();
                // subscribe to press events
                prg.Pressed += pressedHandler;
                Debug.Log(go.name + " subscribed to press events");
            }
        }
Esempio n. 21
0
    protected virtual void onRelease(ReleaseGesture gesture)
    {
        switch (lifeCycle)
        {
        case STATE.STARTING:
            onReleaseStarting(gesture);
            break;

        case STATE.RUNNING:
            onReleaseRunning(gesture);
            break;

        case STATE.DYING:
            onReleaseDying(gesture);
            break;
        }
    }
Esempio n. 22
0
        public void AddReleaseGesture(ReleaseGesture releaseGesture)
        {
            if (_releaseGesture == null)
            {
                _releaseGesture           = releaseGesture;
                _releaseGesture.Released += Released;
            }
            else
            {
                if (_releaseGestures.Count == 0)
                {
                    _releaseGestures.Add(_releaseGesture);
                }

                _releaseGestures.Add(releaseGesture);

                releaseGesture.Released += Released;
            }
        }
Esempio n. 23
0
        protected override void OnStart()
        {
            base.OnStart();
            inputController = _controller as InputController;
            _pressGesture   = GetComponent <PressGesture>();
            _boxCollider    = GetComponent <BoxCollider>();
            _releaseGesture = GetComponent <ReleaseGesture>();

            if (UseIndex)
            {
                inputController.AddPressGesture(_pressGesture, Index);
                inputController.AddReleaseGesture(_releaseGesture, Index);
            }
            else
            {
                inputController.AddPressGesture(_pressGesture);
                inputController.AddReleaseGesture(_releaseGesture);
            }
        }
Esempio n. 24
0
    // Use this for initialization

    void Start()
    {
        ScaleGesture sg = gameObject.AddComponent <ScaleGesture> ();

        sg.Scaled += HandleZoom;

        PanGesture pg = gameObject.AddComponent <PanGesture> ();

        pg.MovementThreshold = 0.25F;
        pg.Panned           += HandlePanned;

        LongPressGesture lpg = gameObject.AddComponent <LongPressGesture> ();

        lpg.LongPressed += HandleLongPressed;
        lpg.AddFriendlyGesture(pg);

        ReleaseGesture rg = gameObject.AddComponent <ReleaseGesture> ();

        rg.Released += HandleReleased;
    }
Esempio n. 25
0
    private void OnEnable()
    {
        if (PressGesture == null)
        {
            PressGesture = GetComponent <PressGesture>();
        }
        PressGesture.Pressed += pressedHandler;

        if (ReleaseGesture == null)
        {
            ReleaseGesture = GetComponent <ReleaseGesture>();
        }
        ReleaseGesture.Released += releasedHandler;

        if (TapGesture == null)
        {
            TapGesture = GetComponent <TapGesture>();
        }
        TapGesture.Tapped += tappedHandler;
    }
 // ----------------------------------------------------------------
 private void OnEnable()
 {
     // Setup Touchscript gestures
     releaseGesture           = GetComponent <ReleaseGesture>();
     releaseGesture.Released += ReleaseHandler;
 }
Esempio n. 27
0
 protected virtual void Awake()
 {
     m       = GetComponent <SpriteRenderer>().material;
     press   = GetComponent <PressGesture> ();
     release = GetComponent <ReleaseGesture> ();
 }
Esempio n. 28
0
 //<summary>
 // subscribes an object to all relevant gestures, according to its tag
 //</summary>
 public void AddAndSubscribeToGestures(GameObject go)
 {
     if (go.tag == Constants.Tags.TAG_LEVEL_ICON || go.tag == Constants.Tags.TAG_WORD_OBJECT ||
         go.tag == Constants.Tags.TAG_BUTTON || go.tag == Constants.Tags.TAG_KID ||
         go.tag == Constants.Tags.TAG_LOCK)
     {
         // add tap gesture component
         TapGesture tg = go.AddComponent <TapGesture>();
         if (tg != null)
         {
             // subscribe to tap events
             tg.Tapped += tappedHandler;
             Debug.Log(go.name + " subscribed to tap events");
         }
         else
         {
             Debug.LogError("Cannot find tap gesture");
         }
     }
     if (go.tag == Constants.Tags.TAG_MOVABLE_LETTER || go.tag == Constants.Tags.TAG_MOVABLE_BLANK)
     {
         // add pan gesture component
         TransformGesture pg = go.AddComponent <TransformGesture>();
         pg.CombineTouchesInterval = 0.2f;
         if (pg != null)
         {
             // subscribe to pan events
             pg.TransformStarted   += panStartedHandler;
             pg.Transformed        += pannedHandler;
             pg.TransformCompleted += panCompleteHandler;
             Debug.Log(go.name + " subscribed to pan events");
         }
         else
         {
             Debug.LogError("Cannot find transform gesture");
         }
         // add press gesture component
         PressGesture prg = go.AddComponent <PressGesture>();
         if (prg != null)
         {
             // subscribe to press events
             prg.Pressed += pressedHandler;
             Debug.Log(go.name + " subscribed to press events");
         }
         else
         {
             Debug.LogError("Cannot find press gesture");
         }
         // add release gesture component
         ReleaseGesture rg = go.AddComponent <ReleaseGesture>();
         if (rg != null)
         {
             // subscribe to release events
             rg.Released += releasedHandler;
             Debug.Log(go.name + " subscribed to release events");
         }
         else
         {
             Debug.LogError("Cannot find release gesture");
         }
         // add transformer component so object automatically moves on drag
         go.AddComponent <Transformer>();
     }
     if (go.tag == Constants.Tags.TAG_TARGET_LETTER || go.tag == Constants.Tags.TAG_TARGET_BLANK)
     {
         // add press gesture component
         PressGesture prg = go.AddComponent <PressGesture>();
         if (prg != null)
         {
             // subscribe to press events
             prg.Pressed += pressedHandler;
             Debug.Log(go.name + " subscribed to press events");
         }
         else
         {
             Debug.LogError("Cannot find press gesture");
         }
     }
 }
        /// <summary>
        /// Subscribes a play object to all relevant gestures - tap, pan,
        /// press, release
        /// </summary>
        /// <param name="go">Game object</param>
        /// <param name="draggable">If set to <c>true</c> is a draggable object.</param>
        public void AddAndSubscribeToGestures(GameObject go, bool draggable, bool storypage)
        {
            // add a tap gesture component if one doesn't exist
            TapGesture tg = go.GetComponent <TapGesture>();

            if (tg == null)
            {
                tg = go.AddComponent <TapGesture>();
            }
            // checking for null anyway in case adding the component didn't work
            if (tg != null)
            {
                tg.Tapped += tappedHandler; // subscribe to tap events
                Logger.Log(go.name + " subscribed to tap events");
            }
            // if this object is draggable, handle pan events
            if (draggable)
            {
                // add pan gesture component if one doesn't exist yet
                TransformGesture trg = go.GetComponent <TransformGesture>();
                if (trg == null)
                {
                    trg      = go.AddComponent <TransformGesture>();
                    trg.Type = TouchScript.Gestures.Base.TransformGestureBase.TransformType.Translation;
                }
                if (trg != null)
                {
                    trg.CombineTouchesInterval = 0.2f;
                    trg.TransformStarted      += transformStartedHandler;
                    trg.Transformed           -= transformedHandler;
                    trg.TransformCompleted    += transformCompleteHandler;
                    Logger.Log(go.name + " subscribed to pan events");
                }

                // make sure we do have a transformer if we're draggable
                Transformer tr = go.GetComponent <Transformer>();
                if (tr == null)
                {
                    tr = go.AddComponent <Transformer>();
                }
            }

            PressGesture prg = go.GetComponent <PressGesture>();

            if (prg == null)
            {
                prg = go.AddComponent <PressGesture>();
            }
            if (prg != null)
            {
                prg.Pressed += pressedHandler;
                Logger.Log(go.name + " subscribed to press events");
            }
            ReleaseGesture rg = go.GetComponent <ReleaseGesture>();

            if (rg == null)
            {
                rg = go.AddComponent <ReleaseGesture>();
            }
            if (rg != null)
            {
                rg.Released += releasedHandler;
                Logger.Log(go.name + " subscribed to release events");
            }


            // if this is a story page, handle swipe/flick events
            if (storypage)
            {
                // add flick gesture component if one doesn't exist yet
                FlickGesture fg = go.GetComponent <FlickGesture>();
                if (fg == null)
                {
                    fg = go.AddComponent <FlickGesture>();
                }
                if (fg != null)
                {
                    fg.Flicked += flickHandler;
                    fg.AddFriendlyGesture(tg);
                    fg.MinDistance       = 0.4f;
                    fg.FlickTime         = 0.5f;
                    fg.MovementThreshold = 0.1f;
                    Logger.Log(go.name + " subscribed to flick events");
                }
            }
        }
        /// <summary>
        /// On destroy, disable some stuff
        /// </summary>
        private void OnDestroy()
        {
            // unsubscribe from gesture events
            GameObject[] gos = GameObject.FindGameObjectsWithTag(Constants.TAG_PLAY_OBJECT);
            foreach (GameObject go in gos)
            {
                TapGesture tg = go.GetComponent <TapGesture>();
                if (tg != null)
                {
                    tg.Tapped -= tappedHandler;
                    Logger.Log(go.name + " unsubscribed from tap events");
                }
                TransformGesture trg = go.GetComponent <TransformGesture>();
                if (trg != null)
                {
                    trg.Transformed        -= transformedHandler;
                    trg.TransformCompleted -= transformCompleteHandler;
                    trg.TransformStarted   -= transformStartedHandler;
                    Logger.Log(go.name + " unsubscribed from pan events");
                }
                PressGesture prg = go.GetComponent <PressGesture>();
                if (prg != null)
                {
                    prg.Pressed -= pressedHandler;
                    Logger.Log(go.name + " unsubscribed from press events");
                }
                ReleaseGesture rg = go.GetComponent <ReleaseGesture>();
                if (rg != null)
                {
                    rg.Released -= releasedHandler;
                    Logger.Log(go.name + " unsubscribed from release events");
                }
                FlickGesture fg = go.GetComponent <FlickGesture>();
                if (fg != null)
                {
                    fg.Flicked -= flickHandler;
                    Logger.Log(go.name + " unsubscribed from flick events");
                }
            }

            //if (this.demo)
            //{
            // also unsubscribe for the sidekick
            GameObject gob = GameObject.FindGameObjectWithTag(Constants.TAG_SIDEKICK);

            if (gob != null)
            {
                TapGesture tapg = gob.GetComponent <TapGesture>();
                if (tapg != null)
                {
                    tapg.Tapped -= tappedHandler;
                    Logger.Log(gob.name + " unsubscribed from tap events");
                }

                PressGesture prg = gob.GetComponent <PressGesture>();
                if (prg != null)
                {
                    prg.Pressed -= pressedHandler;
                    Logger.Log(gob.name + " unsubscribed from press events");
                }
                ReleaseGesture rg = gob.GetComponent <ReleaseGesture>();
                if (rg != null)
                {
                    rg.Released -= releasedHandler;
                    Logger.Log(gob.name + " unsubscribed from release events");
                }
            }
            //}
        }