private void GoalScored(Globals.Team team) { switch (team) { case Globals.Team.LEFT: leftScore++; leftScoreText.text = leftScore.ToString(); break; case Globals.Team.RIGHT: rightScore++; rightScoreText.text = rightScore.ToString(); break; } }
private bool CanSelectTeam(Globals.Team team) { // Can't have more than half players on one team float halfPlayers = 0.5f * controlPosition.Count; int teamCount = 0; foreach (Globals.Team t in controlPosition) { if (t == team) { teamCount++; } } return(teamCount < halfPlayers); }
public void SetTeam(Globals.Team playerTeam) { team = playerTeam; if (team == Globals.Team.NONE) { sr.color = Color.white; } if (team == Globals.Team.LEFT) { sr.color = Color.blue; } if (team == Globals.Team.RIGHT) { sr.color = Color.red; } }
public void Init(int playerId, Globals.Team teamId, Sprite bodySprite) { this.playerID = playerId; this.teamId = teamId; foreach (HandMan hand in GetComponentsInChildren <HandMan>()) { player = ReInput.players.GetPlayer(playerID); hand.player = player; } foreach (Transform child in transform) { if (child.tag == "Body") { child.GetComponent <SpriteRenderer>().sprite = bodySprite; } } }
void Start() { rb = GetComponent <Rigidbody2D>(); teamId = this.transform.parent.GetComponent <Player>().teamId; // new way foreach (Transform child in transform) { if (child.name == "Left Arm") { leftArm = child.transform; foreach (Transform subChild in child) { if (subChild.CompareTag("Hand")) { leftHand = subChild.GetComponent <HandMan>(); leftHand.teamId = teamId; } } } else if (child.name == "Right Arm") { rightArm = child.transform; foreach (Transform subChild in child) { if (subChild.CompareTag("Hand")) { rightHand = subChild.GetComponent <HandMan>(); rightHand.teamId = teamId; } } } } foreach (Transform child in transform) { if (child.tag == "TeamHitter") { child.gameObject.layer = LayerMask.NameToLayer(Globals.TEAM_NAMES[(int)teamId]); } } }