コード例 #1
0
    void sort_floor_cards_after_distributed(List <CCardPicture> begin_cards_picture)
    {
        Dictionary <byte, byte> slots = new Dictionary <byte, byte>();

        for (byte i = 0; i < begin_cards_picture.Count; ++i)
        {
            byte             number = begin_cards_picture[i].card.number;
            CVisualFloorSlot slot   = this.floor_ui_slots.Find(obj => obj.is_same_card(number));
            Vector3          to     = Vector3.zero;
            if (slot == null)
            {
                to = this.floor_slot_position[i];

                slot = this.floor_ui_slots[i];
                slot.add_card(begin_cards_picture[i]);
            }
            else
            {
                to = get_ui_slot_position(slot);

                slot.add_card(begin_cards_picture[i]);
            }


            Vector3 begin = this.floor_slot_position[i];
            move_card(begin_cards_picture[i], begin, to);
        }
    }
コード例 #2
0
    Vector3 get_ui_slot_position(CVisualFloorSlot slot)
    {
        Vector3 position      = this.floor_slot_position[slot.ui_slot_position];
        int     stacked_count = slot.get_card_count();

        position.x += (stacked_count * 7.0f);
        position.y -= (stacked_count * 3.0f);
        return(position);
    }
コード例 #3
0
    byte find_empty_floorslot()
    {
        CVisualFloorSlot slot = this.floor_ui_slots.Find(obj => obj.get_card_count() == 0);

        if (slot == null)
        {
            return(byte.MaxValue);
        }

        return(slot.ui_slot_position);
    }
コード例 #4
0
    void sort_floor_cards_when_finished_turn()
    {
        for (int i = 0; i < this.floor_ui_slots.Count; ++i)
        {
            CVisualFloorSlot slot = this.floor_ui_slots[i];
            if (slot.get_card_count() == 0)
            {
                continue;
            }

            CCardPicture card_pic = slot.get_first_card();
            move_card(card_pic,
                      card_pic.transform.position,
                      this.floor_slot_position[slot.ui_slot_position]);
        }
    }
コード例 #5
0
    public void refresh_hint_mark()
    {
        hide_hint_mark();

        for (int i = 0; i < this.player_hand_card_manager[this.player_me_index].get_card_count(); ++i)
        {
            CCardPicture     card_picture = this.player_hand_card_manager[this.player_me_index].get_card(i);
            CVisualFloorSlot slot         =
                this.floor_ui_slots.Find(obj => obj.is_same_card(card_picture.card.number));
            if (slot == null)
            {
                continue;
            }

            show_hint_mark(card_picture.transform.position);
        }
    }
コード例 #6
0
    void move_card_to_floor(CCardPicture card_picture, CARD_EVENT_TYPE event_type)
    {
        byte    slot_index = 0;
        Vector3 begin      = card_picture.transform.position;
        Vector3 to         = Vector3.zero;

        CVisualFloorSlot slot =
            this.floor_ui_slots.Find(obj => obj.is_same_card(card_picture.card.number));

        if (slot == null)
        {
            byte empty_slot = find_empty_floorslot();
            //Debug.Log(string.Format("empty slot pos " + empty_slot));
            to         = this.floor_slot_position[empty_slot];
            slot_index = empty_slot;
        }
        else
        {
            to = get_ui_slot_position(slot);

            List <CCardPicture> floor_card_pictures = slot.get_cards();
            for (int i = 0; i < floor_card_pictures.Count; ++i)
            {
                Animator ani = floor_card_pictures[i].GetComponentInChildren <Animator>();
                ani.enabled = true;
                ani.Play("card_hit_under");
            }

            slot_index = slot.ui_slot_position;

            if (event_type != CARD_EVENT_TYPE.BOMB)
            {
                CEffectManager.Instance.play_dust(to, 0.1f, false);
            }

            Animator card_ani = card_picture.GetComponentInChildren <Animator>();
            card_ani.enabled = true;
            card_ani.Play("card_hit");
        }

        // 바닥 카드로 등록.
        this.floor_ui_slots[slot_index].add_card(card_picture);
        move_card(card_picture, begin, to, 0.01f);
    }
