示例#1
0
 /// <summary>
 /// Instantiates all the playable characters and feeds them to the gameManager
 /// </summary>
 protected virtual void InstantiateCharacters()
 {
     /// we go through the list of playable characters and instantiate them while adding them to the game manager
     GameManager.Instance.CurrentPlayableCharacters = new List <PlayableCharacter>();
     // for each character in the PlayableCharacters list
     for (int i = 0; i < PlayableCharacters.Count; i++)
     {
         // we instantiate the corresponding prefab
         PlayableCharacter instance = (PlayableCharacter)Instantiate(PlayableCharacters[i]);
         // we position it based on the StartingPosition point
         instance.transform.position = new Vector2(StartingPosition.transform.position.x + i * DistanceBetweenCharacters, StartingPosition.transform.position.y);
         // we set manually its initial position
         instance.SetInitialPosition(instance.transform.position);
         // we feed it to the game manager
         GameManager.Instance.CurrentPlayableCharacters.Add(instance);
     }
 }
示例#2
0
        /// <summary>
        /// Instantiates all the playable characters and feeds them to the gameManager
        /// </summary>
        protected virtual void InstantiateCharacters()
        {
            CurrentPlayableCharacters = new List <PlayableCharacter>();
            /// we go through the list of playable characters and instantiate them while adding them to the list we'll use from any class to access the
            /// currently playable characters

            // we check if there's a stored character in the game manager we should instantiate
            if (CharacterSelectorManager.Instance.StoredCharacter != null)
            {
                PlayableCharacter newPlayer = (PlayableCharacter)Instantiate(CharacterSelectorManager.Instance.StoredCharacter, StartingPosition.transform.position, StartingPosition.transform.rotation);
                newPlayer.name = CharacterSelectorManager.Instance.StoredCharacter.name;
                newPlayer.SetInitialPosition(newPlayer.transform.position);
                CurrentPlayableCharacters.Add(newPlayer);
                MMEventManager.TriggerEvent(new MMGameEvent("PlayableCharactersInstantiated"));
                return;
            }

            if (PlayableCharacters == null)
            {
                return;
            }

            if (PlayableCharacters.Count == 0)
            {
                return;
            }

            // for each character in the PlayableCharacters list
            for (int i = 0; i < PlayableCharacters.Count; i++)
            {
                // we instantiate the corresponding prefab
                PlayableCharacter instance = (PlayableCharacter)Instantiate(PlayableCharacters[i]);
                // we position it based on the StartingPosition point
                instance.transform.position = new Vector3(StartingPosition.transform.position.x + i * DistanceBetweenCharacters, StartingPosition.transform.position.y, StartingPosition.transform.position.z);
                // we set manually its initial position
                instance.SetInitialPosition(instance.transform.position);
                // we feed it to the game manager
                CurrentPlayableCharacters.Add(instance);
            }
            MMEventManager.TriggerEvent(new MMGameEvent("PlayableCharactersInstantiated"));
        }