public void OnReceiveItemPacket(int node, PacketId id, byte[] data) { ItemPacket packet = new ItemPacket(data); ItemData item = packet.GetPacket(); string log = "[SERVER] ReceiveItemData " + "itemId:" + item.itemId + " state:" + item.state.ToString() + " ownerId:" + item.ownerId; Debug.Log(log); dbwin.console().print(log); PickupState state = (PickupState)item.state; switch (state) { case PickupState.PickingUp: MediatePickupItem(item.itemId, item.ownerId); break; case PickupState.Dropping: MediateDropItem(item.itemId, item.ownerId); break; default: break; } }
//서버에서 받았을 시 public void OnReceiveDestroyItem(int node, byte[] data) { ItemPacket packet = new ItemPacket(data); ItemData item = packet.GetPacket(); string name = item.itemId; if (items.ContainsKey(name)) { DestroyItem(name); } }
// ================================================================ // // 아이템 정보 패킷 취득 함수. public void OnReceiveItemPacket(int node, PacketId id, byte[] data) { ItemPacket packet = new ItemPacket(data); ItemData item = packet.GetPacket(); // 서버 상태와 동기화. ItemState istate = new ItemState(); istate.item_id = item.itemId; ItemController.State state = (ItemController.State)item.state; istate.state = (state == ItemController.State.Dropped)? ItemController.State.None : state; istate.owner = item.ownerId; if (GlobalParam.getInstance().item_table.ContainsKey(istate.item_id)) { GlobalParam.getInstance().item_table.Remove(istate.item_id); } GlobalParam.getInstance().item_table.Add(istate.item_id, istate); string log = "[CLIENT] Receive itempacket [" + "itemId:" + item.itemId + " state:" + state.ToString() + " ownerId:" + item.ownerId + "]"; Debug.Log(log); dbwin.console().print(log); if (state == ItemController.State.Picked) { Debug.Log("Receive item pick."); dbwin.console().print("Receive item pick."); // 응답이 있는 쿼리를 탐색. QueryItemPick query_pick = QueryManager.get().findQuery<QueryItemPick>(x => x.target == item.itemId); bool remote_pick = true; if (query_pick != null) { string account_name = PartyControl.get().getLocalPlayer().getAcountID(); if (item.ownerId == account_name) { Debug.Log("Receive item pick local:" + item.ownerId); dbwin.console().print("Receive item pick local:" + item.ownerId); item_query_done(query_pick, true); remote_pick = false; } else { Debug.Log("Receive item pick remote:" + item.ownerId); dbwin.console().print("Receive item pick remote:" + item.ownerId); item_query_done(query_pick, false); } } if (remote_pick == true) { Debug.Log("Remote pick item:" + item.ownerId); dbwin.console().print("Remote pick item:" + item.ownerId); // 리모트 캐릭터가 가지게 한다. chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId); if (remote) { // 아이템 획득 쿼리 발행. QueryItemPick query = remote.cmdItemQueryPick(item.itemId, false, true); if (query != null) { item_query_done(query, true); } } } // 아이템 획득 상태 변경. this.setItemState(item.itemId, ItemController.State.Picked, item.ownerId); } else if (state == ItemController.State.Dropped) { Debug.Log("Receive item drop."); // 응답이 있는 쿼리를 검색. QueryItemDrop query_drop = QueryManager.get().findQuery<QueryItemDrop>(x => x.target == item.itemId); bool remote_drop = true; if (query_drop != null) { // 요청에 대한 응답이 있다. string account_name = AccountManager.get().getAccountData(GlobalParam.get().global_account_id).avator_id; if (item.ownerId == account_name) { // 자신이 획득. Debug.Log("Receive item drop local:" + item.ownerId); item_query_done(query_drop, true); remote_drop = false; } else { // 상대가 획득. Debug.Log("Receive item pick remote:" + item.ownerId); item_query_done(query_drop, false); } } if (remote_drop == true) { // 리모트 캐릭터가 획득. chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId); if (remote) { // 아이템획득 쿼리 발행. Debug.Log ("QuetyitemDrop:cmdItemQueryDrop"); remote.cmdItemDrop(item.itemId, false); } } } else { Debug.Log("Receive item error."); } }
// ================================================================ // // 아이템 정보 패킷 취득 함수. public void OnReceiveItemPacket(int node, PacketId id, byte[] data) { ItemPacket packet = new ItemPacket(data); ItemData item = packet.GetPacket(); // 서버 상태와 동기화. ItemState istate = new ItemState(); istate.item_id = item.itemId; ItemController.State state = (ItemController.State)item.state; istate.state = (state == ItemController.State.Dropped)? ItemController.State.None : state; istate.owner = item.ownerId; if (GlobalParam.getInstance().item_table.ContainsKey(istate.item_id)) { GlobalParam.getInstance().item_table.Remove(istate.item_id); } GlobalParam.getInstance().item_table.Add(istate.item_id, istate); string log = "[CLIENT] Receive itempacket [" + "itemId:" + item.itemId + " state:" + state.ToString() + " ownerId:" + item.ownerId + "]"; Debug.Log(log); dbwin.console().print(log); if (state == ItemController.State.Picked) { Debug.Log("Receive item pick."); dbwin.console().print("Receive item pick."); // 응답이 있는 쿼리를 탐색. QueryItemPick query_pick = QueryManager.get().findQuery <QueryItemPick>(x => x.target == item.itemId); bool remote_pick = true; if (query_pick != null) { string account_name = PartyControl.get().getLocalPlayer().getAcountID(); if (item.ownerId == account_name) { Debug.Log("Receive item pick local:" + item.ownerId); dbwin.console().print("Receive item pick local:" + item.ownerId); item_query_done(query_pick, true); remote_pick = false; } else { Debug.Log("Receive item pick remote:" + item.ownerId); dbwin.console().print("Receive item pick remote:" + item.ownerId); item_query_done(query_pick, false); } } if (remote_pick == true) { Debug.Log("Remote pick item:" + item.ownerId); dbwin.console().print("Remote pick item:" + item.ownerId); // 리모트 캐릭터가 가지게 한다. chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId); if (remote) { // 아이템 획득 쿼리 발행. QueryItemPick query = remote.cmdItemQueryPick(item.itemId, false, true); if (query != null) { item_query_done(query, true); } } } // 아이템 획득 상태 변경. this.setItemState(item.itemId, ItemController.State.Picked, item.ownerId); } else if (state == ItemController.State.Dropped) { Debug.Log("Receive item drop."); // 응답이 있는 쿼리를 검색. QueryItemDrop query_drop = QueryManager.get().findQuery <QueryItemDrop>(x => x.target == item.itemId); bool remote_drop = true; if (query_drop != null) { // 요청에 대한 응답이 있다. string account_name = AccountManager.get().getAccountData(GlobalParam.get().global_account_id).avator_id; if (item.ownerId == account_name) { // 자신이 획득. Debug.Log("Receive item drop local:" + item.ownerId); item_query_done(query_drop, true); remote_drop = false; } else { // 상대가 획득. Debug.Log("Receive item pick remote:" + item.ownerId); item_query_done(query_drop, false); } } if (remote_drop == true) { // 리모트 캐릭터가 획득. chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId); if (remote) { // 아이템획득 쿼리 발행. Debug.Log("QuetyitemDrop:cmdItemQueryDrop"); remote.cmdItemDrop(item.itemId, false); } } } else { Debug.Log("Receive item error."); } }
// ================================================================ // // ?꾩씠???뺣낫 ?⑦궥 痍⑤뱷 ?⑥닔. public void OnReceiveItemPacket(int node, PacketId id, byte[] data) { ItemPacket packet = new ItemPacket(data); ItemData item = packet.GetPacket(); // ?쒕쾭 ?곹깭? ?숆린?? ItemState istate = new ItemState(); istate.item_id = item.itemId; ItemController.State state = (ItemController.State)item.state; istate.state = (state == ItemController.State.Dropped)? ItemController.State.None : state; istate.owner = item.ownerId; if (GlobalParam.getInstance().item_table.ContainsKey(istate.item_id)) { GlobalParam.getInstance().item_table.Remove(istate.item_id); } GlobalParam.getInstance().item_table.Add(istate.item_id, istate); string log = "[CLIENT] Receive itempacket [" + "itemId:" + item.itemId + " state:" + state.ToString() + " ownerId:" + item.ownerId + "]"; Debug.Log(log); dbwin.console().print(log); if (state == ItemController.State.Picked) { Debug.Log("Receive item pick."); dbwin.console().print("Receive item pick."); // ?묐떟???덈뒗 荑쇰━瑜??먯깋. QueryItemPick query_pick = QueryManager.get().findQuery<QueryItemPick>(x => x.target == item.itemId); bool remote_pick = true; if (query_pick != null) { string account_name = PartyControl.get().getLocalPlayer().getAcountID(); if (item.ownerId == account_name) { Debug.Log("Receive item pick local:" + item.ownerId); dbwin.console().print("Receive item pick local:" + item.ownerId); item_query_done(query_pick, true); remote_pick = false; } else { Debug.Log("Receive item pick remote:" + item.ownerId); dbwin.console().print("Receive item pick remote:" + item.ownerId); item_query_done(query_pick, false); } } if (remote_pick == true) { Debug.Log("Remote pick item:" + item.ownerId); dbwin.console().print("Remote pick item:" + item.ownerId); // 由щえ??罹먮┃?곌? 媛吏寃??쒕떎. chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId); if (remote) { // ?꾩씠???띾뱷 荑쇰━ 諛쒗뻾. QueryItemPick query = remote.cmdItemQueryPick(item.itemId, false, true); if (query != null) { item_query_done(query, true); } } } // ?꾩씠???띾뱷 ?곹깭 蹂寃? this.setItemState(item.itemId, ItemController.State.Picked, item.ownerId); } else if (state == ItemController.State.Dropped) { Debug.Log("Receive item drop."); // ?묐떟???덈뒗 荑쇰━瑜?寃?? QueryItemDrop query_drop = QueryManager.get().findQuery<QueryItemDrop>(x => x.target == item.itemId); bool remote_drop = true; if (query_drop != null) { // ?붿껌??????묐떟???덈떎. string account_name = AccountManager.get().getAccountData(GlobalParam.get().global_account_id).avator_id; if (item.ownerId == account_name) { // ?먯떊???띾뱷. Debug.Log("Receive item drop local:" + item.ownerId); item_query_done(query_drop, true); remote_drop = false; } else { // ?곷?媛 ?띾뱷. Debug.Log("Receive item pick remote:" + item.ownerId); item_query_done(query_drop, false); } } if (remote_drop == true) { // 由щえ??罹먮┃?곌? ?띾뱷. chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId); if (remote) { // ?꾩씠?쒗쉷??荑쇰━ 諛쒗뻾. Debug.Log ("QuetyitemDrop:cmdItemQueryDrop"); remote.cmdItemDrop(item.itemId, false); } } } else { Debug.Log("Receive item error."); } }
public void OnReceiveItemPacket(PacketId id, byte[] data) { ItemPacket packet = new ItemPacket(data); ItemData item = packet.GetPacket(); PickupState state = (PickupState) item.state; string log = "[SERVER] ReceiveItemData " + "itemId:" + item.itemId + " state:" + state.ToString() + " ownerId:" + item.ownerId; Debug.Log(log); switch (state) { case PickupState.PickingUp: MediatePickupItem(item.itemId, item.ownerId); break; case PickupState.Dropping: MediateDropItem(item.itemId, item.ownerId); break; default: break; } }
// 아이템 정보 패킷 획득 함수. public void OnReceiveItemPacket(PacketId id, byte[] data) { ItemPacket packet = new ItemPacket(data); ItemData item = packet.GetPacket(); // 서버의 상태와 동기화합니다. ItemState istate = new ItemState(); istate.item_id = item.itemId; ItemController.State state = (ItemController.State)item.state; istate.state = (state == ItemController.State.Dropped)? ItemController.State.None : state; istate.owner = item.ownerId; if (GlobalParam.get().item_table.ContainsKey(item.itemId)) { GlobalParam.get().item_table.Remove(istate.item_id); } GlobalParam.get().item_table.Add(istate.item_id, istate); string log = "[CLIENT] Receive itempacket. " + "itemId:" + item.itemId + " state:" + state.ToString() + " ownerId:" + item.ownerId; Debug.Log(log); if (state == ItemController.State.Picked) { Debug.Log("Receive item pick."); // 응답이 있는 쿼리를 검색. QueryItemPick query_pick = null; foreach (var query in this.queries) { QueryItemPick pick = query as QueryItemPick; if (pick != null && pick.target == item.itemId) { query_pick = pick; break; } } bool remote_pick = true; if (query_pick != null) { if (item.ownerId == GlobalParam.get().account_name) { Debug.Log("Receive item pick local:" + item.ownerId); item_query_done(query_pick, true); remote_pick = false; } else { Debug.Log("Receive item pick remote:" + item.ownerId); item_query_done(query_pick, false); } } if (remote_pick == true) { // 리모트 캐릭터가 취득하게 합니다. chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId); if (remote) { // 아이템 획득 쿼리 발행. QueryItemPick query = remote.cmdItemQueryPick(item.itemId, false, true); if (query != null) { item_query_done(query, true); } } } } else if (state == ItemController.State.Dropped) { Debug.Log("Receive item drop."); // 응답이 있는 쿼리를 검색. QueryItemDrop query_drop = null; foreach (var query in this.queries) { QueryItemDrop drop = query as QueryItemDrop; if (drop != null && drop.target == item.itemId) { query_drop = drop; break; } } bool remote_drop = true; if (query_drop != null) { // 요청에 대한 응답이 있을 때. if (item.ownerId == GlobalParam.get().account_name) { // 자신이 획득. Debug.Log("Receive item drop local:" + item.ownerId); item_query_done(query_drop, true); remote_drop = false; } else { // 상대가 획득. Debug.Log("Receive item pick remote:" + item.ownerId); item_query_done(query_drop, false); } } if (remote_drop == true) { // 리모트 캐릭터가 회득하게 합니다. chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId); if (remote) { // 아이템 획득 쿼리 발행. Debug.Log("QuetyitemDrop:cmdItemQueryDrop"); QueryItemDrop query = remote.cmdItemQueryDrop(false); if (query != null) { query.is_drop_done = true; item_query_done(query, true); } } } } else { Debug.Log("Receive item error."); } }
// 아이템 정보 패킷 획득 함수. public void OnReceiveItemPacket(PacketId id, byte[] data) { ItemPacket packet = new ItemPacket(data); ItemData item = packet.GetPacket(); // 서버의 상태와 동기화합니다. ItemState istate = new ItemState(); istate.item_id = item.itemId; ItemController.State state = (ItemController.State)item.state; istate.state = (state == ItemController.State.Dropped)? ItemController.State.None : state; istate.owner = item.ownerId; if (GlobalParam.get().item_table.ContainsKey(item.itemId)) { GlobalParam.get().item_table.Remove(istate.item_id); } GlobalParam.get().item_table.Add(istate.item_id, istate); string log = "[CLIENT] Receive itempacket. " + "itemId:" + item.itemId + " state:" + state.ToString() + " ownerId:" + item.ownerId; Debug.Log(log); if (state == ItemController.State.Picked) { Debug.Log("Receive item pick."); // 응답이 있는 쿼리를 검색. QueryItemPick query_pick = null; foreach(var query in this.queries) { QueryItemPick pick = query as QueryItemPick; if (pick != null && pick.target == item.itemId) { query_pick = pick; break; } } bool remote_pick = true; if (query_pick != null) { if (item.ownerId == GlobalParam.get().account_name) { Debug.Log("Receive item pick local:" + item.ownerId); item_query_done(query_pick, true); remote_pick = false; } else { Debug.Log("Receive item pick remote:" + item.ownerId); item_query_done(query_pick, false); } } if (remote_pick == true) { // 리모트 캐릭터가 취득하게 합니다. chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId); if (remote) { // 아이템 획득 쿼리 발행. QueryItemPick query = remote.cmdItemQueryPick(item.itemId, false, true); if (query != null) { item_query_done(query, true); } } } } else if (state == ItemController.State.Dropped) { Debug.Log("Receive item drop."); // 응답이 있는 쿼리를 검색. QueryItemDrop query_drop = null; foreach(var query in this.queries) { QueryItemDrop drop = query as QueryItemDrop; if (drop != null && drop.target == item.itemId) { query_drop = drop; break; } } bool remote_drop = true; if (query_drop != null) { // 요청에 대한 응답이 있을 때. if (item.ownerId == GlobalParam.get().account_name) { // 자신이 획득. Debug.Log("Receive item drop local:" + item.ownerId); item_query_done(query_drop, true); remote_drop = false; } else { // 상대가 획득. Debug.Log("Receive item pick remote:" + item.ownerId); item_query_done(query_drop, false); } } if (remote_drop == true) { // 리모트 캐릭터가 회득하게 합니다. chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId); if (remote) { // 아이템 획득 쿼리 발행. Debug.Log ("QuetyitemDrop:cmdItemQueryDrop"); QueryItemDrop query = remote.cmdItemQueryDrop(false); if (query != null) { query.is_drop_done = true; item_query_done(query, true); } } } } else { Debug.Log("Receive item error."); } }
// ================================================================ // // ?꾩씠???뺣낫 ?⑦궥 痍⑤뱷 ?⑥닔. public void OnReceiveItemPacket(int node, PacketId id, byte[] data) { ItemPacket packet = new ItemPacket(data); ItemData item = packet.GetPacket(); // ?쒕쾭 ?곹깭? ?숆린?? ItemState istate = new ItemState(); istate.item_id = item.itemId; ItemController.State state = (ItemController.State)item.state; istate.state = (state == ItemController.State.Dropped)? ItemController.State.None : state; istate.owner = item.ownerId; if (GlobalParam.getInstance().item_table.ContainsKey(istate.item_id)) { GlobalParam.getInstance().item_table.Remove(istate.item_id); } GlobalParam.getInstance().item_table.Add(istate.item_id, istate); string log = "[CLIENT] Receive itempacket [" + "itemId:" + item.itemId + " state:" + state.ToString() + " ownerId:" + item.ownerId + "]"; Debug.Log(log); dbwin.console().print(log); if (state == ItemController.State.Picked) { Debug.Log("Receive item pick."); dbwin.console().print("Receive item pick."); // ?묐떟???덈뒗 荑쇰━瑜??먯깋. QueryItemPick query_pick = QueryManager.get().findQuery <QueryItemPick>(x => x.target == item.itemId); bool remote_pick = true; if (query_pick != null) { string account_name = PartyControl.get().getLocalPlayer().getAcountID(); if (item.ownerId == account_name) { Debug.Log("Receive item pick local:" + item.ownerId); dbwin.console().print("Receive item pick local:" + item.ownerId); item_query_done(query_pick, true); remote_pick = false; } else { Debug.Log("Receive item pick remote:" + item.ownerId); dbwin.console().print("Receive item pick remote:" + item.ownerId); item_query_done(query_pick, false); } } if (remote_pick == true) { Debug.Log("Remote pick item:" + item.ownerId); dbwin.console().print("Remote pick item:" + item.ownerId); // 由щえ??罹먮┃?곌? 媛吏寃??쒕떎. chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId); if (remote) { // ?꾩씠???띾뱷 荑쇰━ 諛쒗뻾. QueryItemPick query = remote.cmdItemQueryPick(item.itemId, false, true); if (query != null) { item_query_done(query, true); } } } // ?꾩씠???띾뱷 ?곹깭 蹂寃? this.setItemState(item.itemId, ItemController.State.Picked, item.ownerId); } else if (state == ItemController.State.Dropped) { Debug.Log("Receive item drop."); // ?묐떟???덈뒗 荑쇰━瑜?寃?? QueryItemDrop query_drop = QueryManager.get().findQuery <QueryItemDrop>(x => x.target == item.itemId); bool remote_drop = true; if (query_drop != null) { // ?붿껌??????묐떟???덈떎. string account_name = AccountManager.get().getAccountData(GlobalParam.get().global_account_id).avator_id; if (item.ownerId == account_name) { // ?먯떊???띾뱷. Debug.Log("Receive item drop local:" + item.ownerId); item_query_done(query_drop, true); remote_drop = false; } else { // ?곷?媛 ?띾뱷. Debug.Log("Receive item pick remote:" + item.ownerId); item_query_done(query_drop, false); } } if (remote_drop == true) { // 由щえ??罹먮┃?곌? ?띾뱷. chrController remote = CharacterRoot.getInstance().findPlayer(item.ownerId); if (remote) { // ?꾩씠?쒗쉷??荑쇰━ 諛쒗뻾. Debug.Log("QuetyitemDrop:cmdItemQueryDrop"); remote.cmdItemDrop(item.itemId, false); } } } else { Debug.Log("Receive item error."); } }