Ejemplo n.º 1
0
    // ================================================================ //

    // 룸 이동 후에 호출되고 싶다.
    public void             onRoomChanged(RoomController room)
    {
        // 열쇠 아이콘을 대응하는 도어 방향으로 표시한다.

        if (room != null)
        {
            Map.EWSN[] key_dir = new Map.EWSN[4];

            for (int i = 0; i < 4; i++)
            {
                key_dir[i] = Map.EWSN.NONE;
            }
            for (int i = 0; i < (int)Map.EWSN.NUM; i++)
            {
                DoorControl door = room.getDoor((Map.EWSN)i);

                if (door == null)
                {
                    continue;
                }

                int key_type = door.KeyType;

                if (key_type >= 4)
                {
                    continue;
                }
                key_dir[key_type] = (Map.EWSN)i;
            }

            Vector2 base_pos = BASE_POS;
            Vector2 pos;

            base_pos.x += KEY_ICON_SIZE.x;
            base_pos.y += KEY_ICON_SIZE.y;

            for (int i = 0; i < 4; i++)
            {
                pos = base_pos - WINDOW_SIZE / 2.0f;

                this.sprite_key[i].setVisible(true);

                // 도어가 없을 때는 비표시로.
                if (key_dir[i] == Map.EWSN.NONE)
                {
                    this.sprite_key[i].setVisible(false);
                    continue;
                }

                // 언락되지 않음 = 열쇠를 아직 줍지 않았으면 비표시.
                DoorControl door = room.getDoor(key_dir[i]);

                if (!door.IsUnlocked())
                {
                    this.sprite_key[i].setVisible(false);
                }

                //

                float offset = KEY_ICON_SIZE.x * 0.6f;

                switch (key_dir[i])
                {
                case Map.EWSN.NORTH:    pos += new Vector2(0.0f, offset);      break;

                case Map.EWSN.SOUTH:    pos += new Vector2(0.0f, -offset);      break;

                case Map.EWSN.EAST:             pos += new Vector2(offset, 0.0f);      break;

                case Map.EWSN.WEST:             pos += new Vector2(-offset, 0.0f);      break;
                }
                this.sprite_key[i].setPosition(pos);
            }
        }
    }