Example #1
0
 /// <summary>
 /// Init this instance.
 /// </summary>
 protected virtual void Init()
 {
     if (character == null)
     {
         character = GameObject.FindObjectOfType <Character>();
     }
     if (character == null)
     {
         characterLoader = CharacterLoader.GetCharacterLoader();
         if (characterLoader != null)
         {
             characterLoader.CharacterLoaded += HandleCharacterLoaded;
         }
         else
         {
             Debug.LogWarning("Game over screen cannot find a Character.");
         }
     }
     else if (autoShowOnGameOver)
     {
         characterHealth = character.GetComponentInChildren <CharacterHealth>();
         if (characterHealth)
         {
             characterHealth.GameOver += HandleGameOver;
         }
         else
         {
             Debug.LogWarning("Game over screen cannot be auto shown as it could not find a ChracterHealth");
         }
     }
 }
Example #2
0
 /// <summary>
 /// Init this instance.
 /// </summary>
 virtual protected void Init()
 {
     counterText = GetComponent <Text> ();
     if (characterHealth == null)
     {
         characterHealth = FindObjectOfType <CharacterHealth>();
         if (characterHealth == null)
         {
             characterLoader = CharacterLoader.GetCharacterLoader();
             if (characterLoader != null)
             {
                 characterLoader.CharacterLoaded += HandleCharacterLoaded;
             }
             else
             {
                 Debug.LogError("Couldn't find a character health or a character loader");
             }
         }
     }
     if (characterHealth != null)
     {
         characterHealth.Died      += HandleChange;
         characterHealth.Loaded    += HandleChange;
         characterHealth.GainLives += HandleChange;
     }
 }
Example #3
0
 /// <summary>
 /// Init this instance.
 /// </summary>
 virtual protected void Init()
 {
     images = GetComponentsInChildren <Image> ();
     if (images == null || images.Length == 0)
     {
         Debug.LogWarning("No health images found by UIHealth_Icons. These should be children of the UIHealth_Icons GameObject.");
     }
     else if (sprites == null || sprites.Length == 0)
     {
         Debug.LogWarning("No health images found.");
     }
     else
     {
         if (characterHealth == null)
         {
             // No health assigned try to find one
             if (characterLoader == null)
             {
                 characterLoader = CharacterLoader.GetCharacterLoader();
             }
             if (characterLoader != null)
             {
                 characterLoader.CharacterLoaded += HandleCharacterLoaded;
             }
             else
             {
                 characterHealth = GameObject.FindObjectOfType <CharacterHealth> ();
                 if (characterHealth == null)
                 {
                     Debug.LogWarning("Couldn't find a character health!");
                 }
             }
         }
         if (characterHealth != null)
         {
             if (images.Length * sprites.Length != characterHealth.MaxHealth)
             {
                 Debug.LogWarning("Number of images times number of sprites should match the MaxHealth");
             }
         }
     }
     if (characterHealth != null)
     {
         RegisterListeners();
     }
 }
 virtual protected void Init()
 {
     barImage = GetComponent <Image> ();
     if (characterHealth == null)
     {
         // No health assigned try to find one
         if (characterLoader == null)
         {
             characterLoader = CharacterLoader.GetCharacterLoader();
         }
         if (characterLoader != null)
         {
             characterLoader.CharacterLoaded += HandleCharacterLoaded;
         }
         else
         {
             characterHealth = GameObject.FindObjectOfType <CharacterHealth> ();
             if (characterHealth == null)
             {
                 Debug.LogWarning("Couldn't find a character health!");
             }
         }
     }
 }