public void Init(Hashtable changeStateData)
    {
        _gameMode = GameMode.COMBAT;

        _playerCombatSystem = _diContainer.Resolve<PlayerCombatSystem>();
        _buildSystem = _diContainer.Resolve<BuildingSystem>();
        _inventorySystem = _diContainer.Resolve<InventorySystem>();
        _enemySystem = _diContainer.Resolve<EnemySystem>();
        _lootSystem = _diContainer.Resolve<LootSystem>();
        _particleGod = _diContainer.Resolve<ParticleGOD>();
        _monsterGenerator = _diContainer.Resolve<MonsterGenerator>();
        
        Singleton.instance.audioSystem.GenerateAudioLookupForLevel();
        _particleGod.InitParticlePool();

        //HUD
        _hudController = new HUDController(_gameConfig.playerConfig,_gameConfig.hudConfig);
        _hudController.Start(() =>
        {
            _monsterGenerator.Init(_hudController, _playerCombatSystem);
        });

        _playerCombatSystem.Init(_hudController);
        _buildSystem.Init();
        _enemySystem.Init();
        _lootSystem.Init();
        _inventorySystem.Init();

        // Get CombatPlayerView
        //_playerCombatSystem.isEnabled = true;
        _dispatcher.AddListener(GameplayEventType.DAMAGE_TAKEN, onDamageTaken);
        _dispatcher.AddListener(GameplayEventType.GAME_COMPLETE, onGameComplete);
        _dispatcher.AddListener(GameplayEventType.GAME_RETRY, onGameRetry);
    }
Exemplo n.º 2
0
    void LoadEnemies()
    {
        var enemies = FindObjectsOfType <EnemySystem>();

        foreach (var runtime in saveGame.enemyRuntimes)
        {
            EnemyRuntime foundRuntime = null;
            EnemySystem  foundSystem  = null;

            foreach (var enemy in enemies)
            {
                var enemySaveGameId = enemy.GetComponent <SaveGameIdSystem>().SaveGameId;
                if (enemySaveGameId == runtime.saveGameId)
                {
                    foundRuntime = runtime;
                    foundSystem  = enemy.GetComponent <EnemySystem>();
                    break;
                }
            }

            if (foundRuntime == null)
            {
                var spawned = Instantiate(runtimePrefabSettings.enemyCharacterPrefab, runtime.position, runtime.rotation);
                spawned.transform.localScale = runtime.scale;
                spawned.GetComponent <SaveGameIdSystem>().SaveGameId = runtime.saveGameId;
                spawned.GetComponent <EnemySystem>().OnLoad(saveGame);
            }
            else
            {
                foundSystem.OnLoad(saveGame);
            }
        }
    }
Exemplo n.º 3
0
        public static EnemySystem Enemy(Data.EnemyEntity.Enemy data, Vector3 position, List <Vector3> waypoints, bool isOwnedByPlayer = true, GameObject prefab = null)
        {
            var enemy       = prefab ?? U.Instantiate(data.Prefab, position, Quaternion.identity, ReferenceHolder.Instance.EnemyParent);
            var enemySystem = new EnemySystem(enemy, waypoints, isOwnedByPlayer)
            {
                Data = data
            };

            enemySystem.SetSystem(GameData.Instance.Player);

            return(enemySystem);
        }
Exemplo n.º 4
0
    //// Public API
    public SpawnSystem(Transform enemyParent)
    {
        this._gameManager = GameManager.Instance;

        GameObject enemyPrefab = Resources.Load("Prefabs/Enemy") as GameObject;

        _enemySystem = new EnemySystem(enemyPrefab, _gameManager.EnemyPoolSize, enemyParent);

        PrepareSpawnPointList();

        LoadDataFiles();
    }
Exemplo n.º 5
0
 public void Init()
 {
     Instanc = this;
     //保存所有种类敌人,可以根据名字获取
     Enemy[] enemys = Resources.LoadAll <Enemy>("Prefab/Chara/EnemyChara");
     for (int i = 0; i < enemys.Length; i++)
     {
         if (!enemyDict.ContainsKey(enemys[i].name))
         {
             enemyDict.Add(enemys[i].name, enemys[i]);
             enemys[i].enemyPool = GameObjectPool.Instance.GetPool(enemys[i].name);
         }
     }
 }
