public void Init(IInitContext context, Settings.Battle settings, Settings.Enemies enemiesSettings, Settings.Weapon[] weaponsSettings, Settings.Size windowSize) { base.Init(new Point(windowSize.Width, windowSize.Height)); initContext = context; this.settings = settings; this.weaponsSettings = weaponsSettings; Health = settings.Health; Amount = settings.Amount; WeaponPods = new WeaponPod[settings.WeaponPlaces.Length]; for (int i = 0; i < settings.WeaponPlaces.Length; i++) { var setting = settings.WeaponPlaces[i]; var wp = context.ObjectPool.GetObject <WeaponPod>(); wp.Init(setting); WeaponPods[i] = wp; } Waves = new EnemyWave[settings.Waves.Length]; for (int i = 0; i < settings.Waves.Length; i++) { var setting = settings.Waves[i]; var wave = context.ObjectPool.GetObject <EnemyWave>(); wave.Init(context, setting, enemiesSettings, settings.Paths); Waves[i] = wave; } changeStatusSubscription = context.Dispatcher.Subscribe <ChangeStatusMessage>(OnChangeStatus); Status = BattleSceneStatus.Active; }
public void Init(IInitContext context, Settings.EnemyWave settings, Settings.Enemies enemiesSettings, Settings.Path[] pathsSettings) { initContext = context; this.settings = settings; logger.Info($"Wave {settings.Id} init"); //Relative = TimeSpan.FromMilliseconds(settings.StartTimeOffset); Sets = new EnemySet[settings.Sets.Length]; for (int i = 0; i < settings.Sets.Length; i++) { var setting = settings.Sets[i]; var set = context.ObjectPool.GetObject <EnemySet>(); var enemySettings = enemiesSettings.GetEnemyById(setting.EnemyId); var pathSettings = pathsSettings.Single(p => string.Equals(p.Id, setting.PathId, StringComparison.Ordinal)); set.Init(context, setting, enemySettings, pathSettings); Sets[i] = set; } Status = EnemyWaveStatus.Ready; }