Пример #1
0
    void SpecialEventOnSpawn()
    {
        _enemyMovement = _enemy.GetComponent <EnemyMovement>();
        OnSpawnEvent onSpawnEvent = _enemy.GetComponent <OnSpawnEvent>();

        onSpawnEvent.SpawnEvent(_enemy);
    }
Пример #2
0
    /// <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();
     }
 }
Пример #4
0
    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);
    }
Пример #5
0
 public void OnSpawn()
 {
     foreach (var pc in m_Pcs)
     {
         pc.OnSpawn();
     }
     OnSpawnEvent?.Invoke();
 }
Пример #6
0
        /// <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;
            }
        }
Пример #7
0
        /// <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;
            }
        }
Пример #8
0
    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);
 }
Пример #10
0
 /// <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));
 }
Пример #11
0
 public void OnGameBegon()
 {
     StartCoroutine(SpawnWave());
     OnSpawnEvent?.Invoke();
     FindObjectOfType <GameManager>().OnRoundEndEvent += EnumarateVariables;
 }
Пример #12
0
 public GameObject Spawn(OnSpawnEvent evt)
 {
     return Spawn(Vector3.zero, Quaternion.identity, evt);
 }
Пример #13
0
 public GameObject Spawn(Vector3 position, Quaternion rotation, OnSpawnEvent evt)
 {
     GameObject go = GameObject.Instantiate(prefab, position, rotation) as GameObject;
     go.SendMessage("OnSpawned", evt);
     return go;
 }
Пример #14
0
        /************************************************************************************************************************/


        public void OnSpawn()
        {
            OnSpawnEvent.Invoke();
        }
Пример #15
0
 public void Spawn(Vector3 position)
 {
     transform.position = position;
     OnSpawnEvent?.Invoke(this);
     Show();
 }