2021-04-14 15:02:33 +08:00
|
|
|
|
using Assets.Scripts;
|
|
|
|
|
|
using Assets.Scripts.Apis.Models;
|
|
|
|
|
|
using Assets.Scripts.UI.UIEffect;
|
|
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections;
|
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
using UnityEngine.EventSystems;
|
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
|
|
2021-04-19 14:36:08 +08:00
|
|
|
|
public class Item : PFUIPanel //, IPointerClickHandler
|
2021-04-14 15:02:33 +08:00
|
|
|
|
{
|
|
|
|
|
|
private Text text;
|
|
|
|
|
|
|
|
|
|
|
|
private string Text
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return text.text;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
text.text = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private Text km;
|
|
|
|
|
|
private string Distance
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return km.text;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
km.text = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
private Text count;
|
|
|
|
|
|
private string Count
|
|
|
|
|
|
{
|
|
|
|
|
|
get
|
|
|
|
|
|
{
|
|
|
|
|
|
return count.text;
|
|
|
|
|
|
}
|
|
|
|
|
|
set
|
|
|
|
|
|
{
|
|
|
|
|
|
count.text = value;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
public Action onClick;
|
2021-04-19 14:36:08 +08:00
|
|
|
|
private Transform hot;
|
|
|
|
|
|
protected override void Awake()
|
2021-04-14 15:02:33 +08:00
|
|
|
|
{
|
|
|
|
|
|
text = this.transform.Find("name").GetComponent<Text>();
|
|
|
|
|
|
km = this.transform.Find("km").GetComponent<Text>();
|
|
|
|
|
|
count = this.transform.Find("count").GetComponent<Text>();
|
|
|
|
|
|
|
|
|
|
|
|
Material material = null;
|
|
|
|
|
|
if (material == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
material = Instantiate(Resources.Load<Material>("UI/Material/RoundedCornersTextureMaterial"));
|
|
|
|
|
|
}
|
|
|
|
|
|
var rect = ((RectTransform)transform).rect;
|
|
|
|
|
|
material.SetVector(Shader.PropertyToID("_WidthHeightRadius"), new Vector4(rect.width, rect.height, rect.height * 0.5f, 0));
|
|
|
|
|
|
this.GetComponent<Image>().material = material;
|
2021-04-19 14:36:08 +08:00
|
|
|
|
|
|
|
|
|
|
hot = this.transform.Find("Hot");
|
|
|
|
|
|
SetRounded(hot, 17);
|
|
|
|
|
|
|
|
|
|
|
|
UIManager.AddEvent(this.gameObject, EventTriggerType.PointerClick, OnPointerClick);
|
2021-04-14 15:02:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Selected(bool value)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (value)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.GetComponent<UIGradient>().enabled = true;
|
|
|
|
|
|
this.GetComponent<UIGradient>().color1 = Utils.HexToColor("FF7485");
|
|
|
|
|
|
this.GetComponent<UIGradient>().color2 = Utils.HexToColor("F93086");
|
|
|
|
|
|
|
|
|
|
|
|
this.GetComponent<Image>().color = Color.white;
|
2021-04-19 14:36:08 +08:00
|
|
|
|
km.color = Color.white;
|
|
|
|
|
|
count.color = Color.white;
|
|
|
|
|
|
this.transform.Find("DistanceIcon").GetComponent<Image>().color = Color.white;
|
|
|
|
|
|
this.transform.Find("BikeIcon").GetComponent<Image>().color = Color.white;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
hot.GetComponent<UIGradient>().color1 = Color.white;
|
|
|
|
|
|
hot.GetComponent<UIGradient>().color2 = Color.white;
|
|
|
|
|
|
hot.Find("PFUIText").GetComponent<Text>().color = Utils.HexToColor("F93086");
|
2021-04-14 15:02:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
this.GetComponent<UIGradient>().enabled = false;
|
|
|
|
|
|
this.GetComponent<Image>().color = Utils.HexToColor("353543");
|
2021-04-19 14:36:08 +08:00
|
|
|
|
km.color = Utils.HexToColor("5C5C6E");
|
|
|
|
|
|
count.color = Utils.HexToColor("F93086");
|
|
|
|
|
|
this.transform.Find("DistanceIcon").GetComponent<Image>().color = Utils.HexToColor("5C5C6E");
|
|
|
|
|
|
this.transform.Find("BikeIcon").GetComponent<Image>().color = Utils.HexToColor("F93086");
|
|
|
|
|
|
|
|
|
|
|
|
hot.GetComponent<UIGradient>().color1 = Utils.HexToColor("FF7485");
|
|
|
|
|
|
hot.GetComponent<UIGradient>().color2 = Utils.HexToColor("F93086");
|
|
|
|
|
|
hot.Find("PFUIText").GetComponent<Text>().color = Color.white;
|
|
|
|
|
|
|
2021-04-14 15:02:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void SetModel(NearRouteModel model)
|
|
|
|
|
|
{
|
|
|
|
|
|
this.Text = model.Name;
|
2021-04-19 14:36:08 +08:00
|
|
|
|
this.Distance = model.Distance.ToString("0.0") + "KM";
|
2021-04-14 15:02:33 +08:00
|
|
|
|
this.Count = model.TheHeat.ToString();
|
2021-04-23 09:22:12 +08:00
|
|
|
|
hot.gameObject.SetActive(model.IsFire);
|
2021-04-14 15:02:33 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
2021-04-19 14:36:08 +08:00
|
|
|
|
protected override void Start()
|
2021-04-14 15:02:33 +08:00
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Update is called once per frame
|
|
|
|
|
|
void Update()
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-04-19 14:36:08 +08:00
|
|
|
|
public void OnPointerClick(BaseEventData eventData)
|
2021-04-14 15:02:33 +08:00
|
|
|
|
{
|
|
|
|
|
|
if(onClick != null)
|
|
|
|
|
|
{
|
|
|
|
|
|
onClick();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|