Esempio n. 1
0
        public void PlaceTransport(uint mapIndex, uint x, uint y, TravelType travelType)
        {
            var position = new Position((int)x, (int)y);

            if (mapIndex != Map.Index)
            {
                if (mapIndex != adjacentMaps[0].Index &&
                    mapIndex != adjacentMaps[1].Index &&
                    mapIndex != adjacentMaps[2].Index)
                {
                    return;
                }

                if (mapIndex == adjacentMaps[0].Index || mapIndex == adjacentMaps[2].Index)
                {
                    position.X += Map.Width;
                }
                if (mapIndex == adjacentMaps[1].Index || mapIndex == adjacentMaps[2].Index)
                {
                    position.Y += Map.Height;
                }
            }

            if (!transportSprites.ContainsKey(position))
            {
                var stationaryImage = travelType.ToStationaryImage();
                var info            = renderView.GameData.StationaryImageInfos[stationaryImage];
                var textureAtlas    = TextureAtlasManager.Instance.GetOrCreate(Layer.Characters);
                var sprite          = renderView.SpriteFactory.Create(info.Width, info.Height, false);
                var offset          = new Position((TILE_WIDTH - info.Width) / 2 - 2, (TILE_HEIGHT - info.Height) / 2 - 2);
                sprite.Layer              = renderView.GetLayer(Layer.Characters);
                sprite.ClipArea           = Game.Map2DViewArea;
                sprite.BaseLineOffset     = TILE_HEIGHT / 2;
                sprite.PaletteIndex       = (byte)game.GetPlayerPaletteIndex();
                sprite.TextureAtlasOffset = textureAtlas.GetOffset(3 * 17 + 11 * 4 + stationaryImage.AsIndex());
                sprite.X       = Global.Map2DViewX + (position.X - (int)ScrollX) * TILE_WIDTH + offset.X;
                sprite.Y       = Global.Map2DViewY + (position.Y - (int)ScrollY) * TILE_HEIGHT + offset.Y;
                sprite.Visible = true;
                transportSprites.Add(position, new KeyValuePair <ISprite, Position>(sprite, offset));
            }
        }