Ejemplo n.º 1
0
    public override void Update()
    {
        var touch = new TouchSensor(input, gameObjectFinder);

        if (touch.insideSprite(Camera.main, buyMusic)) {
            Application.OpenURL("http://itunes.apple.com/us/album/same-not-same-ep/id533347009");
        }
        else if (touch.insideSprite(Camera.main, news)) {
            Application.OpenURL("http://themakingofthemakingof.com");
        }
        else if (touch.hasTaps()) {
            endScene();
        }

        if (cycle_title.Complete()) {
            animateStartButton();
        }

        cycle_title.Update(Time.time);
    }
Ejemplo n.º 2
0
        public void touchInsideSpriteWhenAnotherSpriteNotInFront()
        {
            var sprite = spriteAt(Vector3.zero);
            expectAndReturnAlpha(sprite, 1.0f);
            var backSprite = spriteAt(Vector3.forward);

            var sensor = new TouchSensor(
                inputReturningTouch.MockObject,
                findInScene(new[] { sprite.MockObject, backSprite.MockObject}));

            Assert.That(sensor.insideSprite(camera.MockObject, sprite.MockObject), Iz.True);
        }
Ejemplo n.º 3
0
        public void touchWhenOnlyOneSpriteBeneathFinger()
        {
            var sprite = spriteAt(Vector3.forward);

            expectAndReturnAlpha(sprite, 1.0f);

            var sensor = new TouchSensor(
                inputReturningTouch.MockObject,
                findInScene(new[] { sprite.MockObject }));

            Assert.That(sensor.insideSprite(camera.MockObject, sprite.MockObject), Iz.True);
        }
Ejemplo n.º 4
0
        public void touchInsideSpriteWhenAnotherSpriteNotInFront()
        {
            var sprite = spriteAt(Vector3.zero);

            expectAndReturnAlpha(sprite, 1.0f);
            var backSprite = spriteAt(Vector3.forward);

            var sensor = new TouchSensor(
                inputReturningTouch.MockObject,
                findInScene(new[] { sprite.MockObject, backSprite.MockObject }));

            Assert.That(sensor.insideSprite(camera.MockObject, sprite.MockObject), Iz.True);
        }
Ejemplo n.º 5
0
        public void touchInsideSpriteWhenTransparentSpriteInFront()
        {
            var sprite = spriteAt(Vector3.forward);
            expectAndReturnAlpha(sprite, 1.0f);

            var frontSprite = spriteAt(Vector3.back);
            expectAndReturnAlpha(frontSprite, 0.0f);

            var sensor = new TouchSensor(
                inputReturningTouch.MockObject,
                findInScene(new[] { sprite.MockObject, frontSprite.MockObject}));

            Assert.That(sensor.insideSprite(camera.MockObject, sprite.MockObject), Iz.True);
        }
Ejemplo n.º 6
0
    public override void Update()
    {
        var touch = new TouchSensor(input, gameObjectFinder);

        if (touch.insideSprite(Camera.main, buyMusic))
        {
            Application.OpenURL("http://itunes.apple.com/us/album/same-not-same-ep/id533347009");
        }
        else if (touch.insideSprite(Camera.main, news))
        {
            Application.OpenURL("http://themakingofthemakingof.com");
        }
        else if (touch.hasTaps())
        {
            endScene();
        }

        if (cycle_title.Complete())
        {
            animateStartButton();
        }

        cycle_title.Update(Time.time);
    }
Ejemplo n.º 7
0
        public void noTouchWhenAllSpritesAreTransparent()
        {
            var sprite = spriteAt(Vector3.forward);

            expectAndReturnAlpha(sprite, 0.0f);

            var frontSprite = spriteAt(Vector3.back);

            expectAndReturnAlpha(frontSprite, 0.0f);

            var sensor = new TouchSensor(
                inputReturningTouch.MockObject,
                findInScene(new[] { sprite.MockObject, frontSprite.MockObject }));

            Assert.That(sensor.insideSprite(camera.MockObject, sprite.MockObject), Iz.False);
        }
