Esempio n. 1
0
 /// <summary>
 /// Event called on game end. Sends data to server.
 /// </summary>
 /// <param name="winner">Winner team.</param>
 public void OnGameEnded(TeamTypes winner)
 {
     if (playerControlled)
     {
         networkLayer.OnGameEnded(winner);
     }
 }
Esempio n. 2
0
    /// <summary>
    /// Initializes AI. Gets all references, and starts moving.
    /// </summary>
    public void StartAI()
    {
        playerManager = this.GetComponent <PlayerManager>();
        myProperties  = this.GetComponent <PlayerProperties>();
        navMeshAgent  = this.GetComponent <NavMeshAgent>();

        navMeshAgent.speed = myProperties.actualMovSpd;

        controlledLocally = true;

        this.FindNewPoint();

        gamePanels = GameController.instance.GetGamePanels();

        int enemyID = playerManager.myTeam.GetHashCode();

        enemyID++;
        if (enemyID > TeamTypes.Orange.GetHashCode())
        {
            enemyID = 0;
        }

        enemyTeam  = (TeamTypes)enemyID;
        enemyTower = GameController.instance.GetTower(enemyTeam);

        enemies = GameController.instance.GetPlayersOfTeam(enemyTeam);
    }
    /// <summary>
    /// Callback used when the player successfully joins a room.
    /// </summary>
    public void OnJoinedRoom()
    {
        playersInRoom = new List <PhotonPlayer>(PhotonNetwork.playerList);
        myTeam        = (TeamTypes)((playersInRoom.Count + 1) % 2);


        ExitGames.Client.Photon.Hashtable properties = new ExitGames.Client.Photon.Hashtable();
        properties.Add("Team", myTeam.GetHashCode());
        properties.Add("Character", myCharacter.GetHashCode());
        properties.Add("PlayFabID", PlayFabManager.instance.GetMyPlayerID());

        bool containsOwner = false;

        for (int i = 0; i < PhotonNetwork.otherPlayers.Length; i++)
        {
            object ownerName;
            if (PhotonNetwork.otherPlayers[i].customProperties.TryGetValue("Owner", out ownerName))
            {
                containsOwner = true;
                break;
            }
        }
        if (!containsOwner)
        {
            properties.Add("Owner", PhotonNetwork.player.name);
        }
        PhotonNetwork.player.SetCustomProperties(properties);

        myRoomInfo = PhotonNetwork.room;

        OnJoinedRoomCallback(PhotonNetwork.room);
    }
Esempio n. 4
0
    public void ChangeTeam(bool syncNetwork)
    {
        if (ready)
        {
            return;
        }

        Debug.Log("change team from " + selectedTeam);
        int newID = selectedTeam.GetHashCode();

        newID++;
        if (newID > TeamTypes.Orange.GetHashCode())
        {
            newID = 0;
        }

        TeamTypes newTeam = (TeamTypes)newID;

        if (teamsCount[newTeam.GetHashCode()] == PhotonNetwork.room.maxPlayers / 2)
        {
            return;
        }

        if (newTeam != selectedTeam)
        {
            selectedTeam = newTeam;
            this.RebuildAvatarTextures();

            MultiplayerRoomsManager.instance.ChangeTeam(selectedTeam, syncNetwork);
        }
    }
Esempio n. 5
0
 /// <summary>
 /// Gets random spawn point from team. Used to handle player respawn.
 /// </summary>
 /// <param name="team">Team to get spawn point.</param>
 /// <returns>Random spawn point position.</returns>
 public Vector3 GetRandomSpawnPoint(TeamTypes team)
 {
     if (team == TeamTypes.Blue)
     {
         return(blueSpawnPoints[Random.Range(0, blueSpawnPoints.Length)].transform.position);
     }
     else
     {
         return(orangeSpawnPoints[Random.Range(0, blueSpawnPoints.Length)].transform.position);
     }
 }
Esempio n. 6
0
 /// <summary>
 /// Gets specific tower from team.
 /// </summary>
 /// <param name="team">Tower's team.</param>
 /// <returns>Tower from the team.</returns>
 public TowerManager GetTower(TeamTypes team)
 {
     for (int i = 0; i < gameTowers.Length; i++)
     {
         if (gameTowers[i].myTeam == team)
         {
             return(gameTowers[i]);
         }
     }
     return(null);
 }
Esempio n. 7
0
    /// <summary>
    /// Allocates a new ViewID from Photon, and sends message to instantiate a new character.
    /// </summary>
    /// <param name="myCharacter">Character prefab to use.</param>
    public void AllocateViewIDAndCallInstantiate(CharacterTypes myCharacter, TeamTypes team)
    {
        if (!enteredGame)
        {
            enteredGame = true;

            int myID = PhotonNetwork.AllocateViewID();

            view.RPC("InstantiateObject", PhotonTargets.AllBuffered, myID, myCharacter.GetHashCode(), team.GetHashCode(), PlayFabManager.instance.GetMyPlayerID(), PlayFabManager.instance.playerDisplayName);
        }
    }
Esempio n. 8
0
 public void UpdateTowerLife(TeamTypes towerTeam, float actualHP, float totalHP)
 {
     if (towerTeam == playerTeam)
     {
         myTeamTowerLifebar.fillAmount = (float)actualHP / (float)totalHP;
     }
     else
     {
         enemyTeamTowerLifebar.fillAmount = (float)actualHP / (float)totalHP;
     }
 }
Esempio n. 9
0
 public void UpdateKillcount(TeamTypes team, int amount)
 {
     if (team == playerTeam)
     {
         myTeamKillcount.text = amount.ToString();
     }
     else
     {
         enemyTeamKillcount.text = amount.ToString();
     }
 }
    /// <summary>
    /// Allocates a new ViewID from Photon, and sends message to instantiate a new character.
    /// </summary>
    /// <param name="myCharacter">Character prefab to use.</param>
    public void AllocateViewIDAndCallInstantiate(CharacterTypes myCharacter,TeamTypes team)
    {
        if (!enteredGame)
        {
            enteredGame = true;

            int myID = PhotonNetwork.AllocateViewID();

            view.RPC("InstantiateObject", PhotonTargets.AllBuffered, myID, myCharacter.GetHashCode(), team.GetHashCode(),PlayFabManager.instance.GetMyPlayerID(),PlayFabManager.instance.playerDisplayName);
        }
    }
