void SpecialEventOnSpawn() { _enemyMovement = _enemy.GetComponent <EnemyMovement>(); OnSpawnEvent onSpawnEvent = _enemy.GetComponent <OnSpawnEvent>(); onSpawnEvent.SpawnEvent(_enemy); }
/// <summary> /// Spawn the entity /// </summary> /// <param name="position">The position of entity</param> /// <param name="rotation">The rotation of entity</param> /// <param name="evt">On spawn entity message</param> /// <returns>New entity</returns> public GameObject Spawn(Vector3 position, Quaternion rotation, OnSpawnEvent evt) { GameObject go = GameObject.Instantiate(prefab, position, rotation) as GameObject; go.SendMessage("OnSpawned", evt); return(go); }
// Use this for initialization void OnEnable() { if (OnSpawned == null) { OnSpawned = new OnSpawnEvent(); } }
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(); }
/// <summary> /// Invokes the selected onSpawnEvent /// </summary> /// <param name="onSpawnEvent">Which UnityEvent should get invoked.</param> private void InvokeOnSpawnEvent(OnSpawnEvent onSpawnEvent) { switch (onSpawnEvent) { case OnSpawnEvent.OnSpawnStarted: OnSpawnStarted.Invoke(); break; case OnSpawnEvent.OnSpawnStopped: OnSpawnStopped.Invoke(); break; case OnSpawnEvent.OnSpawnResumed: OnSpawnResumed.Invoke(); break; case OnSpawnEvent.OnSpawnPaused: OnSpawnPaused.Invoke(); break; case OnSpawnEvent.OnSpawnFinished: OnSpawnFinished.Invoke(); break; } }
/// <summary> /// Remove a listener for the specified spawn event callback. /// </summary> /// <param name="onSpawnEvent">Which callback should stop invoking the listener function.</param> /// <param name="listener">Listener to be removed.</param> public void RemoveOnSpawnCallbackListener(OnSpawnEvent onSpawnEvent, UnityAction listener) { switch (onSpawnEvent) { case OnSpawnEvent.OnSpawnStarted: OnSpawnStarted.RemoveListener(listener); break; case OnSpawnEvent.OnSpawnStopped: OnSpawnStopped.RemoveListener(listener); break; case OnSpawnEvent.OnSpawnResumed: OnSpawnResumed.RemoveListener(listener); break; case OnSpawnEvent.OnSpawnPaused: OnSpawnPaused.RemoveListener(listener); break; case OnSpawnEvent.OnSpawnFinished: OnSpawnFinished.RemoveListener(listener); break; } }
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); }
/// <summary> /// Spawn the entity at default position /// </summary> /// <param name="evt">On spawn entity message</param> /// <returns>New entity</returns> public GameObject Spawn(OnSpawnEvent evt) { return(Spawn(Vector3.zero, Quaternion.identity, evt)); }
public void OnGameBegon() { StartCoroutine(SpawnWave()); OnSpawnEvent?.Invoke(); FindObjectOfType <GameManager>().OnRoundEndEvent += EnumarateVariables; }
public GameObject Spawn(OnSpawnEvent evt) { return Spawn(Vector3.zero, Quaternion.identity, evt); }
public GameObject Spawn(Vector3 position, Quaternion rotation, OnSpawnEvent evt) { GameObject go = GameObject.Instantiate(prefab, position, rotation) as GameObject; go.SendMessage("OnSpawned", evt); return go; }
/************************************************************************************************************************/ public void OnSpawn() { OnSpawnEvent.Invoke(); }
public void Spawn(Vector3 position) { transform.position = position; OnSpawnEvent?.Invoke(this); Show(); }