public void Despawn(GameObject go) { Define.WorldObject type = GetWorldObjectType(go); switch (type) { case Define.WorldObject.Monster: { if (_monsters.Contains(go)) { _monsters.Remove(go); if (OnSpawnEvent != null) { OnSpawnEvent.Invoke(-1); } } } break; case Define.WorldObject.Player: { if (_player == go) { _player = null; } } break; } Managers.Resource.Destroy(go); }
public void OnSpawn() { foreach (var pc in m_Pcs) { pc.OnSpawn(); } OnSpawnEvent?.Invoke(); }
private IEnumerator AfterSpawn(GameObject instance) { onSpawn.Invoke(instance); var name = instance.name; yield return(new WaitUntil(() => instance == null)); Debug.Log("AfterSpawn " + name + " destroyed "); onDestroy.Invoke(instance); }
private IEnumerator AfterSpawn(GameObject instance) { var lifecycle = instance.AddComponent(typeof(InstanceLifeCycle)) as InstanceLifeCycle; lifecycle.onDestroy = onDestroy; lifecycle.onMouseDown = onMouseDown; onSpawn.Invoke(instance); var name = instance.name; yield return(new WaitUntil(() => instance == null)); }
void Start() { foreach (var item in spawnInstances) { item.onSpawn.AddListener((GameObject instance) => { onSpawn.Invoke(instance); instances.Add(instance); }); item.onDestroy.AddListener((GameObject instance) => { instances.Remove(instance); onDestroy.Invoke(instance); }); } }
void SpawnObjects() { int randomInt = Random.Range(0, m_SpawnObjects.Count); if (randomInt < m_SpawnObjects.Count) { GameObject curGO = Instantiate(m_SpawnObjects[randomInt], transform.position, Quaternion.identity).gameObject; spawnedObjects.Add(curGO); currentSpanwCount++; if (OnSpawned != null) { OnSpawned.Invoke(curGO); } } }
private void OnDestroy() { if (shouldSpawn) { Transform spawn; if (shareParent) { spawn = Instantiate(Spawn, transform.parent); } else { spawn = Instantiate(Spawn); } spawn.position = transform.position; spawn.rotation = transform.rotation; OnSpawn.Invoke(spawn); } }
public GameObject Spawn(Define.WorldObject type, string path, Transform parent = null) { GameObject go = Managers.Resource.Instantiate(path, parent); switch (type) { case Define.WorldObject.Monster: _monsters.Add(go); if (OnSpawnEvent != null) { OnSpawnEvent.Invoke(1); } break; case Define.WorldObject.Player: _player = go; break; } return(go); }
public void Spawn(PoolType id, GameObject prefab, Vector3 pos, Quaternion rot) { OnSpawnEvent.Invoke(id, prefab, pos, rot); }
void OnDestroy() { onDestroy.Invoke(gameObject); Debug.Log("InstanceLifeCycle OnDestroy " + gameObject.name); }
public void OnGameBegon() { StartCoroutine(SpawnWave()); OnSpawnEvent?.Invoke(); FindObjectOfType <GameManager>().OnRoundEndEvent += EnumarateVariables; }
/************************************************************************************************************************/ public void OnSpawn() { OnSpawnEvent.Invoke(); }
public void Spawn(Vector3 position) { transform.position = position; OnSpawnEvent?.Invoke(this); Show(); }