using Assets.Cyp.Common;
using Assets.Scripts.Apis.Models;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class MyMap 
{
    public string name { get; set; }
    public int rank { get; set; }
    public string image { get; set; }
}
public class MapScript : MonoBehaviour
{
    // Start is called before the first frame update
    //[SerializeField] Text text;
    //[SerializeField] GameObject panel;
    //[SerializeField] RawImage rawImage;
    void Start()
    {
    }

    // Update is called once per frame
    void Update()
    {
        
    }
    public void Initial(MapRoute myMap)
    {
        gameObject.GetComponent<Button>().onClick.AddListener(()=> 
        {
            UIManager.ShowMapDetailPanel(myMap.Id);
            //SceneManager.LoadScene("4-Demo", LoadSceneMode.Additive);
        });
        transform.Find("Name").GetComponent<Text>().text = myMap.Name;
        Utils.DisplayImage(StartCoroutine, transform.Find("MapTitleImg").GetComponent<RawImage>(), myMap.CoverImage);
        var props = transform.Find("Props");
        props.Find("DistanceText").GetComponent<Text>().text = $"{myMap.Distance.ToString("#0.00")}KM";
        props.Find("EleText").GetComponent<Text>().text = $"{(myMap.TotalClimb ?? 0.0).ToString("#0.00")}M";
        props.Find("SlopeText").GetComponent<Text>().text = $"{myMap.AverageGrade.ToString("#0.00")}%";
    }
}
