Esempio n. 1
0
    public PaintBallTeam GameResult()
    {
        var allTeams = PaintBallTeamManager.Instance.teams;
        int maxPTS   = 0;

        PaintBallTeam winnerTeam = null;

        var firstTeamGamePTS = allTeams[0].gamePoints;

        if (allTeams.All(x => x.gamePoints == firstTeamGamePTS))  //if all our teams have the same pts
        {
            /*            return "Tie!";*/
            return(null);
        }
        else
        {
            foreach (PaintBallTeam team in allTeams)
            {
                if (team.gamePoints >= maxPTS)
                {
                    maxPTS     = team.gamePoints;
                    winnerTeam = team;
                }
            }
            return(winnerTeam);
        }
    }
Esempio n. 2
0
    public GameObject GetTeamPedestal(PaintBallTeam team)
    {
        //we take empty team pedestal
        var myPedestal = team.teamPedestals[team.playersInTeam.Count - 1];

        // we fill pedestalID for future spawn point
        myPedestalIndex = myPedestal.GetComponent <PedestalController>().pedestalID;

        return(myPedestal);
    }
Esempio n. 3
0
    void GameFinishEvent(PaintBallTeam team)
    {
        Debug.Log("Game finished! winning team is: " + team.teamName.ToString() + " !");

        object[]          content           = new object[] { team.teamIndex };
        RaiseEventOptions raiseEventOptions = new RaiseEventOptions {
            Receivers = ReceiverGroup.All
        };

        PhotonNetwork.RaiseEvent(GameEvents.PAINTBALL_GAME_FINISHED, content, raiseEventOptions, SendOptions.SendReliable);
    }
Esempio n. 4
0
    void InitializeTeams()
    {
        var allTEams = Enum.GetValues(typeof(TEAM)).Cast <TEAM>().ToList();

        /*        int arrayIndex = 0;*/

        for (int i = 0; i < allTEams.Count; i++)
        {
            GameObject[] teamPedestals = new GameObject[maxPlayersInTeam];
            pedestals.CopyTo(maxPlayersInTeam * i, teamPedestals, 0, maxPlayersInTeam);
            teams[i] = new PaintBallTeam(teamColors[i], allTEams[i], maxPlayersInTeam, teamPedestals, i);
        }
    }
Esempio n. 5
0
    public PaintBallTeam PickTeam(/*PaintBallPlayer player*/)
    {
        //we check every team
        int           theLessPlayerNum = maxPlayersInTeam;
        PaintBallTeam teamToJoin       = null;

        //if one team has less players than another
        foreach (PaintBallTeam team in teams)
        {
            if (team.playersInTeam.Count < theLessPlayerNum)
            {
                theLessPlayerNum = team.playersInTeam.Count;
                teamToJoin       = team;
            }
        }

        return(teamToJoin);
    }
Esempio n. 6
0
    public PaintBallTeam AddPlayerToTeam(int teamIndex, PaintBallPlayer player)
    {
        PaintBallTeam playerNewTeam = null;

        foreach (var team in teams)
        {
            if (team.teamIndex == teamIndex)
            {
                playerNewTeam = team;
                playerNewTeam.JoinTeam(player);
            }
        }

        if (playerNewTeam == null)
        {
            Debug.LogError("CannotFind team by index");
            return(null);
        }
        else
        {
            return(playerNewTeam);
        }
    }
Esempio n. 7
0
 public void InitializePlayerTeam(PaintBallTeam team, Color teamCol)
 {
     myTeamIndex = team.teamIndex;
     currentTeam = team.teamName;
     teamColor   = teamCol;
 }
Esempio n. 8
0
 public void SetMyPlayerAndMyTeam(PaintBallPlayer player, PaintBallTeam team)
 {
     myPlayer = player;
     myTeam   = team;
 }
Esempio n. 9
0
    public void OnEvent(EventData photonEvent)
    {
        byte eventCode = photonEvent.Code;

        if (eventCode == GameEvents.START_CD_GAME_TIMER)
        {
            //we start timer for everybody as callback
            StartCoroutine(CDbeforeGameRoutine());
        }
        else if (eventCode == GameEvents.START_PAINTBALL_GAME)
        {
            InitializeUI();
            gameIsActive = true;
            StartGameTimer();
        }
        else if (eventCode == GameEvents.HIT_RECIEVED)
        {
            object[] data      = (object[])photonEvent.CustomData;
            int      actorNum  = (int)data[0];
            int      currentHP = (int)data[1];
/*            int dmgAmount = (int)data[2];*/
            int fromTeamId = (int)data[3];

            if (PhotonNetwork.LocalPlayer.ActorNumber == actorNum)
            {
                UpdatePlayerHP(currentHP);
            }

            UpdateOverallScore(fromTeamId);
        }
        else if (eventCode == GameEvents.PAINTBALL_GAME_FINISHED)
        {
            object[] data = (object[])photonEvent.CustomData;

            resultText.gameObject.SetActive(true);


            PaintBallTeam wonTeam = PaintBallGameManager.Instance.GameResult();
            if (wonTeam != null)
            {
                resultText.text  = wonTeam.teamName.ToString() + " team wins!";
                resultText.color = wonTeam.GetTeamColor();
            }
            else if (wonTeam == null)
            {
                resultText.text  = "Tie!";
                resultText.color = Color.green; // other color?
            }

            gameIsActive = false;

            Destroy(this);                                 //let's destroy this, we no longer need it
        }
        else if (eventCode == GameEvents.PLAYER_RESPAWNED) //we use heal ui only to our player
        {
            object[] data      = (object[])photonEvent.CustomData;
            int      currentHP = (int)data[0];
            //full heal player
            UpdatePlayerHP(currentHP);
            ammoFill.fillAmount = 1f; //fill ammo at the same time?
        }
    }
Esempio n. 10
0
 public void SetTeam(PaintBallTeam team)
 {
     teamIndex = team.teamIndex;
     teamName  = team.teamName;
 }