Exemple #1
0
    private void Start()
    {
        playerCount = int.Parse(GlobalGameSettings.GetSetting("Players"));

        for (int i = 0; i < playerCount; i++)
        {
            TeamCharacter player = Instantiate(teamPrefab, teamContainer);
            player.Init(i, charContainer.GetChild(i).GetComponent <Animator>(),
                        flagContainer.GetChild(i).GetComponent <Flag>());

            player.doneEvent.AddListener(TeamFinished);

            teams.Add(player);
        }

        for (int i = playerCount; i < 4; i++)
        {
            Destroy(charContainer.GetChild(i).gameObject);
        }

        for (int i = 0; i < charContainer.childCount; i++)
        {
            charContainer.GetChild(i).GetComponent <CharacterColor>()
            .SetColor(PlayerColourContainer.GetPlayerColour(i + 1));
        }

        timer.TimerRanOut.AddListener(TimeUp);
    }
        public override ICharacter CreateCharacter(Vector3 position, string team, LevelDataBase levelData, float difficultyModifier, params ICharacterPreset[] characterPresets)
        {
            if (characterPresets.Length == 0)
            {
                return(new NullCharacter());
            }
            if (characterPresets.Length == 1)
            {
                return(CreateSingleCharacter(position, team, levelData, characterPresets[0], difficultyModifier));
            }

            List <ICharacter> characters = new List <ICharacter>();

            foreach (ICharacterPreset preset in characterPresets)
            {
                characters.Add(CreateSingleCharacter(position, team, levelData, preset, difficultyModifier));
            }
            GameObject    teamCharacter = new GameObject();
            TeamCharacter character     = teamCharacter.AddComponent <TeamCharacter>();

            character.Init(characters);
            return(character);
        }