Esempio n. 1
0
 void Update()
 {
     // DEBUG
     if (Input.GetKeyDown(KeyCode.Alpha0))
     {
         visuals.OnTouched(0, true);
         //print("Touched pin 0");
     }
     if (Input.GetKeyUp(KeyCode.Alpha0))
     {
         visuals.OnTouched(0, false);
         //print("Untouched pin 0");
     }
     if (Input.GetKeyDown(KeyCode.Alpha1))
     {
         visuals.OnTouched(1, true);
     }
     if (Input.GetKeyUp(KeyCode.Alpha1))
     {
         visuals.OnTouched(1, false);
     }
     if (Input.GetKeyDown(KeyCode.Alpha2))
     {
         visuals.OnTouched(2, true);
     }
     if (Input.GetKeyUp(KeyCode.Alpha2))
     {
         visuals.OnTouched(2, false);
     }
     if (Input.GetKeyDown(KeyCode.Alpha3))
     {
         visuals.OnTouched(3, true);
     }
     if (Input.GetKeyUp(KeyCode.Alpha3))
     {
         visuals.OnTouched(3, false);
     }
     if (Input.GetKeyDown(KeyCode.Alpha4))
     {
         visuals.OnTouched(4, true);
     }
     if (Input.GetKeyUp(KeyCode.Alpha4))
     {
         visuals.OnTouched(4, false);
     }
     if (Input.GetKeyDown(KeyCode.Alpha5))
     {
         visuals.OnTouched(5, true);
     }
     if (Input.GetKeyUp(KeyCode.Alpha5))
     {
         visuals.OnTouched(5, false);
     }
     if (Input.GetKeyDown(KeyCode.Alpha6))
     {
         visuals.OnTouched(6, true);
     }
     if (Input.GetKeyUp(KeyCode.Alpha6))
     {
         visuals.OnTouched(6, false);
     }
     if (Input.GetKeyDown(KeyCode.Alpha7))
     {
         visuals.OnTouched(7, true);
     }
     if (Input.GetKeyUp(KeyCode.Alpha7))
     {
         visuals.OnTouched(7, false);
     }
     if (Input.GetKeyDown(KeyCode.Alpha8))
     {
         visuals.OnTouched(8, true);
     }
     if (Input.GetKeyUp(KeyCode.Alpha8))
     {
         visuals.OnTouched(8, false);
     }
     if (Input.GetKeyDown(KeyCode.Alpha9))
     {
         visuals.OnTouched(9, true);
     }
     if (Input.GetKeyUp(KeyCode.Alpha9))
     {
         visuals.OnTouched(9, false);
     }
     if (Input.GetKeyDown(KeyCode.Q))
     {
         visuals.OnTouched(10, true);
     }
     if (Input.GetKeyUp(KeyCode.Q))
     {
         visuals.OnTouched(10, false);
     }
     if (Input.GetKeyDown(KeyCode.W))
     {
         visuals.OnTouched(11, true);
     }
     if (Input.GetKeyUp(KeyCode.W))
     {
         visuals.OnTouched(11, false);
     }
 }
Esempio n. 2
0
    public void OnTouched(int pin, bool touched)
    {
        // TODO: implement double pages!!!

        // If at least one page is detected
        if (activeTrackables.Count > 0)
        {
            // Assuming we only have one page
            TrackableBehaviour trackablePage = activeTrackables[0];

            if (touched)
            {
                print("Touched pin " + pin + " on book page " + trackablePage.TrackableName);
            }
            else
            {
                print("Untouched pin " + pin + " on book page " + trackablePage.TrackableName);
            }

            // Switch condition for each page / tracker ID
            currentPage = trackablePage.TrackableName;


            // TODO: stop pages that are lost
            //CheckIfPageChanged();


            // IF statements for each page (not else if, because two can happen at once)
            if (currentPage == "trackercover")
            {
                switch (pin)
                {
                case 1:     // pin that the "light switch" is connected to

                    if (touched)
                    {
                        // If book is off, turn it on
                        if (!bookON)
                        {
                            cover.TurnOn();
                        }
                        // If book is on, turn it off
                        else
                        {
                            cover.TurnOff();
                        }
                    }
                    break;
                }
            }


            // TODO: add bookON condition, decide what to do if book is off on other pages, are they locked, show "turn on" message? or simply dont work?

            if (bookON)
            {
                if (currentPage == "trackerpage0")
                {
                    page0.OnTouched(pin, touched);
                }
                if (currentPage == "trackerpage1" || currentPage == "trackerpage2")
                {
                    page1_2.OnTouched(pin, touched);
                }
                if (currentPage == "trackerpage3" || currentPage == "trackerpage4")
                {
                    page3_4.OnTouched(pin, touched);
                }
                if (currentPage == "trackerpage5")
                {
                    // Not implemented
                }
            }
        }

        //// If it is a pair of pages
        //else if (activeTrackables.Count == 2)
        //{
        //    TrackableBehaviour trackablePage0 = activeTrackables[0];
        //    TrackableBehaviour trackablePage1 = activeTrackables[1];

        //    if (touched)
        //        print("Touched pin " + pin + " on double book page number " + trackablePage0.Trackable.ID + " - " + trackablePage1.Trackable.ID);
        //    else
        //        print("Untouched pin " + pin + " on double book page number " + trackablePage0.Trackable.ID + " - " + trackablePage1.Trackable.ID);

        //}
    }