Esempio n. 11
0
    void CheckMyPlayerProperties(string playerName, TeamTypes playerTeam, CharacterTypes playerChar)
    {
        if (selectedTeam != playerTeam)
        {
            this.ChangeTeam(false);
        }

        if (selectedCharacter != playerChar)
        {
            this.SelectChar(playerChar.ToString(), false);
        }
    }
    /// <summary>
    /// Rotates player between teams.
    /// </summary>
    public void ChangeTeam(TeamTypes newTeam, bool syncNetwork)
    {
        myTeam = newTeam;

        ExitGames.Client.Photon.Hashtable properties = new ExitGames.Client.Photon.Hashtable();
        properties.Add("Team", myTeam.GetHashCode());
        PhotonNetwork.player.SetCustomProperties(properties);

        if (syncNetwork)
        {
            networkLayer.OnPropertiesChanged();
        }
    }
    /// <summary>
    /// Activates all effects, sets properties, and calls for deactivate after a certain amount of time.
    /// </summary>
    /// <param name="willTestCollisions">Is network owner?</param>
    /// <param name="shotStrength">Amount to take from player's life, if hit.</param>
    public void Shoot(bool willTestCollisions, float shotStrength, TeamTypes towerTeam)
    {
        this.testCollisions = willTestCollisions;
        this.shotStrength = shotStrength;
        this.towerTeam = towerTeam;

        for (int i = 0; i < effectsToActivate.Length; i++)
        {
            effectsToActivate[i].SetActive(true);
        }

        Invoke("DeactivateEffects", 1.2f);
    }
Esempio n. 14
0
    /// <summary>
    /// Activates all effects, sets properties, and calls for deactivate after a certain amount of time.
    /// </summary>
    /// <param name="willTestCollisions">Is network owner?</param>
    /// <param name="shotStrength">Amount to take from player's life, if hit.</param>
    public void Shoot(bool willTestCollisions, float shotStrength, TeamTypes towerTeam)
    {
        this.testCollisions = willTestCollisions;
        this.shotStrength   = shotStrength;
        this.towerTeam      = towerTeam;

        for (int i = 0; i < effectsToActivate.Length; i++)
        {
            effectsToActivate[i].SetActive(true);
        }

        Invoke("DeactivateEffects", 1.2f);
    }
Esempio n. 15
0
 /// <summary>
 /// Reports a kill from a specific team.
 /// </summary>
 /// <param name="team">Team who killed a player.</param>
 public void ReportKill(TeamTypes team)
 {
     if (team == TeamTypes.Blue)
     {
         blueTeamKillCount++;
         GameplayUI.instance.UpdateKillcount(team, blueTeamKillCount);
     }
     else
     {
         orangeTeamKillCount++;
         GameplayUI.instance.UpdateKillcount(team, orangeTeamKillCount);
     }
 }
Esempio n. 16
0
 /// <summary>
 /// Gets all players from a determined team.
 /// </summary>
 /// <param name="team">Team to get players from.</param>
 /// <returns>Players array, containing all that belong to the team.</returns>
 public PlayerManager[] GetPlayersOfTeam(TeamTypes team)
 {
     PlayerManager[] playersOfTeam = new PlayerManager[0];
     for (int i = 0; i < players.Length; i++)
     {
         if (players[i].myTeam == team)
         {
             System.Array.Resize <PlayerManager>(ref playersOfTeam, playersOfTeam.Length + 1);
             playersOfTeam[playersOfTeam.Length - 1] = players[i];
         }
     }
     return(playersOfTeam);
 }
Esempio n. 17
0
        /// <summary>
        /// Ensure that the database has the seeded values
        /// </summary>
        public void EnsureSeedData()
        {
            foreach (var type in Enum.GetValues(typeof(TeamType)).Cast <TeamType>())
            {
                var entry = TeamTypes.SingleOrDefault(t => t.Type == type);
                if (entry != null)
                {
                    // Database entry for enum value mismatch
                    if (entry.Name != Enum.GetName(typeof(TeamType), type))
                    {
                        throw new Exception("Database mapping to enum is incorrect");
                    }
                }
                else
                {
                    TeamTypes.Add(
                        new TeamTypeEntry
                    {
                        Type = type,
                        Name = Enum.GetName(typeof(TeamType), type)
                    });
                }
            }

            foreach (var type in Enum.GetValues(typeof(PositionType)).Cast <PositionType>())
            {
                var entry = PositionTypes.SingleOrDefault(t => t.Type == type);
                if (entry != null)
                {
                    // Database entry for enum value mismatch
                    if (entry.Name != Enum.GetName(typeof(PositionType), type))
                    {
                        throw new Exception("Database mapping to enum is incorrect");
                    }
                }
                else
                {
                    PositionTypes.Add(
                        new PositionTypeEntry
                    {
                        Type = type,
                        Name = Enum.GetName(typeof(PositionType), type)
                    });
                }
            }

            SaveChanges();
        }
    /// <summary>
    /// Creates bullet buffer.
    /// </summary>
    public void CreateBuffer(TeamTypes myTeam)
    {
        unusedBullets = new Bullet[bufferSize];
        usedBullets = new Bullet[bufferSize];


        int playerPhotonID = this.GetComponent<PhotonView>().viewID;
        GameObject _obj;
        for (int i = 0; i < unusedBullets.Length; i++)
        {
            _obj = (GameObject)GameObject.Instantiate(bulletPrefabs[myTeam.GetHashCode()]);
            _obj.name = "Player" + playerPhotonID + "Bullet" + i;
            unusedBullets[i] = _obj.GetComponent<Bullet>();
            unusedBullets[i].Setup(this);
            _obj.SetActive(false);
        }
    }
Esempio n. 19
0
    /// <summary>
    /// Creates bullet buffer.
    /// </summary>
    public void CreateBuffer(TeamTypes myTeam)
    {
        unusedBullets = new Bullet[bufferSize];
        usedBullets   = new Bullet[bufferSize];


        int        playerPhotonID = this.GetComponent <PhotonView>().viewID;
        GameObject _obj;

        for (int i = 0; i < unusedBullets.Length; i++)
        {
            _obj             = (GameObject)GameObject.Instantiate(bulletPrefabs[myTeam.GetHashCode()]);
            _obj.name        = "Player" + playerPhotonID + "Bullet" + i;
            unusedBullets[i] = _obj.GetComponent <Bullet>();
            unusedBullets[i].Setup(this);
            _obj.SetActive(false);
        }
    }
