コード例 #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);
    }
コード例 #2
0
    private void TeamFinished(TeamCharacter winner)
    {
        _CurrentPlace++;
        winner.Flag.Init(_CurrentPlace, timer.TimePassed);
        winner.GetButton().gameObject.SetActive(false);
        audioSource.Play();

        if (_CurrentPlace >= playerCount)
        {
            timer.PauseTimer(true);
            replayButton.gameObject.SetActive(true);
        }
    }
コード例 #3
0
        // Add Character to team
        public bool AddCharacterToTeam(int characterId, int teamId)
        {
            TeamCharacter teamCharacter = new TeamCharacter
            {
                UserId      = _userId,
                CharacterId = characterId,
                TeamId      = teamId
            };

            using (var ctx = new ApplicationDbContext())
            {
                ctx.TeamCharacters.Add(teamCharacter);
                return(ctx.SaveChanges() == 1);
            }
        }
コード例 #4
0
    public void Awake()
    {
        if (characters != null)
        {
            return;
        }

        characters = new TeamCharacter[4];

        for (int i = 0; i < (int)Teams.count; i++)
        {
            characters[i]      = new TeamCharacter();
            characters[i].name = ((Teams)i).ToString();
        }

        Save();
    }
コード例 #5
0
        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);
        }
コード例 #6
0
 public void Init(TeamCharacter teamCharacter, Color color)
 {
     image.color = color;
     hitEvent.AddListener(teamCharacter.Hit);
 }
コード例 #7
0
 public void SetTeam(int teamId)
 {
     currentTeamCharacter = characters[teamId];
 }
コード例 #8
0
 public void AddCharacter(int teamId, TeamCharacter teamChar)
 {
     characters[teamId] = teamChar;
 }