private void FindExactAnimal()
 {
     // if-else structure to determine exact animal type
     if (_player == null)
     {
         _player = _PlayerObj.GetComponent<CatCharacter>();
         if (_player == null)
         {
             _player = _PlayerObj.GetComponent<DogCharacter>();
             if (_player == null)
             {
                 _player = _PlayerObj.GetComponent<RabbitCharacter>();
                 if (_player == null)
                 {
                     _player = _PlayerObj.GetComponent<FoxCharacter>();
                     if (_player == null)
                     {
                         _player = _PlayerObj.GetComponent<PenguinCharacter>();
                         if (_player == null)
                         {
                             _player = _PlayerObj.GetComponent<PandaCharacter>();
                             // if player has not been assigned by this point there was an error
                         }
                     }
                 }
             }
         }
     }
     else
     {
         Debug.LogError("NO PLAYER OBJECT FOUND!");
     }
 }
 public void NextCharacter()
 {
     ResetOutfit();
     ResetRotation();
     GetNextCharacter();
     iAnimal = currentCharacter.GetComponent<IAnimalCharacter>();
     iAnimal.SetandReturnOutfitSystem();
     outfitIndex = 0;
     hatIndex = 0;
     weaponIndex = 0;
     AnimalGameManager manager = FindObjectOfType<AnimalGameManager>();
     manager.PlayerAnimalObject = currentCharacter;
 }
        protected void SetPlayer()
        {
            // clears player reference
            _player = null;
            // determines Player animal type, there should only be 1 player
            // there could possibly be more than 1 animal
            GameObject holder = GameObject.FindGameObjectWithTag("Player");

            // if-else structure to determine exact animal type
            if (_player == null)
            {
                _player = holder.GetComponent<CatCharacter>();
                if (_player == null)
                {
                    _player = holder.GetComponent<DogCharacter>();
                    if (_player == null)
                    {
                        _player = holder.GetComponent<RabbitCharacter>();
                        if (_player == null)
                        {
                            _player = holder.GetComponent<FoxCharacter>();
                            if (_player == null)
                            {
                                _player = holder.GetComponent<PenguinCharacter>();
                                if (_player == null)
                                {
                                    _player = holder.GetComponent<PandaCharacter>();
                                    // if player has not been assigned by this point there was an error
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                Debug.LogError("NO PLAYER OBJECT FOUND!");
            }
            Debug.Log("Player found: " + _player.GetNickName());
        }
 void FixedUpdate()
 {
     if (_player == null)
     {
         _player = FindObjectOfType<Character>();
     }
     else
     {
         //Debug.Log("PLAYER NOT NULL it is: " + _player.GetNickName());
         // keeps player updated to the current visible character in scene
         if (FindObjectOfType<Character>().GetNickName() != null)
             if (_player.GetNickName() != FindObjectOfType<Character>().GetNickName())
                 _player = FindObjectOfType<Character>();
     }
     // NOTE: if player is still null at this point it should be spawned and loaded
 }
        void Awake()
        {
            Debug.Log("The Animal Game Manager Awakens");
            // creates a singleton
            if (_manager == null)
            {
                DontDestroyOnLoad(gameObject);
                _manager = this;
            }
            else if (_manager != this)
            {
                Destroy(gameObject);
            }
            // adds spawner
            _playerSpawner = gameObject.AddComponent<PlayerSpawner>();
            // clears player reference
            _player = null;
            // loads player's info
            _newGame = !Load();

            if (_player == null)
            {
                Debug.Log("THE PLAYER IS NULL");
            }
            else
            {
                Debug.Log("PLAYER NOT NULL");
            }
        }
 // Use this for initialization
 void Start()
 {
     characterIndex = 0;
     outfitIndex = 0;
     hatIndex = 0;
     weaponIndex = 0;
     characters = GameObject.FindGameObjectsWithTag("Player");
     currentCharacter = characters[characterIndex];
     SetCharactersInactive();
     iAnimal = currentCharacter.GetComponent<IAnimalCharacter>();
     iAnimal.SetandReturnOutfitSystem();
 }
Beispiel #7
0
 void SetupController()
 {
     playerHealth = player.GetComponent<PlayerHealth>();
     iAnimal = player.GetComponent<IAnimalCharacter>();
     healthBarSlider = FindObjectOfType<Slider>();
 }