Game Client Lee Hwanguk 2023. 4. 11. 01:16

#상점 시스템이 수정 사항이 있어서 UI도 수정이 필요했다. 어제 구현하지 못한 부분과 시스템수정한 부분까지 해서 다시 수정하고 완성했다. 

 

 *시스템 수정사항 - 장비아이템 16종, 소모 아이템 3종으로 수정되었다 . 특수장비는 삭제.

                             - 페이지를 넘길 필요가 없어졌다. 그리드만 유지하여 간격만 유지하자

                            

 *추가로 구현해야할 부분들 - 일반장비 or 소모아이템 텝을 누르면 활성화가 된 탭을 focus로 보여주자

                                             - 오브잭트가 활성화 되면 기본으로 '일반장비' 텝이 활성화 된 상태여야한다

                                             - 일반장비 또는 소모아이템에서 클릭한 셀에 따라 활성화가 되는 팝업도 내용이 달라야한다 

                                             - 팝업에서 소모아이템과 일반장비가 보여줘야하는 정보가 다르다. 

                                             - 데이터 테이블이 완성 되는 대로 연동할 수 있게 데이터 테이블도 미리 만들어놓자

 

*UI화면구성 수정

*특수장비 텝 삭제, 페이지 버튼 삭제, 오브잭트 활성화 시 일반장비 탭 활성(판매아이템  16종으로 변경-셀 16개 활성화)
*소모아이템은 판매하는 아이템이 3종으로 변경, 텝 활성화 시 배열에서 3개만 활성
*일반장비 탭은 변경 사항 없음
*소모아이템 클릭 시 활성화 되는 팝업의 내용 변경

*스크립트 수정

*UIShop

using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;

public class UIShop : MonoBehaviour
{
    //dim
    [Header("dim")]
    public Button dim; //dim ->팝업 비활성

    //Tab
    [Header("Tab")]
    public Button[] arrTabBtn;
    public GameObject[] arrTabFocus;

    //Grid
    [Header("Graid")]
    public List<GameObject> cellList;

    //Close
    [Header("Close")]
    public Button btnClose;

    //Goods
    [Header("Goods")]
    public Text txtGold; //재화 (골드)
    public Text txtEther; //재화(에테르)

    //UIShopPopup
    public UIShopPopup uiShopPopup;

    private void Start()
    {
        for(int i=0; i< this.cellList.Count; i++)
        {
            var btnCells=this.cellList[i].GetComponent<Button>();
            btnCells.onClick.AddListener(() => {
                this.uiShopPopup.gameObject.SetActive(true);
            });
        }
    }
    public void Init()
    {
        this.dim.onClick.AddListener(() => { 
            this.gameObject.SetActive(false);
        });
        this.btnClose.onClick.AddListener(() => { 
            this.gameObject.SetActive(false);
        });

        //Tab
        this.arrTabBtn[0].onClick.AddListener(() =>
        {
            this.OnNormalTabClick();
            this.uiShopPopup.txtNameDetail.text = "일반장비";
        });
        this.arrTabBtn[1].onClick.AddListener(() =>
        {
            this.OnFoodTabClick();
            this.uiShopPopup.txtNameDetail.text = "소모아이템";
        });

        this.uiShopPopup.Init();
        this.TabInit();
    }

    private void TabInit() //활성화 초기값 = 일반장비 탭만 활성화
    {
        this.arrTabFocus[0].gameObject.SetActive(true);
        this.arrTabFocus[1].gameObject.SetActive(false);
        this.uiShopPopup.transform.Find("frame").Find("FoodTabDetail").gameObject.SetActive(false);
        this.uiShopPopup.transform.Find("frame").Find("NormalTabDetail").gameObject.SetActive(true);
    }

    private void OnNormalTabClick() //normalTabFocus활성화 / foodTabForcus비활성화
    {
        Debug.Log("normal");
        for(int i=0; i<cellList.Count; i++)
        {
            this.cellList[i].gameObject.SetActive(true);
        }
        this.arrTabFocus[0].SetActive(true);
        this.arrTabFocus[1].SetActive(false);
        this.uiShopPopup.transform.Find("frame").Find("FoodTabDetail").gameObject.SetActive(false);
        this.uiShopPopup.transform.Find("frame").Find("NormalTabDetail").gameObject.SetActive(true);
    }
    private void OnFoodTabClick() //foodTabFocus활성화 / normalTabFocus비활성화
    {
        Debug.Log("food");
        for(int i=3; i<this.cellList.Count; i++)  
        {
            this.cellList[i].gameObject.SetActive(false);
        }
        this.arrTabFocus[0].SetActive(false);
        this.arrTabFocus[1].SetActive(true);
        this.uiShopPopup.transform.Find("frame").Find("FoodTabDetail").gameObject.SetActive(true);
        this.uiShopPopup.transform.Find("frame").Find("NormalTabDetail").gameObject.SetActive(false);
    }
}

*UIShopPopup

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class UIShopPopup : MonoBehaviour
{
    public Button dim; //dim
    public Button btnClose; //닫기(X) 버튼 -> 팝업 창 닫힘
    public Button btnSelect; //구매 버튼 ->구입한 장비아이템 이름 보여주기
    public Button btnCancel; //취소 -> 팝업 창 닫힘
    
    //datatable연동
    public Text txtNameDetail;
    public Text typeDetail;
    public Text gradeDetail;
    public Text statDetail;
    public Text priceDetail;
    public void Init() 
    {
        // 팝업 창 닫기, 구매("구매한 아이템 txt 보여주기"), 취소(팝업 창 닫기)
        this.dim.onClick.AddListener(() => { 
            this.gameObject.SetActive(false); 
        });
        this.btnClose.onClick.AddListener(() => {
            this.gameObject.SetActive(false);
        });
        this.btnSelect.onClick.AddListener(() => {
            this.gameObject.SetActive(false);
        });
        this.btnCancel.onClick.AddListener(() => {
            this.gameObject.SetActive(false);
        });
        
    }
}

 

*데이터 테이블에 들어가야할 변수는 내일 회의를 통해 좀더 디테일하게 조정이 필요 할것 같다.