Beispiel #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;
    }
Beispiel #2
0
 private void DestroyPlayer()
 {
     Disable();
     Destroy?.Invoke(_playerModel.CurrentScore);
     _playerView.DestroyPlayer();
     _playerViewUI.DestroyPlayer();
     _playerView   = null;
     _playerViewUI = null;
     _playerModel  = null;
 }
Beispiel #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();
    }
Beispiel #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;
        }
    }
Beispiel #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();
            }
        }
    }
Beispiel #6
0
 protected virtual void OnDestroy()
 {
     Destroy?.Invoke(this, new EventArgs());
 }
Beispiel #7
0
 private void OnDestroy()
 {
     Destroy?.Invoke();
 }
 protected override void OnDestroy()
 {
     Destroy?.Invoke(this, new EventArgs());
     base.OnDestroy();
 }
Beispiel #9
0
 public virtual void OnDestroy()
 {
     Destroy?.Invoke(this, new DestroyEventArgs(this));
 }
Beispiel #10
0
 protected virtual void OnDestroy()
 {
     Destroy?.Invoke(this, EventArgs.Empty);
 }
 private void OnDestroy()
 {
     InvokeCommon <OnDestroyMethodAttribute>();
     Destroy?.Invoke();
     s_instance = null;
 }
Beispiel #12
0
 public void DestroyPlayer(float score)
 {
     Destroy?.Invoke(score);
     _playerController.Destroy -= DestroyPlayer;
     _playerController          = null;
 }
Beispiel #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);
 }
 internal void PerformDestroy()
 {
     OnDestroy();
     Destroy?.Invoke(this);
 }