public SPWorld(MasterRenderer renderer) : base(renderer) { WorldDescription desc = LoadFromFile(Program.GetConfigString("Singleplayer/world")); spawnPos = new Vector3(100, 400, 100); var commandposts = desc.GetObjectsByTag("CommandPost"); foreach (WorldObjectDescription ob in commandposts) { Vector3 position = ob.GetVector3("Position"); Team team = (Team)(ob.GetField <byte>("Team") ?? 0); CommandPost commandPost = new CommandPost(position, team); AddGameObject(commandPost); if (team == Team.A) { spawnPos = position; } } var intels = desc.GetObjectsByTag("Intel"); foreach (WorldObjectDescription ob in intels) { Vector3 position = ob.GetVector3("Position"); Team team = (Team)(ob.GetField <byte>("Team") ?? 0); Intel editorIntel = new Intel(position, team); AddGameObject(editorIntel); } Player = new SPPlayer(Renderer, this, Camera.Active, spawnPos, Team.A); AddGameObject(Player); hud = new HUD(Renderer); hud.Player = Player; hud.ShowCharacterInformation = true; hud.Enable(); Player.AttachCamera(); }
public override void Update(float deltaTime) { if (Player != null) { Player.CharacterController.IsStatic = !Terrain.Ready; hud.Update(deltaTime); if (Player.Health <= 0) { // Respawn player RemoveGameObject(Player); Player.Dispose(); Player = new SPPlayer(Renderer, this, Camera.Active, spawnPos, Team.A); AddGameObject(Player); hud.Player = Player; Player.AttachCamera(); } } base.Update(deltaTime); }