Exemplo n.º 6
0
    public MonsterGenerator(GameConfig gameConfig, EnemySystem enemySystem)
    {
        _dispatcher = Singleton.instance.notificationDispatcher;
        // TODO: Klean it up!
        _dispatcher.AddListener(GameplayEventType.ENEMY_KILLED, onEnemyKilled);
        _dispatcher.AddListener(GameplayEventType.GAME_COMPLETE, OnGameComplete);

        _levelConfig = gameConfig.levelConfig;
        _enemySystem = enemySystem;

        if (_levelConfig.levels.Count == 0)
        {
            Debug.LogError("NO LEVELS LOADED IN LEVEL CONFIG!");
        }
        else
        {
            _levelDef = _levelConfig.levels[0];
        }
    }
Exemplo n.º 7
0
        public void SetSystem(PlayerSystem player)
        {
            Owner = player;
            Owner.PlayerInputSystem.ClickedOnEnemy += OnClickedOnEnemy;
            hpText = EnemyUI.GetComponentInChildren <TextMeshProUGUI>();
            hpBar  = EnemyUI.transform.GetChild(0).GetComponent <Image>();
            EnemyUI.SetActive(false);

            void OnClickedOnEnemy(GameObject e)
            {
                for (int i = 0; i < Owner.EnemyControlSystem.AllEnemies.Count; i++)
                {
                    if (Owner.EnemyControlSystem.AllEnemies[i].Prefab == e)
                    {
                        enemy = Owner.EnemyControlSystem.AllEnemies[i];
                        break;
                    }
                }

                EnemyUI.SetActive(true);
            }
        }
Exemplo n.º 8
0
 private void Awake()
 {
     instance = this;
 }
Exemplo n.º 9
0
 // Start is called before the first frame update
 void Start()
 {
     cardSystem  = CardSystem.instance;
     enemySystem = EnemySystem.instance;
 }
Exemplo n.º 10
0
        void Update()
        {
            pointerEventData.position = Input.mousePosition;

            if (Input.GetMouseButtonDown(0))
            {
                WorldRay = Camera.main.ScreenPointToRay(Input.mousePosition);

                isHitUI = EventSystem.currentSelectedGameObject != null;

                if (!isHitUI)
                {
                    if (Physics.Raycast(WorldRay, out hit, 100000, layerMask))
                    {
                        var isMouseOnSpirit = hit.transform.gameObject.layer == 14;
                        var isMouseOnGround = hit.transform.gameObject.layer == 9;
                        var isMouseOnCell   = hit.transform.gameObject.layer == 15;
                        var isMouseOnEnemy  = hit.transform.gameObject.layer == 12;

                        if (ChoosedSpirit != null)
                        {
                            ChoosedSpirit.ShowRange(false);
                        }

                        if (isMouseOnSpirit)
                        {
                            GetChoosedSpirit();
                            ClickedOnSpirit?.Invoke(hit.transform.gameObject);
                        }

                        if (isMouseOnEnemy)
                        {
                            GetChoosedEnemy();
                            ClickedOnEnemy?.Invoke(hit.transform.gameObject);
                        }

                        if (isMouseOnGround)
                        {
                            ClikedOnGround?.Invoke();
                            ChoosedSpirit = null;
                            choosedEnemy  = null;
                            SetSelection(false);
                        }

                        if (isMouseOnCell)
                        {
                            ClickedOnCell?.Invoke(hit.transform.gameObject);
                            ChoosedSpirit = null;
                            choosedEnemy  = null;
                            SetSelection(false);
                        }
                    }
                }
            }

            if (Input.GetMouseButtonDown(1))
            {
                RMBPresed?.Invoke();
                ChoosedSpirit = null;
                choosedEnemy  = null;
                SetSelection(false);
            }


            #region Helper functions

            void GetChoosedSpirit()
            {
                ChoosedSpirit = Owner.SpiritControlSystem.AllSpirits.Find(spirit => spirit.Prefab == hit.transform.gameObject);
                ChoosedSpirit.ShowRange(true);
                Owner.SpiritUISystem.ActivateUpgradeButton(CheckGradeListOk(out _));
                ActivateSelection(ChoosedSpirit);
            }

            void GetChoosedEnemy()
            {
                choosedEnemy = Owner.EnemyControlSystem.AllEnemies.Find(enemy => enemy.Prefab == hit.transform.gameObject);
                ActivateSelection(choosedEnemy);
            }

            #endregion
        }