/// <summary> /// Send level up packet to client and update database /// </summary> /// <param name="client">The MapClient</param> /// <param name="type">The LevelType that gained level(s)</param> /// <param name="numLevels">The number of levels gained</param> private void SendLevelUp(MapClient client, LevelType type, uint numLevels) { //Update DB Packets.Server.LevelUp sendPacket = new SagaMap.Packets.Server.LevelUp(); sendPacket.SetLevelType((byte)type); sendPacket.SetActorID(client.Char.id); sendPacket.SetLevels(1); client.netIO.SendPacket(sendPacket, client.SessionID); switch (type) { case LevelType.CLEVEL: SagaMap.Skills.SkillHandler.CalcHPSP(ref client.Char); client.Char.HP = client.Char.maxHP; client.Char.SP = client.Char.maxSP; client.Char.cLevel += numLevels; client.Char.stpoints += (byte)(2 * numLevels); // TODO implement getting this from level configuration client.SendBattleStatus(); client.SendCharStatus(0); client.SendExtStats(); break; case LevelType.JLEVEL: client.Char.jLevel += numLevels; client.Char.HP = client.Char.maxHP; client.Char.SP = client.Char.maxSP; client.SendCharStatus(0); break; } Logger.ShowInfo(client.Char.name + " gained " + numLevels + "x" + type.ToString(), null); //if (client.Party != null) // client.Party.UpdateMemberInfo(client); }
/// <summary> /// Check whether input clients experience at the input level type has reached beyond it's current level or not. /// If it has, process the new level (update database and inform client), if not, proceed as nothing happened. /// </summary> /// <param name="client"></param> /// <param name="type"></param> public void CheckExp(MapClient client, LevelType type) { switch (type) { case LevelType.CLEVEL: this.lvlDelta = this.GetLevelDelta(client.Char.cLevel, client.Char.cExp, LevelType.CLEVEL, true); if (this.lvlDelta > 0) { this.SendLevelUp(client, type, this.lvlDelta); } break; case LevelType.JLEVEL: this.lvlDelta = this.GetLevelDelta(client.Char.jLevel, client.Char.jExp, LevelType.JLEVEL, true); if (this.lvlDelta > 0) { this.SendLevelUp(client, type, this.lvlDelta); } break; case LevelType.WLEVEL: Weapon weapon = WeaponFactory.GetActiveWeapon(client.Char); this.lvlDelta = this.GetLevelDelta(weapon.level, weapon.exp, LevelType.WLEVEL, false); if (this.lvlDelta > 0) { // Make sure that the wexp don't exceed the maximum weapon.exp = this.Chart[weapon.level].wxp; } break; } }
public void ListClients(MapClient sclient) { string message = ""; int i = 0; foreach (Client j in this.clients.Values) { if (j.GetType() != typeof(MapClient)) { continue; } MapClient temp = (MapClient)j; if (temp.Char == null) { continue; } message += (temp.Char.name + " "); if ((i % 4) == 0 && i != 0) { sclient.SendMessage("Saga", message); message = ""; } i++; } if (message != "") { sclient.SendMessage("Saga", message); } }
/// <summary> /// Connects new clients /// </summary> public override void NetworkLoop(int maxNewConnections) { for (int i = 0; listener.Pending() && i < maxNewConnections; i++) { Socket sock = listener.AcceptSocket(); Logger.ShowInfo("New client from: " + sock.RemoteEndPoint.ToString(), null); uint sessionid = (uint)((uint)0xFFFFFFFF - clients.Count); MapClient client = new MapClient(sock, this.commandTable, sessionid); ClientManager.EnterCriticalArea(); while (clients.ContainsKey(sessionid)) { if (sessionid > 0x40000000) { sessionid--; } else { sessionid++; } } clients.Add(sessionid, client); ClientManager.LeaveCriticalArea(); } }
public GameClient(Uri ph_uri, Uri mh_uri, Uri ch_uri) { client = this; // Create game simulation. game_sim = new ClientSimulation(); // Create game state. game_state = new ClientState(); // Create rendering instance renderer = new Renderer(320, 240); // Create connection Hubs player_hub_conn = new HubConnectionBuilder().WithUrl(ph_uri).Build(); map_hub_conn = new HubConnectionBuilder().WithUrl(mh_uri).Build(); chat_hub_conn = new HubConnectionBuilder().WithUrl(ch_uri).Build(); player_client = new PlayerClient(player_hub_conn); map_client = new MapClient(map_hub_conn); map_client.loadMapFromServer(); chat_client = new ChatClient(chat_hub_conn); //chat_client.onChatUpdated += refreshMessages; player_hub_conn.SendAsync("registerPlayerConnection", game_state.player); player_hub_conn.SendAsync("getSprites"); player_hub_conn.SendAsync("getTextures"); b_is_running = true; doGameLoop(); }
public Regeneration(MapClient client,ushort hp,ushort sp,int period) { this.dueTime = 1000; this.period = period; this.client = client; this.hp = hp; this.sp = sp; }
public Regeneration(MapClient client, ushort hp, ushort sp, int period) { this.dueTime = 1000; this.period = period; this.client = client; this.hp = hp; this.sp = sp; }
public MapRemoteDataSource( ILogger <MapRemoteDataSource> logger, MapClient client ) { this.logger = logger; this.client = client; }
public override void OnClientDisconnect(Client client) { MapClient client_ = (MapClient)client; if (this.clients.ContainsKey(client_.SessionID)) { this.clients.Remove(client_.SessionID); } }
private byte GetIndexForClient(MapClient c1, MapClient c2) { /*int index1, index2; * index1 = this.Members.IndexOf(c1); * index2 = this.Members.IndexOf(c2); * if (c1 == c2) return 1; * if (index1 < index2) return (byte)(index1 + 2); * else return (byte)(index1 + 1);*/ return(1); }
/// <summary> /// called the first time a user shows up to the page /// </summary> /// <param name="message"></param> public void Join(MapClient message) { // add the user to the list of clients _clients.Add(this.Context.ConnectionId, message); // let all of the clients know a new user is here this.Clients.All.addClient(message); // tell the caller about the full list this.Clients.Caller.addClients(_clients.ToArray()); }
/// <summary> /// Connects new clients /// </summary> public override void NetworkLoop(int maxNewConnections) { for (int i = 0; listener.Pending() && i < maxNewConnections; i++) { Socket sock = listener.AcceptSocket(); string ip = sock.RemoteEndPoint.ToString().Substring(0, sock.RemoteEndPoint.ToString().IndexOf(':')); Logger.ShowInfo(string.Format(LocalManager.Instance.Strings.NEW_CLIENT, sock.RemoteEndPoint.ToString()), null); MapClient client = new MapClient(sock, this.commandTable); clients.Add(client); } }
public void RemoveMember(MapClient client, byte index) { /*foreach (MapClient c in this.Members) * { * if (GetIndexForClient(client, c) == index) * { * RemoveMember(this.Members[index]); * return; * } * }*/ RemoveMember(this.Members[index]); }
public void SendLoot(MapClient client, uint id) { Packets.Server.PartyMemberLoot p = new SagaMap.Packets.Server.PartyMemberLoot(); p.SetIndex((byte)(this.Members.IndexOf(client) + 1)); p.SetActorID(client.Char.id); p.SetItemID(id); foreach (MapClient c in this.Members) { if (c != client) { c.netIO.SendPacket(p, c.SessionID); } } }
private void SendPartyInfo(MapClient client) { Packets.Server.SendPartyInfo p = new SagaMap.Packets.Server.SendPartyInfo(); p.SetLeaderIndex((byte)(this.Members.IndexOf(this.Leader) + 1)); p.SetLeader(Leader.Char.id); p.SetSetting1((byte)LootShare); //p.SetSetting1(LootShare); //p.SetSetting2(1); p.SetSetting2((byte)XPShare); p.SetSetting3(0); p.SetSetting4(0); p.SetMemberInfo(this.Members); client.netIO.SendPacket(p, client.SessionID); }
public JsonResult GetElementTypes() { var mapClient = new MapClient(apiConfig.GetString("ImxApiMediaUrl"), apiConfig.GetString("oAuthConsumerKey"), apiConfig.GetString("oAuthConsumerSecret"), 1); var apiElementTypes = mapClient.GetMapElementTypes(); var elementTypes = new List<ElementType>(); foreach (var element in apiElementTypes) { elementTypes.Add(new ElementType(element.ID, element.Name, element.Clear_ImageUrl)); } return Json(elementTypes, JsonRequestBehavior.AllowGet); }
public void UpdateMemberInfo(MapClient client) { if (!this.Members.Contains(client)) { return; } Packets.Server.PartyMemberInfo p1 = new SagaMap.Packets.Server.PartyMemberInfo(); p1.SetIndex(1); p1.SetActorID(client.Char.id); p1.SetActorInfo(client.Char); foreach (MapClient c in this.Members) { c.netIO.SendPacket(p1, c.SessionID); } }
public override void Parse(SagaLib.Client client) { try { LoginSession client_ = (LoginSession)client; Packets.Login.Send.MapPong p = new SagaMap.Packets.Login.Send.MapPong(); client.netIO.SendPacket(p, client_.SessionID); } catch { MapClient client_ = (MapClient)client; Packets.Login.Send.MapPong p = new SagaMap.Packets.Login.Send.MapPong(); client.netIO.SendPacket(p, client_.SessionID); } }
public void ListClientsAndInfo(MapClient sclient) { foreach (Client i in this.clients.Values) { if (i.GetType() != typeof(MapClient)) { continue; } MapClient client = (MapClient)i; if (client.Char == null) { continue; } sclient.SendMessage("Saga", "Char: " + client.Char.name + " Map: " + client.Char.mapID + " x:" + client.Char.x + " y:" + client.Char.y + " z:" + client.Char.z); } }
private void SendNewMemberInfoToOldMember(MapClient client) { Packets.Server.PartyNewMember p = new SagaMap.Packets.Server.PartyNewMember(); p.SetIndex(1); p.SetActorID(client.Char.id); p.SetUnknown(1); p.SetName(client.Char.name); Packets.Server.PartyMemberInfo p1 = new SagaMap.Packets.Server.PartyMemberInfo(); p1.SetIndex(1); p1.SetActorID(client.Char.id); p1.SetActorInfo(client.Char); foreach (MapClient c in this.Members) { c.netIO.SendPacket(p, c.SessionID); c.netIO.SendPacket(p1, c.SessionID); } }
public void SendPosition(MapClient client) { Packets.Server.PartyMemberPosition p = new SagaMap.Packets.Server.PartyMemberPosition(); p.SetIndex(1); p.SetActorID(client.Char.id); p.SetX(client.Char.x / 1000); p.SetY(client.Char.y / 1000); foreach (MapClient c in this.Members) { if (c != client) { if (c.Char.mapID == client.Char.mapID) { c.netIO.SendPacket(p, c.SessionID); } } } }
public void RemoveMember(MapClient client) { foreach (MapClient c in this.Members) { if (c.state == MapClient.SESSION_STATE.LOGGEDOFF) { continue; } Packets.Server.PartyMemberQuit p = new SagaMap.Packets.Server.PartyMemberQuit(); //p.SetIndex(GetIndexForClient(c, client)); p.SetIndex((byte)(this.Members.IndexOf(client) + 1)); p.SetUnknown(1); p.SetActorID(client.Char.id); c.netIO.SendPacket(p, c.SessionID); } Packets.Server.PartyDismissed tp = new SagaMap.Packets.Server.PartyDismissed(); if (client.state != MapClient.SESSION_STATE.LOGGEDOFF) { client.netIO.SendPacket(tp, client.SessionID); } this.Members.Remove(client); client.Party = null; if (this.Members.Count == 1) { Packets.Server.PartyDismissed p = new SagaMap.Packets.Server.PartyDismissed(); this.Members[0].netIO.SendPacket(p, this.Members[0].SessionID); this.Members[0].Party = null; } else { if (this.Leader == client) { this.Leader = this.Members[0]; } foreach (MapClient c in this.Members) { if (c.state == MapClient.SESSION_STATE.LOGGEDOFF) { continue; } SendPartyInfo(c); } } }
/// <summary> /// /// </summary> /// <param name="settings"></param> /// <param name="deviceProfile"></param> /// <param name="authenticatedUser"></param> public PokemonGoApiClient(IApiSettings settings, IDeviceProfile deviceProfile, AuthenticatedUser authenticatedUser = null) : this() { StartTime = DateTimeOffset.UtcNow; CancellationTokenSource = new CancellationTokenSource(); RequestQueue = new BlockingCollection <RequestEnvelope>(); Player = new PlayerClient(this); Download = new DownloadClient(this); Inventory = new InventoryClient(this); Map = new MapClient(this); Fort = new FortClient(this); Encounter = new EncounterClient(this); ApiSettings = settings; DeviceProfile = deviceProfile; SetAuthenticationProvider(); AuthenticatedUser = authenticatedUser; Player.SetCoordinates(ApiSettings.DefaultPosition.Latitude, ApiSettings.DefaultPosition.Longitude, ApiSettings.DefaultPosition.Accuracy); }
public PortMapProcess(MapClient mapClient, Route route, Socket srcSocket, String serverAddress2, int serverPort2, string password_proxy_md5, string dstAddress, int dstPort) { this.mapClient = mapClient; this.serverAddress = serverAddress2; this.serverPort = serverPort2; this.srcSocket = srcSocket; this.password_proxy_md5 = password_proxy_md5; try { srcIs = new DataInputStream(srcSocket.getInputStream()); srcOs = new DataOutputStream(srcSocket.getOutputStream()); conn = route.getConnection(serverAddress, serverPort, null); tis = conn.uis; tos = conn.uos; JSONObject requestJson = new JSONObject(); requestJson.put("dst_address", dstAddress); requestJson.put("dst_port", dstPort); requestJson.put("password_proxy_md5", password_proxy_md5); byte[] requestData = requestJson.toJSONString().getBytes("utf-8"); tos.write(requestData, 0, requestData.length); final Pipe p1 = new Pipe(); final Pipe p2 = new Pipe(); byte[] responeData = tis.read2(); String hs = new String(responeData, "utf-8"); JSONObject responeJSon = JSONObject.parseObject(hs); int code = responeJSon.getIntValue("code"); String message = responeJSon.getString("message"); String uimessage = ""; if (code == Constant.code_success) { Route.es.execute(new Runnable() { @Override
public void AddMember(MapClient client) { if (this.Members.Count != 0) { if (this.Members.Count >= 2) { SendNewMemberInfoToOldMember(client); this.Members.Add(client); } else { this.Members.Add(client); SendPartyInfo(this.Members[0]); } SendPartyInfo(client); } else { this.Members.Add(client); } }
public GameClient(GameConnection connection, MapConnection mapConnection) { _mapClient = new MapClient(mapConnection); _mapClient.ConnectionOpened += MapClient_ConnectionOpened; _mapClient.ConnectionClosed += MapClient_ConnectionClosed; _mapClient.ConnectionFailed += MapClient_ConnectionFailed; _mapClient.MapLoaded += MapClient_MapLoaded; _connection = connection; _connection.PacketReceived += OnPacketReceived; _connection.Connected += OnConnectionOpened; _connection.Disconnected += OnConnectionClosed; Rand = new Random(); I18n = new Language(); Team = new List<Pokemon>(); CurrentPCBox = new List<Pokemon>(); Items = new List<InventoryItem>(); Channels = new List<ChatChannel>(); Conversations = new List<string>(); Players = new Dictionary<string, PlayerInfos>(); PCGreatestUid = -1; IsPrivateMessageOn = true; }
public AutoSave(MapClient client) { this.dueTime = 1000; this.period = 1800000; this.client = client; }
public void ListClients(MapClient sclient) { string message = ""; int i = 0; foreach (Client j in this.clients.Values) { if (j.GetType() != typeof(MapClient)) continue; MapClient temp = (MapClient)j; if (temp.Char == null) continue; message += (temp.Char.name + " "); if ((i % 4) == 0 && i != 0) { sclient.SendMessage("Saga", message); message = ""; } i++; } if(message != "") sclient.SendMessage("Saga", message); }
/// <summary> /// Connects new clients /// </summary> public override void NetworkLoop(int maxNewConnections) { for (int i = 0; listener.Pending() && i < maxNewConnections; i++) { Socket sock = listener.AcceptSocket(); Logger.ShowInfo("New client from: " + sock.RemoteEndPoint.ToString(), null); uint sessionid = (uint)((uint)0xFFFFFFFF - clients.Count); MapClient client = new MapClient(sock, this.commandTable, sessionid); ClientManager.EnterCriticalArea(); while (clients.ContainsKey(sessionid)) { if (sessionid > 0x40000000) sessionid--; else sessionid++; } clients.Add(sessionid, client); ClientManager.LeaveCriticalArea(); } }
public void ReloadScript(MapClient client) { //Get all NPCs List <string> tmp2 = new List <string>(); foreach (string i in this.scripts.Keys) { Npc npc = this.scripts[i]; if (npc.isItem == false) { if (npc.Actor.npcType < 10000 || npc.Actor.npcType > 50000) { tmp2.Add(i); npc.Map.DeleteActor(npc.Actor); } } else { MapItem item = (MapItem)npc; item.Map.DeleteActor(item.ActorI); tmp2.Add(i); } } foreach (string i in tmp2) { this.scripts[i].Dispose(); this.scripts.Remove(i); } Quest.QuestsManager.QuestItem = new Dictionary <uint, Dictionary <uint, List <SagaMap.Quest.QuestsManager.questI> > >(); Quest.QuestsManager.MobQuestItem = new Dictionary <uint, List <SagaMap.Quest.QuestsManager.LootInfo> >(); Quest.QuestsManager.Enemys = new Dictionary <uint, Dictionary <uint, List <SagaMap.Quest.QuestsManager.EnemyInfo> > >(); Quest.QuestsManager.WayPoints = new Dictionary <uint, Dictionary <uint, List <SagaMap.Quest.QuestsManager.WayPointInfo> > >(); Logger.ShowInfo("Loading uncompiled scripts", null); CSharpCodeProvider provider = new CSharpCodeProvider(); int npccount = 0; int mapitemcount = 0; try { try { Assembly newAssembly = CompileScript(Directory.GetFiles("scripts/npcs", "*.cs", SearchOption.AllDirectories), provider, client); int[] tmp; if (newAssembly != null) { tmp = LoadAssembly(newAssembly); mapitemcount += tmp[0]; npccount += tmp[1]; } } catch (Exception ex) { Logger.ShowError(ex, null); } } catch (Exception) { } Logger.ShowInfo("Loading compiled scripts", null); try { foreach (string s in Directory.GetFiles("cscripts")) { try { int[] tmp; Assembly newAssembly = Assembly.LoadFrom(s); tmp = LoadAssembly(newAssembly); mapitemcount += tmp[0]; npccount += tmp[1]; } catch (Exception) { } } } catch (Exception) { } Logger.ShowInfo(string.Format("Reloaded {0} NPCs and {1} MapItems", npccount, mapitemcount), null); }
public PCEventHandler(MapClient client) { Client = client; }
public PC_EventHandler(ActorPC actor, MapClient client) { this.I = actor; this.C = client; }
public OxygenUsage(MapClient client) { this.dueTime = 1; this.period = 1000; this.client = client; }
public LPReduction(MapClient client) { this.dueTime = 1000; this.period = 10000; this.client = client; }
public CheckHeartbeat(MapClient client) { this.dueTime = 1000; this.period = 10000; this.client = client; }
public static Assembly CompileScript(string[] Source, CodeDomProvider Provider, MapClient client) { //ICodeCompiler compiler = Provider.; CompilerParameters parms = new CompilerParameters(); CompilerResults results; // Configure parameters parms.CompilerOptions = "/target:library /optimize"; parms.GenerateExecutable = false; parms.GenerateInMemory = true; parms.IncludeDebugInformation = true; parms.ReferencedAssemblies.Add("System.dll"); parms.ReferencedAssemblies.Add("SagaLib.dll"); parms.ReferencedAssemblies.Add("SagaDB.dll"); parms.ReferencedAssemblies.Add("SagaMap.exe"); // Compile results = Provider.CompileAssemblyFromFile(parms, Source); if (results.Errors.Count > 0) { foreach (CompilerError error in results.Errors) { if (client != null) { client.SendMessage("Saga", "Compile Error:" + error.ErrorText); client.SendMessage("Saga", "File:" + error.FileName + ":" + error.Line); } Logger.ShowError("Compile Error:" + error.ErrorText, null); Logger.ShowError("File:" + error.FileName + ":" + error.Line, null); } return(null); } //get a hold of the actual assembly that was generated return(results.CompiledAssembly); }
public void ListClientsAndInfo(MapClient sclient) { foreach (Client i in this.clients.Values) { if (i.GetType() != typeof(MapClient)) continue; MapClient client = (MapClient)i; if (client.Char == null) continue; sclient.SendMessage("Saga", "Char: " + client.Char.name + " Map: " + client.Char.mapID + " x:" + client.Char.x + " y:" + client.Char.y + " z:" + client.Char.z); } }
public ActionResult GetMapById(int mapIdFrom) { var mapClient = new MapClient(apiConfig.GetString("ImxApiMediaUrl"), apiConfig.GetString("oAuthConsumerKey"), apiConfig.GetString("oAuthConsumerSecret"), 1); ImxMap mapInfo = mapClient.GetMap(mapIdFrom); return Json(mapInfo, JsonRequestBehavior.AllowGet); }
public override void Parse(SagaLib.Client client) { MapClient cli = (MapClient)client; cli.OnSupplySelect(this); }