Example #1
0
        /**
         * Called whenever a toggle is turned on. Will determine which
         * toggles get turned off
         */
        public void NotifyToggleOn(GemToggle toggle)
        {
            //will disable all toggles expcept current toggle and last selected toggle
            for (var i = 0; i < m_Toggles.Count; i++)
            {
                if (m_Toggles [i] == toggle || m_Toggles [i].LastGemSelected)
                {
                    continue;
                }

                m_Toggles [i].isOn = false;
            }

            //Will change booleans associated with toggles to match current game state
            for (var i = 0; i < m_Toggles.Count; i++)
            {
                if (m_Toggles [i].LastGemSelected)
                {
                    gm.SetGemTwo(m_Toggles [i].AssociatedGem);
                    m_Toggles [i].LastGemSelected = false;
                }

                if (m_Toggles [i] == toggle)
                {
                    gm.SetGemOne(m_Toggles [i].AssociatedGem);
                    m_Toggles [i].LastGemSelected = true;
                }
            }
        }
Example #2
0
 /**
  * Will run everytime toggle in group is clicked.
  */
 public void NotifyToggleClick(GemToggle toggle)
 {
     if (ActiveToggles().Count() == 1)
     {
         for (var i = 0; i < m_Toggles.Count; i++)
         {
             if (m_Toggles [i].isOn)
             {
                 gm.SetGemOne(m_Toggles [i].AssociatedGem);
                 gm.SetGemTwo(m_Toggles [i].AssociatedGem);
             }
         }
     }
     if (!toggle.isOn)
     {
         if (gm.GetGemOne() == toggle.AssociatedGem)
         {
             gm.ClearGemOne();
         }
         else if (gm.GetGemTwo() == toggle.AssociatedGem)
         {
             gm.ClearGemTwo();
         }
     }
     Debug.Log("***********************");
     Debug.Log(gm.GetGemOne().ToString());
     Debug.Log(gm.GetGemTwo().ToString());
 }
Example #3
0
 /**
  * Removes toggle from group
  */
 public void UnregisterToggle(GemToggle toggle)
 {
     if (m_Toggles.Contains(toggle))
     {
         m_Toggles.Remove(toggle);
     }
 }
Example #4
0
        /**
         * Adds toggle to group
         */
        public void RegisterToggle(GemToggle toggle)
        {
            //following line used for testing
            //gm.LockAllGems ();


            // Will set  up gem system if hasnt been used before
            gm.CheckFirstGame();

            //will unlock the default gems
            gm.UnlockGem(GemOneDefault);
            gm.UnlockGem(GemTwoDefault);

            if (PlayerPrefs.GetInt("SpiderLevelScene") > 0)
            {
                gm.UnlockGem(Gem.Blue);
            }

            if (PlayerPrefs.GetInt("HeightsLevelScene") > 0)
            {
                gm.UnlockGem(Gem.Turquoise);
            }

            if (PlayerPrefs.GetInt("DarknessLevelScene") > 0)
            {
                gm.UnlockGem(Gem.Yellow);
            }

            if (PlayerPrefs.GetInt("SpiderLevelScene") > 500 &&
                PlayerPrefs.GetInt("HeightsLevelScene") > 500 &&
                PlayerPrefs.GetInt("DarknessLevelScene") > 500)
            {
                gm.UnlockGem(Gem.Purple);
            }


            //will register the default selection to gem manager
            gm.SetDefaultSelection(GemOneDefault, GemTwoDefault);

            Debug.Log(gm.GetDefaultGemOne().ToString() + "  default gem 1");
            Debug.Log(gm.GetDefaultGemTwo().ToString() + "  default gem 2");

            toggle.isOn            = false;
            toggle.LastGemSelected = false;

            //Will set gem toggle state for default gems
            if (toggle.AssociatedGem == gm.GetDefaultGemOne())
            {
                toggle.isOn            = true;
                toggle.LastGemSelected = false;
            }
            else if (toggle.AssociatedGem == gm.GetDefaultGemTwo())
            {
                toggle.isOn            = true;
                toggle.LastGemSelected = true;
            }

            if (!m_Toggles.Contains(toggle))
            {
                m_Toggles.Add(toggle);
            }
        }