public Scene3D( Game game, ICameraController cameraController, MapFile mapFile, Terrain.Terrain terrain, MapScriptCollection scripts, GameObjectCollection gameObjects, WaypointCollection waypoints, WaypointPathCollection waypointPaths, WorldLighting lighting) { Camera = new CameraComponent(game); CameraController = cameraController; MapFile = mapFile; Terrain = terrain; Scripts = scripts; GameObjects = AddDisposable(gameObjects); Waypoints = waypoints; WaypointPaths = waypointPaths; Lighting = lighting; _cameraInputMessageHandler = new CameraInputMessageHandler(); game.InputMessageBuffer.Handlers.Add(_cameraInputMessageHandler); AddDisposeAction(() => game.InputMessageBuffer.Handlers.Remove(_cameraInputMessageHandler)); _particleSystemManager = AddDisposable(new ParticleSystemManager(game, this)); _players = new List <Player>(); }
internal Scene3D( Game game, InputMessageBuffer inputMessageBuffer, Func <Viewport> getViewport, ICameraController cameraController, WorldLighting lighting, int randomSeed, bool isDiagnosticScene = false) : this(game, getViewport, inputMessageBuffer, randomSeed, isDiagnosticScene, null, null) { _players = new List <Player>(); _teams = new List <Team>(); // TODO: This is completely wrong. LocalPlayer = _players.FirstOrDefault(); WaterAreas = AddDisposable(new WaterAreaCollection()); Lighting = lighting; Roads = AddDisposable(new RoadCollection()); Bridges = Array.Empty <Bridge>(); Waypoints = new WaypointCollection(); Cameras = new CameraCollection(); CameraController = cameraController; }
/// <summary> /// Set public components /// </summary> public void Initialize() { Locator = new Geolocator(); WaypointCol = new WaypointCollection(); Locator.DesiredAccuracy = PositionAccuracy.High; Locator.PositionChanged += Locator_PositionChanged; ClearGeofences(); GeofenceMonitor.Current.GeofenceStateChanged += Current_GeofenceStateChanged; }
/* * Lifecycle methods */ void Start() { WaypointCollection wps = (WaypointCollection)gameObject.GetComponent("WaypointCollection"); if (wps.getWaypoints() != null) { waypointCollection = wps.getWaypoints(); currentIndex = 0; } }
internal Scene3D(Game game, MapFile mapFile, int randomSeed) : this(game, () => game.Viewport, game.InputMessageBuffer, randomSeed, false, mapFile) { var contentManager = game.ContentManager; _players = Player.FromMapData(mapFile.SidesList.Players, game.AssetStore).ToList(); // TODO: This is completely wrong. LocalPlayer = _players.FirstOrDefault(); _teams = (mapFile.SidesList.Teams ?? mapFile.Teams.Items) .Select(team => Team.FromMapData(team, _players)) .ToList(); Audio = game.Audio; AssetLoadContext = game.AssetStore.LoadContext; Lighting = new WorldLighting( mapFile.GlobalLighting.LightingConfigurations.ToLightSettingsDictionary(), mapFile.GlobalLighting.Time); LoadObjects( game.AssetStore.LoadContext, Terrain.HeightMap, mapFile.ObjectsList.Objects, MapFile.NamedCameras, _teams, out var waypoints, out var roads, out var bridges, out var cameras); Roads = roads; Bridges = bridges; Waypoints = waypoints; Cameras = cameras; PlayerScripts = mapFile .GetPlayerScriptsList() .ScriptLists .Select(s => new MapScriptCollection(s)) .ToArray(); KeyBindingController = new KeyBindingController(contentManager); CameraController = new RtsCameraController(game.AssetStore.GameData.Current, KeyBindingController) { TerrainPosition = Terrain.HeightMap.GetPosition( Terrain.HeightMap.Width / 2, Terrain.HeightMap.Height / 2) }; contentManager.GraphicsDevice.WaitForIdle(); }
internal Scene3D( Game game, MapFile mapFile, string mapPath, int randomSeed, Data.Map.Player[] mapPlayers, Data.Map.Team[] mapTeams, ScriptList[] mapScriptLists, GameType gameType) : this(game, () => game.Viewport, game.InputMessageBuffer, randomSeed, false, mapFile, mapPath) { var contentManager = game.ContentManager; PlayerManager.OnNewGame(mapPlayers, game, gameType); TeamFactory = new TeamFactory(); TeamFactory.Initialize(mapTeams, PlayerManager); Audio = game.Audio; AssetLoadContext = game.AssetStore.LoadContext; Lighting = new WorldLighting( mapFile.GlobalLighting.LightingConfigurations.ToLightSettingsDictionary(), mapFile.GlobalLighting.Time); LoadObjects( game.AssetStore.LoadContext, Terrain.HeightMap, mapFile.ObjectsList.Objects, MapFile.NamedCameras, out var waypoints, out var roads, out var bridges, out var cameras); Roads = roads; Bridges = bridges; Waypoints = waypoints; Cameras = cameras; PlayerScripts = new PlayerScriptsList { ScriptLists = mapScriptLists }; CameraController = new RtsCameraController(game.AssetStore.GameData.Current, Camera, Terrain.HeightMap) { TerrainPosition = Terrain.HeightMap.GetPosition( Terrain.HeightMap.Width / 2, Terrain.HeightMap.Height / 2) }; contentManager.GraphicsDevice.WaitForIdle(); }
public Scene3D( Game game, InputMessageBuffer inputMessageBuffer, Func <Viewport> getViewport, ICameraController cameraController, MapFile mapFile, Terrain.Terrain terrain, Terrain.WaterArea[] waterAreas, Terrain.Road[] roads, Terrain.Bridge[] bridges, MapScriptCollection scripts, GameObjectCollection gameObjects, WaypointCollection waypoints, WaypointPathCollection waypointPaths, WorldLighting lighting, Player[] players, Team[] teams, bool isDiagnosticScene = false) { Camera = new Camera(getViewport); CameraController = cameraController; MapFile = mapFile; Terrain = terrain; WaterAreas = waterAreas; Roads = roads; Bridges = bridges; Scripts = scripts; GameObjects = AddDisposable(gameObjects); Waypoints = waypoints; WaypointPaths = waypointPaths; Lighting = lighting; SelectionGui = new SelectionGui(); RegisterInputHandler(_cameraInputMessageHandler = new CameraInputMessageHandler(), inputMessageBuffer); DebugOverlay = new DebugOverlay(this, game.ContentManager); if (!isDiagnosticScene) { RegisterInputHandler(_selectionMessageHandler = new SelectionMessageHandler(game.Selection), inputMessageBuffer); RegisterInputHandler(_orderGeneratorInputHandler = new OrderGeneratorInputHandler(game.OrderGenerator), inputMessageBuffer); RegisterInputHandler(_debugMessageHandler = new DebugMessageHandler(DebugOverlay), inputMessageBuffer); } _particleSystemManager = AddDisposable(new ParticleSystemManager(this)); _players = players.ToList(); _teams = teams.ToList(); // TODO: This is completely wrong. LocalPlayer = _players.FirstOrDefault(); }
private static void LoadObjects( ContentManager contentManager, HeightMap heightMap, MapObject[] mapObjects, Team[] teams, out WaypointCollection waypointCollection, out GameObjectCollection gameObjects) { var waypoints = new List <Waypoint>(); gameObjects = new GameObjectCollection(contentManager); foreach (var mapObject in mapObjects) { switch (mapObject.RoadType) { case RoadType.None: var position = mapObject.Position; switch (mapObject.TypeName) { case "*Waypoints/Waypoint": waypoints.Add(CreateWaypoint(mapObject)); break; default: // TODO: Handle locomotors when they're implemented. position.Z += heightMap.GetHeight(position.X, position.Y); var gameObject = CreateGameObject(mapObject, teams, contentManager); if (gameObject != null) { gameObject.Transform.Translation = position; gameObject.Transform.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, mapObject.Angle); gameObjects.Add(gameObject); } break; } break; default: // TODO: Roads. break; } contentManager.GraphicsDevice.WaitForIdle(); } waypointCollection = new WaypointCollection(waypoints); }
void Start() { rb = GetComponent <Rigidbody>(); wpc = GameObject.FindObjectOfType <WaypointCollection>(); pinSet = GameObject.FindObjectOfType <PinSet>(); startPosition = GameObject.FindObjectOfType <StartPosition>(); bounds = GetComponent <SphereCollider>().bounds; arrowPointer = GetComponentInChildren <ArrowPointer>(); arrowOriginRotation = arrowPointer.transform.rotation; arrowPointer.gameObject.SetActive(false); }
public Scene3D( Game game, ICameraController cameraController, MapFile mapFile, Terrain.Terrain terrain, Terrain.WaterArea[] waterAreas, Terrain.Road[] roads, Terrain.Bridge[] bridges, MapScriptCollection scripts, GameObjectCollection gameObjects, WaypointCollection waypoints, WaypointPathCollection waypointPaths, WorldLighting lighting, Player[] players, Team[] teams) { Camera = new Camera(() => game.Viewport); CameraController = cameraController; MapFile = mapFile; Terrain = terrain; WaterAreas = waterAreas; Roads = roads; Bridges = bridges; Scripts = scripts; GameObjects = AddDisposable(gameObjects); Waypoints = waypoints; WaypointPaths = waypointPaths; Lighting = lighting; SelectionGui = new SelectionGui(); _selectionMessageHandler = new SelectionMessageHandler(game.Selection); game.InputMessageBuffer.Handlers.Add(_selectionMessageHandler); AddDisposeAction(() => game.InputMessageBuffer.Handlers.Remove(_selectionMessageHandler)); _cameraInputMessageHandler = new CameraInputMessageHandler(); game.InputMessageBuffer.Handlers.Add(_cameraInputMessageHandler); AddDisposeAction(() => game.InputMessageBuffer.Handlers.Remove(_cameraInputMessageHandler)); DebugOverlay = new DebugOverlay(this, game.ContentManager); _debugMessageHandler = new DebugMessageHandler(DebugOverlay); game.InputMessageBuffer.Handlers.Add(_debugMessageHandler); AddDisposeAction(() => game.InputMessageBuffer.Handlers.Remove(_debugMessageHandler)); _particleSystemManager = AddDisposable(new ParticleSystemManager(game, this)); _players = players.ToList(); _teams = teams.ToList(); // TODO: This is completely wrong. LocalPlayer = _players.FirstOrDefault(); }
public async void Handle(ObservableCollection <Spostamento> message) { List <int> toRemove = pushpinVecchietti.Keys.Except(message.Select(x => x.PartecipanteObj.IDSpostamento).ToList()).ToList(); WaypointCollection wayColl = new WaypointCollection(); bool firstAdded = false; while (MapLayer.GetPosition(posizioneAttuale) == null) { await Task.Delay(TimeSpan.FromSeconds(1)); } wayColl.Add(new Waypoint(MapLayer.GetPosition(posizioneAttuale))); foreach (int idSpos in toRemove) { mappaBing.Children.Remove(pushpinVecchietti[idSpos]); pushpinVecchietti.Remove(idSpos); } foreach (Spostamento part in message) { if (pushpinVecchietti.ContainsKey(part.PartecipanteObj.IDSpostamento)) { if (part.PartecipanteObj.FKIDStato == 2) { pushpinVecchietti[part.PartecipanteObj.IDSpostamento].Template = this.Resources["DiscesaTemplate"] as ControlTemplate; } MapLayer.SetPosition(pushpinVecchietti[part.PartecipanteObj.IDSpostamento], new Location(part.Latitudine, part.Longitudine)); } else { pushpinVecchietti.Add(part.PartecipanteObj.IDSpostamento, CaricaVecchietti(part.Latitudine, part.Longitudine, part.PartecipanteObj.FKIDStato == 1)); } if (!firstAdded) { wayColl.Add(new Waypoint(MapLayer.GetPosition(pushpinVecchietti[part.PartecipanteObj.IDSpostamento]))); firstAdded = true; } } mappaBing.DirectionsManager.Waypoints = wayColl; mappaBing.DirectionsManager.CalculateDirectionsAsync(); }
internal Scene3D( Game game, InputMessageBuffer inputMessageBuffer, Func <Viewport> getViewport, ICameraController cameraController, WorldLighting lighting, int randomSeed, bool isDiagnosticScene = false) : this(game, getViewport, inputMessageBuffer, randomSeed, isDiagnosticScene, null, null) { WaterAreas = AddDisposable(new WaterAreaCollection()); Lighting = lighting; Roads = AddDisposable(new RoadCollection()); Bridges = Array.Empty <Bridge>(); Waypoints = new WaypointCollection(); Cameras = new CameraCollection(); CameraController = cameraController; }
public Scene3D( Game game, ICameraController cameraController, MapFile mapFile, Terrain.Terrain terrain, MapScriptCollection scripts, GameObjectCollection gameObjects, WaypointCollection waypoints, WaypointPathCollection waypointPaths, WorldLighting lighting, Player[] players, Team[] teams) { Camera = new CameraComponent(game); CameraController = cameraController; MapFile = mapFile; Terrain = terrain; Scripts = scripts; GameObjects = AddDisposable(gameObjects); Waypoints = waypoints; WaypointPaths = waypointPaths; Lighting = lighting; SelectionGui = new SelectionGui(); _selectionMessageHandler = new SelectionMessageHandler(game.Selection); game.InputMessageBuffer.Handlers.Add(_selectionMessageHandler); AddDisposeAction(() => game.InputMessageBuffer.Handlers.Remove(_selectionMessageHandler)); _cameraInputMessageHandler = new CameraInputMessageHandler(); game.InputMessageBuffer.Handlers.Add(_cameraInputMessageHandler); AddDisposeAction(() => game.InputMessageBuffer.Handlers.Remove(_cameraInputMessageHandler)); _particleSystemManager = AddDisposable(new ParticleSystemManager(game, this)); _players = players.ToList(); _teams = teams.ToList(); // TODO: This is completely wrong. LocalPlayer = _players.FirstOrDefault(); }
private void LoadObjects( AssetLoadContext loadContext, HeightMap heightMap, MapObject[] mapObjects, NamedCameras namedCameras, List <Team> teams, out WaypointCollection waypointCollection, out RoadCollection roads, out Bridge[] bridges, out CameraCollection cameras) { var waypoints = new List <Waypoint>(); var bridgesList = new List <Bridge>(); var roadTopology = new RoadTopology(); for (var i = 0; i < mapObjects.Length; i++) { var mapObject = mapObjects[i]; switch (mapObject.RoadType & RoadType.PrimaryType) { case RoadType.None: switch (mapObject.TypeName) { case Waypoint.ObjectTypeName: waypoints.Add(new Waypoint(mapObject)); break; default: GameObject.FromMapObject(mapObject, loadContext.AssetStore, GameObjects, heightMap, null, teams); break; } break; case RoadType.BridgeStart: case RoadType.BridgeEnd: // Multiple invalid bridges can be found in e.g GLA01. if ((i + 1) >= mapObjects.Length || !mapObjects[i + 1].RoadType.HasFlag(RoadType.BridgeEnd)) { Logger.Warn($"Invalid bridge: {mapObject.ToString()}, skipping..."); continue; } var bridgeEnd = mapObjects[++i]; bridgesList.Add(AddDisposable(new Bridge( loadContext, heightMap, mapObject, mapObject.Position, bridgeEnd.Position, GameObjects))); break; case RoadType.Start: case RoadType.End: var roadEnd = mapObjects[++i]; // Some maps have roads with invalid start- or endpoints. // We'll skip processing them altogether. if (mapObject.TypeName == "" || roadEnd.TypeName == "") { Logger.Warn($"Road {mapObject.ToString()} has invalid start- or endpoint, skipping..."); continue; } if (!mapObject.RoadType.HasFlag(RoadType.Start) || !roadEnd.RoadType.HasFlag(RoadType.End)) { throw new InvalidDataException(); } // Note that we're searching with the type of either end. // This is because of weirdly corrupted roads with unmatched ends in USA04, which work fine in WB and SAGE. var roadTemplate = loadContext.AssetStore.RoadTemplates.GetByName(mapObject.TypeName) ?? loadContext.AssetStore.RoadTemplates.GetByName(roadEnd.TypeName); if (roadTemplate == null) { throw new InvalidDataException($"Missing road template: {mapObject.TypeName}"); } roadTopology.AddSegment(roadTemplate, mapObject, roadEnd); break; } loadContext.GraphicsDevice.WaitForIdle(); } cameras = new CameraCollection(namedCameras?.Cameras); roads = AddDisposable(new RoadCollection(roadTopology, loadContext, heightMap)); waypointCollection = new WaypointCollection(waypoints, MapFile.WaypointsList.WaypointPaths); bridges = bridgesList.ToArray(); }
public void Read(BinaryReader _br, uint _version) { //ECD ecd = new EntityCreationData(); ecd.read(_br, false); //FOOD/DRINK food = new LiveStats(Constants.cMaxPlayerFood, Constants.cFoodOversaturate); food.Read(_br); drink = new LiveStats(Constants.cMaxPlayerDrink, Constants.cDrinkOversaturate); drink.Read(_br); //INVENTORY inventory = GameUtils.ReadItemStack(_br); selectedInventorySlot = _br.ReadByte(); //BAG bag = GameUtils.ReadItemStack(_br); //REMOVED - To allow for bigger backpack mods //if (bag.Length > 32) //{ // var destinationArray = ItemStack.CreateArray(32); // Array.Copy(bag, destinationArray, 32); // bag = destinationArray; //} //CRAFTED alreadyCraftedList = new HashSet <string>(); int num = _br.ReadUInt16(); for (var i = 0; i < num; i++) { alreadyCraftedList.Add(_br.ReadString()); } //SPAWNS var b = _br.ReadByte(); for (var j = 0; j < b; j++) { spawnPoints.Add(new Vector3i(_br.ReadInt32(), _br.ReadInt32(), _br.ReadInt32())); } selectedSpawnPointKey = _br.ReadInt64(); //LOADED _br.ReadBoolean(); _br.ReadInt16(); if (_version > 1u) { bLoaded = _br.ReadBoolean(); } //LASTSPAWN if (_version > 2u) { lastSpawnPosition = new SpawnPosition(new Vector3i(_br.ReadInt32(), _br.ReadInt32(), _br.ReadInt32()), _br.ReadSingle()); } else if (_version > 1u) { lastSpawnPosition = new SpawnPosition(new Vector3i(_br.ReadInt32(), _br.ReadInt32(), _br.ReadInt32()), 0f); } //ID if (_version > 3u) { id = _br.ReadInt32(); } //BACKPACK if (_version > 4u) { droppedBackpackPosition = new Vector3i(_br.ReadInt32(), _br.ReadInt32(), _br.ReadInt32()); } //STATS/EQUIPMENT if (_version > 5u) { playerKills = _br.ReadInt32(); zombieKills = _br.ReadInt32(); deaths = _br.ReadInt32(); score = _br.ReadInt32(); equipment = Equipment.Read(_br); } //RECIPES if (_version > 6u) { unlockedRecipeList = new List <string>(); num = _br.ReadUInt16(); for (var k = 0; k < num; k++) { unlockedRecipeList.Add(_br.ReadString()); } } //MARKER if (_version > 7u) { _br.ReadUInt16(); markerPosition = NetworkUtils.ReadVector3i(_br); } //FAVS if (_version > 8u) { favoriteEquipment = Equipment.Read(_br); } //EXP if (_version > 10u) { experience = _br.ReadUInt32(); } //LEVEL if (_version > 22u) { level = _br.ReadInt32(); } //CROUCHED if (_version > 11u) { bCrouchedLocked = _br.ReadBoolean(); } //CRAFTINGDATA craftingData.Read(_br, _version); //SKILLS - part1 if (_version > 14u) { if (_version < 18u) { var pdfskills = new Skills(); pdfskills.Read(_br, _version); } } //FAVRECIPES if (_version > 16u) { favoriteRecipeList = new List <string>(); num = _br.ReadUInt16(); for (var l = 0; l < num; l++) { favoriteRecipeList.Add(_br.ReadString()); } } //SKILLS - part2 if (_version > 17u) { var num2 = (int)_br.ReadUInt32(); if (num2 > 0) { //custom skill loader var pdfskills = new MemoryStream(_br.ReadBytes(num2)); var skillsReader = new Skills(); skillsReader.Read(new BinaryReader(pdfskills), _version); skills = skillsReader.GetAllSkills(); //end custom skill loader } } //STATS if (_version > 18u) { totalItemsCrafted = _br.ReadUInt32(); distanceWalked = _br.ReadSingle(); longestLife = _br.ReadSingle(); } if (_version > 35u) { gameStageLifetimeTicks = _br.ReadUInt64(); } else { gameStageLifetimeTicks = 0uL; } if (_version > 19u) { waypoints = new WaypointCollection(); waypoints.Read(_br); } if (_version > 23u) { skillPoints = _br.ReadInt32(); } if (_version > 24u) { questJournal = new QuestJournal(); questJournal.Read(_br); } if (_version > 25u) { deathUpdateTime = _br.ReadInt32(); } if (_version > 26u) { currentLife = _br.ReadSingle(); } if (_version > 29u) { bDead = _br.ReadBoolean(); } if (_version > 30u) { _br.ReadByte(); IsModdedSave = _br.ReadBoolean(); } if (_version > 31u) { playerJournal = new PlayerJournal(); playerJournal.Read(_br); } if (_version > 32u) { rentedVMPosition = NetworkUtils.ReadVector3i(_br); rentalEndTime = _br.ReadUInt64(); } if (_version > 33u) { trackedFriendEntityIds.Clear(); int num3 = _br.ReadUInt16(); for (var m = 0; m < num3; m++) { trackedFriendEntityIds.Add(_br.ReadInt32()); } } if (_version > 34u) { var num4 = _br.ReadInt32(); if (num4 > 0) { //var pdfstealth = new MemoryStream(_br.ReadBytes(num4)); //todo: custom loader } } }
public void Read(BinaryReader _br, uint _version) { ecd = new EntityCreationData(); ecd.read(_br, false); food = new LiveStats(Constants.cMaxPlayerFood, Constants.cFoodOversaturate); food.Read(_br); drink = new LiveStats(Constants.cMaxPlayerDrink, Constants.cDrinkOversaturate); drink.Read(_br); inventory = GameUtils.ReadItemStack(_br); selectedInventorySlot = _br.ReadByte(); bag = GameUtils.ReadItemStack(_br); if (bag.Length > 32) { ItemStack[] destinationArray = ItemStack.CreateArray(32); Array.Copy(bag, destinationArray, 32); bag = destinationArray; } alreadyCraftedList = new HashSet <string>(); int num = _br.ReadUInt16(); for (int i = 0; i < num; i++) { alreadyCraftedList.Add(_br.ReadString()); } byte b = _br.ReadByte(); for (int j = 0; j < b; j++) { spawnPoints.Add(new Vector3i(_br.ReadInt32(), _br.ReadInt32(), _br.ReadInt32())); } selectedSpawnPointKey = _br.ReadInt64(); _br.ReadBoolean(); _br.ReadInt16(); if (_version > 1u) { bLoaded = _br.ReadBoolean(); } if (_version > 2u) { lastSpawnPosition = new SpawnPosition(new Vector3i(_br.ReadInt32(), _br.ReadInt32(), _br.ReadInt32()), _br.ReadSingle()); } else if (_version > 1u) { lastSpawnPosition = new SpawnPosition(new Vector3i(_br.ReadInt32(), _br.ReadInt32(), _br.ReadInt32()), 0f); } if (_version > 3u) { id = _br.ReadInt32(); } if (_version > 4u) { droppedBackpackPosition = new Vector3i(_br.ReadInt32(), _br.ReadInt32(), _br.ReadInt32()); } if (_version > 5u) { playerKills = _br.ReadInt32(); zombieKills = _br.ReadInt32(); deaths = _br.ReadInt32(); score = _br.ReadInt32(); equipment = Equipment.Read(_br); } if (_version > 6u) { unlockedRecipeList = new List <string>(); num = _br.ReadUInt16(); for (int k = 0; k < num; k++) { unlockedRecipeList.Add(_br.ReadString()); } } if (_version > 7u) { _br.ReadUInt16(); markerPosition = NetworkUtils.ReadVector3i(_br); } if (_version > 8u) { favoriteEquipment = Equipment.Read(_br); } if (_version > 10u) { experience = _br.ReadUInt32(); } if (_version > 22u) { level = _br.ReadInt32(); } if (_version > 11u) { bCrouchedLocked = _br.ReadBoolean(); } craftingData.Read(_br, _version); if (_version > 14u) { if (_version < 18u) { Skills pdfskills = new Skills(); pdfskills.Read(_br, _version); } } if (_version > 16u) { favoriteRecipeList = new List <string>(); num = _br.ReadUInt16(); for (int l = 0; l < num; l++) { favoriteRecipeList.Add(_br.ReadString()); } } if (_version > 17u) { int num2 = (int)_br.ReadUInt32(); if (num2 > 0) { //custom skill loader MemoryStream pdfskills = new MemoryStream(0); pdfskills = new MemoryStream(_br.ReadBytes(num2)); EntityPlayer EP = new EntityPlayer(); EP.Skills = new Skills(); if (pdfskills.Length > 0L) { EP.Skills.Read(new BinaryReader(pdfskills), 34u); } skills = EP.Skills.GetAllSkills(); //end custom skill loader } } if (_version > 18u) { totalItemsCrafted = _br.ReadUInt32(); distanceWalked = _br.ReadSingle(); longestLife = _br.ReadSingle(); } if (_version > 19u) { waypoints = new WaypointCollection(); waypoints.Read(_br); } if (_version > 23u) { skillPoints = _br.ReadInt32(); } if (_version > 24u) { questJournal = new QuestJournal(); questJournal.Read(_br); } if (_version > 25u) { deathUpdateTime = _br.ReadInt32(); } if (_version > 26u) { currentLife = _br.ReadSingle(); } if (_version > 29u) { bDead = _br.ReadBoolean(); } if (_version > 30u) { _br.ReadByte(); IsModdedSave = _br.ReadBoolean(); } if (_version > 31u) { playerJournal = new PlayerJournal(); playerJournal.Read(_br); } if (_version > 32u) { rentedVMPosition = NetworkUtils.ReadVector3i(_br); rentalEndTime = _br.ReadUInt64(); } if (_version > 33u) { trackedFriendEntityIds.Clear(); int num3 = _br.ReadUInt16(); for (int m = 0; m < num3; m++) { trackedFriendEntityIds.Add(_br.ReadInt32()); } } }
private void LoadObjects( ContentManager contentManager, HeightMap heightMap, MapObject[] mapObjects, Team[] teams, out WaypointCollection waypointCollection, out GameObjectCollection gameObjects, out Road[] roads, out Bridge[] bridges) { var waypoints = new List <Waypoint>(); gameObjects = new GameObjectCollection(contentManager); var roadsList = new List <Road>(); var bridgesList = new List <Bridge>(); var roadTopology = new RoadTopology(); for (var i = 0; i < mapObjects.Length; i++) { var mapObject = mapObjects[i]; var position = mapObject.Position; switch (mapObject.RoadType & RoadType.PrimaryType) { case RoadType.None: switch (mapObject.TypeName) { case "*Waypoints/Waypoint": waypoints.Add(CreateWaypoint(mapObject)); break; default: position.Z += heightMap.GetHeight(position.X, position.Y); var gameObject = CreateGameObject(mapObject, teams, contentManager); if (gameObject != null) { gameObject.Transform.Translation = position; gameObject.Transform.Rotation = Quaternion.CreateFromAxisAngle(Vector3.UnitZ, mapObject.Angle); gameObjects.Add(gameObject); if (gameObject.Definition.IsBridge) { // This is a landmark bridge. We need to add towers at the corners. CreateTowers(contentManager, gameObjects, gameObject, mapObject); } } break; } break; case RoadType.BridgeStart: case RoadType.BridgeEnd: // Multiple invalid bridges can be found in e.g GLA01. // TODO: Log a warning. if ((i + 1) >= mapObjects.Length || !mapObjects[i + 1].RoadType.HasFlag(RoadType.BridgeEnd)) { continue; } var bridgeEnd = mapObjects[++i]; var bridgeTemplate = GetBridgeTemplate(contentManager, mapObject); if (Bridge.TryCreateBridge( contentManager, heightMap, bridgeTemplate, mapObject.Position, bridgeEnd.Position, out var bridge)) { bridgesList.Add(AddDisposable(bridge)); } break; default: var roadEnd = mapObjects[++i]; // Some maps have roads with invalid start- or endpoints. // We'll skip processing them altogether. // TODO: Log a warning. if (mapObject.TypeName == "" || roadEnd.TypeName == "") { continue; } if (!mapObject.RoadType.HasFlag(RoadType.Start) || !roadEnd.RoadType.HasFlag(RoadType.End)) { throw new InvalidDataException(); } // Note that we're searching with the type of either end. // This is because of weirdly corrupted roads with unmatched ends in USA04, which work fine in WB and SAGE. var roadTemplate = contentManager.IniDataContext.RoadTemplates.Find(x => x.Name == mapObject.TypeName || x.Name == roadEnd.TypeName); if (roadTemplate == null) { throw new InvalidDataException($"Missing road template: {mapObject.TypeName}"); } roadTopology.AddSegment(roadTemplate, mapObject, roadEnd); break; } contentManager.GraphicsDevice.WaitForIdle(); } // The map stores road segments with no connectivity: // - a segment is from point A to point B // - with a road type name // - and start and end curve types (angled, tight curve, broad curve). // The goal is to create road networks of connected road segments, // where a network has only a single road type. // A road network is composed of 2 or more nodes. // A network is a (potentially) cyclic graph. // A road node has > 1 and <= 4 edges connected to it. // A node can be part of multiple networks. // An edge can only exist in one network. // TODO: If a node stored in the map has > 4 edges, the extra edges // are put into a separate network. var networks = roadTopology.BuildNetworks(); foreach (var network in networks) { foreach (var edge in network.Edges) { var startPosition = edge.Start.TopologyNode.Position; var endPosition = edge.End.TopologyNode.Position; startPosition.Z += heightMap.GetHeight(startPosition.X, startPosition.Y); endPosition.Z += heightMap.GetHeight(endPosition.X, endPosition.Y); roadsList.Add(AddDisposable(new Road( contentManager, heightMap, edge.TopologyEdge.Template, startPosition, endPosition))); } } waypointCollection = new WaypointCollection(waypoints); roads = roadsList.ToArray(); bridges = bridgesList.ToArray(); }
public async void createRoute(List<Bing.Maps.Location> locs) { WaypointCollection col = new WaypointCollection(); for (int i = 0; i < locs.Count; i = i + 2) { col.Add(new Waypoint(locs[i])); //System.Diagnostics.Debug.WriteLine("Lat: " + locs[i].Latitude); //System.Diagnostics.Debug.WriteLine("Lon: " + locs[i].Longitude); } //col.Add(new Waypoint(locs[0])); //col.Add(new Waypoint(locs[locs.Count - 1])); //foreach (Location loc in locs) //{ // col.Add(new Waypoint(loc)); // System.Diagnostics.Debug.WriteLine("Lat: " + loc.Latitude); // System.Diagnostics.Debug.WriteLine("Lon: " + loc.Longitude); //} DirectionsManager manager = Map.DirectionsManager; manager.Waypoints = col; manager.RequestOptions.RouteMode = RouteModeOption.Walking; RouteResponse route_response = await manager.CalculateDirectionsAsync(); route_response.Routes[0].RoutePath.LineColor = new Windows.UI.Color { A = 200, R = 0, B = 200, G = 0 }; route_response.Routes[0].RoutePath.LineWidth = 10.0; manager.ShowRoutePath(route_response.Routes[0]); mc.Route = route_response.Routes[0]; }
public async void createRoute2(List<Bing.Maps.Location> locs) { double km = await getTotalDistanceKM(locs); int breakpoint; try { LocationCollection routePoints = new LocationCollection(); WaypointCollection col = new WaypointCollection(); for (int i = 0; i < locs.Count / 2; i++) { col.Add(new Waypoint(locs[i])); } DirectionsManager manager = Map.DirectionsManager; manager.RequestOptions.RouteMode = RouteModeOption.Walking; manager.Waypoints = col; manager.RenderOptions.WaypointPushpinOptions.Visible = false; RouteResponse resp = await manager.CalculateDirectionsAsync(); foreach (Bing.Maps.Location l in resp.Routes[0].RoutePath.PathPoints) { routePoints.Add(l); } manager.Waypoints.Clear(); col.Clear(); for (int i = locs.Count / 2; i < locs.Count; i++) { col.Add(new Waypoint(locs[i])); } manager.Waypoints = col; resp = await manager.CalculateDirectionsAsync(); foreach (Bing.Maps.Location l in resp.Routes[0].RoutePath.PathPoints) { routePoints.Add(l); } MapPolyline line = new MapPolyline { Locations = routePoints }; line.Color = new Windows.UI.Color { A = 50, R = 0, G = 0, B = 200 }; line.Width = 10.0; RouteLayer.Shapes.Add(line); mc.pathLocations = routePoints; Map.ShapeLayers.Add(RouteLayer); } catch(Exception d) { System.Diagnostics.Debug.WriteLine(d); showInternetPopup(); } }
public async void createRouteToVVV(Bing.Maps.Location curLoc,Bing.Maps.Location vvvLoc) { try { foreach (MapShapeLayer layer in Map.ShapeLayers) { if (layer.Equals(RouteLayer)) { layer.Shapes.Clear(); RouteLayer.Shapes.Clear(); } } Map.ShapeLayers.Clear(); WaypointCollection routePoints = new WaypointCollection { new Waypoint(curLoc), new Waypoint(vvvLoc) }; DirectionsManager manager = Map.DirectionsManager; manager.Waypoints.Clear(); manager.RequestOptions.RouteMode = RouteModeOption.Walking; manager.Waypoints = routePoints; manager.RenderOptions.WalkingPolylineOptions.Visible = true; RouteResponse resp = await manager.CalculateDirectionsAsync(); resp.Routes[0].RoutePath.LineWidth = 10.0; resp.Routes[0].RoutePath.LineColor = new Windows.UI.Color { A = 200, R = 200, B = 0, G = 2 }; MapShapeLayer layer10 = new MapShapeLayer(); LocationCollection locs = new LocationCollection(); foreach(Bing.Maps.Location l in resp.Routes[0].RoutePath.PathPoints) { Pushpin p = new Pushpin(); p.Text = "Pin"; MapLayer.SetPosition(p, l); Map.Children.Add(p); locs.Add(l); } MapPolyline line = new MapPolyline { Locations = locs }; line.Color = new Windows.UI.Color { A = 100, G = 0, B = 200, R = 0 }; line.Visible = true; line.Width = 10.0; layer10.Shapes.Add(line); Map.ShapeLayers.Add(layer10); manager.ShowRoutePath(resp.Routes[0]); } catch(Exception d) { System.Diagnostics.Debug.WriteLine(d); showInternetPopup(); } }
public async Task calculateRoute(List<WeBreda.Model.Waypoint> wpList) { routeCollection.Clear(); directionsManager.Waypoints.Clear(); WaypointCollection wpCollection = new WaypointCollection(); foreach (WeBreda.Model.Waypoint wp in wpList) { Bing.Maps.Directions.Waypoint bingwp = new Bing.Maps.Directions.Waypoint(new Location() { Latitude = wp.Latitude, Longitude = wp.Longitude }); Debug.Print(wp.Latitude + " " + wp.Longitude); directionsManager.Waypoints.Add(bingwp); wpCollection.Add(bingwp); if (directionsManager.Waypoints.Count > 4) { Bing.Maps.Directions.RouteResponse response = await directionsManager.CalculateDirectionsAsync(); if (response.Routes.Count > 0) { Bing.Maps.Directions.Route route = response.Routes[0]; routeCollection.Add(route); waypointCollectionList.Add(wpCollection); wpCollection = new WaypointCollection(); directionsManager.Waypoints.Clear(); directionsManager.Waypoints.Add(bingwp); wpCollection.Add(bingwp); } } } drawRouteLine(wpList); routeIndex = control.currentRoute.RouteIndex; directionsManager.ActiveRoute = routeCollection[routeIndex]; routeCalculated = true; }
private async void DirectionsAppBarButton_Click(object sender, RoutedEventArgs e) { Waypoint start = new Waypoint(currentLocation); ; Waypoint end = new Waypoint(destinationLocation); WaypointCollection waypoints = new WaypointCollection() { start, end }; ReverseGeocodeRequestOptions reverseRequestOptions = new ReverseGeocodeRequestOptions(currentLocation); await GetReverseGeocodeAddress(reverseRequestOptions, true); reverseRequestOptions.Location = destinationLocation; await GetReverseGeocodeAddress(reverseRequestOptions, false); directionsManager.RequestOptions.RouteMode = routeMode; directionsManager.Waypoints = waypoints; await directionsManager.CalculateDirectionsAsync(); // Check if route found if (directionsManager.RouteResult.Count > 0) { Instructions.Content = directionsManager.RouteSummaryView; itenaryItems = directionsManager.RouteResult[0].RouteLegs[0].ItineraryItems; } else { Instructions.Content = null; RouteMode.Text = string.Format("{0}: No route found", routeMode.ToString()); } if (DirectionsPanel.Visibility == Visibility.Collapsed) { OpenDirectionsButton.Visibility = Visibility.Collapsed; DirectionsPanel.Visibility = Visibility.Visible; } }