/// <summary> /// 플레이어의 패의 위치를 갱신한다. /// 패를 내면 중간중간 빠진 자리가 생기는데 그 자리를 처음부터 다시 채워준다. /// </summary> /// <param name="player_index"></param> void refresh_player_hand_slots(byte player_index) { CPlayerHandCardManager hand_card_manager = this.player_hand_card_manager[player_index]; byte count = (byte)hand_card_manager.get_card_count(); for (byte card_index = 0; card_index < count; ++card_index) { CCardPicture card = hand_card_manager.get_card(card_index); // 슬롯 인덱스를 재설정 한다. card.set_slot_index(card_index); // 화면 위치를 재설정 한다. card.transform.position = this.player_card_positions[player_index].get_hand_position(card_index); } }
IEnumerator distribute_cards(Queue <CCard> floor_cards, Dictionary <byte, Queue <CCard> > player_cards) { yield return(new WaitForSeconds(1.0f)); List <CCardPicture> begin_cards_picture = new List <CCardPicture>(); // [바닥 -> 1P -> 2P 나눠주기] 를 두번 반복한다. for (int looping = 0; looping < 2; ++looping) { // 바닥에는 4장씩 분배한다. for (int i = 0; i < 4; ++i) { CCard card = floor_cards.Dequeue(); CCardPicture card_picture = this.deck_cards.Pop(); card_picture.update_card(card, get_hwatoo_sprite(card)); begin_cards_picture.Add(card_picture); card_picture.transform.localScale = SCALE_TO_FLOOR; move_card(card_picture, card_picture.transform.position, this.floor_slot_position[i + looping * 4]); yield return(new WaitForSeconds(0.02f)); } yield return(new WaitForSeconds(0.1f)); // 플레어이의 카드를 분배한다. foreach (KeyValuePair <byte, Queue <CCard> > kvp in player_cards) { byte player_index = kvp.Key; Queue <CCard> cards = kvp.Value; byte ui_slot_index = (byte)(looping * 5); // 플레이어에게는 한번에 5장씩 분배한다. for (int card_index = 0; card_index < 5; ++card_index) { CCardPicture card_picture = this.deck_cards.Pop(); card_picture.set_slot_index(ui_slot_index); this.player_hand_card_manager[player_index].add(card_picture); // 본인 카드는 해당 이미지를 보여주고, // 상대방 카드(is_nullcard)는 back_image로 처리한다. if (player_index == this.player_me_index) { CCard card = cards.Dequeue(); card_picture.update_card(card, get_hwatoo_sprite(card)); card_picture.transform.localScale = SCALE_TO_MY_HAND; move_card(card_picture, card_picture.transform.position, this.player_card_positions[player_index].get_hand_position(ui_slot_index)); } else { card_picture.update_backcard(this.back_image); card_picture.transform.localScale = SCALE_TO_OTHER_HAND; move_card(card_picture, card_picture.transform.position, this.player_card_positions[player_index].get_hand_position(ui_slot_index)); } ++ui_slot_index; yield return(new WaitForSeconds(0.02f)); } } } sort_floor_cards_after_distributed(begin_cards_picture); sort_player_hand_slots(this.player_me_index); CPacket msg = CPacket.create((short)PROTOCOL.DISTRIBUTED_ALL_CARDS); CNetworkManager.Instance.send(msg); }