public ActionResult Create() { var user = System.Web.HttpContext.Current.GetCurrentUser(); TeamViewModel model = TeamExtensions.CreateNewTeam(user.UserId); return(View(model)); }
/*--------------------------------------------------------------------*/ /*######### # GUI # #########*/ /*--------------------------------------------------------------------*/ void OnGUI() { /*PhotonView photonView = PhotonView.Get(this); * //Drawing the score * if(Input.GetKeyDown(KeyCode.Tab)) * { * drawTheScore=true; * } * if(Input.GetKeyUp(KeyCode.Tab)) * { * drawTheScore=false; * } * * if(drawTheScore) * { * if(photonView.isMine) * { * drawScore(); * } * }*/ //drawTeamScores(); PhotonView myView = PhotonView.Get(this); PhotonPlayer myPlayer = myView.owner; string myTeam = TeamExtensions.getStringTeam(myPlayer); GUI.Label(new Rect(400, 250, 250, 50), "PUNTeam: " + myTeam); }
public void Start() { PlayersPerTeam = new Dictionary <Team, List <PhotonPlayer> >(); Array enumVals = Enum.GetValues(typeof(Team)); foreach (var enumVal in enumVals) { PlayersPerTeam[(Team)enumVal] = new List <PhotonPlayer>(); } this.UpdateTeams(); //We get the playercount string players = this.countPlayers(); string[] playerTab = players.Split(';'); int blueCount = int.Parse(playerTab[0]); int redCount = int.Parse(playerTab[1]); //We get our player PhotonView myView = PhotonView.Get(this); PhotonPlayer myPlayer = myView.owner; //We set the team depending on the players if (myView.isMine) { if (blueCount <= redCount) { TeamExtensions.SetTeam(myPlayer, Team.blue); } else { TeamExtensions.SetTeam(myPlayer, Team.red); } Debug.Log("You are on team " + TeamExtensions.GetTeam(myPlayer)); } //If we are the masterclient we verify the score and if there are none we set it if (PhotonNetwork.isMasterClient) { if (!TeamExtensions.isTeamScoreSet("Blue")) { TeamExtensions.SetTeamScore("Blue", 0); } if (!TeamExtensions.isTeamScoreSet("Red")) { TeamExtensions.SetTeamScore("Red", 0); } if (isKillFeedEmpty) { TeamExtensions.AddKillFeed(-1, -1); } } }
public void AddPlayersToTeam(Player player) { Debug.Log(PunTeams.PlayersPerTeam[PunTeams.Team.blue].Count); Debug.Log(PunTeams.PlayersPerTeam[PunTeams.Team.red].Count); if (PunTeams.PlayersPerTeam[PunTeams.Team.blue].Count < PunTeams.PlayersPerTeam[PunTeams.Team.red].Count) { Debug.Log("blue"); TeamExtensions.SetTeam(player, PunTeams.Team.blue); } else if (PunTeams.PlayersPerTeam[PunTeams.Team.blue].Count >= PunTeams.PlayersPerTeam[PunTeams.Team.red].Count) { Debug.Log("red"); TeamExtensions.SetTeam(player, PunTeams.Team.red); } punTeams.UpdateTeams(); // pv.RPC("RPC_AddPlayersToTeam", RpcTarget.All, playername); }
// Update is called once per frame void Update() { //Getting the transforms timerPanel = transform.Find("TimerPanel"); bluePanel = transform.Find("BluePanel"); redPanel = transform.Find("RedPanel"); //Getting the text objects timerObj = timerPanel.GetChild(0); blueObj = bluePanel.GetChild(0); redObj = redPanel.GetChild(0); //Getting the score texts timerText = timerObj.GetComponent <Text>(); blueText = blueObj.GetComponent <Text>(); redText = redObj.GetComponent <Text>(); blueScore = TeamExtensions.GetTeamScore("Blue"); redScore = TeamExtensions.GetTeamScore("Red"); //We get the timer endChrono = endMoment - PhotonNetwork.time; endTime = (int)(endChrono); //Blue score blueText.text = blueScore.ToString(); redText.text = redScore.ToString(); //-------- TIMER //Minutes timerText.text = (endTime / 60).ToString() + ":"; //Seconds if (endTime % 60 < 10) { timerText.text += "0" + (endTime % 60).ToString(); } else { timerText.text += (endTime % 60).ToString(); } }
// Update is called once per frame void Update() { lastKills = TeamExtensions.GetKillFeed(); lastKillFeed = lastKills.Split(';'); lastKiller = int.Parse(lastKillFeed[0]); lastKilled = int.Parse(lastKillFeed[1]); if (lastKiller != -1 && lastKilled != -1) { if (lastKiller != actualKiller || lastKilled != actualDead) { killerPlayer = PhotonPlayer.Find(lastKiller); deadPlayer = PhotonPlayer.Find(lastKilled); killerTag = killerPlayer.name; deadTag = deadPlayer.name; displayNewKill(killerTag, deadTag); actualDead = lastKilled; actualKiller = lastKiller; } } if (isDisplaying) { if (counter >= 0f) { counter -= Time.deltaTime; } else { isDisplaying = false; killFeedText.gameObject.active = false; } } }
/*---------------------------- UPDATE ----------------------------*/ // Update is called once per frame void Update() { PhotonView photonView = PhotonView.Get(this); /*------------------------- VERIFYING SYNCHRONIZATION -------------*/ //We check if we have the scores of everyone /*if(!isUpdated) //We're not updated * { * if(updateCounter >= 2.0f) * { * int myID = photonView.owner.ID; * * photonView.RPC("updateMe", PhotonTargets.MasterClient, null); * updateCounter = 0f; * Debug.Log("Requesting update"); * } * else * { * updateCounter += Time.deltaTime; * } * } * * /*----------------------------- WE UPDATE THE PLAYERS REGULARLY -----------*/ if (PhotonNetwork.isMasterClient) { /*if(updateTimer >= 2.0f) * { * string theTeamScores = blueScore + ";" + redScore; * photonView.RPC("updateTeamScores", PhotonTargets.Others, theTeamScores); * updateTimer = 0f; * } * else * { * updateTimer += Time.deltaTime; * }*/ if (pingUpdate >= 5.0f) { pingFunction(); pingUpdate = 0f; } else { pingUpdate += Time.deltaTime; } pingTimer += Time.deltaTime; } /*--------------------------------------------------------------------*/ //When our playerCreator is created we add ourself on the scoreboards playerSpawn playSpawn = GetComponent <playerSpawn>(); //Managing the kills //We update the last shot each frame foreach (Transform child in transform) { if (child.name != "globalHUD" && child.name != "scoreBoardUI" && child.name != "InGameMenu" && child.name != "littleScoreBoardUI" && child.name != "PlayerHUD") { playerNetwork playSet = child.GetComponent <playerNetwork>(); myLastShot = playSet.lastShot; } } //If we're killed we add the kill and update the score if (wasKilled) { PhotonPlayer killer = PhotonPlayer.Find(myLastShot); PunPlayerScores playerScoreScript = GetComponent <PunPlayerScores>(); ScoreExtensions.AddScore(killer, 1); int myID = photonView.owner.ID; //photonView.RPC("addKill", killer, null); //photonView.RPC("addKill", PhotonTargets.All, myLastShot); if (myTeam == "Blue") { //photonView.RPC("addRedKill", PhotonTargets.All, myLastShot); //photonView.RPC("addRedKill", PhotonTargets.All, null); TeamExtensions.AddTeamScore("Red"); //photonView.RPC("addBlueDeath", PhotonTargets.All, myID); } else { //photonView.RPC("addBlueKill", PhotonTargets.All, myLastShot); //photonView.RPC("addBlueKill", PhotonTargets.All, null); TeamExtensions.AddTeamScore("Blue"); //photonView.RPC("addRedDeath", PhotonTargets.All, myID); } PhotonPlayer myPlayer = PhotonPlayer.Find(myID); //addDeath(); DeathExtensions.AddDeath(myPlayer, 1); //KILLFEED TeamExtensions.AddKillFeed(myLastShot, myID); wasKilled = false; } /*--------------------------- SCOREBOARD ----------------------*/ //We get the scoreboard object Transform scoreB = transform.Find("scoreBoardUI"); //Drawing the score if (Input.GetKeyDown(KeyCode.Tab)) { drawTheScore = true; } if (Input.GetKeyUp(KeyCode.Tab)) { drawTheScore = false; } if (photonView.isMine) { if (drawTheScore || isMatchEnded) //If the player press tab we activate the board { scoreB.gameObject.active = true; } else { scoreB.gameObject.active = false; } } else { scoreB.gameObject.active = false; } /*------------------------------ TIMER ------------------------*/ //At the end of the match the masterclient stops it if (matchTimer <= 0f) { if (PhotonNetwork.isMasterClient) { photonView.RPC("stopMatch", PhotonTargets.All, null); } } else { matchTimer -= Time.deltaTime; //if(PhotonNetwork.isMasterClient) //updateMatchTimer(); } }
// Update is called once per frame void Update() { //Increment int i = 0; //For each player int j = 0; //For each button foreach (PhotonPlayer pl in PhotonNetwork.playerList) { string playerTeam = TeamExtensions.getStringTeam(pl); //If the team of the player is the one of the panel if (playerTeam == panelTeam) { string scoreButton; if (panelTeam == "Blue") { scoreButton = "blueNo" + (j + 1).ToString(); } else { scoreButton = "redNo" + (j + 1).ToString(); } Transform child = transform.Find(scoreButton); child.gameObject.active = true; //We activate the button //We get the child text of the button Transform playerText = child.transform.GetChild(0); displayScore = playerText.gameObject.GetComponent <Text>(); int playScore = ScoreExtensions.GetScore(pl); int playDeath = DeathExtensions.GetDeath(pl); displayScore.text = "(" + pl.ID + ") " + pl.name + " | " + playScore + " | " + playDeath; //BUTTONS COLORS //Host color ColorBlock hostColor = ColorBlock.defaultColorBlock; hostColor.normalColor = new Color(0, 0.6f, 0.2f, 1); hostColor.highlightedColor = new Color(0, 0.7f, 0.25f, 1); hostColor.pressedColor = new Color(0, 0.5f, 0.15f, 1); //Player color ColorBlock myColor = ColorBlock.defaultColorBlock; myColor.normalColor = new Color(0, 0.2f, 0.6f, 1); myColor.highlightedColor = new Color(0, 0.25f, 0.7f, 1); myColor.pressedColor = new Color(0, 0.15f, 0.5f, 1); ColorBlock defColor = ColorBlock.defaultColorBlock; defColor.normalColor = new Color(0.3f, 0.3f, 0.3f, 1); defColor.highlightedColor = new Color(0.4f, 0.4f, 0.4f, 1); defColor.pressedColor = new Color(0.2f, 0.2f, 0.2f, 1); if (pl.isLocal) { child.GetComponent <Button>().colors = myColor; } else { if (pl.isMasterClient) { child.GetComponent <Button>().colors = hostColor; } else { child.GetComponent <Button>().colors = defColor; } } j++; } i++; } //We deactivate the useless buttons for (int n = j; n < 4; n++) { Transform disabledButton = transform.GetChild(n); //We deactivate the button disabledButton.gameObject.active = false; } //For each button we display the score if there's one /*while(i<4) * { * if(panelTeam=="Blue") * { * if(scoreScript.playerScoreBlue[i,0]!=0) //If there's one player on this button * { * Transform child = transform.GetChild(j); * child.gameObject.active = true; //We activate the button * * //We get the child text of the button * Transform playerText = child.transform.GetChild(0); * displayScore = playerText.gameObject.GetComponent<Text>(); * * //We take the score to display * playerScore = scoreScript.playerTagsBlue[i] + " | " + scoreScript.playerScoreBlue[i,1].ToString() + " | " + scoreScript.playerScoreBlue[i,2].ToString() + " | " + scoreScript.playerScoreBlue[i,3].ToString(); * displayScore.text = playerScore; * * j++; * } * } * else * { * if(scoreScript.playerScoreRed[i,0]!=0) //If there's one player on this button * { * Transform child = transform.GetChild(j); * child.gameObject.active = true; //We activate the button * * //We get the child text of the button * Transform playerText = child.transform.GetChild(0); * displayScore = playerText.gameObject.GetComponent<Text>(); * * //We take the score to display * playerScore = scoreScript.playerTagsRed[i] + " | " + scoreScript.playerScoreRed[i,1].ToString() + " | " + scoreScript.playerScoreRed[i,2].ToString() + " | " + scoreScript.playerScoreRed[i,3].ToString(); * displayScore.text = playerScore; * * j++; * } * } * i++; * }*/ }
protected override void ReadMessage(MessagePayload payload) { _team = TeamExtensions.ToTeam(((JoinGameRequest)payload).TeamId); }