public void RefreshPassable(LogicGameObject gameObject) { if (gameObject.IsStaticObject()) { int tileX = gameObject.GetTileX(); int tileY = gameObject.GetTileY(); if (tileX >= 0 && tileY >= 0) { int sizeX = gameObject.GetWidthInTiles(); int sizeY = gameObject.GetHeightInTiles(); for (int i = 0; i < sizeY; i++) { for (int j = 0; j < sizeX; j++) { LogicTile tile = this.GetTile(tileX + j, tileY + i); Debugger.DoAssert(tile != null, "illegal tile index"); tile.RefreshPassableFlag(); } } this.UpdateRoomIndices(); } } }
/// <summary> /// Refreshes passable of the specified <see cref="LogicGameObject"/> instance.. /// </summary> public void RefreshPassable(LogicGameObject gameObject) { if (gameObject.IsStaticObject()) { int tileX = gameObject.GetTileX(); int tileY = gameObject.GetTileY(); if (tileX >= 0) { if (tileY >= 0) { int sizeX = gameObject.GetWidthInTiles(); int sizeY = gameObject.GetHeightInTiles(); for (int i = 0; i < sizeY; i++) { for (int j = 0; j < sizeX; j++) { this.GetTile(tileX + j, tileY + i).RefreshPassableFlag(); } } if (!gameObject.IsPassable()) { this.UpdateRoomIndices(); } } } } }
public void RemoveGameObject(LogicGameObject gameObject) { if (gameObject.IsStaticObject()) { int tileX = gameObject.GetTileX(); int tileY = gameObject.GetTileY(); if (tileX >= 0 && tileY >= 0) { int sizeX = gameObject.GetWidthInTiles(); int sizeY = gameObject.GetHeightInTiles(); for (int i = 0; i < sizeY; i++) { for (int j = 0; j < sizeX; j++) { this.m_tiles[(tileX + j) + this.m_sizeX * (tileY + i)].RemoveGameObject(gameObject); } } if (!gameObject.IsPassable()) { this.UpdateRoomIndices(); } } } }
/// <summary> /// Called when the specified gameobject has been moved. /// </summary> public void GameObjectMoved(LogicGameObject gameObject, int oldTileX, int oldTileY) { if (gameObject.IsStaticObject()) { int tileX = gameObject.GetTileX(); int tileY = gameObject.GetTileY(); if (tileX >= 0) { if (tileY >= 0) { int sizeX = gameObject.GetWidthInTiles(); int sizeY = gameObject.GetHeightInTiles(); for (int i = 0; i < sizeY; i++) { for (int j = 0; j < sizeX; j++) { this.GetTile(oldTileX + j, oldTileY + i).RemoveGameObject(gameObject); this.GetTile(tileX + j, tileY + i).AddGameObject(gameObject); } } if (!gameObject.IsPassable()) { this.UpdateRoomIndices(); } } } } }