private IAction CreateAction(ActionConfig actionConfig, DungeonLogic dungeonLogic) { Type actionClass = Type.GetType(actionConfig.ClassName()); IAction action = (IAction)actionClass.GetConstructor(Type.EmptyTypes).Invoke(new object[] { }); action.SetCookies(actionConfig.CookiesList()); action.SetEnv(defaultEnvironment); action.SetDungeonLogic(dungeonLogic); return(action); }
public DungeonLogic CreateDungeon(int dungeonId) { DungeonLogic dungeonLogic = new DungeonLogic(); dungeonLogic.AddComponent(new EnvironmentComponent(defaultEnvironment)); CreateStages(dungeonConfig, dungeonLogic); CreateGates(dungeonConfig, dungeonLogic); CreateStageActivators(dungeonConfig, dungeonLogic); return(dungeonLogic); }
private void CreateGates(Configs.DungeonConfig dungeonCfg, DungeonLogic dungeonLogic) { foreach (GateConfig gateConfig in dungeonCfg.ShowGateList()) { Type gateClass = Type.GetType(gateConfig.ClassName()); Gates.GateController gateController = (Gates.GateController)gateClass .GetConstructor(new[] { typeof(int), typeof(Environment.Environment) }) .Invoke(new object[] { gateConfig.Id(), defaultEnvironment }); gateClass.GetMethod("SetCookies").Invoke(gateController, new[] { gateConfig.CookiesList() }); dungeonLogic.AddGate(gateController); } }
private void CreateStages(DungeonConfig dungeonCfg, DungeonLogic dungeonLogic) { foreach (StageConfig stageConfig in dungeonCfg.StageList()) { DefaultStage stage = new DefaultStage(defaultEnvironment); dungeonLogic.AddStage(stage); CreateGoals(stageConfig, stage); CreateLosingConditions(stageConfig, stage); CreateWaves(stageConfig, stage, dungeonLogic); } }
private void CreateStageActivators(Configs.DungeonConfig dungeonConfigCfg, DungeonLogic dungeonLogic) { foreach (StageActivatorConfig stageActivatorConfig in dungeonConfigCfg.StageActivatorList()) { Type stageActivatorClass = Type.GetType(stageActivatorConfig.ClassName()); StageActivators.StageActivator stageActivator = (StageActivators.StageActivator)stageActivatorClass .GetConstructor(new[] { typeof(Environment.Environment) }) .Invoke(new object[] { defaultEnvironment }); stageActivatorClass.GetMethod("SetCookies") .Invoke(stageActivator, new[] { stageActivatorConfig.CookiesList() }); dungeonLogic.AddStageActivator(stageActivator); } }
private void CreateWaves(StageConfig stageConfig, DefaultStage stage, DungeonLogic dungeonLogic) { List <WaveConfig> waves = stageConfig.WaveList(); for (int waveIndex = 0; waveIndex < waves.Count; waveIndex++) { WaveConfig w = waves[waveIndex]; if (w.IsDisabled()) { continue; } DefaultWaveLogic waveLogic = new DefaultWaveLogic(waveIndex + 1); List <ChallengeConfig> challengeConfigs = w.ChallengeList(); for (int challengeIndex = 0; challengeIndex < challengeConfigs.Count; challengeIndex++) { ChallengeConfig challengeConfig = challengeConfigs[challengeIndex]; if (challengeConfig.IsDisabled()) { continue; } ActionsByLayer actionsByLayer = CreateActionsByLayer(challengeConfig.SpawnConfig().ActionConfigs(), dungeonLogic); Challenge challenge = CreateChallenge(challengeConfig, actionsByLayer.allActions, dungeonLogic); // challenge.Name = (waveIndex + 1) + "-" + (challengeIndex + 1); waveLogic.AddChallenge(challenge); foreach (IAction stageAction in actionsByLayer.stageActions) { stage.AddAction(stageAction); } foreach (IAction dungeonAction in actionsByLayer.dungeonActions) { dungeonLogic.AddAction(dungeonAction); } } stage.AddWave(waveLogic); } }
private ActionsByLayer CreateActionsByLayer(List <ActionConfig> actionConfigs, DungeonLogic dungeonLogic) { ActionsByLayer actionsByLayer = new ActionsByLayer(); foreach (ActionConfig actionConfig in actionConfigs) { if (actionConfig.IsDisabled()) { continue; } IAction action = CreateAction(actionConfig, dungeonLogic); actionsByLayer.allActions.Add(action); switch (action.GetLayer()) { case DungeonSpawnConfig.ActionLayer.Stage: actionsByLayer.stageActions.Add(action); break; case DungeonSpawnConfig.ActionLayer.Dungeon: actionsByLayer.dungeonActions.Add(action); break; } } return(actionsByLayer); }
private Challenge CreateChallenge(ChallengeConfig challengeConfig, List <IAction> actions, DungeonLogic dungeonLogic) { Trigger startTrigger = CreateTrigger(challengeConfig.StartTrigger()); SpawnOverTime sot = CreateSpawnOverTime(challengeConfig.SpawnConfig()); List <TrackerConfig> trackerConfigs = challengeConfig.SpawnConfig().TrackerConfigs(); foreach (TrackerConfig trackerConfig in trackerConfigs) { if (!trackerConfig.IsActive()) { continue; } Tracker tracker = CreateTracker(trackerConfig); sot.AddTracker(tracker); } // List<ActionConfig> actionConfigs = challengeConfig.SpawnConfig().ActionConfigs(); // foreach (ActionConfig actionConfig in actionConfigs) // { // if (actionConfig.IsDisabled()) continue; // // IAction action = CreateAction(actionConfig, dungeonLogic); // sot.AddAction(action); // } foreach (IAction action in actions) { sot.AddAction(action); } DefaultChallenge challenge = new DefaultChallenge(startTrigger, sot); return(challenge); }