public T SpawnPlayerFor <T>(PrefabSelector <T, SpawnPrefabs> selector, Vector3 position, Quaternion rotation, GameObjectInitializer <T> initializer, GameObject player) where T : Component { var prefab = selector(prefabs); T gameObject = GameObject.Instantiate(prefab, position, rotation); initializer(gameObject); NetworkServer.SpawnWithClientAuthority(gameObject.gameObject, player); return(gameObject); }
void Start() { if (m_owningPlayer.playerNumber == 0) { m_constructableTowerSegments.Add(m_winTowerSegmentPrefabPlayer0); } else { m_constructableTowerSegments.Add(m_winTowerSegmentPrefabPlayer1); } m_prefabSelector = GetComponentInChildren <PrefabSelector>(); foreach (TowerSegment segment in m_constructableTowerSegments) { m_prefabSelector.AddSelection(segment); } }
void Start() { PrefabSelector objects = GetComponent <PrefabSelector>(); EnemySelector enemies = GetComponent <EnemySelector>(); for (int i = 0; i < prefabSpawn; i++) { float testX = Random.Range(-24 + transform.position.x, 24 + transform.position.x); int useX = Mathf.RoundToInt(testX); float testZ = Random.Range(-24 + transform.position.z, 24 + transform.position.z); int useZ = Mathf.RoundToInt(testZ); Vector3 testSpot = new Vector3(useX, 0, useZ); if (CheckSpots(testSpot)) { GameObject addMe = Instantiate(objects.givePrefab(), testSpot, Quaternion.identity) as GameObject; addMe.transform.parent = transform; TakeSpots.Add(testSpot); } } for (int i = 0; i < enemySpawn; i++) { float testX = Random.Range(-24 + transform.position.x, 24 + transform.position.x); int useX = Mathf.RoundToInt(testX); float testZ = Random.Range(-24 + transform.position.z, 24 + transform.position.z); int useZ = Mathf.RoundToInt(testZ); Vector3 testSpot = new Vector3(useX, 0, useZ); if (CheckEnemySpots(testSpot)) { GameObject addMe = Instantiate(enemies.givePrefab(), testSpot, Quaternion.identity) as GameObject; addMe.transform.parent = transform; TakeSpots.Add(testSpot); } else { i--; } } }
public T GetPrefab <T>(PrefabSelector <T, SpawnPrefabs> selector) where T : Component { return(selector(prefabs)); }