using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;
using Sirenix.OdinInspector;
using UnityEngine.InputSystem;
///
/// 控制转场黑块
///
public class Blcak : MonoBehaviour
{
public enum State{停, 入, 全, 出}
///
/// 黑块的目前运行状态
///
[Header("状态")][ReadOnly]
public State state;
public enum Type{水平, 竖直}
[Header("类型")]
public Type tyepe;
private RectTransform rectTransform;
void Start(){
Init();
}
private void Init(){
rectTransform = GetComponent();
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
);
}
);
}
}
}