using System.Collections; using System.Collections.Generic; using UnityEngine; using DG.Tweening; using System; namespace DisComputer { /* * @func 硬盘动画 * */ public class YingPanAnimation : SpareAnimationBase { [Header("动画路径")] public List pointConfigs; public GameObject yingPanGo; //螺丝 public Transform luosiTran; //显示距离 public Vector3 showDis; // Start is called before the first frame update void Start() { } public override void SetLoadState() { yingPanGo.SetActive(true); luosiTran.gameObject.SetActive(true); yingPanGo.transform.localPosition = pointConfigs[0].point; luosiTran.localPosition = Vector3.zero; } public override void SetUnloadState() { yingPanGo.SetActive(false); luosiTran.gameObject.SetActive(false); yingPanGo.transform.localPosition = pointConfigs[2].point; luosiTran.localPosition = showDis; } public override bool IsCompareTag(object data) { if (GameConfig.state == GameState.Unload) { ToolType 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(Focuse()); } public override void OnLoadAct() { base.OnLoadAct(); yingPanGo.SetActive(true); Sequence sequence = DOTween.Sequence(); sequence.Append(yingPanGo.transform.DOLocalMove(pointConfigs[2].point, 0.4f).SetEase(Ease.Linear)) .Append(yingPanGo.transform.DOLocalMove(pointConfigs[1].point, 0.4f).SetEase(Ease.Linear)) .Append(yingPanGo.transform.DOLocalMove(pointConfigs[0].point, 0.4f).SetEase(Ease.Linear)).OnComplete(() => { luosiTran.gameObject.SetActive(true); luosiTran.DOLocalMove(Vector3.zero, 0.35f).SetEase(Ease.Linear).SetDelay(0.3f).OnComplete(() => { OnLoadFinishHandle?.Invoke(); }); }); } IEnumerator Focuse() { yield return StartCoroutine(ProgressFocuse()); BoltDriver driver = luosiTran.GetComponent(); luosiTran.gameObject.SetActive(true); yield return StartCoroutine(driver.RotationLouSi()) ; luosiTran.DOLocalMove(showDis, 0.35f).SetEase(Ease.Linear).OnComplete(() => { Sequence sequence = DOTween.Sequence(); sequence.Append(yingPanGo.transform.DOLocalMove(pointConfigs[0].point, 0.4f).SetEase(Ease.Linear)).SetDelay(0.3f) .Append(yingPanGo.transform.DOLocalMove(pointConfigs[1].point, 0.4f).SetEase(Ease.Linear)).SetDelay(0.2f) .Append(yingPanGo.transform.DOLocalMove(pointConfigs[2].point, 0.4f).SetEase(Ease.Linear)).OnComplete(() => { CommonTool.WaitTimeAfterDo(this, .35f, () => { OnUnLoadFinishHandle?.Invoke(); yingPanGo.SetActive(false); luosiTran.gameObject.SetActive(false); RewindCameraView(); }); }); }); } } }