/// <summary> /// Starts the game for the DistrictManager for a given amount of teams. /// </summary> public void StartGame(int amountOfTeams) { m_DistrictColliders = new PolygonCollider2D[gameObject.transform.childCount]; for (int i = 0; i < gameObject.transform.childCount; i++) { m_DistrictColliders[i] = gameObject.transform.GetChild(i).gameObject.GetComponent <PolygonCollider2D>(); } // Loops trough all district groups and allocates the teams and types. for (int i = 0; i < transform.childCount; i++) { Transform child = transform.GetChild(i); CapturableDistrict cd = child.GetComponent <CapturableDistrict>(); if (cd != null) { int teamIndex = CurrentGame.Instance.GetTeamIndex(transform.GetChild(i).gameObject.name); bool mainDistrict = CurrentGame.Instance.isHeadDistrict(transform.GetChild(i).gameObject.name); if (transform.GetChild(i).gameObject.name.Equals("4a", StringComparison.InvariantCultureIgnoreCase)) { Debug.Log("DSITRICT FOUND"); } //find team if any ServerTeam team = null; if (teamIndex >= 0) { team = CurrentGame.Instance.gameDetail.GetTeamByIndex(teamIndex); } //check for main district and assign if (mainDistrict) { HeadDistrict district = transform.GetChild(i).gameObject.GetComponent <HeadDistrict>(); district.Team = team; district.enabled = true; m_HeadDistricts.Add(district); Destroy(district.GetComponent <CapturableDistrict>()); Treasure square = district.transform.GetChild(0).gameObject.GetComponent <Treasure>(); square.Team = team; square.enabled = true; Destroy(district.transform.GetChild(0).GetComponent <CapturePoint>()); } else { CapturableDistrict district = transform.GetChild(i).gameObject.GetComponent <CapturableDistrict>(); district.Team = team; district.enabled = true; Destroy(district.GetComponent <HeadDistrict>()); CapturePoint square = district.transform.GetChild(0).gameObject.GetComponent <CapturePoint>(); square.Team = team; square.enabled = true; Destroy(district.transform.GetChild(0).GetComponent <Treasure>()); district.OnTeamChanged(); } } } }
/// <summary> /// Starts the game for the DistrictManager for a given amount of teams. /// </summary> public void StartGame(int amountOfTeams) { m_DistrictColliders = new PolygonCollider2D[gameObject.transform.childCount]; for (int i = 0; i < gameObject.transform.childCount; i++) { m_DistrictColliders[i] = gameObject.transform.GetChild(i).gameObject.GetComponent <PolygonCollider2D>(); } // Loops trough all district groups and allocates the teams and types. for (int i = 1; i <= 6; i++) { if (amountOfTeams >= i) { HeadDistrict district = transform.GetChild(i).gameObject.GetComponent <HeadDistrict>(); district.Team = (TeamID)(i); district.enabled = true; m_HeadDistricts.Add(district); Destroy(district.GetComponent <CapturableDistrict>()); Treasure square = district.transform.GetChild(0).gameObject.GetComponent <Treasure>(); square.Team = (TeamID)(i); square.enabled = true; Destroy(district.transform.GetChild(0).GetComponent <CapturePoint>()); } else { CapturableDistrict district = transform.GetChild(i).gameObject.GetComponent <CapturableDistrict>(); district.Team = TeamID.NoTeam; district.enabled = true; Destroy(district.GetComponent <HeadDistrict>()); CapturePoint square = district.transform.GetChild(0).gameObject.GetComponent <CapturePoint>(); square.Team = TeamID.NoTeam; square.enabled = true; Destroy(district.transform.GetChild(0).GetComponent <Treasure>()); } } }