Ejemplo n.º 1
0
        // Handle press events
        private void pressedHandler(object sender, EventArgs e)
        {
            // get the gesture that was sent to us, which will tell us which object was pressed
            PressGesture gesture = sender as PressGesture;

            // get info about where the hit object was located when the gesture was recognized
            ITouchHit hit;

            if (gesture.GetTargetHitResult(out hit))
            {
                // want the info as a 2D point
                ITouchHit2D hit2d = (ITouchHit2D)hit;
                Debug.Log("PRESS on " + gesture.gameObject.name + " at " + hit2d.Point);
            }

            // play audio clip attached to object when pressed
            PlaySound(gesture.gameObject);

            // If the loaded scene is Spelling Game, re-enable collisions
            // when a letter is first pressed after resetting incorrect letters
            if (Application.loadedLevelName == "5. Spelling Game")
            {
                CollisionManager.EnableCollisions(gesture.gameObject, "TargetBlank");
            }

            // if the loaded scene is the sound game, re-enable collisions
            // when a sound blank is first pressed after resetting incorrect blanks
            if (Application.loadedLevelName == "6. Sound Game")
            {
                CollisionManager.EnableCollisions(gesture.gameObject, "TargetLetter");
            }
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
    // Use this for initialization
    protected virtual void Start()
    {
        PressGesture press = gameObject.AddComponent <PressGesture> ();

        press.Pressed += TouchEvent;

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

        pan.Panned += TouchEvent;

        TapGesture tap = gameObject.AddComponent <TapGesture>();

        tap.Tapped += TouchEvent;
        tap.NumberOfTapsRequired = 2;
        tap.TimeLimit            = 0.5f;

        ScaleGesture scale = gameObject.AddComponent <ScaleGesture> ();

        scale.Scaled += TouchEvent;

        gameObject.AddComponent <PressGesture>().Pressed += TouchEvent;

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

        longPress.LongPressed += TouchEvent;
        longPress.TimeToPress  = 0.2f;
        longPress.AddFriendlyGesture(pan);

        gameObject.AddComponent <ReleaseGesture>().Released += TouchEvent;
    }
Ejemplo n.º 4
0
 void Awake()
 {
     myTransformGesture = GetComponent <TransformGesture> ();
     myPressGesture     = GetComponent <PressGesture> ();
     //myReleaseGesture = GetComponent<ReleaseGesture> ();
     //Debug.Log ("my press gesture: " + myPressGesture.ToString ());
 }
Ejemplo n.º 5
0
        private void pressedHandler(object sender, System.EventArgs e)
        {
            //Debug.Log("TouchPanel: pressed")
            PressGesture gesture = (PressGesture)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.OnPressed(lane);
            }
        }
 public static IObservable <EventPattern <EventArgs> > PressedAsObservable(this PressGesture gesture)
 {
     return(Observable.FromEventPattern <EventHandler <EventArgs>, EventArgs>(
                h => h.Invoke,
                h => gesture.Pressed += h,
                h => gesture.Pressed -= h));
 }
Ejemplo n.º 7
0
    void Start()
    {
        tapGesture = GetComponent <TapGesture>();
        if (tapGesture != null)
        {
            tapGesture.Tapped += (sender, args) =>
            {
                Debug.Log(transform.name + " tapped");

                if (field_wall == null)
                {
                    AddObjects(CellObjects.WALL);
                }
                else
                {
                    RemoveObjects(CellObjects.WALL);
                }
            };
        }
        pressGesture = GetComponent <PressGesture>();
        if (pressGesture != null)
        {
            pressGesture.Pressed += (sender, args) =>
            {
                Debug.Log(transform.name + " pressed");
            };
        }
    }
Ejemplo n.º 8
0
    /// <summary>
    /// Updates the IsPressable property
    /// Components are added/enabled/disabled as needed
    /// </summary>
    protected void UpdateIsPressableField()
    {
        if (m_isPressable == m_isPressablePrev)
        {
            return;
        }

        if (m_isPressable)
        {
            AddOrGetComponentCollider2D();
            m_pressGesture         = this.gameObject.AddComponentNoDupe <PressGesture>();
            m_pressGesture.enabled = true;
            AddPressDelegate(OnObjectPress);
            AddReleaseDelegate(OnObjectRelease);
        }
        else
        {
            if (m_pressGesture != null)
            {
                RemovePressDelegate(OnObjectPress);
                RemoveReleaseDelegate(OnObjectRelease);
                m_pressGesture.enabled = false;
            }
        }

        m_isPressablePrev = m_isPressable;
    }
