Ejemplo n.º 1
0
        public void StartUp()
        {
            //DLog.Log("Dungeon start up");
            foreach (Component component in components)
            {
                component.StartUp();
            }

            CheckStagesIsConfigProperly();
            activeStage          = stages[0];
            activeStageComponent = new StageComponent(activeStage);
            AddComponent(activeStageComponent);

            CheckStageCountMatchGateCount();
            if (gates.Count > 0)
            {
                activeGateController = gates[0];
            }

            CheckStageCountMatchStageActivatorCount();
            if (stageActivators.Count > 0)
            {
                activeStageActivator = stageActivators[0];
            }

            activeStage.OnStart();
            activeStage.ListenToWaveCycle(OnWaveCycle);

            DungeonActionComponent actionComponent = new DungeonActionComponent(actions);

            AddComponent(actionComponent);
        }
Ejemplo n.º 2
0
 private void CreateGoals(StageConfig stageConfigConfig, DefaultStage stage)
 {
     foreach (GoalConfig goalConfig in stageConfigConfig.GoalList())
     {
         Type goalClass         = Type.GetType(goalConfig.ClassName());
         Stages.Goals.Goal goal = (Stages.Goals.Goal)goalClass
                                  .GetConstructor(new[] { typeof(Environment.Environment) })
                                  .Invoke(new object[] { defaultEnvironment });
         goalClass.GetMethod("SetCookies").Invoke(goal, new[] { goalConfig.CookiesList() });
         stage.AddGoal(goal);
     }
 }
Ejemplo n.º 3
0
 private void CreateLosingConditions(StageConfig stageConfigConfig, DefaultStage stage)
 {
     foreach (LosingCondition losingConditionConfig in stageConfigConfig.LosingConditionList())
     {
         Type losingConditionClass = Type.GetType(losingConditionConfig.ClassName());
         Stages.LosingConditions.LosingCondition losingCondition =
             (Stages.LosingConditions.LosingCondition)losingConditionClass
             .GetConstructor(new[] { typeof(Environment.Environment) })
             .Invoke(new object[] { defaultEnvironment });
         losingConditionClass.GetMethod("SetCookies")
         .Invoke(losingCondition, new[] { losingConditionConfig.CookiesList() });
         stage.AddLosingCondition(losingCondition);
     }
 }
Ejemplo n.º 4
0
        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);
            }
        }
Ejemplo n.º 5
0
        private void MoveToNextStage()
        {
            activeStage.UnlistenToWaveCycle(OnWaveCycle);
            int indexOfActiveStage = stages.IndexOf(activeStage);

            NotifyStageCycle(indexOfActiveStage + 1, StageCycle.End);
            activeStage = stages[indexOfActiveStage + 1];
            activeStage.OnStart();
            activeStage.ListenToWaveCycle(OnWaveCycle);
            components.Remove(activeStageComponent);
            activeStageComponent = new StageComponent(activeStage);
            activeStageComponent.StartUp();
            activeStageComponent.Start();
            AddComponent(activeStageComponent);
            currentStageOrder = indexOfActiveStage + 2;
            NotifyStageCycle(currentStageOrder, StageCycle.Start);
            //DLog.Log("NEXT STAGE");
        }
Ejemplo n.º 6
0
        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);
            }
        }
 public void OnAddedToStage(DefaultStage stage)
 {
 }
Ejemplo n.º 8
0
        public void AddStage(DefaultStage stage)
        {
            notNullReference.Check(stage, "stage");

            stages.Add(stage);
        }
Ejemplo n.º 9
0
        public void OnAddedToStage(DefaultStage stage)
        {
            new NotNullReference().Check(stage, "stage is null");

            this.stage = stage;
        }