コード例 #7
0
    IEnumerator move_after_flip_card(byte player_index,
                                     List <CCardPicture> take_cards_from_others,
                                     List <CCard> cards_to_give)
    {
        // 상대방에게 뺏어올 카드 움직이기.
        for (int i = 0; i < take_cards_from_others.Count; ++i)
        {
            Vector3 pos = get_player_card_position(player_index, PAE_TYPE.PEE);
            move_card(take_cards_from_others[i],
                      take_cards_from_others[i].transform.position,
                      pos);
            this.player_card_manager[player_index].add(take_cards_from_others[i]);

            yield return(new WaitForSeconds(0.5f));
        }


        // 카드 가져오기.
        for (int i = 0; i < cards_to_give.Count; ++i)
        {
            CVisualFloorSlot slot =
                this.floor_ui_slots.Find(obj => obj.is_same_card(cards_to_give[i].number));
            if (slot == null)
            {
                UnityEngine.Debug.LogError(string.Format("Cannot find floor slot. {0}, {1}, {2}",
                                                         cards_to_give[i].number, cards_to_give[i].pae_type, cards_to_give[i].position));
            }
            CCardPicture card_pic = slot.find_card(cards_to_give[i]);

            if (card_pic == null)
            {
                UnityEngine.Debug.LogError(string.Format("Cannot find the card. {0}, {1}, {2}",
                                                         cards_to_give[i].number, cards_to_give[i].pae_type, cards_to_give[i].position));
            }

            slot.remove_card(card_pic);

            Vector3 begin = card_pic.transform.position;
            Vector3 to    = get_player_card_position(player_index, card_pic.card.pae_type);

            if (this.player_me_index == player_index)
            {
                card_pic.transform.localScale = SCALE_TO_MY_FLOOR;
            }
            else
            {
                card_pic.transform.localScale = SCALE_TO_OTHER_FLOOR;
            }

            move_card(card_pic, begin, to);

            this.player_card_manager[player_index].add(card_pic);

            yield return(new WaitForSeconds(0.1f));
        }


        //yield return new WaitForSeconds(0.5f);

        sort_floor_cards_when_finished_turn();
        refresh_player_hand_slots(player_index);

        yield return(new WaitForSeconds(0.2f));

        CPacket finish = CPacket.create((short)PROTOCOL.TURN_END);

        CNetworkManager.Instance.send(finish);
    }
コード例 #8
0
    /// <summary>
    /// 플레이어가 선택한 카드를 바닥에 내는 장면 구현.
    /// 폭탄 이벤트가 존재할 경우 같은 번호의 카드 세장을 한꺼번에 내도록 구현한다.
    /// </summary>
    /// <param name="player_index"></param>
    /// <param name="event_type"></param>
    /// <param name="slot_index"></param>
    /// <param name="player_card_number"></param>
    /// <param name="player_card_pae_type"></param>
    /// <param name="player_card_position"></param>
    /// <returns></returns>
    IEnumerator move_player_cards_to_floor(
        byte player_index,
        CARD_EVENT_TYPE event_type,
        List <CCard> bomb_cards_info,
        byte slot_index,
        byte player_card_number,
        PAE_TYPE player_card_pae_type,
        byte player_card_position)
    {
        float card_moving_delay = 0.2f;

        List <CCardPicture> targets = new List <CCardPicture>();

        if (event_type == CARD_EVENT_TYPE.BOMB)
        {
            card_moving_delay = 0.1f;

            // 폭탄인 경우에는 폭탄 카드 수 만큼 낸다.
            if (this.player_me_index == player_index)
            {
                for (int i = 0; i < bomb_cards_info.Count; ++i)
                {
                    CCardPicture card_picture = this.player_hand_card_manager[player_index].find_card(
                        bomb_cards_info[i].number, bomb_cards_info[i].pae_type, bomb_cards_info[i].position);
                    targets.Add(card_picture);
                }
            }
            else
            {
                for (int i = 0; i < bomb_cards_info.Count; ++i)
                {
                    CCardPicture card_picture = this.player_hand_card_manager[player_index].get_card(i);
                    CCard        card         = this.card_manager.find_card(bomb_cards_info[i].number,
                                                                            bomb_cards_info[i].pae_type, bomb_cards_info[i].position);
                    card_picture.update_card(card, get_hwatoo_sprite(card));
                    targets.Add(card_picture);
                }
            }
        }
        else
        {
            // 폭탄이 아닌 경우에는 한장의 카드만 낸다.
            CCardPicture card_picture = this.player_hand_card_manager[player_index].get_card(slot_index);
            targets.Add(card_picture);

            if (this.player_me_index != player_index)
            {
                CCard card = this.card_manager.find_card(player_card_number,
                                                         player_card_pae_type, player_card_position);
                card_picture.update_card(card, get_hwatoo_sprite(card));
            }
        }


        if (event_type == CARD_EVENT_TYPE.BOMB)
        {
            CVisualFloorSlot slot =
                this.floor_ui_slots.Find(obj => obj.is_same_card(player_card_number));
            Vector3 to = get_ui_slot_position(slot);
            CEffectManager.Instance.play_dust(to, 0.3f, true);
        }


        // 카드 움직이기.
        for (int i = 0; i < targets.Count; ++i)
        {
            // 손에 들고 있는 패에서 제거한다.
            CCardPicture player_card = targets[i];
            this.player_hand_card_manager[player_index].remove(player_card);

            // 스케일 장면.
            yield return(StartCoroutine(scale_to(
                                            player_card,
                                            3.5f,
                                            0.05f)));

            yield return(new WaitForSeconds(card_moving_delay));

            // 이동 장면.
            player_card.transform.localScale = SCALE_TO_FLOOR;
            move_card_to_floor(player_card, event_type);
        }
    }