예제 #1
0
    public void DestroyEnemy(EnemyController controller, EnemyView view)
    {
        var model = _controllerModelPairs[controller];

        if (model.Description.CreateNewEnemyAfterDie)
        {
            EnemyController[] controllers;
            EnemyModel[]      models;
            EnemyView[]       views;

            int numPrefab   = Convert.ToInt32(model.Description.TypeEnemy);
            int countChilds = 2;
            _enemySpawnManager.SpawnChildEnemy(model, _enemyPrefabs[numPrefab], countChilds, out controllers, out models, out views);
            if (controllers != null && models != null && views != null)
            {
                for (int i = 0; i < countChilds; i++)
                {
                    controllers[i].Destroy += DestroyEnemy;
                    _controllerModelPairs.Add(controllers[i], models[i]);
                    _viewModelPairs.Add(views[i], models[i]);
                    _enemyModels.Add(models[i]);
                }
            }
        }
        Destroy?.Invoke(model);
        _enemyModels.Remove(model);
        _controllerModelPairs.Remove(controller);
        _viewModelPairs.Remove(view);
        controller.Destroy -= DestroyEnemy;
        controller          = null;
    }
예제 #2
0
 private void DestroyPlayer()
 {
     Disable();
     Destroy?.Invoke(_playerModel.CurrentScore);
     _playerView.DestroyPlayer();
     _playerViewUI.DestroyPlayer();
     _playerView   = null;
     _playerViewUI = null;
     _playerModel  = null;
 }
예제 #3
0
    //销毁
    public void Release()
    {
        using (var enumerator = m_inactitveGameObjects.GetEnumerator())
        {
            while (enumerator.MoveNext())
            {
                if (pDestroy != null)
                {
                    pDestroy.Invoke(enumerator.Current);
                }
            }
        }
        for (int i = 0; i < m_actitveGameObjects.Count; i++)
        {
            if (pDestroy != null)
            {
                pDestroy.Invoke(m_actitveGameObjects[i]);
            }
        }

        m_inactitveGameObjects.Clear();
        m_actitveGameObjects.Clear();
    }
예제 #4
0
    public void DestroyAllEnemies()
    {
        _viewModelPairs.Clear();
        var controllerModelArray = _controllerModelPairs.Keys.ToArray();

        for (int i = controllerModelArray.Length - 1; i >= 0; i--)
        {
            var model = _controllerModelPairs[controllerModelArray[i]];
            Destroy?.Invoke(model);
            _enemyModels.Remove(model);
            _controllerModelPairs.Remove(controllerModelArray[i]);
            controllerModelArray[i].Destroy -= DestroyEnemy;
            controllerModelArray[i]          = null;
        }
    }
예제 #5
0
    private void OnDestroy()
    {
        Destroy?.Invoke();
        if (_enemy != null)
        {
            _enemy.Kill?.Invoke();
        }

        var units = transform.parent.GetComponentsInChildren <Unit>();

        if (_enemy != null && units.Length == 1)
        {
            if (_enemy.GetComponent <WorkWithUI>() != null)
            {
                _enemy.GetComponent <WorkWithUI>().StopGame();
            }
        }
    }
예제 #6
0
 protected virtual void OnDestroy()
 {
     Destroy?.Invoke(this, new EventArgs());
 }
예제 #7
0
 private void OnDestroy()
 {
     Destroy?.Invoke();
 }
예제 #8
0
 protected override void OnDestroy()
 {
     Destroy?.Invoke(this, new EventArgs());
     base.OnDestroy();
 }
예제 #9
0
 public virtual void OnDestroy()
 {
     Destroy?.Invoke(this, new DestroyEventArgs(this));
 }
예제 #10
0
 protected virtual void OnDestroy()
 {
     Destroy?.Invoke(this, EventArgs.Empty);
 }
 private void OnDestroy()
 {
     InvokeCommon <OnDestroyMethodAttribute>();
     Destroy?.Invoke();
     s_instance = null;
 }
예제 #12
0
 public void DestroyPlayer(float score)
 {
     Destroy?.Invoke(score);
     _playerController.Destroy -= DestroyPlayer;
     _playerController          = null;
 }
예제 #13
0
 private void OnPlaneHit(object sender, EventArgs ea)
 {
     Destroy?.Invoke(this, EventArgs.Empty);
 }
 public void OnDestroy()
 {
     Destroy?.Invoke(this, this);
 }
 public void Hit()
 {
     Destroy?.Invoke(this, EventArgs.Empty);
 }
예제 #16
0
 internal void PerformDestroy()
 {
     OnDestroy();
     Destroy?.Invoke(this);
 }