Ejemplo n.º 8
0
    // Cycles through displaying a sequence of action-response pairs for each object that is touched.
    // Calls onComplete when it reaches the end of a cycle with the object for which the sequence was completed.
    public void hintWhenTouched(Action<Sprite> onComplete, TouchSensor sensor, float currentTime, Dictionary<Sprite, ActionResponsePair[]> interactions)
    {
        //if (!sensor.hasTaps()) return; // only act on touches

        // if there was an interaction but a dialog has not shown yet...
        if (currentTime <= actionPrintedAt + promptTime && touchedObject != null) {
            // ignore a tap if it's been at least a half second since prompting
            if (sensor.hasTaps() && currentTime > actionPrintedAt + 0.5f) {
                return;
            }
            // ignore touches of the same object before the first dialog is shown
            if (touchedObject != null && sensor.insideSprite(Camera.main, touchedObject, TouchSensor.allPhases)) {
                return;
            }
        }

        // if a dialog was just shown, let it sit there for a moment
        if (currentTime <= actionPrintedAt + promptTime + 0.5f) {
            return;
        }

        // cycle through remaining dialogs
        if (remainingMessages.Count > 0) {
            if (sensor.hasTaps()) {
                messageBox.setMessage(remainingMessages[0]);
                remainingMessages.RemoveAt(0);
                actionPrintedAt = currentTime - promptTime;
                Debug.Log("tapped. messages remaining: " + remainingMessages.Count);
            }
            return;
        }

        // start an action-dialog sequence if they touched an interactive object

        touchedObject = detectObjectInteraction(sensor, interactions);

        if (touchedObject == null) return;

        var message = interactions[touchedObject][0];
        var action = message.action;
        var responses = message.responses;
        actionPrintedAt = currentTime;
        print(action, responses[0]);

        var restOfresponses = new List<string>(responses).Skip(1).ToList();
        hint(action, restOfresponses);

        if (interactions[touchedObject].Length > 1) {
            interactions[touchedObject] = interactions[touchedObject].Skip(1).ToArray();
        } else {
            target = touchedObject;
            this.onComplete = onComplete;
        }
    }
Ejemplo n.º 9
0
 private Sprite detectObjectInteraction(TouchSensor sensor, Dictionary<Sprite, ActionResponsePair[]> interactions)
 {
     Sprite touched = null;
     foreach(var sprite in interactions.Keys) {
         if (sensor.insideSprite(Camera.main, sprite, new[] {TouchInput.TouchPhase.Began})) {
             touched = sprite;
         }
     }
     return touched;
 }
Ejemplo n.º 10
0
 public bool touchedBed(TouchSensor touch)
 {
     return touch.insideSprite(Camera.main, cover.GetComponent<Sprite>(), new[] {TouchPhase.Began});
 }
Ejemplo n.º 11
0
 public static bool belowFinger(this Sprite obj, TouchSensor sensor)
 {
     return sensor.insideSprite(Camera.main, obj, new[] {TouchPhase.Began, TouchPhase.Moved});
 }
Ejemplo n.º 12
0
 public bool touchedBed(TouchSensor touch)
 {
     return(touch.insideSprite(Camera.main, cover.GetComponent <Sprite>(), new[] { TouchPhase.Began }));
 }
Ejemplo n.º 13
0
 public bool touchedBed(TouchSensor touch)
 {
     return touch.insideSprite(Camera.main, cover, new[] {TouchInput.TouchPhase.Began});
 }
Ejemplo n.º 14
0
        public void touchWhenOnlyOneSpriteBeneathFinger()
        {
            var sprite = spriteAt(Vector3.forward);
            expectAndReturnAlpha(sprite, 1.0f);

            var sensor = new TouchSensor(
                inputReturningTouch.MockObject,
                findInScene(new[] { sprite.MockObject}));

            Assert.That(sensor.insideSprite(camera.MockObject, sprite.MockObject), Iz.True);
        }