Ejemplo n.º 9
0
    private void Start()
    {
        pressGesture          = GetComponent <PressGesture>();
        pressGesture.Pressed += PressGesture_Pressed;

        //boxCollider = GetComponent<BoxCollider>();
    }
Ejemplo n.º 10
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;
         }
     }
 }
        protected override void OnStart()
        {
            base.OnStart();

            _pg = GetComponent <PressGesture>();

            _pg.Pressed += OnPressed;
        }
Ejemplo n.º 12
0
    //start 程序运行时并且处于可见状态运行
    void Start()
    {
        pressGesture          = GetComponent <PressGesture>();
        pressGesture.Pressed += PressGesture_Pressed;

        //行星页面
        currentPanel = transform.parent.parent.gameObject;
    }
Ejemplo n.º 13
0
    //start 程序运行时并且处于可见状态运行
    void Start()
    {
        pressGesture          = GetComponent <PressGesture>();
        pressGesture.Pressed += PressGesture_Pressed;

        //无法找到隐藏的物体
        planetPage = GameObject.FindGameObjectWithTag("planetPanel");
        // planetUIPanel=GameObject.FindGameObjectWithTag("planetUIPanel");
    }
Ejemplo n.º 14
0
    void Start()
    {
        pressGesture          = GetComponent <PressGesture>();
        pressGesture.Pressed += PressGesture_Pressed;

        tipText = transform.GetChild(0).gameObject;
        GetImage();
        AutoPopImage();
    }
Ejemplo n.º 15
0
 private void HandlePress(object sender, TouchScript.Events.GestureStateChangeEventArgs e)
 {
     if (e.State == Gesture.GestureState.Recognized)
     {
         FlowView.Instance.StopInertia();
         PressGesture gesture = sender as PressGesture;
         ScaleUp(gesture.gameObject);
     }
 }
Ejemplo n.º 16
0
        private void OnEnable()
        {
            rnd = GetComponent <MeshRenderer>();
            longPressGesture = GetComponent <LongPressGesture>();
            pressGesture     = GetComponent <PressGesture>();

            longPressGesture.StateChanged += longPressedHandler;
            pressGesture.Pressed          += pressedHandler;
        }
Ejemplo n.º 17
0
 void OnDisable()
 {
     for (int i = 0; i < gestures.Count; i++)
     {
         PressGesture gesture = gestures[i];
         gesture.Pressed -= pressHandler;
     }
     gestures.Clear();
 }
Ejemplo n.º 18
0
        /// <summary>
        /// Handle press events - log and turn on highlight
        /// </summary>
        /// <param name="sender">Sender.</param>
        /// <param name="e">E.</param>
        private void pressedHandler(object sender, EventArgs e)
        {
            // get the gesture that was sent to us, which will tell us
            // which object was pressed
            PressGesture gesture = sender as PressGesture;
            HitData      hit     = gesture.GetScreenPositionHitData();

            // get info about where the hit object was located when the gesture was
            // recognized - i.e., where on the object (in screen dimensions) did
            // the press occur?
            Logger.Log("PRESS on " + gesture.gameObject.name + " at " + hit.Point);

            // fire event to logger to log this action
            if (this.logEvent != null)
            {
                // if this is a social stories game, log additional info about
                // what object was pressed
                if (this.socialStories)
                {
                    // log the press plus whether or not the pressed object was a YES or NO
                    // button, or whether the object was a CORRECT or INCORRECT object
                    this.logEvent(this, new LogEvent(LogEvent.EventType.Action,
                                                     gesture.gameObject.name, "press", hit.Point,
                                                     (gesture.gameObject.name.Contains("start_button") ? "START"
                        : (gesture.gameObject.name.Contains("no_button") ? "NO"
                           // If the game object doesn't have SavedProperties component, don't add
                           // an additional message. Otherwise, log whether it was correct or not.
                        : gesture.gameObject.GetComponent <SavedProperties>() == null ? ""
                        : (gesture.gameObject.GetComponent <SavedProperties>().isCorrect ? "CORRECT"
                        : (gesture.gameObject.GetComponent <SavedProperties>().isIncorrect ? "INCORRECT"
                        : ""))))));
                }
                else
                {
                    // log the press
                    this.logEvent(this, new LogEvent(LogEvent.EventType.Action,
                                                     gesture.gameObject.name, "press", hit.Point));
                }
            }

            // move highlighting light and set active
            // don't highlight touches in a story
            if (this.allowTouch)// && !this.story)
            {
                // Center the light behind the pressed object, regardless of
                // where on the pressed object the touch was.
                LightOn(1, gesture.gameObject.transform.position);
            }

            // trigger sound on press
            if (this.allowTouch && gesture.gameObject.tag.Contains(Constants.TAG_PLAY_OBJECT))
            {
                Logger.Log("going to play a sound for " + gesture.gameObject.name);
                PlaySoundAndPulse(gesture.gameObject);
            }
        }
