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