107 lines
3.0 KiB
C#
107 lines
3.0 KiB
C#
using DG.Tweening;
|
|
using System.Collections;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class CameraManager : MonoBehaviour
|
|
{
|
|
public static CameraManager instance;
|
|
public Camera Camera;
|
|
|
|
/// <summary>
|
|
/// 所有的种子
|
|
/// </summary>
|
|
public GameObject[] seed_Obj;
|
|
public Transform[] StepTrans;
|
|
/// <summary>
|
|
/// 入水种子
|
|
/// </summary>
|
|
public GameObject Seed_Obj;
|
|
|
|
/// <summary>
|
|
/// 水面
|
|
/// </summary>
|
|
public GameObject water_Obj;
|
|
|
|
/// <summary>
|
|
/// 农药
|
|
/// </summary>
|
|
public Transform pesticide_Trans;
|
|
|
|
public Transform pesticideRot_Trans;
|
|
|
|
/// <summary>
|
|
/// 种子播放动画
|
|
/// </summary>
|
|
public Animator Seed_Ani;
|
|
|
|
/// <summary>
|
|
/// 种子生长动画
|
|
/// </summary>
|
|
public Animation water_Ani;
|
|
|
|
private void Awake()
|
|
{
|
|
instance = this;
|
|
}
|
|
|
|
private void Update()
|
|
{
|
|
if (Input.GetMouseButtonDown(0))
|
|
{
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
RaycastHit hit;
|
|
bool raycast = Physics.Raycast(ray, out hit);
|
|
if (raycast)
|
|
{
|
|
if (hit.collider.gameObject.tag.Equals("CompleteSeeds"))
|
|
{
|
|
Debug.Log("被点击物体的标签是" + hit.collider.gameObject.tag);
|
|
hit.collider.gameObject.SetActive(false);
|
|
|
|
bool allSeedsHidden = true;
|
|
for (int i = 0; i < seed_Obj.Length; i++)
|
|
{
|
|
if (seed_Obj[i].activeInHierarchy)
|
|
{
|
|
allSeedsHidden = false;
|
|
Debug.Log("还有种子没有点到");
|
|
break; // 只要有一个种子没隐藏,就退出循环
|
|
}
|
|
}
|
|
|
|
// 检查是否所有种子都被隐藏(放在循环外)
|
|
if (allSeedsHidden)
|
|
{
|
|
Debug.Log("所有种子都被隐藏");
|
|
Camera.fieldOfView = 60;
|
|
StartCoroutine(SeedIsFalse());
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
public IEnumerator SeedIsFalse()
|
|
{
|
|
Camera.transform.SetPositionAndRotation
|
|
(StepTrans[2].transform.position, StepTrans[1].transform.rotation);
|
|
yield return new WaitForSeconds(1f);
|
|
Seed_Obj.transform.DOMoveY(0, 1f);
|
|
yield return new WaitForSeconds(2.1f);
|
|
pesticide_Trans.transform.DORotate
|
|
(new Vector3(pesticideRot_Trans.rotation.x, pesticideRot_Trans.rotation.y, pesticideRot_Trans.rotation.z),1.5f);
|
|
yield return new WaitForSeconds(1.5f);
|
|
water_Obj.transform.DOMoveY(0.1f, 1.5f);
|
|
yield return new WaitForSeconds(2.5f);
|
|
UI_FadePanel.Instance.Init();
|
|
yield return new WaitForSeconds(9f);
|
|
UI_FadePanel.Instance.Next_Btn.gameObject.SetActive(true);
|
|
}
|
|
|
|
public IEnumerator SeedIE()
|
|
{
|
|
yield return new WaitForSeconds(1f);
|
|
}
|
|
}
|