521 lines
20 KiB
C#
521 lines
20 KiB
C#
using System.Collections;
|
|||
|
|
using System.Collections.Generic;
|
||
|
|
using Newtonsoft.Json;
|
||
|
|
using UnityEngine;
|
||
|
|
using DG.Tweening;
|
||
|
|
using LoveLegend;
|
||
|
|
|
||
|
|
using Unity.VisualScripting;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
|
||
|
|
public class level4 : MonoBehaviour
|
||
|
|
{
|
||
|
|
public GameObject feiliao;
|
||
|
|
public GameObject zhongzi;
|
||
|
|
public GameObject feiliaodai;
|
||
|
|
public GameObject zhongzidai;
|
||
|
|
public Text progress_text;
|
||
|
|
public Image progress_;
|
||
|
|
public Image end_point;
|
||
|
|
public GameObject sunlight;
|
||
|
|
public Camera cam;
|
||
|
|
private GameObject selected;
|
||
|
|
private Vector3 offset;
|
||
|
|
private int out_layers = 30;
|
||
|
|
public GameObject water_;
|
||
|
|
private float now_sunlight;
|
||
|
|
private float max_sunlight = 300;
|
||
|
|
public List<ItemState_4> _itemlist = new List<ItemState_4>();
|
||
|
|
public List<GameObject> sunlight_list = new List<GameObject>();
|
||
|
|
void Awake()
|
||
|
|
{
|
||
|
|
Camera orthoCamera = GameObject.Find("Main Camera").GetComponent<Camera>();
|
||
|
|
|
||
|
|
float size = (float)System.Math.Round(5.5f / ((float)Screen.width / Screen.height), 4);
|
||
|
|
// string type = SystemInfo.deviceModel.ToLower().Trim();
|
||
|
|
// // Debug.Log($"type==========={type}");
|
||
|
|
// if (type.Substring(0, 3) == "ipa")
|
||
|
|
// {//iPad机型
|
||
|
|
// size = 49.9f;
|
||
|
|
// }
|
||
|
|
Debug.Log(size + "////////////////");
|
||
|
|
orthoCamera.orthographicSize = size;
|
||
|
|
}
|
||
|
|
void Start()
|
||
|
|
{
|
||
|
|
for (int i = 0; i < 5; i++)
|
||
|
|
{
|
||
|
|
ItemState_4 _item = new ItemState_4()
|
||
|
|
{
|
||
|
|
_gameobject = GameObject.Find("item_" + i),
|
||
|
|
};
|
||
|
|
_itemlist.Add(_item);
|
||
|
|
}
|
||
|
|
_itemlist[0].plant_state = 1;
|
||
|
|
progress_text.text = now_sunlight + "/" + max_sunlight;
|
||
|
|
progress_.rectTransform.sizeDelta = new Vector2(0, 20);
|
||
|
|
}
|
||
|
|
private int stage_ = 0;
|
||
|
|
private float spawnTimer = 0f;
|
||
|
|
private float spawnInterval = 0.1f;
|
||
|
|
private GameObject Popup;
|
||
|
|
void Update()
|
||
|
|
{
|
||
|
|
// 鼠标按下时检测
|
||
|
|
if (Input.GetMouseButtonDown(0))
|
||
|
|
{
|
||
|
|
if (Popup == null) Popup = GameObject.Find("Popup");
|
||
|
|
if (Popup != null && Popup.transform.childCount != 0) return;
|
||
|
|
Vector2 mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
|
||
|
|
RaycastHit2D[] hits = Physics2D.RaycastAll(mousePos, Vector2.zero);
|
||
|
|
|
||
|
|
if (hits.Length > 0)
|
||
|
|
{
|
||
|
|
selected = GetTopSprite(hits);
|
||
|
|
if (selected != null)
|
||
|
|
{
|
||
|
|
|
||
|
|
if (selected.tag == "item_tag_0" || selected.tag == "item_tag_1")
|
||
|
|
{
|
||
|
|
selected.transform.DORotate(new Vector3(0, 0, 45), 0.2f).SetEase(Ease.OutQuad);
|
||
|
|
}
|
||
|
|
|
||
|
|
Vector3 pos = cam.ScreenToWorldPoint(Input.mousePosition);
|
||
|
|
offset = selected.transform.position - new Vector3(pos.x, pos.y, selected.transform.position.z);
|
||
|
|
selected.GetComponent<SpriteRenderer>().sortingOrder = 2;
|
||
|
|
//out_layers++;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if (Input.GetMouseButton(0) && selected != null)
|
||
|
|
{
|
||
|
|
Vector3 pos = cam.ScreenToWorldPoint(Input.mousePosition);
|
||
|
|
|
||
|
|
if (selected.tag == "bg")
|
||
|
|
{
|
||
|
|
float newX = pos.x + offset.x;
|
||
|
|
newX = Mathf.Clamp(newX, -5f, 5f);
|
||
|
|
|
||
|
|
selected.transform.position = new Vector3(
|
||
|
|
newX,
|
||
|
|
selected.transform.position.y,
|
||
|
|
selected.transform.position.z);
|
||
|
|
|
||
|
|
water_.SetActive(true);
|
||
|
|
if (stage_ == 0)
|
||
|
|
{
|
||
|
|
if ((selected.transform.position.x > -1) && (selected.transform.position.x < 1))
|
||
|
|
{
|
||
|
|
_itemlist[0].water_time += Time.deltaTime;
|
||
|
|
}
|
||
|
|
if (_itemlist[0].water_time >= 1 && _itemlist[0].plant_state < 5)
|
||
|
|
{
|
||
|
|
_itemlist[0]._gameobject.transform.GetChild(_itemlist[0].plant_state - 1).GetComponent<SpriteRenderer>().enabled = false;
|
||
|
|
_itemlist[0]._gameobject.transform.GetChild(_itemlist[0].plant_state).GetComponent<SpriteRenderer>().enabled = true;
|
||
|
|
_itemlist[0].plant_state++;
|
||
|
|
_itemlist[0].water_time = 0;
|
||
|
|
|
||
|
|
}
|
||
|
|
if (_itemlist[0].plant_state == 5 && !_itemlist[0].is_end)
|
||
|
|
{
|
||
|
|
_itemlist[0].is_end = true;
|
||
|
|
CrearSunlight(0);
|
||
|
|
Debug.Log("生产阳光");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (stage_ == 1)
|
||
|
|
{
|
||
|
|
if ((selected.transform.position.x > -3) && (selected.transform.position.x < -1) && (_itemlist[1].plant_state > 0))
|
||
|
|
{
|
||
|
|
_itemlist[1].water_time += Time.deltaTime;
|
||
|
|
}
|
||
|
|
if ((selected.transform.position.x > 1) && (selected.transform.position.x < 3) && (_itemlist[2].plant_state > 0))
|
||
|
|
{
|
||
|
|
_itemlist[2].water_time += Time.deltaTime;
|
||
|
|
}
|
||
|
|
for (int i = 1; i < 3; i++)
|
||
|
|
{
|
||
|
|
if (_itemlist[i].water_time >= 1 && _itemlist[i].plant_state < 5)
|
||
|
|
{
|
||
|
|
|
||
|
|
if (!_itemlist[i].use_feiliao && _itemlist[i].plant_state == 4)
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
_itemlist[i]._gameobject.transform.GetChild(_itemlist[i].plant_state - 1).GetComponent<SpriteRenderer>().enabled = false;
|
||
|
|
_itemlist[i]._gameobject.transform.GetChild(_itemlist[i].plant_state).GetComponent<SpriteRenderer>().enabled = true;
|
||
|
|
_itemlist[i].plant_state++;
|
||
|
|
_itemlist[i].water_time = 0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (_itemlist[i].plant_state == 5 && !_itemlist[i].is_end)
|
||
|
|
{
|
||
|
|
_itemlist[i].is_end = true;
|
||
|
|
// _itemlist[i]._gameobject.SetActive(false);
|
||
|
|
// Debug.Log("生产阳光");
|
||
|
|
CrearSunlight(i);
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if (stage_ == 2)
|
||
|
|
{
|
||
|
|
if ((selected.transform.position.x > -3) && (selected.transform.position.x < -1) && (_itemlist[3].plant_state > 0))
|
||
|
|
{
|
||
|
|
_itemlist[3].water_time += Time.deltaTime;
|
||
|
|
}
|
||
|
|
if ((selected.transform.position.x > 1) && (selected.transform.position.x < 3) && (_itemlist[4].plant_state > 0))
|
||
|
|
{
|
||
|
|
_itemlist[4].water_time += Time.deltaTime;
|
||
|
|
}
|
||
|
|
for (int i = 3; i < 5; i++)
|
||
|
|
{
|
||
|
|
if (_itemlist[i].water_time >= 1 && _itemlist[i].plant_state < 5)
|
||
|
|
{
|
||
|
|
|
||
|
|
if (!_itemlist[i].use_feiliao && _itemlist[i].plant_state == 4)
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
_itemlist[i]._gameobject.transform.GetChild(_itemlist[i].plant_state - 1).GetComponent<SpriteRenderer>().enabled = false;
|
||
|
|
_itemlist[i]._gameobject.transform.GetChild(_itemlist[i].plant_state).GetComponent<SpriteRenderer>().enabled = true;
|
||
|
|
_itemlist[i].plant_state++;
|
||
|
|
_itemlist[i].water_time = 0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (_itemlist[i].plant_state == 5 && !_itemlist[i].is_end)
|
||
|
|
{
|
||
|
|
_itemlist[i].is_end = true;
|
||
|
|
// _itemlist[i]._gameobject.SetActive(false);
|
||
|
|
// // stage_ = 1;
|
||
|
|
// Debug.Log("生产阳光");
|
||
|
|
CrearSunlight(i);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
selected.transform.position = new Vector3(pos.x, pos.y, selected.transform.position.z) + offset;
|
||
|
|
|
||
|
|
// Y > 2 时开始定时生成
|
||
|
|
if (selected.transform.position.y > 0f)
|
||
|
|
{
|
||
|
|
spawnTimer += Time.deltaTime;
|
||
|
|
|
||
|
|
if (spawnTimer >= spawnInterval)
|
||
|
|
{
|
||
|
|
spawnTimer = 0f;
|
||
|
|
if (selected.tag == "item_tag_0") SpawnDropObject(0);
|
||
|
|
else if (selected.tag == "item_tag_1") SpawnDropObject(1);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
spawnTimer = 0f;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
spawnTimer = 0f;
|
||
|
|
}
|
||
|
|
if (Input.GetMouseButton(0))
|
||
|
|
{
|
||
|
|
if (Popup == null) Popup = GameObject.Find("Popup");
|
||
|
|
if (Popup != null && Popup.transform.childCount != 0) return;
|
||
|
|
Vector2 mousePos = cam.ScreenToWorldPoint(Input.mousePosition);
|
||
|
|
RaycastHit2D[] hits = Physics2D.RaycastAll(mousePos, Vector2.zero);
|
||
|
|
|
||
|
|
foreach (var hit in hits)
|
||
|
|
{
|
||
|
|
if (hit.collider.CompareTag("item_tag_3"))
|
||
|
|
{
|
||
|
|
Transform obj = hit.collider.transform;
|
||
|
|
|
||
|
|
// 1. UI 转屏幕坐标(传入你的 UI 所属的 Canvas 的相机)
|
||
|
|
Vector3 screenPos = RectTransformUtility.WorldToScreenPoint(cam, end_point.rectTransform.position);
|
||
|
|
|
||
|
|
// 2. 屏幕坐标转场景世界坐标,z 要给一个合适的深度
|
||
|
|
Vector3 targetPos = cam.ScreenToWorldPoint(new Vector3(screenPos.x, screenPos.y, cam.nearClipPlane + 5f));
|
||
|
|
|
||
|
|
// 3. DOTween Sequence:移动 + 缩放,同时执行
|
||
|
|
DG.Tweening.Sequence seq = DOTween.Sequence();
|
||
|
|
seq.Join(obj.DOMove(targetPos, 0.7f).SetEase(Ease.OutCubic));
|
||
|
|
seq.Join(obj.DOScale(Vector3.one * 0.2f, 0.7f).SetEase(Ease.OutCubic));
|
||
|
|
|
||
|
|
// 4. 动画完成后销毁物体
|
||
|
|
seq.OnComplete(() =>
|
||
|
|
{
|
||
|
|
sunlight_list.Remove(obj.gameObject);
|
||
|
|
now_sunlight += 10;
|
||
|
|
|
||
|
|
progress_text.text = now_sunlight + "/" + max_sunlight;
|
||
|
|
progress_.rectTransform.sizeDelta = new Vector2((now_sunlight / max_sunlight) * 100, 20);
|
||
|
|
Destroy(obj.gameObject);
|
||
|
|
if (sunlight_list.Count <= 0)
|
||
|
|
{
|
||
|
|
if (stage_ == 0)
|
||
|
|
{
|
||
|
|
// _itemlist[0]._gameobject.SetActive(false);
|
||
|
|
SpriteRenderer sr = _itemlist[0]._gameobject.transform.GetChild(4).GetComponent<SpriteRenderer>();
|
||
|
|
sr.DOFade(0f, 1f); // 1秒内透明度变为0
|
||
|
|
|
||
|
|
stage_ = 1;
|
||
|
|
}
|
||
|
|
else if (stage_ == 1)
|
||
|
|
{
|
||
|
|
if (_itemlist[1].is_end && _itemlist[2].is_end)
|
||
|
|
{
|
||
|
|
// _itemlist[1]._gameobject.SetActive(false);
|
||
|
|
// _itemlist[2]._gameobject.SetActive(false);
|
||
|
|
SpriteRenderer sr = _itemlist[1]._gameobject.transform.GetChild(4).GetComponent<SpriteRenderer>();
|
||
|
|
sr.DOFade(0f, 1f); // 1秒内透明度变为0
|
||
|
|
SpriteRenderer sr1 = _itemlist[2]._gameobject.transform.GetChild(4).GetComponent<SpriteRenderer>();
|
||
|
|
sr1.DOFade(0f, 1f); // 1秒内透明度变为0
|
||
|
|
stage_ = 2;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
else if (stage_ == 2)
|
||
|
|
{
|
||
|
|
if (_itemlist[3].is_end && _itemlist[4].is_end)
|
||
|
|
{
|
||
|
|
Debug.Log("所有物体都已吸附完成!");
|
||
|
|
GameDispatcher.Instance.Dispatch(GameMsg.GameSuccess);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
});
|
||
|
|
|
||
|
|
hit.collider.enabled = false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
|
||
|
|
// 鼠标松开
|
||
|
|
if (Input.GetMouseButtonUp(0) && selected != null)
|
||
|
|
{
|
||
|
|
if (selected.tag == "bg")
|
||
|
|
{
|
||
|
|
water_.SetActive(false);
|
||
|
|
selected.transform.DOMove(new Vector3(-5, -11.44f, 0), 0.4f).SetEase(Ease.Linear);
|
||
|
|
|
||
|
|
}
|
||
|
|
if (selected.tag == "item_tag_0")
|
||
|
|
{
|
||
|
|
|
||
|
|
selected.transform.DORotate(Vector3.zero, 0.2f).SetEase(Ease.OutQuad);
|
||
|
|
selected.transform.DOMove(new Vector3(2.64f, -4.73f, 0), 0.3f).SetEase(Ease.Linear);
|
||
|
|
selected.GetComponent<SpriteRenderer>().sortingOrder = 1;
|
||
|
|
}
|
||
|
|
if (selected.tag == "item_tag_1")
|
||
|
|
{
|
||
|
|
|
||
|
|
selected.transform.DORotate(Vector3.zero, 0.2f).SetEase(Ease.OutQuad);
|
||
|
|
selected.transform.DOMove(new Vector3(3.91f, -3.88f, 0), 0.3f).SetEase(Ease.Linear);
|
||
|
|
selected.GetComponent<SpriteRenderer>().sortingOrder = 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
selected = null;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
void SpawnDropObject(int type)
|
||
|
|
{
|
||
|
|
|
||
|
|
GameObject go = null;
|
||
|
|
if (type == 0)
|
||
|
|
{
|
||
|
|
go = Instantiate(
|
||
|
|
zhongzi,
|
||
|
|
new Vector3(selected.transform.position.x - 1f, selected.transform.position.y, 0),
|
||
|
|
Quaternion.identity);
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
go = Instantiate(
|
||
|
|
feiliao,
|
||
|
|
new Vector3(selected.transform.position.x - 1f, selected.transform.position.y, 0),
|
||
|
|
Quaternion.identity);
|
||
|
|
}
|
||
|
|
|
||
|
|
go.transform.DOMoveY(-1f, 8f)
|
||
|
|
.SetSpeedBased()
|
||
|
|
.SetEase(Ease.Linear)
|
||
|
|
.OnComplete(() =>
|
||
|
|
{
|
||
|
|
if (stage_ == 1 && type == 0)
|
||
|
|
{
|
||
|
|
if (_itemlist[1].plant_state == 0)
|
||
|
|
{
|
||
|
|
if (go.transform.position.x > -3 && go.transform.position.x < -1)
|
||
|
|
{
|
||
|
|
_itemlist[1].plant_state = 1;
|
||
|
|
_itemlist[1]._gameobject.transform.GetChild(0).GetComponent<SpriteRenderer>().enabled = true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if (_itemlist[2].plant_state == 0)
|
||
|
|
{
|
||
|
|
if (go.transform.position.x > 1 && go.transform.position.x < 3)
|
||
|
|
{
|
||
|
|
_itemlist[2].plant_state = 1;
|
||
|
|
_itemlist[2]._gameobject.transform.GetChild(0).GetComponent<SpriteRenderer>().enabled = true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if (stage_ == 2 && type == 0)
|
||
|
|
{
|
||
|
|
if (_itemlist[3].plant_state == 0)
|
||
|
|
{
|
||
|
|
if (go.transform.position.x > -3 && go.transform.position.x < -1)
|
||
|
|
{
|
||
|
|
_itemlist[3].plant_state = 1;
|
||
|
|
_itemlist[3]._gameobject.transform.GetChild(0).GetComponent<SpriteRenderer>().enabled = true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if (_itemlist[4].plant_state == 0)
|
||
|
|
{
|
||
|
|
if (go.transform.position.x > 1 && go.transform.position.x < 3)
|
||
|
|
{
|
||
|
|
_itemlist[4].plant_state = 1;
|
||
|
|
_itemlist[4]._gameobject.transform.GetChild(0).GetComponent<SpriteRenderer>().enabled = true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
if (stage_ == 1 && type == 1)
|
||
|
|
{
|
||
|
|
|
||
|
|
if (go.transform.position.x > -3 && go.transform.position.x < -1)
|
||
|
|
{
|
||
|
|
CheckFeiliao(1);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (go.transform.position.x > 1 && go.transform.position.x < 3)
|
||
|
|
{
|
||
|
|
CheckFeiliao(2);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
if (stage_ == 2 && type == 1)
|
||
|
|
{
|
||
|
|
|
||
|
|
if (go.transform.position.x > -3 && go.transform.position.x < -1)
|
||
|
|
{
|
||
|
|
CheckFeiliao(3);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (go.transform.position.x > 1 && go.transform.position.x < 3)
|
||
|
|
{
|
||
|
|
CheckFeiliao(4);
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
Destroy(go);
|
||
|
|
});
|
||
|
|
}
|
||
|
|
void CheckFeiliao(int index)
|
||
|
|
{
|
||
|
|
if (!_itemlist[index].use_feiliao)
|
||
|
|
{
|
||
|
|
_itemlist[index].use_feiliao = true;
|
||
|
|
if (_itemlist[index].water_time >= 1 && _itemlist[index].plant_state < 5)
|
||
|
|
{
|
||
|
|
if (!_itemlist[index].use_feiliao && _itemlist[index].plant_state == 4)
|
||
|
|
{
|
||
|
|
|
||
|
|
}
|
||
|
|
else
|
||
|
|
{
|
||
|
|
_itemlist[index]._gameobject.transform.GetChild(_itemlist[index].plant_state - 1).GetComponent<SpriteRenderer>().enabled = false;
|
||
|
|
_itemlist[index]._gameobject.transform.GetChild(_itemlist[index].plant_state).GetComponent<SpriteRenderer>().enabled = true;
|
||
|
|
_itemlist[index].plant_state++;
|
||
|
|
_itemlist[index].water_time = 0;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
if (_itemlist[index].plant_state == 5 && !_itemlist[index].is_end)
|
||
|
|
{
|
||
|
|
_itemlist[index].is_end = true;
|
||
|
|
// _itemlist[index]._gameobject.SetActive(false);
|
||
|
|
// // stage_ = 1;
|
||
|
|
// Debug.Log("生产阳光");
|
||
|
|
CrearSunlight(index);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
void CrearSunlight(int index)
|
||
|
|
{
|
||
|
|
for (int j = 0; j < 6; j++)
|
||
|
|
{
|
||
|
|
// 在指定位置生成
|
||
|
|
GameObject obj = Instantiate(sunlight, _itemlist[index]._gameobject.transform.position, Quaternion.identity);
|
||
|
|
|
||
|
|
// 获取刚体
|
||
|
|
Rigidbody2D rb = obj.GetComponent<Rigidbody2D>();
|
||
|
|
if (rb != null)
|
||
|
|
{
|
||
|
|
// 随机方向
|
||
|
|
Vector2 randomDir = Random.insideUnitCircle.normalized;
|
||
|
|
// 随机力度
|
||
|
|
float randomForce = Random.Range(2, 3);
|
||
|
|
// 添加力(瞬间冲量)
|
||
|
|
rb.AddForce(randomDir * randomForce, ForceMode2D.Impulse);
|
||
|
|
}
|
||
|
|
sunlight_list.Add(obj);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
private GameObject GetTopSprite(RaycastHit2D[] hits)
|
||
|
|
{
|
||
|
|
GameObject top = null;
|
||
|
|
int topLayer = int.MinValue;
|
||
|
|
int topOrder = int.MinValue;
|
||
|
|
|
||
|
|
foreach (var hit in hits)
|
||
|
|
{
|
||
|
|
SpriteRenderer sr = hit.collider.GetComponent<SpriteRenderer>();
|
||
|
|
if (sr != null)
|
||
|
|
{
|
||
|
|
int layerID = SortingLayer.GetLayerValueFromID(sr.sortingLayerID);
|
||
|
|
int order = sr.sortingOrder;
|
||
|
|
|
||
|
|
if (layerID > topLayer || (layerID == topLayer && order > topOrder))
|
||
|
|
{
|
||
|
|
top = sr.gameObject;
|
||
|
|
topLayer = layerID;
|
||
|
|
topOrder = order;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
return top;
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
public class ItemState_4
|
||
|
|
{
|
||
|
|
public float water_time = 0f;
|
||
|
|
public int plant_state = 0;
|
||
|
|
public bool use_feiliao = false;
|
||
|
|
public GameObject _gameobject;
|
||
|
|
public bool is_end;
|
||
|
|
}
|
||
|
|
|