/// <summary> /// Check if 2 photonviews are on the same team /// </summary> /// <param name="id1">1st photon view</param> /// <param name="id2">2nd photon view</param> /// <returns>well are they?</returns> bool issameteam(int id1, int id2) { if (PhotonNetwork.inRoom) { ExitGames.Client.Photon.Hashtable hash = PhotonNetwork.room.CustomProperties; List <int> team1 = LobbyScreenController.getteam1(); List <int> team2 = LobbyScreenController.getteam2(); if (team1.Contains(id1) && team1.Contains(id2)) { return(true); } else if (team2.Contains(id1) && team2.Contains(id2)) { return(true); } else { return(false); } } else { return(false); } }
/// <summary> /// Removes the team in the event of a player leaving. /// </summary> /// <param name="thingtoadd">The left players PhotonID.</param> /// <param name="teamkey">The left players Team</param> public void removetoteam(int thingtoadd, string teamkey) { List <int> templist = LobbyScreenController.getteaminput(teamkey); if (templist.Contains(thingtoadd) == true) { templist.Remove(thingtoadd); } LobbyScreenController.setteaminput(templist, teamkey); Debug.Log("removed: " + thingtoadd + " from " + teamkey); }
/// <summary> /// find the spawn position (with an int) from the starting position of the player. /// </summary> /// <param name="input"></param> /// <returns>returns the spawn position to spawn into</returns> public int findspawnpos(int input) { int output = 0; Debug.Log(LobbyScreenController.getteam1()); if (LobbyScreenController.getteam1().Contains(input)) { output = LobbyScreenController.getteam1().IndexOf(input) + 1; } if (LobbyScreenController.getteam2().Contains(input)) { output = 4 + LobbyScreenController.getteam2().IndexOf(input); } return(output); }
/// <summary> /// Adds bots to the teams in the custom properties. /// </summary> /// <returns>returns a full list of players and bots</returns> public List <int> team2wbots() { List <int> output = LobbyScreenController.getteam2(); int maxplayerstemp = PhotonNetwork.room.MaxPlayers; if (maxplayerstemp == 4 && (string)PhotonNetwork.room.CustomProperties["3v3"] == "Yes") { maxplayerstemp = 6; } while (output.Count < (maxplayerstemp / 2)) { if (bots) { output.Add(300); } } LobbyScreenController.setteam2(output); return(output); }
public int findteam(int check) { if (PhotonNetwork.inRoom) { int output = 2; if (LobbyScreenController.getteam1().Contains(check)) { output = 1; } else if (LobbyScreenController.getteam2().Contains(check)) { output = 2; } return(output); } else { return(1); } }
/// <summary> /// Asign the current player to a team at the start of a match, this uses a rooms custom properties to ensure continuaty across the entire program. /// </summary> /// <param name="ownerID">The PhotonID to add to the customproperties</param> /// <param name="team">the team to add the PhotonID to.</param> public void AsignTeam(int ownerID, int team) { List <int> team1 = LobbyScreenController.getteam1(); List <int> team2 = LobbyScreenController.getteam2(); int maxplayerstemp = PhotonNetwork.room.MaxPlayers; if (maxplayerstemp == 4 && (string)PhotonNetwork.room.CustomProperties["3v3"] == "Yes") { maxplayerstemp = 6; } int maxplayersperteam = maxplayerstemp / 2; if (team == 1 && team1.Count <= maxplayersperteam) { if (team2.Contains(ownerID)) { team2.Remove(ownerID); } if (team1.Contains(ownerID) == false) { team1.Add(ownerID); } } else if (team2.Count <= maxplayersperteam) { if (team1.Contains(ownerID)) { team1.Remove(ownerID); } if (team2.Contains(ownerID) == false) { team2.Add(ownerID); } } LobbyScreenController.setteam1(team1); LobbyScreenController.setteam2(team2); }
/// <summary> /// Asign the current player to a team after the match starts. /// </summary> /// <param name="thingtoadd">The players PhotonID</param> /// <param name="teamkey">The team to add the PhotonID too.</param> public void addtoteam(int thingtoadd, string teamkey) { List <int> templist = LobbyScreenController.getteaminput(teamkey); int maxplayerstemp = PhotonNetwork.room.MaxPlayers; if (maxplayerstemp == 4 && (string)PhotonNetwork.room.CustomProperties["3v3"] == "Yes") { maxplayerstemp = 6; } int maxplayersperteam = maxplayerstemp / 2; if (templist.Count <= maxplayersperteam) { if (templist.Contains(thingtoadd) == false) { templist.Add(thingtoadd); } } else { Debug.Log("ERROR: TEAM FULL"); } LobbyScreenController.setteaminput(templist, teamkey); }
/// <summary> /// Remove all bots from the team lists and make those entities null. /// </summary> public void wipebots() { LobbyScreenController.setteam1(new List <int>()); LobbyScreenController.setteam2(new List <int>()); }
/// <summary> /// Repeats every second to update the minimap. /// </summary> void Rep() { if (UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex != 0 && UnityEngine.SceneManagement.SceneManager.GetActiveScene().buildIndex != 1) { if (Blue) { // give the player an indicator or how many ships each color owns and the player name assosiated with those ships. if (Green.gameObject.GetActive() == true) { Green.text = getplayername(LobbyScreenController.getteam1(), 0) + "Green: " + unitcontrol.teammembersout(_Ship.eShipColor.Green).Count + " ships"; } if (Blue.gameObject.GetActive() == true) { Blue.text = getplayername(LobbyScreenController.getteam1(), 1) + "Blue: " + unitcontrol.teammembersout(_Ship.eShipColor.Blue).Count + " ships"; } if (White.gameObject.GetActive() == true) { White.text = getplayername(LobbyScreenController.getteam1(), 2) + "White: " + unitcontrol.teammembersout(_Ship.eShipColor.White).Count + " ships"; } if (Yellow.gameObject.GetActive() == true) { Yellow.text = getplayername(LobbyScreenController.getteam2(), 0) + "Yellow: " + unitcontrol.teammembersout(_Ship.eShipColor.Yellow).Count + " ships"; } if (Grey.gameObject.GetActive() == true) { Grey.text = getplayername(LobbyScreenController.getteam2(), 1) + "Grey: " + unitcontrol.teammembersout(_Ship.eShipColor.Grey).Count + " ships"; } if (Red.gameObject.GetActive() == true) { Red.text = getplayername(LobbyScreenController.getteam2(), 2) + "Red: " + unitcontrol.teammembersout(_Ship.eShipColor.Red).Count + " ships"; } } if (unitcontrol == null) { unitcontrol = GameObject.Find("Controllers").GetComponent <UnitMovementcommandcontroller>(); } // moves unused blips out of view. foreach (bliplinecontroller blip in allyblips) { blip.transform.localPosition = new Vector3(100000, 100000, 100000); } foreach (bliplinecontroller blip in enemyblips) { blip.transform.localPosition = new Vector3(100000, 100000, 100000); } foreach (bliplinecontroller blip in allyblips) { blip.targetgam = new Vector3(0, 0, 0); } List <GameObject> temp = unitcontrol.teammembersout(unitcontrol.team); if (temp != null && Ships_Left_Text != null) { Kills_Text.text = " ships : " + temp.Count.ToString() + " out of " + UnitMovementcommandcontroller.getmaxshipnumbers().ToString(); List <TSTransform> enemies = unitcontrol.targetsout(unitcontrol.team); for (int i = 0; i < enemies.Count; i++) { if (enemyblips[i] != null && enemyblips[i].gameObject != null && enemies[i] != null && enemies[i].gameObject != null) { enemyblips[i].transform.localPosition = new Vector3(0, enemies[i].transform.localPosition.x * 0.35f, enemies[i].transform.localPosition.z * 0.35f); } } } if (Time_Left_Text && ismission == false) { Time_Left_Text.text = unitcontrol.gettimeleft(); } else if (AIController && AIController.timepassedactual < 30) { Time_Left_Text.text = "Time til attack: " + (30 - TSMath.Round(AIController.timepassedactual)).ToString(); } else if (unitcontrol.crosslevelholder.campaign == true && unitcontrol.crosslevelholder.campaignlevel.objective == MainMenuCampaignControlScript.eMissionObjective.Survive) { Time_Left_Text.text = "Survive for: " + unitcontrol.gettimeleft(); } else if (Time_Left_Text) { Time_Left_Text.text = unitcontrol.gettimeleft(); } List <TSTransform> allies = unitcontrol.alliesout(); for (int i = 0; i < allies.Count; i++) { if (allyblip && allyblips[i].gameObject != null) { // asigns blip positions allyblips[i].source = allies[i]; allyblips[i].transform.localPosition = new Vector3(0, allies[i].transform.localPosition.x * 0.35f, allies[i].transform.localPosition.z * 0.35f); Vector3 tempa = allies[i].shipscript.fac.localtarget.ToVector() * 0.35f; allyblips[i].targetgam = new Vector3(0, tempa.x, tempa.z); } } if (Objectsholder == null) { Objectsholder = GameObject.Find("Objects"); } if (Cameratracking == null) { if (GameObject.Find("Camera (eye)") != null) { Cameratracking = GameObject.Find("Camera (eye)"); } else { Cameratracking = GameObject.Find("CenterEyeAnchor"); } } Vector3 playerloc = Objectsholder.transform.InverseTransformPoint(Cameratracking.transform.position); playerblip.transform.localPosition = new Vector3(0, playerloc.x * 0.35f, playerloc.z * 0.35f); } }