public void InstantiateFromDatabase() { RelayTwo relay = new RelayTwo(); TableTwo table = relay.CreateTable(Ting.TABLE_NAME); relay.CreateTable(Room.TABLE_NAME); table.AddField <string>(RelayObjectTwo.CSHARP_CLASS_FIELD_NAME); table.AddField <string>("species"); table.AddField <string>("name"); table.AddField <int>("age"); int row0 = table.CreateRow().row; int row1 = table.CreateRow().row; table.SetValue(row0, RelayObjectTwo.CSHARP_CLASS_FIELD_NAME, "Animal"); table.SetValue(row0, "species", "Monkey"); table.SetValue(row0, "name", "Herr Nilsson"); table.SetValue(row0, "age", 78); table.SetValue(row1, RelayObjectTwo.CSHARP_CLASS_FIELD_NAME, "Animal"); table.SetValue(row1, "species", "Horse"); table.SetValue(row1, "name", "Lilla Gubben"); table.SetValue(row1, "age", 50); TingRunner tingRunner = new TingRunner(relay, new RoomRunner(relay)); Animal herrNilsson = tingRunner.GetTing("Herr Nilsson") as Animal; Animal lillaGubben = tingRunner.GetTing("Lilla Gubben") as Animal; Assert.IsNotNull(herrNilsson); Assert.IsNotNull(lillaGubben); Assert.AreEqual(78, herrNilsson.age); Assert.AreEqual(50, lillaGubben.age); }
public void SetupTingsThenSaveAndLoadFromDisk() { { TingRunner tingRunner = CreateTingRunnerWithSomeRoom(); Animal bo = tingRunner.CreateTing <Animal>("Bo", new WorldCoordinate("SomeRoom", IntPoint.Zero)); bo.species = "cow"; bo.age = 10; Animal howly = tingRunner.CreateTing <Animal>("Howly", new WorldCoordinate("SomeRoom", IntPoint.Zero)); howly.species = "owl"; Assert.AreEqual("cow", bo.species); Assert.AreEqual(10, bo.age); Assert.AreEqual("owl", howly.species); Assert.AreEqual(0, howly.age); // <- default value howly.age = 35; relay.SaveAll("farm.json"); } { relay = new RelayTwo(); relay.LoadAll("farm.json"); TingRunner tingRunner = new TingRunner(relay, new RoomRunner(relay)); Animal bo = tingRunner.GetTing("Bo") as Animal; Animal howly = tingRunner.GetTing("Howly") as Animal; Assert.AreEqual("cow", bo.species); Assert.AreEqual(10, bo.age); Assert.AreEqual("owl", howly.species); Assert.AreEqual(35, howly.age); } }
public void InstantiateFromDatabase() { RelayTwo relay = new RelayTwo(); TableTwo table = relay.CreateTable(Ting.TABLE_NAME); relay.CreateTable(Room.TABLE_NAME); table.AddField<string>(RelayObjectTwo.CSHARP_CLASS_FIELD_NAME); table.AddField<string>("species"); table.AddField<string>("name"); table.AddField<int>("age"); int row0 = table.CreateRow().row; int row1 = table.CreateRow().row; table.SetValue(row0, RelayObjectTwo.CSHARP_CLASS_FIELD_NAME, "Animal"); table.SetValue(row0, "species", "Monkey"); table.SetValue(row0, "name", "Herr Nilsson"); table.SetValue(row0, "age", 78); table.SetValue(row1, RelayObjectTwo.CSHARP_CLASS_FIELD_NAME, "Animal"); table.SetValue(row1, "species", "Horse"); table.SetValue(row1, "name", "Lilla Gubben"); table.SetValue(row1, "age", 50); TingRunner tingRunner = new TingRunner(relay, new RoomRunner(relay)); Animal herrNilsson = tingRunner.GetTing("Herr Nilsson") as Animal; Animal lillaGubben = tingRunner.GetTing("Lilla Gubben") as Animal; Assert.IsNotNull(herrNilsson); Assert.IsNotNull(lillaGubben); Assert.AreEqual(78, herrNilsson.age); Assert.AreEqual(50, lillaGubben.age); }
public static MimanTing GetTingFromNameOrSourceCodeName(TingRunner pTingRunner, string pName) { //Console.WriteLine("Will get ting with name " + pName); var mimanTing = pTingRunner.GetTingUnsafe(pName) as MimanTing; if (mimanTing != null) { return(mimanTing); } // now try to get it through program name foreach (var ting in pTingRunner.GetTings()) { var mimanTingWithProgram = (ting as MimanTing); if (mimanTingWithProgram.masterProgram == null) { continue; } if (mimanTingWithProgram.masterProgram.sourceCodeName == pName) { return(mimanTingWithProgram); } // else { // Console.WriteLine("Discarding miman ting with sourceCodeName " + mimanTingWithProgram.masterProgram.sourceCodeName); // } } return(null); }
public void GetTingFromObjectId() { TingRunner tingRunner = CreateTingRunnerWithSomeRoom(); Ting puma = tingRunner.CreateTing <Animal>("Puma", new WorldCoordinate("SomeRoom", IntPoint.Zero)); Ting samePuma = tingRunner.GetTing(puma.name); Assert.AreSame(puma, samePuma); }
public void HasTing() { TingRunner tingRunner = CreateTingRunnerWithSomeRoom(); tingRunner.CreateTing <Animal>("Puma", new WorldCoordinate("SomeRoom", IntPoint.Zero)); Assert.IsTrue(tingRunner.HasTing("Puma")); Assert.IsFalse(tingRunner.HasTing("Donkey")); }
public void CreateNewTingDuringRuntime() { TingRunner tingRunner = CreateTingRunnerWithSomeRoom(); tingRunner.CreateTing <Animal>("Joe", new WorldCoordinate("SomeRoom", IntPoint.Zero)); Animal a = tingRunner.GetTing("Joe") as Animal; Assert.IsNotNull(a); }
TingRunner CreateTingRunnerWithSomeRoom() { relay = new RelayTwo(); relay.CreateTable(Ting.TABLE_NAME); relay.CreateTable(Room.TABLE_NAME); RoomRunner rr = new RoomRunner(relay); rr.CreateRoom <Room>("SomeRoom"); TingRunner tingRunner = new TingRunner(relay, rr); return(tingRunner); }
public void TryingToGetTingWithWrongName() { RelayTwo relay = new RelayTwo(); relay.CreateTable(Ting.TABLE_NAME); relay.CreateTable(Room.TABLE_NAME); TingRunner tingRunner = new TingRunner(relay, new RoomRunner(relay)); Assert.Throws <CantFindTingException>(() => { tingRunner.GetTing("wrong ting name"); }); }
public void RemoveTingUsingName() { TingRunner tingRunner = CreateTingRunnerWithSomeRoom(); tingRunner.CreateTing <Animal>("Bee", new WorldCoordinate("SomeRoom", IntPoint.Zero)); tingRunner.CreateTing <Animal>("Spider", new WorldCoordinate("SomeRoom", IntPoint.Zero)); tingRunner.CreateTing <Animal>("Ant", new WorldCoordinate("SomeRoom", IntPoint.Zero)); tingRunner.RemoveTing("Bee"); Assert.IsFalse(tingRunner.HasTing("Bee")); Assert.IsTrue(tingRunner.HasTing("Spider")); Assert.IsTrue(tingRunner.HasTing("Ant")); }
private static void UsingCellId() { RelayTwo relay = new RelayTwo(); relay.CreateTable(Ting.TABLE_NAME); TingRunner tingRunner = new TingRunner(relay, new RoomRunner(relay)); TestTing1UsingCellIdWithConvenienceFunctions t = tingRunner.CreateTing<TestTing1UsingCellIdWithConvenienceFunctions>("TestTing", WorldCoordinate.NONE); Console.WriteLine("Using class " + t.ToString()); for(int i = 0; i < COUNTER; i++) { float a = t.awesome; a += 1.0f; t.awesome = a; } Console.WriteLine("1. awesome = " + t.awesome); }
private static void UsingNormalAccessor() { RelayTwo relay = new RelayTwo(); relay.CreateTable(Ting.TABLE_NAME); TingRunner tingRunner = new TingRunner(relay, new RoomRunner(relay)); TestTing2UsingNormalAccessor t = tingRunner.CreateTing<TestTing2UsingNormalAccessor>("TestTing", WorldCoordinate.NONE); Console.WriteLine("Using class " + t.ToString()); for(int i = 0; i < COUNTER; i++) { float a = t.awesome; a += 1.0f; t.awesome = a; } Console.WriteLine("2. awesome = " + t.awesome); }
private static void UsingNormalAccessor() { RelayTwo relay = new RelayTwo(); relay.CreateTable(Ting.TABLE_NAME); TingRunner tingRunner = new TingRunner(relay, new RoomRunner(relay)); TestTing2UsingNormalAccessor t = tingRunner.CreateTing <TestTing2UsingNormalAccessor>("TestTing", WorldCoordinate.NONE); Console.WriteLine("Using class " + t.ToString()); for (int i = 0; i < COUNTER; i++) { float a = t.awesome; a += 1.0f; t.awesome = a; } Console.WriteLine("2. awesome = " + t.awesome); }
private static void UsingCellId() { RelayTwo relay = new RelayTwo(); relay.CreateTable(Ting.TABLE_NAME); TingRunner tingRunner = new TingRunner(relay, new RoomRunner(relay)); TestTing1UsingCellIdWithConvenienceFunctions t = tingRunner.CreateTing <TestTing1UsingCellIdWithConvenienceFunctions>("TestTing", WorldCoordinate.NONE); Console.WriteLine("Using class " + t.ToString()); for (int i = 0; i < COUNTER; i++) { float a = t.awesome; a += 1.0f; t.awesome = a; } Console.WriteLine("1. awesome = " + t.awesome); }
public void Setup() { _relay = new RelayTwo(); _table = _relay.CreateTable(Ting.TABLE_NAME); _relay.CreateTable(Room.TABLE_NAME); _roomRunner = new RoomRunner(_relay); Room room = _roomRunner.CreateRoom <Room>(ROOM_NAME); for (int i = 0; i < 100; i++) { room.AddTile(new PointTileNode(new IntPoint(i % 10, i / 10), room)); } _tingRunner = new TingRunner(_relay, _roomRunner); _tingRunner.CreateTing <MyTing>("Ting0", new WorldCoordinate(ROOM_NAME, new IntPoint(0, 0))); _tingRunner.CreateTing <MyTing>("Ting1", new WorldCoordinate(ROOM_NAME, new IntPoint(1, 0))); }
public void Setup() { _relay = new RelayTwo(); _table = _relay.CreateTable(Ting.TABLE_NAME); _relay.CreateTable(Room.TABLE_NAME); _roomRunner = new RoomRunner(_relay); Room room = _roomRunner.CreateRoom<Room>(ROOM_NAME); for (int i = 0; i < 100; i++) { room.AddTile(new PointTileNode(new IntPoint(i % 10, i / 10), room)); } _tingRunner = new TingRunner(_relay, _roomRunner); _tingRunner.CreateTing<MyTing>("Ting0", new WorldCoordinate(ROOM_NAME, new IntPoint(0, 0))); _tingRunner.CreateTing<MyTing>("Ting1", new WorldCoordinate(ROOM_NAME, new IntPoint(1, 0))); }
public SmartWalkBehaviour(Character pCharacter, RoomRunner pRoomRunner, TingRunner pTingRunner, WorldSettings pWorldSettings) { #if LOG && DEEP s_logger.Log("Created SmartWalkBehaviour for character " + pCharacter.name); #endif _character = pCharacter; _roomRunner = pRoomRunner; _tingRunner = pTingRunner; _worldSettings = pWorldSettings; _mimanPathFinder = new MimanPathfinder2(_tingRunner, _roomRunner); //_mimanPathFinder = new MimanPathfinder_DEPRECATED(_tingRunner); CalculateFinalTargetPosition(); bool startWalkingAgain = RefreshPaths(); if(startWalkingAgain) { _character.StartAction("Walking", null, Character.LONG_TIME, Character.LONG_TIME); } else { } }
public SmartWalkBehaviour(Character pCharacter, RoomRunner pRoomRunner, TingRunner pTingRunner, WorldSettings pWorldSettings) { #if LOG && DEEP s_logger.Log("Created SmartWalkBehaviour for character " + pCharacter.name); #endif _character = pCharacter; _roomRunner = pRoomRunner; _tingRunner = pTingRunner; _worldSettings = pWorldSettings; _mimanPathFinder = new MimanPathfinder2(_tingRunner, _roomRunner); //_mimanPathFinder = new MimanPathfinder_DEPRECATED(_tingRunner); CalculateFinalTargetPosition(); bool startWalkingAgain = RefreshPaths(); if (startWalkingAgain) { _character.StartAction("Walking", null, Character.LONG_TIME, Character.LONG_TIME); } else { } }
TingRunner CreateTingRunnerWithSomeRoom() { relay = new RelayTwo(); relay.CreateTable(Ting.TABLE_NAME); relay.CreateTable(Room.TABLE_NAME); RoomRunner rr = new RoomRunner(relay); rr.CreateRoom<Room>("SomeRoom"); TingRunner tingRunner = new TingRunner(relay, rr); return tingRunner; }
public void TryingToGetTingWithWrongName() { RelayTwo relay = new RelayTwo(); relay.CreateTable(Ting.TABLE_NAME); relay.CreateTable(Room.TABLE_NAME); TingRunner tingRunner = new TingRunner(relay, new RoomRunner(relay)); Assert.Throws<CantFindTingException>(() => { tingRunner.GetTing("wrong ting name"); }); }
public void SetupTingsThenSaveAndLoadFromDisk() { { TingRunner tingRunner = CreateTingRunnerWithSomeRoom(); Animal bo = tingRunner.CreateTing<Animal>("Bo", new WorldCoordinate("SomeRoom", IntPoint.Zero)); bo.species = "cow"; bo.age = 10; Animal howly = tingRunner.CreateTing<Animal>("Howly", new WorldCoordinate("SomeRoom", IntPoint.Zero)); howly.species = "owl"; Assert.AreEqual("cow", bo.species); Assert.AreEqual(10, bo.age); Assert.AreEqual("owl", howly.species); Assert.AreEqual(0, howly.age); // <- default value howly.age = 35; relay.SaveAll("farm.json"); } { relay = new RelayTwo(); relay.LoadAll("farm.json"); TingRunner tingRunner = new TingRunner(relay, new RoomRunner(relay)); Animal bo = tingRunner.GetTing("Bo") as Animal; Animal howly = tingRunner.GetTing("Howly") as Animal; Assert.AreEqual("cow", bo.species); Assert.AreEqual(10, bo.age); Assert.AreEqual("owl", howly.species); Assert.AreEqual(35, howly.age); } }
public VoiceAPI(Computer pComputer, TingRunner pTingRunner, DialogueRunner pDialogueRunner) { _computer = pComputer; //_tingRunner = pTingRunner; _dialogueRunner = pDialogueRunner; }
public TingrunnerAPI(Computer pComputer, TingRunner pTingRunner, RoomRunner pRoomRunner) { _computer = pComputer; _tingRunner = pTingRunner; _roomRunner = pRoomRunner; }
public TrapAPI(Computer pComputer, TingRunner pTingRunner, DialogueRunner pDialogueRunner) { _computer = pComputer; _tingRunner = pTingRunner; _dialogueRunner = pDialogueRunner; _tingRunner.onTingHasNewRoom += OnTingHasNewRoom; _dialogueRunner.AddOnEventListener (OnEvent); _computerRoomCache = _computer.room.name; //D.Log("Trap API for " + pComputer + " is rigged!"); }
public LampAPI(Computer pComputer, TingRunner pTingRunner) { _computer = pComputer; _tingRunner = pTingRunner; }
public MemoryAPI(Computer pComputer, TingRunner pTingRunner) { _computer = pComputer; _tingRunner = pTingRunner; }
public HeartAPI(Computer pComputer, TingRunner pTingRunner, DialogueRunner pDialogueRunner) { _computer = pComputer; _tingRunner = pTingRunner; _dialogueRunner = pDialogueRunner; }
//TingRunner _tingRunner; public InternetAPI(Computer pComputer, TingRunner pTingRunner) { _computer = pComputer; //_tingRunner = pTingRunner; }
//TingRunner _tingRunner; public FloppyAPI(Computer pComputer, TingRunner pTingRunner) { _computer = pComputer; //_tingRunner = pTingRunner; }
//TingRunner _tingRunner; public ElevatorAPI(Computer pComputer, TingRunner pTingRunner) { _computer = pComputer; //_tingRunner = pTingRunner; }
// OBS!!! With this solution only one program in the Ting can use the API safely!!! public ConnectionAPI(MimanTing pCaller, TingRunner pTingRunner, Program pProgram) { _caller = pCaller; _tingRunner = pTingRunner; _program = pProgram; }
public MimanPathfinder2(TingRunner pTingRunner, RoomRunner pRoomRunner) { _tingRunner = pTingRunner; _roomRunner = pRoomRunner; }
public MimanPathfinder_DEPRECATED(TingRunner pTingRunner) { _tingRunner = pTingRunner; }
// OBS!!! With this solution only one program in the Ting can use the API safely!!! public ConnectionAPI_Optimized(MimanTing pCaller, TingRunner pTingRunner, Program pProgram) { _caller = pCaller; _tingRunner = pTingRunner; _program = pProgram; }
public static MimanTing GetTingFromNameOrSourceCodeName(TingRunner pTingRunner, string pName) { //Console.WriteLine("Will get ting with name " + pName); var mimanTing = pTingRunner.GetTingUnsafe(pName) as MimanTing; if(mimanTing != null) { return mimanTing; } // now try to get it through program name foreach(var ting in pTingRunner.GetTings()) { var mimanTingWithProgram = (ting as MimanTing); if(mimanTingWithProgram.masterProgram == null) { continue; } if(mimanTingWithProgram.masterProgram.sourceCodeName == pName) { return mimanTingWithProgram; } // else { // Console.WriteLine("Discarding miman ting with sourceCodeName " + mimanTingWithProgram.masterProgram.sourceCodeName); // } } return null; }
internal void SetupBaseRunners(TingRunner pTingRunner, RoomRunner pRoomRunner) { _roomRunner = pRoomRunner; _tingRunner = pTingRunner; }
public MimanPathfinder_DEPRECATED(TingRunner pTingRunner) { _tingRunner = pTingRunner; }