示例#1
0
 internal void SetMimanRunners(ProgramRunner pProgramRunner, SourceCodeDispenser pSourceCodeDispenser, DialogueRunner pDialogueRunner, WorldSettings pWorldSettings)
 {
     _programRunner       = pProgramRunner;
     _sourceCodeDispenser = pSourceCodeDispenser;
     _dialogueRunner      = pDialogueRunner;
     _worldSettings       = pWorldSettings;
 }
示例#2
0
		internal void SetMimanRunners(ProgramRunner pProgramRunner, SourceCodeDispenser pSourceCodeDispenser, DialogueRunner pDialogueRunner, WorldSettings pWorldSettings) 
        {
			_programRunner = pProgramRunner;
			_sourceCodeDispenser = pSourceCodeDispenser;
            _dialogueRunner = pDialogueRunner;
			_worldSettings = pWorldSettings;
		}
示例#3
0
        public IEnumerable <float> LoadRelayFromDirectory(string pInputDirectory, bool pOnlyLoadTingsAndRooms)
        {
#if PROFILE
            Stopwatch sw = new Stopwatch();
            sw.Start();
#endif

            _relay = CreateEmptyRelay();
            DialogueRunner dialogueRunner = new DialogueRunner(_relay, Language.DEFAULT);
            _dialogueScriptLoader = new DialogueScriptLoader(dialogueRunner);
            _sourceCodeDispenser  = new SourceCodeDispenser(_relay);
            _timetableRunner      = new TimetableRunner(_relay);

            string[] files = GetFilesRecursively(pInputDirectory);

            for (int i = 0; i < files.Length; i++)
            {
                FoundFile(files[i], pOnlyLoadTingsAndRooms);
                yield return((float)i / (float)files.Length);
            }

#if PROFILE
            sw.Stop();
            logger.Log("Loading relay from directory " + pInputDirectory + " took " + sw.Elapsed.TotalSeconds + " s.");
#endif
        }
示例#4
0
        public RelayTwo CreateRelay(string pInputDirectory, bool pOnlyLoadTingsAndRooms)
        {
            _relay = CreateEmptyRelay();
            DialogueRunner dialogueRunner = new DialogueRunner(_relay, Language.DEFAULT);

            _dialogueScriptLoader = new DialogueScriptLoader(dialogueRunner);
            _sourceCodeDispenser  = new SourceCodeDispenser(_relay);
            _timetableRunner      = new TimetableRunner(_relay);

            foreach (string s in GetFilesRecursively(pInputDirectory))
            {
                FoundFile(s, pOnlyLoadTingsAndRooms);
            }

            return(_relay);
        }
示例#5
0
 private void Init(RelayTwo pRelay)
 {
     paused              = false;
     isReadyToPlay       = false;
     relay               = pRelay;
     dialogueRunner      = new DialogueRunner(relay, Language.DEFAULT);
     roomRunner          = new RoomRunner(relay);
     programRunner       = new ProgramRunner(relay);
     sourceCodeDispenser = new SourceCodeDispenser(relay);
     timetableRunner     = new TimetableRunner(relay);
     settings            = new WorldSettings(relay);
     tingRunner          = new MimanTingRunner(relay, dialogueRunner, programRunner, sourceCodeDispenser, roomRunner, timetableRunner, settings);
     grimmApiDefinitions = new MimanGrimmApiDefinitions(this);
     grimmApiDefinitions.RegisterFunctions();
     grimmApiDefinitions.RegisterExpressions();
     translator = new Translator(Translator.Language.SWEDISH);
 }
示例#6
0
		private void Init(RelayTwo pRelay)
        {
			paused = false;
			isReadyToPlay = false;
			relay = pRelay;
			dialogueRunner = new DialogueRunner(relay, Language.DEFAULT);
			roomRunner = new RoomRunner(relay);
			programRunner = new ProgramRunner(relay);
			sourceCodeDispenser = new SourceCodeDispenser(relay);
			timetableRunner = new TimetableRunner(relay);
			settings = new WorldSettings(relay);
            tingRunner = new MimanTingRunner(relay, dialogueRunner, programRunner, sourceCodeDispenser, roomRunner, timetableRunner, settings);
			grimmApiDefinitions = new MimanGrimmApiDefinitions(this);
			grimmApiDefinitions.RegisterFunctions();
			grimmApiDefinitions.RegisterExpressions();
			translator = new Translator (Translator.Language.SWEDISH);
		}
示例#7
0
        public MimanTingRunner(
            RelayTwo pRelay,
            DialogueRunner pDialogueRunner,
            ProgramRunner pProgramRunner,
            SourceCodeDispenser pSourceCodeDispenser,
            RoomRunner pRoomRunner,
            TimetableRunner pTimetableRunner,
            WorldSettings pWorldSettings
            )
            : base(pRelay, pRoomRunner)
        {
            _dialogueRunner = pDialogueRunner;
            _dialogueRunner.AddOnSomeoneSaidSomethingListener(this.OnSomeoneSaidSomething);
            _programRunner       = pProgramRunner;
            _sourceCodeDispenser = pSourceCodeDispenser;
            _timetableRunner     = pTimetableRunner;
            _worldSettings       = pWorldSettings;

            foreach (Ting ting in _tings.Values)
            {
                if (ting is MimanTing)
                {
                    (ting as MimanTing).SetMimanRunners(_programRunner, _sourceCodeDispenser, _dialogueRunner, _worldSettings);
                }
                if (ting is Character)
                {
                    (ting as Character).SetTimetableRunner(_timetableRunner);
                }
            }

            foreach (Ting ting in _tings.Values)
            {
                if (ting is MimanTing)
                {
                    var mimanTing = ting as MimanTing;
                    mimanTing.Init();
                    if (mimanTing.autoUnregisterFromUpdate && mimanTing.dialogueLine != "")
                    {
                        Unregister(mimanTing);
                    }
                }
            }
        }
        public void BasicUsage()
        {
            const string saveName = "SourceCodeDispenserTest.json";

            {
                RelayTwo relay = new RelayTwo();
                relay.CreateTable(SourceCode.TABLE_NAME);

                SourceCodeDispenser sourceCodeDispenser = new SourceCodeDispenser(relay);
                sourceCodeDispenser.LoadSourceCode(WorldTestHelper.INIT_DATA_PATH + "Sprak/helloworld.sprak");

                SourceCode s = sourceCodeDispenser.GetSourceCode("helloworld");
                Assert.AreEqual("print(\"Hello World!\")", s.content);

                relay.SaveAll(saveName);
            }

            {
                RelayTwo relay = new RelayTwo(saveName);
                SourceCodeDispenser sourceCodeDispenser = new SourceCodeDispenser(relay);
                SourceCode s = sourceCodeDispenser.GetSourceCode("helloworld");
                Assert.AreEqual("print(\"Hello World!\")", s.content);
            }
        }