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

public class gameSceneAreaGroupHandler : gridView
{
    public float itemWidth = 110f;
    public float itemHeight = 110f;
    public float itemInterval = 5f;
    private bool isInit = false;
    private float scale = 1;
    public float ItemWidth
    {
        get { return ItemWidth; }
    }
    public float ItemHeight
    {
        get { return itemHeight; }
    }
    public float ItemInterval
    {
        get { return itemInterval; }
    }
    
    // Start is called before the first frame update
    void Start()
    {
        if (isInit == true) return;
        isInit = true;
        RectTransform rectTransform = transform.parent.GetComponent<RectTransform>();
        var nowTransform = GetComponent<RectTransform>();
        utilsTools.DisplaySize = new Vector2(rectTransform.rect.width, rectTransform.rect.height);
        scale = (rectTransform.rect.height / 1920f); //1920/rectTransform.rect.height;
        if((itemHeight * scale) > (nowTransform.rect.height * 0.8))
        {
            scale = (nowTransform.rect.height * 0.8f) / itemHeight;
        }
    }

    // Update is called once per frame
    void Update(){
    }
    public void setDataNoGrid(int cout, gradViewBack gradView)
    {
        if (isInit == false)
        {
            Start();
        }
        Debug.Log(string.Format("width = {0},height={1},interval={2}", itemWidth, itemHeight, itemInterval));
        
        setDataNoGrid(cout, itemWidth * scale, itemHeight * scale, itemInterval * scale,(GameObject obj,int idx,ListViewBackTypeEnum lvb) =>
        {
            var aa1 = obj.GetComponent<RectTransform>();
            aa1.localScale = new Vector3(scale,scale);
            gradView(obj,idx,lvb);
        }, false,null,20);
    }
}
