public void SetMap(Map map) { //_map.Add(map); _map = map; }
public void SetMap(Map map, Vector2 pos) { Player p = null; if (_currentMap != null) { p = _currentMap.ObjectManager.GetPlayer(playerID); _currentMap.ObjectManager.Remove(playerID); } _currentMap = map; if (p != null) { p.SetPosition(pos); _currentMap.ObjectManager.Add(p); } IGORR.Protocol.Messages.ChangeMapMessage cmm = (IGORR.Protocol.Messages.ChangeMapMessage)ProtocolHelper.GetContainerMessage(MessageTypes.ChangeMap, Connection); cmm.mapid = map.ID; ProtocolHelper.SendContainer(cmm, Connection); //_clientConnection.SendMessage(cmm.GetMessage(), NetDeliveryMethod.ReliableOrdered, 1); if (p != null) { AssignPlayerMessage apm = (AssignPlayerMessage)ProtocolHelper.GetContainerMessage(MessageTypes.AssignPlayer, Connection); apm.objectID = p.ID; ProtocolHelper.SendContainer(apm, Connection); } SpawnMessage sm; for (int x = 0; x < _currentMap.ObjectManager.Objects.Count; x++) { sm = (SpawnMessage)ProtocolHelper.GetContainerMessage(MessageTypes.Spawn, Connection); sm.position = _currentMap.ObjectManager.Objects[x].Rect; sm.objectType = _currentMap.ObjectManager.Objects[x].ObjectType; sm.id = _currentMap.ObjectManager.Objects[x].ID; sm.Info = _currentMap.ObjectManager.Objects[x].Info; ProtocolHelper.SendContainer(sm, Connection); _currentMap.ObjectManager.Objects[x].SendInfo(Connection); Player play = _currentMap.ObjectManager.Objects[x] as Player; if (play != null) { PositionMessage pm = (PositionMessage)ProtocolHelper.GetContainerMessage(MessageTypes.Position, Connection); pm.Position = play.Position; pm.Move = new Vector3(play.Movement, play.LastSpeed.Y); pm.id = play.ID; ProtocolHelper.SendContainer(pm, Connection); SetPlayerStatusMessage dm = (SetPlayerStatusMessage)ProtocolHelper.GetContainerMessage(MessageTypes.SetHP, Connection); dm.playerID = play.ID; dm.currentHP = play.HP; dm.maxHP = play.MaxHP; dm.Exp = 0;// play.TotalXP; dm.lastLevelExp = 0;// play.LastLevelXP; dm.nextLevelExp = 0;// play.NextLevelXP; ProtocolHelper.SendContainer(dm, Connection); } } for (int x = 0; x < _currentMap.TileMods.Count; x++) { ChangeTileMessage ctm = (ChangeTileMessage)ProtocolHelper.GetContainerMessage(MessageTypes.ChangeTile, Connection); ctm.tileID = _currentMap.TileMods[x].TileID; ctm.x = _currentMap.TileMods[x].Position.X; ctm.y = _currentMap.TileMods[x].Position.Y; ctm.layer = _currentMap.TileMods[x].layer; ProtocolHelper.SendContainer(ctm, Connection); } if (p != null) { p.map = _currentMap; for (int x = 0; x < p.Inventory.Count; x++) { PickupMessage pum = (PickupMessage)ProtocolHelper.GetContainerMessage(MessageTypes.Pickup, Connection); pum.id = p.Inventory[x].GetID(); pum.autoEquip = false; pum.PlayerID = playerID; ProtocolHelper.SendContainer(pum, Connection); } } ProtocolHelper.FlushContainer(Connection, 1); if (p != null) { p.Body.SendBody(null); for (int x = 0; x < _currentMap.ObjectManager.Objects.Count; x++) { Player play = _currentMap.ObjectManager.Objects[x] as Player; if (play != null && play != p) { play.Body.SendBody(p); } } } }