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.
253 lines
7.0 KiB
253 lines
7.0 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using DG.Tweening;
|
|
using System;
|
|
|
|
namespace DisComputer
|
|
{
|
|
/// <summary>
|
|
/// 光驱动画
|
|
/// </summary>
|
|
public class GuangQuAnimation : SpareAnimationBase
|
|
{
|
|
|
|
[Header("动画路径")]
|
|
public List<AnimationPointConfig> pointConfigs;
|
|
|
|
|
|
|
|
//螺丝
|
|
public Transform luosiTran;
|
|
|
|
//显示距离
|
|
public Vector3 showDis;
|
|
|
|
[Header("机箱光驱盖")]
|
|
public Transform jxGaiTran;
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
|
|
}
|
|
|
|
public override void SetLoadState()
|
|
{
|
|
mainGo.SetActive(true);
|
|
|
|
if (luosiTran != null)
|
|
{
|
|
luosiTran.gameObject.SetActive(true);
|
|
luosiTran.localPosition = Vector3.zero;
|
|
}
|
|
|
|
|
|
mainGo.transform.localPosition = pointConfigs[0].point;
|
|
|
|
}
|
|
|
|
public override void SetUnloadState()
|
|
{
|
|
mainGo.SetActive(false);
|
|
|
|
mainGo.transform.localPosition = pointConfigs[2].point;
|
|
|
|
if (luosiTran != null)
|
|
{
|
|
luosiTran.gameObject.SetActive(false);
|
|
luosiTran.localPosition = showDis;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public override bool IsCompareTag(object data)
|
|
{
|
|
|
|
if (GameConfig.state == GameState.Unload)
|
|
{
|
|
ToolType toolType = ToolType.Hand;
|
|
if (luosiTran != null)
|
|
{
|
|
toolType = ToolType.BoltDriver;
|
|
}
|
|
|
|
|
|
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 OnUnLoadAct()
|
|
{
|
|
base.OnUnLoadAct();
|
|
StartCoroutine(UnloadFocuse());
|
|
}
|
|
|
|
|
|
public override void OnLoadAct()
|
|
{
|
|
base.OnLoadAct();
|
|
StartCoroutine(LoadFocuse());
|
|
}
|
|
|
|
protected override IEnumerator UnloadFocuse()
|
|
{
|
|
|
|
if (luosiTran != null)
|
|
{
|
|
|
|
|
|
BoltDriver driver = luosiTran.GetComponent<BoltDriver>();
|
|
luosiTran.gameObject.SetActive(true);
|
|
yield return StartCoroutine(driver.RotationLouSi());
|
|
|
|
|
|
yield return StartCoroutine(JiXiangGaiAni(0));
|
|
|
|
|
|
luosiTran.DOLocalMove(showDis, 0.35f).SetEase(Ease.Linear).OnComplete(() => {
|
|
Sequence sequence = DOTween.Sequence();
|
|
sequence.Append(mainGo.transform.DOLocalMove(pointConfigs[0].point, 0.4f).SetEase(Ease.Linear)).SetDelay(0.3f)
|
|
.Append(mainGo.transform.DOLocalMove(pointConfigs[1].point, 0.4f).SetEase(Ease.Linear)).SetDelay(0.2f)
|
|
.Append(mainGo.transform.DOLocalMove(pointConfigs[2].point, 0.4f).SetEase(Ease.Linear)).OnComplete(() =>
|
|
{
|
|
StartCoroutine(JiXiangGaiAni(1,()=>
|
|
{
|
|
CommonTool.WaitTimeAfterDo(this, .35f, () => {
|
|
OnUnLoadFinishHandle?.Invoke();
|
|
mainGo.SetActive(false);
|
|
luosiTran.gameObject.SetActive(false);
|
|
RewindCameraView();
|
|
});
|
|
}));
|
|
|
|
|
|
});
|
|
|
|
});
|
|
}
|
|
else
|
|
{
|
|
|
|
yield return StartCoroutine(JiXiangGaiAni(0));
|
|
|
|
Sequence sequence = DOTween.Sequence();
|
|
sequence.Append(mainGo.transform.DOLocalMove(pointConfigs[0].point, 0.4f).SetEase(Ease.Linear)).SetDelay(0.3f)
|
|
.Append(mainGo.transform.DOLocalMove(pointConfigs[1].point, 0.4f).SetEase(Ease.Linear)).SetDelay(0.2f)
|
|
.Append(mainGo.transform.DOLocalMove(pointConfigs[2].point, 0.4f).SetEase(Ease.Linear)).OnComplete(() =>
|
|
{
|
|
CommonTool.WaitTimeAfterDo(this, .35f, () => {
|
|
OnUnLoadFinishHandle?.Invoke();
|
|
mainGo.SetActive(false);
|
|
|
|
RewindCameraView();
|
|
});
|
|
|
|
});
|
|
}
|
|
|
|
}
|
|
|
|
protected override IEnumerator LoadFocuse()
|
|
{
|
|
|
|
yield return StartCoroutine(JiXiangGaiAni(0));
|
|
|
|
mainGo.SetActive(true);
|
|
Sequence sequence = DOTween.Sequence();
|
|
sequence.Append(mainGo.transform.DOLocalMove(pointConfigs[2].point, 0.4f).SetEase(Ease.Linear))
|
|
.Append(mainGo.transform.DOLocalMove(pointConfigs[1].point, 0.4f).SetEase(Ease.Linear))
|
|
.Append(mainGo.transform.DOLocalMove(pointConfigs[0].point, 0.4f).SetEase(Ease.Linear)).OnComplete(() =>
|
|
{
|
|
|
|
if (luosiTran != null)
|
|
{
|
|
luosiTran.gameObject.SetActive(true);
|
|
luosiTran.DOLocalMove(Vector3.zero, 0.35f).SetEase(Ease.Linear).SetDelay(0.3f).OnComplete(() =>
|
|
{
|
|
|
|
});
|
|
}
|
|
|
|
});
|
|
|
|
yield return new WaitForSeconds(1.8f);
|
|
|
|
yield return StartCoroutine(JiXiangGaiAni(1));
|
|
|
|
if (luosiTran != null)
|
|
{
|
|
BoltDriver driver = luosiTran.GetComponent<BoltDriver>();
|
|
luosiTran.gameObject.SetActive(true);
|
|
yield return StartCoroutine(driver.RotationLouSi());
|
|
}
|
|
|
|
OnLoadFinishHandle?.Invoke();
|
|
LzFramework.UI.TTUIPage.ShowPage<SparePartsView>();
|
|
RewindCameraView();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
/// 机箱盖动画
|
|
/// </summary>
|
|
/// <param name="dir">0向上1向下</param>
|
|
/// <returns></returns>
|
|
public IEnumerator JiXiangGaiAni(int dir,Action finish = null)
|
|
{
|
|
yield return new WaitForEndOfFrame();
|
|
if (jxGaiTran != null)
|
|
{
|
|
if(dir == 0)
|
|
{
|
|
jxGaiTran.DOLocalMoveY(0.24f, 0.75f).SetEase(Ease.Linear) ;
|
|
yield return new WaitForSeconds(1.0f);
|
|
}
|
|
else
|
|
{
|
|
jxGaiTran.DOLocalMoveY(0.0f, 0.75f).SetEase(Ease.Linear);
|
|
yield return new WaitForSeconds(1.0f);
|
|
}
|
|
|
|
finish?.Invoke();
|
|
}else
|
|
{
|
|
finish?.Invoke();
|
|
yield break;
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
}
|
|
|