95 lines
2.3 KiB
C#
Raw Normal View History

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using Sirenix.OdinInspector;
using UnityEngine.InputSystem;
/// <summary>
/// 控制转场黑块
/// </summary>
public class Blcak : MonoBehaviour
{
public enum State{, , , }
/// <summary>
/// 黑块的目前运行状态
/// </summary>
[Header("状态")][ReadOnly]
public State state;
public enum Type{, }
[Header("类型")]
public Type tyepe;
private RectTransform rectTransform;
void Start(){
Init();
}
private void Init(){
rectTransform = GetComponent<RectTransform>();
state = State.;
}
public void OnCall(Type type){
StartCoroutine(Perform(type));
}
private IEnumerator Perform(Type type){
//修改状态
state = State.;
//执行“入”的Tween动画
if(type == Type.){
Tweener tweener = rectTransform.DOLocalMoveX(
0,
1f
).OnStepComplete(
() => {
state = State.;
}
);
}
if(type == Type.){
Tweener tweener = rectTransform.DOLocalMoveY(
0,
1f
).OnStepComplete(
() => {
state = State.;
}
);
}
yield return new WaitForSeconds(2f);
//执行“出”的Tween动画
state = State.;
if(type == Type.){
Tweener tweener = rectTransform.DOLocalMoveX(
-3358,
1f
).OnStepComplete(
() =>{
//恢复黑块位置
rectTransform.localPosition = new Vector3(
3320,-6,0
);
}
);
}
if(type == Type.){
Tweener tweener = rectTransform.DOLocalMoveY(
2723,
1f
).OnStepComplete(
() =>{
//恢复黑块位置
rectTransform.localPosition = new Vector3(
0,-2722,0
);
}
);
}
}
}