public void update_pos(byte[] bytes) { MPosCSHeader pos_header = new MPosCSHeader(HeaderConst.HEADER_POS_MSG_ID); pos_header.Header_Decode(bytes); int player_id = (int)pos_header.GetVal("player_id"); Debug.Log("update_pos " + player_id); if (m_dicNoSycCache.ContainsKey(player_id) == false) { m_dicNoSycCache[player_id] = new List <MPosCSHeader>(); } m_dicNoSycCache[player_id].Add(pos_header); }
public void pull_data(List <string> inputs) { float delta_x = 0f; float delta_y = 0f; foreach (string input in inputs) { if (input == "up") { delta_y += 1; } else if (input == "down") { delta_y -= 1; } else if (input == "left") { delta_x -= 1; } else if (input == "right") { delta_x += 1; } } if (delta_x == 0 && delta_y == 0) { return; } float target_x = delta_x + m_x; float target_y = delta_y + m_y; MPosCSHeader header = new MPosCSHeader(HeaderConst.HEADER_POS_MSG_ID); header.SetVal("player_id", m_player_id); header.SetVal("pos_x", target_x); header.SetVal("pos_y", target_y); Debug.Log("player_id is " + m_player_id + " target_x " + target_x + " target_y " + target_y); var bin = Proto.encode_buffer(header.Header_Encode()); var ct = GameMgr.get_instance().get_owner_client(); if (ct != null) { ct.SendMsg(bin); } }