private void Awake() { MatchZonesContainer container = GetComponentInParent <MatchZonesContainer>() as MatchZonesContainer; if (container != null) { container.AddZone(this); } }
private FieldZone GetZone(Zone _zone, MatchZonesContainer _container) { FieldZone zone = null; foreach (FieldZone z in _container.ZoneList) { if (z.Zone == _zone) { zone = z; } } return(zone); }
private void SpawnPlayers(TeamData _team, List <MatchPlayer> _list, Vector2 _spawnPoint, MatchZonesContainer _zones) { PlayerData[] players = _team.Squad; FormationData formation = _team.Formation; for (int i = 0; i < players.Length; i++) { MatchPlayer player = Instantiate(playerTemplate, playersContainer); player.transform.localPosition = _spawnPoint; player.Populate(players[i], (i + 1).ToString()); player.gameObject.SetActive(true); _list.Add(player); } for (int j = 0; j < formation.Zones.Length; j++) { Zone zone = formation.Zones[j]; _list[j].MoveTo(GetZone(zone, _zones).transform.position, 1f, 0.1f * j); } }