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.

168 lines
4.3 KiB

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
namespace DisComputer
{
/*
* @func 主板动画控制
* @author lz
* @date 2020/06/01
* */
public class ZhuBanAnimation : SpareAnimationBase
{
[Header("展示位置")]
public Vector3 showPos;
[Header("初始位置")]
public Vector3 initPos;
public GameObject zhubanGo;
//螺丝
public Transform luosiTran;
//显示距离
public Vector3 showDis;
//机箱后主板插口
public GameObject zhuban_jiXiang_go;
// Start is called before the first frame update
void Start()
{
}
public override void SetUnloadState()
{
zhubanGo.SetActive(false);
luosiTran.gameObject.SetActive(false);
zhuban_jiXiang_go.SetActive(false);
zhubanGo.transform.localPosition = showPos;
luosiTran.localPosition = showDis;
}
public override void SetLoadState()
{
zhubanGo.SetActive(true);
luosiTran.gameObject.SetActive(true);
zhuban_jiXiang_go.gameObject.SetActive(true);
zhubanGo.transform.localPosition = initPos;
luosiTran.localPosition = Vector3.zero;
}
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(UnloadFocuse());
}
public override void OnLoadAct()
{
base.OnLoadAct();
StartCoroutine(LoadFocuse());
}
protected override IEnumerator LoadFocuse()
{
yield return StartCoroutine(ProgressFocuse());
zhubanGo.SetActive(true);
zhubanGo.transform.DOLocalMove(initPos, 0.5f).SetEase(Ease.Linear).OnComplete(() =>
{
luosiTran.gameObject.SetActive(true);
luosiTran.DOLocalMove(Vector3.zero, 0.5f).SetEase(Ease.OutQuart).SetDelay(0.3f).OnComplete(() =>
{
});
});
yield return new WaitForSeconds(1.80f);
BoltDriver driver = luosiTran.GetComponent<BoltDriver>();
yield return StartCoroutine(driver.RotationLouSi());
yield return new WaitForSeconds(0.50f);
zhuban_jiXiang_go.SetActive(true);
OnLoadFinishHandle?.Invoke();
LzFramework.UI.TTUIPage.ShowPage<SparePartsView>();
RewindCameraView();
}
protected override IEnumerator UnloadFocuse()
{
yield return StartCoroutine(ProgressFocuse());
luosiTran.gameObject.SetActive(true);
BoltDriver driver = luosiTran.GetComponent<BoltDriver>();
yield return StartCoroutine(driver.RotationLouSi());
luosiTran.DOLocalMove(showDis, 0.5f).SetEase(Ease.Linear).OnComplete(() => {
zhuban_jiXiang_go.SetActive(false);
zhubanGo.transform.DOLocalMove(showPos, 0.55f).SetDelay(0.3f).SetEase(Ease.Linear).OnComplete(() =>
{
CommonTool.WaitTimeAfterDo(this, .35f, () => {
OnUnLoadFinishHandle?.Invoke();
zhubanGo.SetActive(false);
luosiTran.gameObject.SetActive(false);
RewindCameraView();
});
});
});
}
}
}