Esempio n. 1
0
        public TingRunner(RelayTwo pRelay, RoomRunner pRoomRunner)
        {
            D.isNull(pRelay);
            D.isNull(pRoomRunner);

            _roomRunner = pRoomRunner;
            _relay      = pRelay;

            Type[]      classes    = InstantiatorTwo.GetSubclasses(typeof(Ting));
            List <Ting> tingsToAdd = new List <Ting>();

            foreach (Type t in classes)
            {
                TableTwo table = AssertTable(t, pRelay);

                if (!_loadedTingTables.ContainsKey(table.name))
                {
                    //Console.WriteLine("Adding table " + table.name + " for type " + t.Name);
                    tingsToAdd.AddRange(InstantiatorTwo.Process <Ting>(table));
                    _loadedTingTables.Add(table.name, table);
                }
            }

            foreach (Ting t in tingsToAdd)
            {
                AddTing(t);
                t.SetupBaseRunners(this, _roomRunner);
            }

            actionTime = 0;
        }
Esempio n. 2
0
        public void SettingNameOfTing()
        {
            Ting t = InstantiatorTwo.Create <MyTing>(_table);

            t.SetInitCreateValues("Monkey", WorldCoordinate.NONE, Direction.UP);
            t.CreateNewRelayEntry(_table, "MyTing");
            Assert.AreEqual("Monkey", t.name);
        }
Esempio n. 3
0
        public TimetableRunner(RelayTwo pRelay)         //, TingRunner pTingRunner)
        {
            _timetableTable = pRelay.GetTable(Timetable.TABLE_NAME);

            foreach (var timetable in InstantiatorTwo.Process <Timetable>(_timetableTable))
            {
                _timetables[timetable.name] = timetable;
            }
        }
Esempio n. 4
0
 public SourceCodeDispenser(RelayTwo pRelay)
 {
     _sourceCodeTable = pRelay.GetTable(SourceCode.TABLE_NAME);
     //Console.WriteLine("Getting source code from " + _sourceCodeTable.name);
     _sourceCodes = InstantiatorTwo.Process <SourceCode>(_sourceCodeTable);
     foreach (SourceCode sc in _sourceCodes)
     {
         //Console.WriteLine("found source code " + sc.name);
     }
 }
Esempio n. 5
0
 public ProgramRunner(RelayTwo pRelay)
 {
     D.isNull(pRelay);
     _programTable = pRelay.GetTable(Program.TABLE_NAME);
     _programsList = InstantiatorTwo.Process <Program>(_programTable);
     foreach (var program in _programsList)
     {
         program.Init(this);
         _programsDictionary.Add(program.objectId, program);
     }
 }
Esempio n. 6
0
        public T CreateRoom <T>(string pName) where T : Room
        {
#if DEBUG
            if (HasRoom(pName))
            {
                throw new TingTingException("There is already a room called '" + pName + "' in Room Runner");
            }
#endif
            T newRoom = InstantiatorTwo.Create <T>(_roomTable);
            newRoom.name = pName;
            _rooms.Add(newRoom);
            return(newRoom);
        }
Esempio n. 7
0
        public void NonExistingFieldTest()
        {
            RelayLib.RelayTwo r2 = new RelayLib.RelayTwo();
            r2.CreateTable(TingTing.Ting.TABLE_NAME);
            r2.CreateTable(TingTing.Room.TABLE_NAME);
            RoomRunner rr = new TingTing.RoomRunner(r2);

            rr.CreateRoom <Room>(WorldCoordinate.UNDEFINED_ROOM);
            TingTing.TingRunner tr = new TingTing.TingRunner(r2, rr);
            tr.CreateTing <SomeLesserTing>("TingA", TingTing.WorldCoordinate.NONE);
            r2.GetTable(TingTing.Ting.TABLE_NAME)[0].Set <string>(TingTing.Ting.CSHARP_CLASS_FIELD_NAME, "TerreTingThongDong");
            List <TingTing.Ting> list = InstantiatorTwo.Process <TingTing.Ting>(r2.GetTable(TingTing.Ting.TABLE_NAME));

            Console.WriteLine("list length" + list.Count);
            Assert.NotNull((list[0] as TerreTingThongDong));
            Assert.AreSame("Something", (list[0] as TerreTingThongDong).funk);
        }
Esempio n. 8
0
        public void BasicUsage()
        {
            RelayTwo relay = new RelayTwo();
            TableTwo table = relay.CreateTable("Stuffs");

            table.AddField <string>("name");
            table.AddField <string>(RelayObjectTwo.CSHARP_CLASS_FIELD_NAME);
            table.CreateRow().Set(RelayObjectTwo.CSHARP_CLASS_FIELD_NAME, "Stuff").Set("name", "first");
            table.CreateRow().Set(RelayObjectTwo.CSHARP_CLASS_FIELD_NAME, "Stuff").Set("name", "second");
            List <Stuff> objects = InstantiatorTwo.Process <Stuff>(table);

            Assert.AreEqual(2, objects.Count);

            Stuff first  = objects[0];
            Stuff second = objects[1];

            Assert.AreEqual("first", first.name);
            Assert.AreEqual("second", second.name);
        }
Esempio n. 9
0
        public DialogueRunner(RelayTwo pRelay, Language pLanguage)
        {
            D.isNull(pRelay);

            _dialogueTable = pRelay.GetTable(DialogueNode.TABLE_NAME);
            _language      = pLanguage;
            _dialogueNodes = InstantiatorTwo.Process <DialogueNode>(_dialogueTable);
            foreach (DialogueNode n in _dialogueNodes)
            {
                n.SetRunner(this);
                if (n is IRegisteredDialogueNode)
                {
                    IRegisteredDialogueNode ir = n as IRegisteredDialogueNode;
                    _registeredDialogueNodes.Add(ir);
                }
                if (n.isOn)
                {
                    _nodesThatAreOn.Add(n);
                }
                AddNodeToNodeForConversationDictionary(n.conversation, n);
            }
            RegisterBuiltInAPIExpressions();
        }
Esempio n. 10
0
 public RoomRunner(RelayTwo pRelay)
 {
     D.isNull(pRelay);
     _roomTable = pRelay.GetTable(Room.TABLE_NAME);
     _rooms     = InstantiatorTwo.Process <Room>(_roomTable);
 }