Esempio n. 20
0
    /// <summary>
    /// Not finished
    /// </summary>
    /// <param name="newTeam"></param>
    /// <param name="StartingPos"></param>
    /// <param name="TeamID"></param>
    public void AddTeam(TeamTypes newTeam, Vector2 StartingPos, int TeamID)
    {
        BaseAITeam nTeam = null;// = Instantiate(Resources.Load<BaseAITeam>("TeamPrefabs/BaseTeam"));

        switch (newTeam)
        {
        case TeamTypes.Utility:
        default:
            GameObject Temp = (GameObject)Instantiate(Resources.Load("TeamPrefabs/" + newTeam.ToString()));
            nTeam = Temp.GetComponent <BaseAITeam>();
            break;
        }

        nTeam.StartingLocation = StartingPos;
        nTeam.TeamID           = TeamID;
        nTeam.transform.SetParent(transform);
        Teams.Add(nTeam);
    }
Esempio n. 21
0
    /// <summary>
    /// Start method. Gets all references.
    /// </summary>
    public void StartPlayer(bool playerControlled, TeamTypes myTeam, string playerPlayFabID, string playFabName)
    {
        this.playerPlayFabID   = playerPlayFabID;
        this.myTeam            = myTeam;
        this.playerControlled  = playerControlled;
        this.playerPlayFabName = playFabName;

        myProperties     = this.GetComponent <PlayerProperties>();
        networkLayer     = this.GetComponent <PlayerNetworkLayer>();
        animationManager = this.GetComponent <PlayerAnimationManager>();
        shooterManager   = this.GetComponent <ShooterManager>();
        aiManager        = this.GetComponent <PlayerAIManager>();

        shooterManager.CreateBuffer(myTeam);

        myTower = GameController.instance.GetTower(myTeam);

        playerExp = playerLevel = 0;

        myProperties.Initialize();

        baseSprite.color = spriteTeamColors[myTeam.GetHashCode()];

        Debug.Log("initializing player. is human? " + playerControlled + " is local? " + networkLayer.isMine);
        if (networkLayer.isMine)
        {
            if (playerControlled)
            {
                Camera.main.transform.SetParent(this.transform, true);

                //levelText = GameController.instance.GetLevelText();
                expText = GameController.instance.GetExpText();

                GameplayUI.instance.Initialize(myTeam, this);
                GameplayUI.instance.UpdateSidebarStats(myProperties);

                InGameStoreAndCurrencyManager.instance.SetUpgradesCallbacks(new ProjectDelegates.OnPlayerBoughtStatUpgradeCallback[] {
                    myProperties.IncreaseAtk, myProperties.IncreaseMovSpd, myProperties.IncreaseHP
                });
            }

            this.transform.position = GameController.instance.GetRandomSpawnPoint(myTeam);
        }
    }
Esempio n. 22
0
    /// <summary>
    /// Checks the abount of alive entities by team in a list and returns the amount
    /// </summary>
    /// <param name="_pool"></param>
    /// <param name="_team"></param>
    /// <returns></returns>
    public int CheckAmountEntitiesAlive(List <GameObject> _pool, TeamTypes _team)
    {
        int _amount = 0;

        for (int _i = 0; _i < _pool.Count; _i++)
        {
            GameObject _obj = _pool[_i];

            if (_obj != null && _obj.GetComponent <Entity>() != null && _obj.GetComponent <Entity>().teamCurrent == _team && _obj.GetComponent <Entity>().entityStateCurrent == EntityStates.Alive)
            {
                //Increase the amount
                _amount++;
            }
        }

        print("Entities Alive: " + _amount.ToString());

        return(_amount);
    }
Esempio n. 23
0
    /// <summary>
    /// Reports a new win to PlayFab, sends push to losers.
    /// </summary>
    public void ReportWin()
    {
        if (networkLayer.isMine && playerControlled)
        {
            GameplaySFXManager.instance.PlayWinSound();
            AccountManager.instance.winsAmount++;
            PlayFabManager.instance.ReportWins(AccountManager.instance.winsAmount);

            TeamTypes otherTeam = myTeam == TeamTypes.Blue ? TeamTypes.Orange : TeamTypes.Blue;

            PlayerManager[] losers = GameController.instance.GetPlayersOfTeam(otherTeam);

            for (int i = 0; i < losers.Length; i++)
            {
                if (losers[i].playerPlayFabID.Length > 0)
                {
                    //TO DO: add Cloud Script to do this
                    // PlayFabManager.instance.SendPush(losers[i].playerPlayFabID, PlayFabManager.instance.playerUsername + " has just defeated you!");
                }
            }
        }
    }
Esempio n. 24
0
    /// <summary>
    /// Finishes the game.
    /// </summary>
    public void FinishGame(TeamTypes winner)
    {
        if (actualState == GameStates.EndGame)
        {
            return;
        }

        blackFadeout.SetActive(true);

        actualState = GameStates.EndGame;

        Debug.Log("FinishGame");
        for (int i = 0; i < players.Length; i++)
        {
            if (players[i] == null)
            {
                continue;
            }

            players[i].ReportKills();
            players[i].GiveExpToAccount();

            if (players[i].myTeam == winner)
            {
                players[i].ReportWin();
            }
            else
            {
                players[i].LoseGame();
            }

            players[i].OnGameEnded(winner);
        }

        Invoke("DisableCamera", 1f);
    }
Esempio n. 25
0
    /// <summary>
    /// Checks if the game has ended. Game ends if a team has no more towers and players alive.
    /// </summary>
    public void CheckEndGame()
    {
        for (int i = 0; i < gameTowers.Length; i++)
        {
            if (gameTowers[i].actualState == TowerStates.Dead)
            {
                bool anyoneAlive = false;
                for (int j = 0; j < players.Length; j++)
                {
                    if (players[j].myTeam == gameTowers[i].myTeam)
                    {
                        if (players[j].actualState != PlayerStates.Dead)
                        {
                            anyoneAlive = true;
                            break;
                        }
                    }
                }

                if (!anyoneAlive)
                {
                    int winnerTeamID = gameTowers[i].myTeam.GetHashCode() + 1;
                    if (winnerTeamID > 1)
                    {
                        winnerTeamID = 0;
                    }

                    TeamTypes winnerTeam = (TeamTypes)winnerTeamID;

                    this.FinishGame(winnerTeam);

                    EndGameScreen.winnerTeam = winnerTeam;
                }
            }
        }
    }
 protected override void RunCommand(IEnumerable <string> args)
 {
     listImpl(animal => !TeamTypes.ForTeam(animal.GetPropertyValue <int>("TargetingTeam")).IsTamed(), args);
 }
