You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
289 lines
7.9 KiB
289 lines
7.9 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DG.Tweening;
|
|
using System;
|
|
|
|
namespace DisComputer
|
|
{
|
|
|
|
/*
|
|
* @func 内存条
|
|
* @author lz
|
|
* @date 2020/06/01
|
|
* */
|
|
public class NeiCunTiaoAnimation : SpareAnimationBase
|
|
{
|
|
[Header("拆卸提示操作指引")]
|
|
public GameObject unLoadTipGo;
|
|
|
|
[Header("安装提示操作指引")]
|
|
public GameObject loadTipGo;
|
|
|
|
|
|
|
|
public Vector3 mainShowPos;
|
|
|
|
public Vector3 mainInitPos;
|
|
|
|
|
|
[Header("卡扣01")]
|
|
public GameObject buckle01Go;
|
|
|
|
public Vector3 openEuler;
|
|
|
|
public Vector3 closeEuler;
|
|
|
|
|
|
[Header("卡扣02")]
|
|
public GameObject buckle02Go;
|
|
|
|
public Vector3 openBuck02Euler;
|
|
|
|
public Vector3 closeBuck02Euler;
|
|
|
|
|
|
public GameObject lock01Go;
|
|
|
|
public GameObject lock02Go;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
isHit01 = false;
|
|
isHit02 = false;
|
|
}
|
|
|
|
|
|
private void Update()
|
|
{
|
|
if (isHit01)
|
|
{
|
|
if (Input.GetMouseButtonDown(0))
|
|
{
|
|
if(hit.collider)
|
|
{
|
|
hit.collider.gameObject.SetActive(false);
|
|
if(GameConfig.state == GameState.Unload)
|
|
{
|
|
buckle01Go.transform.DOLocalRotate(openEuler, 0.35f).SetEase(Ease.Linear);
|
|
}else
|
|
{
|
|
buckle01Go.transform.DOLocalRotate(closeEuler, 0.35f).SetEase(Ease.Linear);
|
|
}
|
|
|
|
isHit01 = false;
|
|
onclick--;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
if (isHit02) {
|
|
if (Input.GetMouseButtonDown(0))
|
|
{
|
|
if (hit.collider)
|
|
{
|
|
hit.collider.gameObject.SetActive(false);
|
|
if (GameConfig.state == GameState.Unload)
|
|
{
|
|
buckle02Go.transform.DOLocalRotate(openBuck02Euler, 0.35f).SetEase(Ease.Linear);
|
|
}
|
|
else
|
|
{
|
|
buckle02Go.transform.DOLocalRotate(closeBuck02Euler, 0.35f).SetEase(Ease.Linear);
|
|
}
|
|
|
|
onclick--;
|
|
isHit02 = false;
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
|
|
|
|
public override void SetUnloadState()
|
|
{
|
|
unLoadTipGo.SetActive(false);
|
|
loadTipGo.SetActive(false);
|
|
mainGo.SetActive(false);
|
|
buckle01Go.transform.localEulerAngles = openEuler;
|
|
buckle02Go.transform.localEulerAngles = openBuck02Euler;
|
|
mainGo.transform.localPosition = mainShowPos;
|
|
|
|
}
|
|
|
|
public override void SetLoadState()
|
|
{
|
|
unLoadTipGo.SetActive(false);
|
|
loadTipGo.SetActive(false);
|
|
mainGo.SetActive(true);
|
|
buckle01Go.transform.localEulerAngles = closeEuler;
|
|
buckle02Go.transform.localEulerAngles = closeBuck02Euler;
|
|
mainGo.transform.localPosition = mainInitPos;
|
|
}
|
|
|
|
|
|
public override bool IsCompareTag(object data)
|
|
{
|
|
|
|
if (GameConfig.state == GameState.Unload)
|
|
{
|
|
ToolType toolType = ToolType.Hand;
|
|
ToolItem item = (ToolItem)data;
|
|
if (item.toolType == toolType)
|
|
{
|
|
return true;
|
|
}
|
|
CoolPointTip("请使用合适的工具");
|
|
return false;
|
|
|
|
}
|
|
else
|
|
{
|
|
|
|
Grid grid = (Grid)data;
|
|
if (grid.type == _type)
|
|
{
|
|
return true;
|
|
}
|
|
CoolPointTip("请选择正确的零件");
|
|
return false;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
public override void OnLoadAct()
|
|
{
|
|
base.OnLoadAct();
|
|
StartCoroutine(LoadFocuse());
|
|
}
|
|
|
|
public override void OnUnLoadAct()
|
|
{
|
|
base.OnUnLoadAct();
|
|
StartCoroutine(UnloadFocuse());
|
|
|
|
}
|
|
|
|
//零件检测层
|
|
public LayerMask checkLayer;
|
|
private RaycastHit hit;
|
|
private bool isHit01 = false;
|
|
private bool isHit02 = false;
|
|
private int onclick = 2;
|
|
|
|
protected override IEnumerator LoadFocuse()
|
|
{
|
|
yield return StartCoroutine(ProgressFocuse());
|
|
loadTipGo.SetActive(true);
|
|
lock01Go.SetActive(true);
|
|
lock02Go.SetActive(true);
|
|
onclick = 2;
|
|
isHit01 = false;
|
|
isHit02 = false;
|
|
|
|
mainGo.SetActive(true);
|
|
mainGo.transform.DOLocalMove(mainInitPos, 0.35f).SetEase(Ease.Linear).OnComplete(() => {
|
|
});
|
|
|
|
while (true)
|
|
{
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
if (Physics.Raycast(ray, out hit, 50, checkLayer.value))
|
|
{
|
|
|
|
if (hit.collider.gameObject.name.Contains("lock01"))
|
|
{
|
|
|
|
isHit01 = true;
|
|
//Debug.LogFormat(">>>>>>>>>>>> hit go {0}", hit.collider.gameObject.tag);
|
|
|
|
}
|
|
if (hit.collider.gameObject.name.Contains("lock02"))
|
|
{
|
|
//Debug.LogFormat(">>>>>>>>>>>> hit go {0}", hit.collider.gameObject.tag);
|
|
isHit02 = true;
|
|
}
|
|
}
|
|
|
|
if (onclick == 0)
|
|
{
|
|
break;
|
|
}
|
|
yield return new WaitForEndOfFrame();
|
|
}
|
|
loadTipGo.SetActive(false);
|
|
|
|
yield return new WaitForSeconds(0.50f);
|
|
OnLoadFinishHandle?.Invoke();
|
|
LzFramework.UI.TTUIPage.ShowPage<SparePartsView>();
|
|
RewindCameraView();
|
|
}
|
|
|
|
protected override IEnumerator UnloadFocuse()
|
|
{
|
|
yield return StartCoroutine(ProgressFocuse());
|
|
unLoadTipGo.SetActive(true);
|
|
lock01Go.SetActive(true);
|
|
lock02Go.SetActive(true);
|
|
onclick = 2;
|
|
isHit01 = false;
|
|
isHit02 = false;
|
|
while (true)
|
|
{
|
|
|
|
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
|
|
if (Physics.Raycast(ray, out hit, 50, checkLayer.value))
|
|
{
|
|
|
|
if (hit.collider.gameObject.name.Contains("lock01"))
|
|
{
|
|
|
|
isHit01 = true;
|
|
//Debug.LogFormat(">>>>>>>>>>>> hit go {0}", hit.collider.gameObject.tag);
|
|
|
|
}
|
|
if (hit.collider.gameObject.name.Contains("lock02"))
|
|
{
|
|
//Debug.LogFormat(">>>>>>>>>>>> hit go {0}", hit.collider.gameObject.tag);
|
|
isHit02 = true;
|
|
}
|
|
}
|
|
|
|
if (onclick == 0)
|
|
{
|
|
break;
|
|
}
|
|
yield return new WaitForEndOfFrame();
|
|
}
|
|
|
|
yield return new WaitForSeconds(0.50f);
|
|
|
|
unLoadTipGo.SetActive(false);
|
|
mainGo.transform.DOLocalMove(mainShowPos, 0.35f).SetEase(Ease.Linear).OnComplete(() => {
|
|
|
|
CommonTool.WaitTimeAfterDo(this, .35f, () => {
|
|
OnUnLoadFinishHandle?.Invoke();
|
|
mainGo.SetActive(false);
|
|
RewindCameraView();
|
|
});
|
|
|
|
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|