示例#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);
    }
 private void SetupMultiPlayer(int highestScore)
 {
     for (int i = 0; i < Scores.Count; i++)
     {
         if (Scores[i] > 0)
         {
             ScoreBar temp = Instantiate(ScoreBarBase, P_Scoring.transform).GetComponent <ScoreBar>();
             temp.SetNewBarColour(PlayerColourContainer.GetPlayerColour(i + 1));
             temp.Begin(Scores[i], (float)Scores[i] / (float)highestScore, BarRiseAnimationTime, Scores[i] > Highscore && Scores[i] == highestScore, Scores[i] == highestScore, 0.1f);
         }
     }
 }
 private void Awake()
 {
     if (_Instance == null)
     {
         _Instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Debug.LogWarning("PlayerColourContainer | Awake | A second PlayerColourContainer was initialized, please make sure that there will be only one in a scene.");
         Destroy(this);
     }
 }
示例#4
0
    public void Init(int player, Animator character, Flag flag)
    {
        _Character      = character;
        _CharacterStart = _Character.transform.position;
        _CharacterEnd   = new Vector3(-_CharacterStart.x, _CharacterStart.y, _CharacterStart.z);

        stepCount = Convert.ToInt16(GlobalGameSettings.GetSetting("Steps"));

        Flag   = flag;
        _Team  = player;
        _Color = PlayerColourContainer.GetPlayerColour(_Team + 1);
        button.Init(this, _Color);
    }
    private void SetupSinglePlayer(int playerNr)
    {
        int highestScore;

        if (Scores[playerNr] > _Highscore.Highscores[_LevelIndex])
        {
            highestScore = Scores[playerNr];
        }
        else
        {
            highestScore = _Highscore.Highscores[_LevelIndex];
        }
        ScoreBar temp = Instantiate(ScoreBarBase, P_Scoring.transform).GetComponent <ScoreBar>();

        temp.SetNewBarColour(PlayerColourContainer.GetPlayerColour(playerNr + 1));
        temp.Begin(Scores[playerNr], (float)Scores[playerNr] / (float)highestScore, BarRiseAnimationTime, Scores[playerNr] > _Highscore.Highscores[_LevelIndex], Scores[playerNr] > _Highscore.Highscores[_LevelIndex], 0.1f);

        temp = Instantiate(ScoreBarBase, P_Scoring.transform).GetComponent <ScoreBar>();
        temp.SetNewBarColour(PlayerColourContainer.GetPlayerColour(0));
        temp.Begin(_Highscore.Highscores[_LevelIndex], (float)_Highscore.Highscores[_LevelIndex] / (float)highestScore, BarRiseAnimationTime, false, false, 0.1f);
    }
    private void SetupSinglePlayer(int playerNr, bool _TimeGame)
    {
        int highestScore;

        if (_TimeGame == false)
        {
            if (Scores[playerNr] > Highscore)
            {
                highestScore = Scores[playerNr];
            }
            else
            {
                highestScore = Highscore;
            }
        }
        else if (_TimeGame == true && Highscore != 0)
        {
            if (Scores[playerNr] < Highscore)
            {
                highestScore = Scores[playerNr];
            }
            else
            {
                highestScore = Highscore;
            }
        }
        else
        {
            highestScore = Scores[playerNr];
        }
        ScoreBar temp = Instantiate(ScoreBarBase, P_Scoring.transform).GetComponent <ScoreBar>();

        temp.SetNewBarColour(PlayerColourContainer.GetPlayerColour(playerNr + 1));
        if (_TimeGame == true && Highscore != 0)
        {
            if (Scores[playerNr] < highestScore)
            {
                temp.Begin(Scores[playerNr], (float)Scores[playerNr] / (float)highestScore, BarRiseAnimationTime, Scores[playerNr] < Highscore, Scores[playerNr] < Highscore, 0.1f);
            }
            else
            {
                temp.Begin(Scores[playerNr], (float)highestScore / (float)Scores[playerNr], BarRiseAnimationTime, Scores[playerNr] < Highscore, Scores[playerNr] < Highscore, 0.1f);
            }
        }
        else if (highestScore != 0)
        {
            temp.Begin(Scores[playerNr], (float)Scores[playerNr] / (float)highestScore, BarRiseAnimationTime, Scores[playerNr] > Highscore, Scores[playerNr] > Highscore, 0.1f);
        }
        temp = Instantiate(ScoreBarBase, P_Scoring.transform).GetComponent <ScoreBar>();
        temp.SetNewBarColour(PlayerColourContainer.GetPlayerColour(0));
        if (_TimeGame == false && Highscore != 0)
        {
            temp.Begin(Highscore, (float)Highscore / (float)highestScore, BarRiseAnimationTime, false, false, 0.1f);
        }
        else if (Highscore != 0)
        {
            if (Scores[playerNr] < highestScore)
            {
                temp.Begin(Highscore, (float)Highscore / (float)highestScore, BarRiseAnimationTime, false, false, 0.1f);
            }
            else
            {
                temp.Begin(Highscore, (float)highestScore / (float)Highscore, BarRiseAnimationTime, false, false, 0.1f);
            }
        }
    }