Esempio n. 27
0
    public void Initialize(TeamTypes myTeam, PlayerManager playerToUpdate)
    {
        this.playerToUpdate = playerToUpdate;

        this.playerTeam = myTeam;
    }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="team"></param>
        /// <param name="week"></param>
        /// <param name="season"></param>
        /// <returns></returns>
        public PlayerGames GetByTeamAndWeek(TeamTypes team, int season, int week)
        {
            string url = string.Format("/{0}/{1}/{2}/{3}", PlayerGameStatsByTeamKey, season, week, team.ToString());

              return GetRequest<PlayerGames>(url);
        }
Esempio n. 29
0
 public void SetTeam(TeamTypes team)
 {
     spawnedByTeam = team;
 }
        public async Task<News> GetForTeamAsync(TeamTypes team)
        {
            var url = string.Format("/{0}/{1}", NewsByTeamKey, team.ToString());

            return await this.GetRequestAsync<News>(url);
        }
 /// <summary>
 /// Gets all players from a determined team.
 /// </summary>
 /// <param name="team">Team to get players from.</param>
 /// <returns>Players array, containing all that belong to the team.</returns>
 public PlayerManager[] GetPlayersOfTeam(TeamTypes team)
 {
     PlayerManager[] playersOfTeam = new PlayerManager[0];
     for (int i = 0; i < players.Length; i++)
     {
         if (players[i].myTeam == team)
         {
             System.Array.Resize<PlayerManager>(ref playersOfTeam, playersOfTeam.Length + 1);
             playersOfTeam[playersOfTeam.Length - 1] = players[i];
         }
     }
     return playersOfTeam;
 }
