public ToyWorld(Map tmxDeserializedMap, StreamReader tileTable) { if (tileTable == null) { throw new ArgumentNullException("tileTable"); } if (tmxDeserializedMap == null) { throw new ArgumentNullException("tmxDeserializedMap"); } Contract.EndContractBlock(); Size = new Vector2I(tmxDeserializedMap.Width, tmxDeserializedMap.Height); AutoupdateRegister = new AutoupdateRegister(100000); TilesetTable = new TilesetTable(tmxDeserializedMap, tileTable); InitAtlas(tmxDeserializedMap); InitPhysics(); TileDetectorRegister = new TileDetectorRegister(Atlas); RegisterSignals(); m_consoleThread = new Thread(() => { m_luaConsole = new LuaConsole(this, Atlas); m_luaConsole.ShowDialog(); }); m_consoleThread.Start(); }
public void TestRegisterForThisStepThrows() { AutoupdateRegister register = new AutoupdateRegister(); Mock<IAutoupdateableGameActor> mock = new Mock<IAutoupdateableGameActor>(); Assert.Throws<ArgumentOutOfRangeException>(() => register.Register(mock.Object, 0)); }
// // TODO: methods below will be moved to some physics class // #region Updating public void Update() { UpdateTime(); UpdateScheduled(); UpdateLayers(); UpdateAvatars(); UpdateCharacters(); AutoupdateRegister.UpdateItems(Atlas, TilesetTable); UpdatePhysics(); UpdateAtmosphere(); //Log.Instance.Debug("World.ToyWorldCore.ToyWorld: ===================Step performed======================"); }
public ToyWorld(Map tmxDeserializedMap, StreamReader tileTable) { if (tileTable == null) throw new ArgumentNullException("tileTable"); if (tmxDeserializedMap == null) throw new ArgumentNullException("tmxDeserializedMap"); Contract.EndContractBlock(); Size = new Vector2I(tmxDeserializedMap.Width, tmxDeserializedMap.Height); AutoupdateRegister = new AutoupdateRegister(100000); TilesetTable = new TilesetTable(tmxDeserializedMap, tileTable); InitAtlas(tmxDeserializedMap); InitPhysics(); TileDetectorRegister = new TileDetectorRegister(Atlas, TilesetTable); RegisterSignals(); }
private void InitAtlas(Map tmxDeserializedMap) { Action <GameActor> initializer = delegate(GameActor actor) { IAutoupdateable updateable = actor as IAutoupdateable; if (updateable != null && updateable.NextUpdateAfter > 0) { AutoupdateRegister.Register(updateable, updateable.NextUpdateAfter); } }; Atlas = MapLoader.LoadMap(tmxDeserializedMap, TilesetTable, initializer); Atlas.DayLength = TWConfig.Instance.DayLengh; Atlas.YearLength = TWConfig.Instance.YearLength; IAtmosphere atmosphere = new SimpleAtmosphere(Atlas); Atlas.Atmosphere = atmosphere; }
public ToyWorld(Map tmxDeserializedMap, StreamReader tileTable) { if (tileTable == null) { throw new ArgumentNullException("tileTable"); } if (tmxDeserializedMap == null) { throw new ArgumentNullException("tmxDeserializedMap"); } Contract.EndContractBlock(); Size = new Vector2I(tmxDeserializedMap.Width, tmxDeserializedMap.Height); AutoupdateRegister = new AutoupdateRegister(100000); TilesetTable = new TilesetTable(tmxDeserializedMap, tileTable); InitAtlas(tmxDeserializedMap); InitPhysics(); TileDetectorRegister = new TileDetectorRegister(Atlas, TilesetTable); RegisterSignals(); }
private void UpdateScheduled() { TileDetectorRegister.Update(); AutoupdateRegister.UpdateItems(Atlas); AutoupdateRegister.Tick(); }
public void TestRegisterNullThrows() { AutoupdateRegister register = new AutoupdateRegister(); Assert.Throws<ArgumentNullException>(() => register.Register(null)); }
public void TestCreateWithDefaultSize() { AutoupdateRegister register = new AutoupdateRegister(); Assert.Equal(true, register.Size > 0); }
public void TestCreateWithSize() { AutoupdateRegister register = new AutoupdateRegister(7); Assert.Equal(7, register.Size); }
public void TestUpdateItems() { Mock<IAtlas> mockAtlas = new Mock<IAtlas>(); AutoupdateRegister register = new AutoupdateRegister(); Mock<IAutoupdateableGameActor> mock1 = new Mock<IAutoupdateableGameActor>(); mock1.Setup(x => x.Update(It.IsAny<IAtlas>(), It.IsAny<TilesetTable>())); Mock<IAutoupdateableGameActor> mock2 = new Mock<IAutoupdateableGameActor>(); mock2.Setup(x => x.Update(It.IsAny<IAtlas>(), It.IsAny<TilesetTable>())); register.Register(mock1.Object, 1); register.Register(mock2.Object, 2); // Act register.Tick(); register.UpdateItems(mockAtlas.Object, It.IsAny<TilesetTable>()); // Assert mock1.Verify(x => x.Update(It.IsAny<IAtlas>(), It.IsAny<TilesetTable>())); mock2.Verify(x => x.Update(It.IsAny<IAtlas>(), It.IsAny<TilesetTable>()), Times.Never()); // Act register.Tick(); register.UpdateItems(mockAtlas.Object, It.IsAny<TilesetTable>()); // Assert mock2.Verify(x => x.Update(It.IsAny<IAtlas>(), It.IsAny<TilesetTable>())); }
public void SetRegister(AutoupdateRegister register) { AutoupdateRegister = register; }