Ejemplo n.º 19
0
        private void Awake()
        {
            MoveGesture = GetComponent <TransformGesture>();

            deleteButtonTrans = transform.Find("Delete");
            ClosePressGesture = deleteButtonTrans.GetComponent <PressGesture>();

            boxCollider         = GetComponent <BoxCollider>();
            boxCollider.enabled = IsModifiable;
        }
Ejemplo n.º 20
0
        private void OnEnable()
        {
            tapGesture     = GetComponent <TapGesture>();
            pressGesture   = GetComponent <PressGesture>();
            releaseGesture = GetComponent <ReleaseGesture>();

            tapGesture.Tapped       += tappedHandler;
            pressGesture.Pressed    += pressedHandler;
            releaseGesture.Released += releasedHandler;
        }
Ejemplo n.º 21
0
        private void Awake()
        {
            ScaleRange *= Camera.main.orthographicSize;

            HorizontalMoveGesture = GetComponent <ScreenTransformGesture>();
            ScaleGesture          = GetComponent <TransformGesture>();
            PressGesture          = GetComponent <PressGesture>();
            ReleaseGesture        = GetComponent <ReleaseGesture>();
            FlickGesture          = GetComponent <FlickGesture>();
        }
Ejemplo n.º 22
0
 /// <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;
 }
Ejemplo n.º 23
0
        private void OnEnable()
        {
            _PressGesture          = GetComponent <PressGesture>();
            _PressGesture.Pressed += PressHandler;

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

            _TransformGesture              = GetComponent <TransformGesture>();
            _TransformGesture.Transformed += TransformHandler;
        }
Ejemplo n.º 24
0
        public override void OnEnter()
        {
            gesture = GestureUtils.GetGesture <PressGesture>(Fsm, GameObject, Component, true);
            if (gesture == null)
            {
                LogError("Gesture is missing");
                return;
            }

            gesture.Pressed += gesturePressedHandler;
        }
Ejemplo n.º 25
0
    /// <summary>
    /// Awake this instance.
    /// </summary>
    protected override void Awake()
    {
        base.Awake();

        // Make sure element has a PressGesture component
        m_pressGesture = this.gameObject.AddComponentNoDupe <PressGesture>();
        // No need for ReleaseGesture - this script has a different implementation for release

        AddPressDelegate(OnButtonPress);
        AddReleaseDelegate(OnButtonRelease);
    }
Ejemplo n.º 26
0
    void Start()
    {
        pressGesture = GetComponent <PressGesture>();
        if (pressGesture == null)
        {
            pressGesture = gameObject.AddComponent <PressGesture>();
        }
        pressGesture.Pressed += PressGesture_Pressed;


        rect = GetComponent <RectTransform>();
    }
Ejemplo n.º 27
0
    //プレス(押した時)
    protected virtual void PressHandle(object sender, System.EventArgs e)
    {
        //MyDebug.Instance.AdminLog("PressHandle");
        PressGesture gesture = sender as PressGesture;

        point      = gesture.ScreenPosition;
        isDraging  = false;
        isPinching = false;
        isTwisting = false;
        totalPinch = 0;
        totalTwist = 0;
    }
Ejemplo n.º 28
0
    void PressHandler(object sender, System.EventArgs e)
    {
        //print("Press Detected");
        player.GetComponent <MonsterController>().SetMonsterTapped(true);
        player.GetComponent <MonsterController>().RecieveMovmentImput(Vector2.zero);
        AnimationSetter.instance.SetMovement(false);

        PressGesture gesture = sender as PressGesture;
        TouchHit     hitPress;

        gesture.GetTargetHitResult(out hitPress);
        pressPoint = hitPress.Point;
    }
Ejemplo n.º 29
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;
    }
Ejemplo n.º 30
0
 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;
 }