Esempio n. 32
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="team"></param>
        /// <param name="week"></param>
        /// <param name="season"></param>
        /// <returns></returns>
        public Injuries GetByWeekAndTeam(TeamTypes team, string season, int week)
        {
            string url = string.Format("/{0}/{1}/{2}/{3}", InjuriesKey, season, week, team.ToString());

            return(GetRequest <Injuries>(url));
        }
 /// <summary>
 /// Gets specific tower from team.
 /// </summary>
 /// <param name="team">Tower's team.</param>
 /// <returns>Tower from the team.</returns>
 public TowerManager GetTower(TeamTypes team)
 {
     for (int i = 0; i < gameTowers.Length; i++)
     {
         if (gameTowers[i].myTeam == team)
         {
             return gameTowers[i];
         }
     }
     return null;
 }
    /// <summary>
    /// Finishes the game.
    /// </summary>
    public void FinishGame(TeamTypes winner)
    {
		if (actualState == GameStates.EndGame)
			return;

        blackFadeout.SetActive(true);

        actualState = GameStates.EndGame;

        Debug.Log("FinishGame");
        for (int i = 0; i < players.Length; i++)
        {
			if(players[i] == null) continue;

            players[i].ReportKills();
            players[i].GiveExpToAccount();

            if (players[i].myTeam == winner)
            {
                players[i].ReportWin();
            }
            else
            {
                players[i].LoseGame();
            }

			players[i].OnGameEnded(winner);
        }

        Invoke("DisableCamera", 1f);
    }
 /// <summary>
 /// Gets random spawn point from team. Used to handle player respawn.
 /// </summary>
 /// <param name="team">Team to get spawn point.</param>
 /// <returns>Random spawn point position.</returns>
 public Vector3 GetRandomSpawnPoint(TeamTypes team)
 {
     if (team == TeamTypes.Blue)
     {
         return blueSpawnPoints[Random.Range(0, blueSpawnPoints.Length)].transform.position;
     }
     else
     {
         return orangeSpawnPoints[Random.Range(0, blueSpawnPoints.Length)].transform.position;
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="team"></param>
        /// <param name="week"></param>
        /// <param name="season"></param>
        /// <returns></returns>
        public PlayerGames GetByTeamAndWeek(TeamTypes team, string season, int week)
        {
            string url = string.Format("/{0}/{1}/{2}/{3}", PlayerGameStatsByTeamKey, season, week, team.ToString());

            return(GetRequest <PlayerGames>(url));
        }
 public void UpdateTowerLife(TeamTypes towerTeam, float actualHP, float totalHP)
 {
     if (towerTeam == playerTeam)
     {
         myTeamTowerLifebar.fillAmount = (float)actualHP / (float)totalHP;
     }
     else
     {
         enemyTeamTowerLifebar.fillAmount = (float)actualHP / (float)totalHP;
     }
 }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="team"></param>
        /// <param name="week"></param>
        /// <param name="season"></param>
        /// <returns></returns>
        public async Task<PlayerGames> GetByTeamAndWeekAsync(TeamTypes team, int season, int week)
        {
            string url = string.Format("/{0}/{1}/{2}/{3}", PlayerGameStatsByTeamKey, season, week, team.ToString());

            return await this.GetRequestAsync<PlayerGames>(url);
        }
        public News GetForTeam(TeamTypes team)
        {
            var url = string.Format("/{0}/{1}", NewsByTeamKey, team.ToString());

            return GetRequest<News>(url);
        }
    /// <summary>
    /// Rotates player between teams.
    /// </summary>
    public void ChangeTeam(TeamTypes newTeam, bool syncNetwork)
    {
        myTeam = newTeam;

        ExitGames.Client.Photon.Hashtable properties = new ExitGames.Client.Photon.Hashtable();
        properties.Add("Team", myTeam.GetHashCode());
        PhotonNetwork.player.SetCustomProperties(properties);

        if (syncNetwork)
        {
            networkLayer.OnPropertiesChanged();
        }
    }
    /// <summary>
    /// Event called on game end. Handles local behaviours.
    /// </summary>
    /// <param name="winner">Winner team.</param>
	public void OnNetworkGameEnded(TeamTypes winner){
		GameController.instance.FinishGame (winner);
	}
    /// <summary>
    /// Callback used when the player successfully joins a room.
    /// </summary>
    public void OnJoinedRoom()
    {
        playersInRoom = new List<PhotonPlayer>(PhotonNetwork.playerList);
        myTeam = (TeamTypes)((playersInRoom.Count + 1) % 2);


        ExitGames.Client.Photon.Hashtable properties = new ExitGames.Client.Photon.Hashtable();
        properties.Add("Team", myTeam.GetHashCode());
        properties.Add("Character", myCharacter.GetHashCode());
        properties.Add("PlayFabID", PlayFabManager.instance.GetMyPlayerID());

        bool containsOwner = false;
        for (int i = 0; i < PhotonNetwork.otherPlayers.Length; i++)
        {
            object ownerName;
            if (PhotonNetwork.otherPlayers[i].customProperties.TryGetValue("Owner", out ownerName))
            {
                containsOwner = true;
                break;
            }
        }
        if (!containsOwner)
        {
            properties.Add("Owner", PhotonNetwork.player.name);
        }
        PhotonNetwork.player.SetCustomProperties(properties);

        myRoomInfo = PhotonNetwork.room;

        OnJoinedRoomCallback(PhotonNetwork.room);
    }
    /// <summary>
    /// Event called on game end. Sends data to server.
    /// </summary>
    /// <param name="winner">Winner team.</param>
	public void OnGameEnded(TeamTypes winner){
        if (playerControlled)
        {
            networkLayer.OnGameEnded(winner);
        }
	}
    void CheckMyPlayerProperties(string playerName, TeamTypes playerTeam, CharacterTypes playerChar)
    {
        
        if (selectedTeam != playerTeam)
        {
            this.ChangeTeam(false);
        }

        if (selectedCharacter != playerChar)
        {
            this.SelectChar(playerChar.ToString(), false);
        }
    }
    /// <summary>
    /// Start method. Gets all references.
    /// </summary>
    public void StartPlayer(bool playerControlled, TeamTypes myTeam, string playerPlayFabID, string playFabName)
    {
        this.playerPlayFabID = playerPlayFabID;
        this.myTeam = myTeam;
        this.playerControlled = playerControlled;
        this.playerPlayFabName = playFabName;

        myProperties = this.GetComponent<PlayerProperties>();
        networkLayer = this.GetComponent<PlayerNetworkLayer>();
        animationManager = this.GetComponent<PlayerAnimationManager>();
        shooterManager = this.GetComponent<ShooterManager>();
        aiManager = this.GetComponent<PlayerAIManager>();

        shooterManager.CreateBuffer(myTeam);

        myTower = GameController.instance.GetTower(myTeam);

        playerExp = playerLevel = 0;

        myProperties.Initialize();

        baseSprite.color = spriteTeamColors[myTeam.GetHashCode()];

        Debug.Log("initializing player. is human? " + playerControlled+" is local? "+networkLayer.isMine);
        if (networkLayer.isMine)
        {
            if (playerControlled)
            {
                Camera.main.transform.SetParent(this.transform, true);

                //levelText = GameController.instance.GetLevelText();
                expText = GameController.instance.GetExpText();

                GameplayUI.instance.Initialize(myTeam,this);
                GameplayUI.instance.UpdateSidebarStats(myProperties);

                InGameStoreAndCurrencyManager.instance.SetUpgradesCallbacks(new ProjectDelegates.OnPlayerBoughtStatUpgradeCallback[]{
                    myProperties.IncreaseAtk,myProperties.IncreaseMovSpd,myProperties.IncreaseHP
                });
            }

            this.transform.position = GameController.instance.GetRandomSpawnPoint(myTeam);
        }
    }
Esempio n. 46
0
    void OnRoomPropertiesChanged(RoomInfo roomInfo)
    {
        this.ClearPortraits();

        this.CheckStartTimer();

        PhotonPlayer[] players = PhotonNetwork.playerList;

        if (!timerStarted)
        {
            gameTimerText.text = players.Length + "/" + PhotonNetwork.room.maxPlayers;
        }

        int readyCount = 0;

        for (int i = 0; i < players.Length; i++)
        {
            string         playerName  = players[i].name;
            TeamTypes      playerTeam  = (TeamTypes)int.Parse(players[i].customProperties["Team"].ToString());
            CharacterTypes playerChar  = (CharacterTypes)int.Parse(players[i].customProperties["Character"].ToString());
            bool           playerReady = System.Convert.ToBoolean(players[i].customProperties["Ready"]);

            bool isMe = players[i].name == AccountManager.instance.displayName;

            if (playerReady)
            {
                readyCount++;
            }

            if (isMe)
            {
                this.CheckMyPlayerProperties(playerName, playerTeam, playerChar);
            }

            int myTeamCount = teamsCount[playerTeam.GetHashCode()];

            if (playerTeam == TeamTypes.Blue)
            {
                //blueTeamNames[myTeamCount].text = playerName;
                if (playerChar == CharacterTypes.He)
                {
                    blueTeamPortraits[myTeamCount].sprite = hePortraits[playerTeam.GetHashCode()];
                }
                else
                {
                    blueTeamPortraits[myTeamCount].sprite = shePortraits[playerTeam.GetHashCode()];
                }

                if (isMe)
                {
                    blueTeamPortraitBorders[myTeamCount].color = Color.yellow;
                }
                else
                {
                    blueTeamPortraitBorders[myTeamCount].color = Color.white;
                }
            }
            else
            {
                //orangeTeamNames[myTeamCount].text = playerName;
                if (playerChar == CharacterTypes.He)
                {
                    orangeTeamPortraits[myTeamCount].sprite = hePortraits[playerTeam.GetHashCode()];
                }
                else
                {
                    orangeTeamPortraits[myTeamCount].sprite = shePortraits[playerTeam.GetHashCode()];
                }

                if (isMe)
                {
                    orangeTeamPortraitBorders[myTeamCount].color = Color.yellow;
                }
                else
                {
                    orangeTeamPortraitBorders[myTeamCount].color = Color.white;
                }
            }

            teamsCount[playerTeam.GetHashCode()]++;
        }

        playersReady = readyCount;

        if (playersReady == PhotonNetwork.room.playerCount)
        {
            timerCounter = 0;
            MultiplayerRoomsManager.instance.StartGame();
        }

        if (timerStarted && players.Length < PhotonNetwork.room.playerCount)
        {
            MultiplayerRoomsManager.instance.ResetTimer();
        }
    }
    /// <summary>
    /// Initializes AI. Gets all references, and starts moving.
    /// </summary>
    public void StartAI()
    {
        playerManager = this.GetComponent<PlayerManager>();
        myProperties = this.GetComponent<PlayerProperties>();
        navMeshAgent = this.GetComponent<NavMeshAgent>();

        navMeshAgent.speed = myProperties.actualMovSpd;

        controlledLocally = true;

        this.FindNewPoint();

        gamePanels = GameController.instance.GetGamePanels();

        int enemyID = playerManager.myTeam.GetHashCode();
        enemyID++;
        if (enemyID > TeamTypes.Orange.GetHashCode())
        {
            enemyID = 0;
        }

        enemyTeam = (TeamTypes)enemyID;
        enemyTower = GameController.instance.GetTower(enemyTeam);

        enemies = GameController.instance.GetPlayersOfTeam(enemyTeam);
    }
    public void ChangeTeam(bool syncNetwork)
    {
        if (ready) return;

        Debug.Log("change team from " + selectedTeam);
        int newID = selectedTeam.GetHashCode();
        newID++;
        if (newID > TeamTypes.Orange.GetHashCode())
        {
            newID = 0;
        }

        TeamTypes newTeam = (TeamTypes)newID;

        if (teamsCount[newTeam.GetHashCode()] == PhotonNetwork.room.maxPlayers / 2) return;

        if (newTeam != selectedTeam)
        {
            selectedTeam = newTeam;
            this.RebuildAvatarTextures();

            MultiplayerRoomsManager.instance.ChangeTeam(selectedTeam,syncNetwork);
        }
    }
Esempio n. 49
0
 /// <summary>
 /// Event to be called when the game ends.
 /// </summary>
 /// <param name="winner">Winner team.</param>
 public void OnGameEnded(TeamTypes winner)
 {
     photonView.RPC("OnNetworkGameEnded", PhotonTargets.AllBuffered, winner.GetHashCode());
 }
Esempio n. 50
0
        protected override void RunCommand(IEnumerable <string> args)
        {
            List <string> argsList = args.ToList();

            if (showCommandHelp(argsList))
            {
                return;
            }

            bool itemsLong      = withItems == "long";
            bool inventoryLong  = withInventory == "long";
            bool tamedLong      = tamed == "long";
            bool structuresLong = withStructures == "long";

            Stopwatch stopwatch = new Stopwatch(GlobalOptions.UseStopWatch);

            bool mapNeeded = withItems != null || tamed != null || withStructures != null || withInventory != null;

            if (!GlobalOptions.Quiet && mapNeeded)
            {
                Console.WriteLine("Need to load map, this may take some time...");
            }

            string saveGame        = argsList.Count > 0 ? argsList[0] : Path.Combine(GlobalOptions.ArkToolsConfiguration.BasePath, GlobalOptions.ArkToolsConfiguration.ArkSavegameFilename);
            string outputDirectory = argsList.Count > 1 ? argsList[1] : Path.Combine(GlobalOptions.ArkToolsConfiguration.BasePath, GlobalOptions.ArkToolsConfiguration.TribesPath);
            string saveDir         = Path.GetDirectoryName(saveGame);

            Dictionary <int, HashSet <TribeBase> > baseMap;
            CustomDataContext context = new CustomDataContext();

            if (mapNeeded)
            {
                ArkDataManager.LoadData(GlobalOptions.Language);

                ArkSavegame mapSave = new ArkSavegame().ReadBinary <ArkSavegame>(saveGame, ReadingOptions.Create().WithBuildComponentTree(true));
                context.Savegame = mapSave;
                context.MapData  = LatLonCalculator.ForSave(context.Savegame);
                stopwatch.Stop("Loading map data");
                if (withBases)
                {
                    baseMap = new Dictionary <int, HashSet <TribeBase> >();
                    foreach (GameObject gameObject in mapSave)
                    {
                        // Skip items and stuff without a location
                        if (gameObject.IsItem || gameObject.Location == null)
                        {
                            continue;
                        }

                        string signText      = gameObject.GetPropertyValue <string>("SignText");
                        long?  targetingTeam = gameObject.GetPropertyValue <long?>("TargetingTeam");

                        if (signText != null && targetingTeam != null)
                        {
                            // Might be a 'Base' sign
                            MatchCollection matcher = basePattern.Matches(signText);
                            if (matcher.Any())
                            {
                                // Found a base sign, add it to the set, automatically replacing duplicates
                                int          tribeId  = (int)targetingTeam;
                                LocationData location = gameObject.Location;
                                string       baseName = matcher[1].Value;
                                float        size     = float.Parse(matcher[2].Value);

                                TribeBase tribeBase = new TribeBase(baseName, location.X, location.Y, location.Z, size);

                                if (!baseMap.ContainsKey(tribeId))
                                {
                                    baseMap[tribeId] = new HashSet <TribeBase>();
                                }

                                baseMap[tribeId].Add(tribeBase);
                            }
                        }
                    }

                    stopwatch.Stop("Collecting bases");
                }
                else
                {
                    baseMap = null;
                }

                if (mapSave.HibernationEntries.Any() && tamed != null)
                {
                    List <GameObject> combinedObjects = context.Savegame.Objects.ToList();

                    foreach (HibernationEntry entry in context.Savegame.HibernationEntries)
                    {
                        ObjectCollector collector = new ObjectCollector(entry, 1);
                        combinedObjects.AddRange(collector.Remap(combinedObjects.Count));
                    }

                    context.ObjectContainer = new GameObjectContainer(combinedObjects);
                }
                else
                {
                    context.ObjectContainer = mapSave;
                }
            }
            else
            {
                baseMap = null;
            }

            List <Action> tasks = GlobalOptions.Parallel ? new List <Action>() : null;

            void mapWriter(JsonTextWriter generator, int tribeId)
            {
                if (!mapNeeded)
                {
                    return;
                }
                List <GameObject>  structures   = new List <GameObject>();
                List <GameObject>  creatures    = new List <GameObject>();
                List <Item>        items        = new List <Item>();
                List <Item>        blueprints   = new List <Item>();
                List <DroppedItem> droppedItems = new List <DroppedItem>();
                // Apparently there is a behavior in ARK causing certain structures to exist twice within a save
                HashSet <ArkName> processedList = new HashSet <ArkName>();
                // Bases
                HashSet <TribeBase> bases = withBases ? baseMap[tribeId] : null;

                foreach (GameObject gameObject in context.ObjectContainer)
                {
                    if (gameObject.IsItem)
                    {
                        continue;
                    }

                    int targetingTeam = gameObject.GetPropertyValue <int>("TargetingTeam", defaultValue: -1);
                    if (targetingTeam == -1)
                    {
                        continue;
                    }

                    TeamType teamType = TeamTypes.ForTeam(targetingTeam);
                    if (tribeId == -1 && teamType != TeamType.Player)
                    {
                        continue;
                    }

                    if (tribeId == 0 && teamType != TeamType.NonPlayer)
                    {
                        continue;
                    }

                    if (tribeId > 0 && tribeId != targetingTeam)
                    {
                        continue;
                    }

                    // Determine base if we have bases
                    TribeBase tribeBase;
                    if (bases != null && gameObject.Location != null)
                    {
                        TribeBase matchedBase = null;
                        foreach (TribeBase potentialBase in bases)
                        {
                            if (potentialBase.InsideBounds(gameObject.Location))
                            {
                                matchedBase = potentialBase;
                                break;
                            }
                        }

                        tribeBase = matchedBase;
                    }
                    else
                    {
                        tribeBase = null;
                    }

                    if (gameObject.IsCreature())
                    {
                        if (!processedList.Contains(gameObject.Names[0]))
                        {
                            if (tribeBase != null)
                            {
                                tribeBase.Creatures.Add(gameObject);
                            }
                            else
                            {
                                creatures.Add(gameObject);
                            }

                            processedList.Add(gameObject.Names[0]);
                        }
                        else
                        {
                            // Duped Creature
                            continue;
                        }
                    }
                    else if (!gameObject.IsPlayer() && !gameObject.IsWeapon() && !gameObject.IsDroppedItem())
                    {
                        // LinkedPlayerDataID: Players ain't structures
                        // AssociatedPrimalItem: Items equipped by sleeping players
                        // MyItem: dropped item
                        if (!processedList.Contains(gameObject.Names[0]))
                        {
                            if (tribeBase != null)
                            {
                                tribeBase.Structures.Add(gameObject);
                            }
                            else
                            {
                                structures.Add(gameObject);
                            }

                            processedList.Add(gameObject.Names[0]);
                        }
                        else
                        {
                            // Duped Structure
                            continue;
                        }
                    }
                    else
                    {
                        if (!processedList.Contains(gameObject.Names[0]))
                        {
                            processedList.Add(gameObject.Names[0]);
                        }
                        else
                        {
                            // Duped Player or dropped Item or weapon
                            continue;
                        }
                    }

                    void itemHandler(ObjectReference itemReference)
                    {
                        GameObject item = itemReference.GetObject(context.Savegame);

                        if (item != null && !Item.isDefaultItem(item))
                        {
                            if (processedList.Contains(item.Names[0]))
                            {
                                // happens for players having items in their quick bar
                                return;
                            }

                            processedList.Add(item.Names[0]);

                            if (item.HasAnyProperty("bIsBlueprint"))
                            {
                                if (tribeBase != null)
                                {
                                    tribeBase.Blueprints.Add(new Item(item));
                                }
                                else
                                {
                                    blueprints.Add(new Item(item));
                                }
                            }
                            else
                            {
                                if (tribeBase != null)
                                {
                                    tribeBase.Items.Add(new Item(item));
                                }
                                else
                                {
                                    items.Add(new Item(item));
                                }
                            }
                        }
                    }

                    void droppedItemHandler(GameObject droppedItemObject)
                    {
                        DroppedItem droppedItem = new DroppedItem(droppedItemObject, context.Savegame);

                        if (tribeBase != null)
                        {
                            tribeBase.DroppedItems.Add(droppedItem);
                        }
                        else
                        {
                            droppedItems.Add(droppedItem);
                        }
                    }

                    if (withItems != null && withInventory == null)
                    {
                        foreach (GameObject inventory in gameObject.Components.Values)
                        {
                            if (!inventory.IsInventory())
                            {
                                continue;
                            }

                            List <ObjectReference> inventoryItems = inventory.GetPropertyValue <IArkArray, ArkArrayObjectReference>("InventoryItems");
                            foreach (ObjectReference itemReference in inventoryItems ?? Enumerable.Empty <ObjectReference>())
                            {
                                itemHandler(itemReference);
                            }

                            List <ObjectReference> equippedItems = inventory.GetPropertyValue <IArkArray, ArkArrayObjectReference>("EquippedItems");
                            foreach (ObjectReference itemReference in equippedItems ?? Enumerable.Empty <ObjectReference>())
                            {
                                itemHandler(itemReference);
                            }
                        }
                    }

                    ObjectReference myItem = gameObject.GetPropertyValue <ObjectReference>("MyItem");

                    if (myItem != null)
                    {
                        if (withItems != null && withInventory == null)
                        {
                            itemHandler(myItem);
                        }
                        else if (withInventory != null)
                        {
                            droppedItemHandler(gameObject);
                        }
                    }
                }

                void writeStructures(IEnumerable <GameObject> structList)
                {
                    if (withStructures == null)
                    {
                        return;
                    }
                    generator.WriteArrayFieldStart("structures");

                    if (structuresLong)
                    {
                        foreach (GameObject structureObject in structList)
                        {
                            Structure structure = new Structure(structureObject, context.Savegame);

                            generator.WriteStartObject();

                            structure.writeAllProperties(generator, context, writeAllFields);

                            if (withInventory != null)
                            {
                                structure.writeInventory(generator, context, writeAllFields, !inventoryLong);
                            }

                            generator.WriteEndObject();
                        }
                    }
                    else
                    {
                        Dictionary <ArkName, long> structMap = structList.GroupBy(o => o.ClassName).ToDictionary(objects => objects.Key, objects => objects.LongCount());
                        foreach (KeyValuePair <ArkName, long> entry in structMap.OrderByDescending(pair => pair.Value))
                        {
                            generator.WriteStartObject();

                            string name = entry.Key.ToString();
                            if (ArkDataManager.HasStructure(name))
                            {
                                name = ArkDataManager.GetStructure(name).Name;
                            }

                            generator.WriteField("name", name);
                            generator.WriteField("count", entry.Value);

                            generator.WriteEndObject();
                        }
                    }

                    generator.WriteEndArray();
                }

                void writeCreatures(List <GameObject> creaList)
                {
                    if (tamed == null)
                    {
                        return;
                    }
                    generator.WriteArrayFieldStart("tamed");

                    if (tamedLong)
                    {
                        foreach (GameObject creatureObject in creaList)
                        {
                            Creature creature = new Creature(creatureObject, context.Savegame);

                            generator.WriteStartObject();

                            creature.writeAllProperties(generator, context, writeAllFields);

                            if (withInventory != null)
                            {
                                creature.writeInventory(generator, context, writeAllFields, !inventoryLong);
                            }

                            generator.WriteEndObject();
                        }
                    }
                    else
                    {
                        Dictionary <ArkName, long> creaMap = creaList.GroupBy(o => o.ClassName).ToDictionary(objects => objects.Key, objects => objects.LongCount());
                        foreach (KeyValuePair <ArkName, long> entry in creaMap.OrderByDescending(pair => pair.Value))
                        {
                            generator.WriteStartObject();

                            string name = entry.Key.ToString();
                            if (ArkDataManager.HasCreature(name))
                            {
                                name = ArkDataManager.GetCreature(name).Name;
                            }

                            generator.WriteField("name", name);
                            generator.WriteField("count", entry.Value);

                            generator.WriteEndObject();
                        }
                    }

                    generator.WriteEndArray();
                }

                void writeDroppedItems(List <DroppedItem> droppedList)
                {
                    if (withInventory == null)
                    {
                        return;
                    }
                    generator.WriteArrayFieldStart("droppedItems");

                    foreach (DroppedItem droppedItem in droppedList)
                    {
                        generator.WriteStartObject();

                        droppedItem.writeAllProperties(generator, context, writeAllFields);
                        droppedItem.writeInventory(generator, context, writeAllFields, !inventoryLong);

                        generator.WriteEndObject();
                    }

                    generator.WriteEndArray();
                }

                if (withBases && bases != null)
                {
                    generator.WriteArrayFieldStart("bases");

                    foreach (TribeBase tribeBase in bases)
                    {
                        generator.WriteStartObject();

                        generator.WriteField("name", tribeBase.Name);
                        generator.WriteField("x", tribeBase.X);
                        generator.WriteField("y", tribeBase.Y);
                        generator.WriteField("z", tribeBase.Z);
                        generator.WriteField("lat", context.MapData.CalculateLat(tribeBase.Y));
                        generator.WriteField("lon", context.MapData.CalculateLon(tribeBase.X));
                        generator.WriteField("radius", tribeBase.Size);
                        writeCreatures(tribeBase.Creatures);
                        writeStructures(tribeBase.Structures);
                        writeDroppedItems(tribeBase.DroppedItems);
                        if (itemsLong)
                        {
                            generator.WritePropertyName("items");
                            Inventory.writeInventoryLong(generator, context, tribeBase.Items, writeAllFields);
                            generator.WritePropertyName("blueprints");
                            Inventory.writeInventoryLong(generator, context, tribeBase.Blueprints, writeAllFields);
                        }
                        else
                        {
                            generator.WritePropertyName("items");
                            Inventory.writeInventorySummary(generator, tribeBase.Items);
                            generator.WritePropertyName("blueprints");
                            Inventory.writeInventorySummary(generator, tribeBase.Blueprints);
                        }

                        generator.WriteEndObject();
                    }

                    generator.WriteStartObject();
                }

                writeCreatures(creatures);
                writeStructures(structures);
                writeDroppedItems(droppedItems);
                if (itemsLong)
                {
                    generator.WritePropertyName("items");
                    Inventory.writeInventoryLong(generator, context, items, writeAllFields);
                    generator.WritePropertyName("blueprints");
                    Inventory.writeInventoryLong(generator, context, blueprints, writeAllFields);
                }
                else
                {
                    generator.WritePropertyName("items");
                    Inventory.writeInventorySummary(generator, items);
                    generator.WritePropertyName("blueprints");
                    Inventory.writeInventorySummary(generator, blueprints);
                }

                if (withBases && bases != null)
                {
                    generator.WriteEndObject();

                    generator.WriteEndArray();
                }
            }

            foreach (string path in Directory.EnumerateFiles(saveDir).Where(path => tribePattern.IsMatch(path)))
            {
                Action task = () => {
                    try {
                        Tribe tribe = new Tribe(path, ReadingOptions.Create());

                        string tribeFileName = tribe.tribeId + ".json";

                        string tribePath = Path.Combine(outputDirectory, tribeFileName);

                        CommonFunctions.WriteJson(tribePath, (generator, writingOptions) => {
                            generator.WriteStartObject();

                            tribe.writeAllProperties(generator, context, writeAllFields);

                            mapWriter(generator, tribe.tribeId);

                            generator.WriteEndObject();
                        }, writingOptions);
                    } catch (Exception ex) {
                        Console.Error.WriteLine("Found potentially corrupt ArkTribe: " + path);
                        if (GlobalOptions.Verbose)
                        {
                            Console.Error.WriteLine(ex.Message);
                            Console.Error.WriteLine(ex.StackTrace);
                        }
                    }
                };

                if (tasks != null)
                {
                    tasks.Add(task);
                }
                else
                {
                    task();
                }
            }

            if (tasks != null)
            {
                Parallel.ForEach(tasks, task => task());
            }

            if (tribeless)
            {
                string tribePath = Path.Combine(outputDirectory, "tribeless.json");

                CommonFunctions.WriteJson(tribePath, (generator, writingOptions) => {
                    generator.WriteStartObject();

                    mapWriter(generator, -1);

                    generator.WriteEndObject();
                }, writingOptions);
            }

            if (nonPlayers)
            {
                string tribePath = Path.Combine(outputDirectory, "non-players.json");

                CommonFunctions.WriteJson(tribePath, (generator, writingOptions) => {
                    generator.WriteStartObject();

                    mapWriter(generator, 0);

                    generator.WriteEndObject();
                }, writingOptions);
            }

            stopwatch.Stop("Loading tribes and writing info");
            stopwatch.Print();
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="team"></param>
        /// <param name="week"></param>
        /// <param name="season"></param>
        /// <returns></returns>
        public Injuries GetByWeekAndTeam(TeamTypes team, int season, int week)
        {
            string url = string.Format("/{0}/{1}/{2}/{3}", InjuriesKey, season, week, team.ToString());

              return GetRequest<Injuries>(url);
        }
    /// <summary>
    /// Event to be called when the game ends.
    /// </summary>
    /// <param name="winner">Winner team.</param>
	public void OnGameEnded (TeamTypes winner)
	{
		photonView.RPC("OnNetworkGameEnded", PhotonTargets.AllBuffered, winner.GetHashCode());
	}
    public void Initialize(TeamTypes myTeam, PlayerManager playerToUpdate)
    {
        this.playerToUpdate = playerToUpdate;

        this.playerTeam = myTeam;
    }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="team"></param>
        /// <param name="week"></param>
        /// <param name="season"></param>
        /// <returns></returns>
        public async Task<Injuries> GetByWeekAndTeamAsync(TeamTypes team, int season, int week)
        {
            string url = string.Format("/{0}/{1}/{2}/{3}", InjuriesKey, season, week, team.ToString());

            return await this.GetRequestAsync<Injuries>(url);
        }
 public void UpdateKillcount(TeamTypes team, int amount)
 {
     if (team == playerTeam)
     {
         myTeamKillcount.text = amount.ToString();
     }
     else
     {
         enemyTeamKillcount.text = amount.ToString();
     }
 }
 /// <summary>
 /// Reports a kill from a specific team.
 /// </summary>
 /// <param name="team">Team who killed a player.</param>
 public void ReportKill(TeamTypes team)
 {
     if (team == TeamTypes.Blue)
     {
         blueTeamKillCount++;
         GameplayUI.instance.UpdateKillcount(team, blueTeamKillCount);
     }
     else
     {
         orangeTeamKillCount++;
         GameplayUI.instance.UpdateKillcount(team, orangeTeamKillCount);
     }
 }