public void BuildPreRequisites(ITilesCollection mapTileCollection) { new Thread(new ThreadStart(() => { _pathAtoB = new Pathfinder(mapTileCollection) .GetPath(_home.getLocation(), _destination.getLocation(), _size); _pathBtoA = new Pathfinder(mapTileCollection) .GetPath(_destination.getLocation(), _home.getLocation(), _size); SetPath(); _pathCalculated = true; })).Start(); }
public Ship(TimeSpan waitTime, Texture2D texture, Cargo cargo, Harbour Home, Harbour Destination, int speed, ITilesCollection mapTileCollection) { _mapTileCollection = mapTileCollection; _fromOff = new Vector2((WorldInformation.mapWidth / 2) - Home.getLocation().X, (WorldInformation.mapHeight / 2) - Home.getLocation().Y); _waitTime = waitTime; _texture = texture; _cargo = cargo; _home = Home; _destination = Destination; _position = Home.getLocation() * EngineSettings.TileSize; _baseSpeed = speed * GSS.ClockSpeed; _speed = (500f / _baseSpeed); _size = new Vector2(texture.Width, texture.Height); _halfSize = _size / 2; _origin = _size / 2; }
/// <summary> /// Initialize the tile engine /// </summary> /// <param name="tiles">List of tiles to use</param> /// <param name="worldMap">Bitmap index of world-map</param> /// <param name="ScreenTexturecolors">Index of colors from the worldMap bitmap</param> /// <param name="Outofbound">Fallback texture to use on tiles not render-able</param> public void LoadWorld() { MapTileCollection = GSS.TextureLoader.WorldMapTiles(); _autoElements = GSS.TextureLoader.WorldAutoElements(); _autoElements.SetMapTileCollection(MapTileCollection); worldCharacter = GSS.TextureLoader.WorldCharacter(); worldCharacter.SetMapTileCollection(MapTileCollection); cloudsTileCollection = GSS.TextureLoader.Clouds(); Minimap = GSS.TextureLoader.Minimap(); _worldMapAnimationSet = GSS.TextureLoader.WorldMaps(); _minimapSpriteAnimator = new AnimationRotator <Rectangle>(_minimapLightAnimationSize, AnimationFunction.FORWARD_BACKWARD, playTimeSeconds: 2f); WorldInformation.mapWidth = (int)_worldMapAnimationSet.Size.X; WorldInformation.mapHeight = (int)_worldMapAnimationSet.Size.Y; _minimapW = (int)(DisplayOutputSettings.ScreenWidth * 0.2); _minimapH = (int)(DisplayOutputSettings.ScreenHeight * 0.2); int mapCount = _worldMapAnimationSet.Length; _worldMapSpriteSet = new Color[mapCount][]; for (int a = 0; a < mapCount; a++) { _worldMapSpriteSet[a] = new Color[(int)(_worldMapAnimationSet.Size.X * _worldMapAnimationSet.Size.Y)]; _worldMapAnimationSet.GetTexture(a).GetData(_worldMapSpriteSet[a]); } _worldmapAnimator = new AnimationRotator <Color[]>(_worldMapSpriteSet, AnimationFunction.FORWARD_BACKWARD, playTimeSeconds: 3f); WorldInformation.worldMapCheck = _worldMapSpriteSet[0]; _tileUsedBy = new object[WorldInformation.mapHeight * WorldInformation.mapWidth]; //+1 is added to buffed draw the next coulomb to the right of the frame //1600 is screen width _halfHeightPlus = (int)(DisplayOutputSettings.ScreenWidth / (float)EngineSettings.TileSize) + 1; //900 is screen height //+2 is added to buffed draw the next two rows bellow the frame (one row was not enough) _halfWidthPlus = (int)(DisplayOutputSettings.ScreenHeight / (float)EngineSettings.TileSize) + 2; minimapXoff = DisplayOutputSettings.ScreenWidth - _minimapW - 10; RunInitWork(MapTileCollection); sw.Start(); }
public Pathfinder(ITilesCollection mapTileCollection) { _mapTileCollection = mapTileCollection; }
public void SetMapTileCollection(ITilesCollection mapTileCollection) { _mapTileCollection = mapTileCollection; }
private void RunInitWork(ITilesCollection mapTileCollection) { _autoElements.BuildPreRequisites(mapTileCollection); }
internal void SetMapTileCollection(ITilesCollection mapTileCollection) { _mapTileCollection = mapTileCollection; }
public void BuildPreRequisites(ITilesCollection mapTileCollection) { Ships.ForEach(a => a.BuildPreRequisites(mapTileCollection)); }