Esempio n. 1
0
    private void CreateEnemies()
    {
        if (_enemyViews == null)
        {
            _enemyViews = new List <EnemyView>();
        }
        _enemyViews.Clear();
        EnemyModel[] enemyModels = _currentInfo.enemies;

        //实例化View并初始化
        foreach (var model in enemyModels)
        {
            string     prefabPath = JsonUtility.GetEnemyPrefabPath(model.enemyType);
            GameObject prefab     = Resources.Load <GameObject>(prefabPath);
            EnemyView  view       = ViewBase.CreateView <EnemyView>(prefab);
            view.Init(model);
            _enemyViews.Add(view);
        }
    }