Commit 3c1dfe10 authored by wanqing's avatar wanqing

修改场景切换逻辑

parent 03d4743f
...@@ -124,7 +124,7 @@ public class BattleCtrl : MonoBehaviour ...@@ -124,7 +124,7 @@ public class BattleCtrl : MonoBehaviour
public void OnBattleWin() public void OnBattleWin()
{ {
_IsEndBattle = true; _IsEndBattle = true;
battleUI.OnBattleWin(); //battleUI.OnBattleWin();
//int varCurTime = (int)levelManager.curLevel.bestTime; //int varCurTime = (int)levelManager.curLevel.bestTime;
//if(LocalRecord.HasKey(levelManager.CurLevelIndex.ToString())) //if(LocalRecord.HasKey(levelManager.CurLevelIndex.ToString()))
//{ //{
...@@ -152,7 +152,7 @@ public class BattleCtrl : MonoBehaviour ...@@ -152,7 +152,7 @@ public class BattleCtrl : MonoBehaviour
{ {
LocalRecord.SetIntRecord(levelManager.CurLevelIndex.ToString(), varCurStar); LocalRecord.SetIntRecord(levelManager.CurLevelIndex.ToString(), varCurStar);
} }
Invoke("DelayChangeToSelectScene", 3.0f); Invoke("DelayChangeToSelectScene", 2.0f);
} }
//延迟切换场景 //延迟切换场景
......
...@@ -68,6 +68,7 @@ public class BattleUI : MonoBehaviour ...@@ -68,6 +68,7 @@ public class BattleUI : MonoBehaviour
public Action onFieldNearBtn; public Action onFieldNearBtn;
public Action onClawMoveSpeedAddBtn; public Action onClawMoveSpeedAddBtn;
public Action onClawMoveSpeedDownBtn; public Action onClawMoveSpeedDownBtn;
public Action onNextBtn;
//private Text m_ShowOrHideMouseText;//显示或隐藏手指text //private Text m_ShowOrHideMouseText;//显示或隐藏手指text
private int m_mouseIndex = 0;//点击次数 private int m_mouseIndex = 0;//点击次数
...@@ -117,7 +118,7 @@ public class BattleUI : MonoBehaviour ...@@ -117,7 +118,7 @@ public class BattleUI : MonoBehaviour
private void Start() private void Start()
{ {
m_boomBtn.interactable = false; m_boomBtn.interactable = false;
BattleCtrl.instance.levelManager.selectLevel.onMoveFinish = StartFade; BattleCtrl.instance.levelManager.selectLevel.onMoveFinish = MoveFinish;
} }
void SetDragMode() void SetDragMode()
{ {
...@@ -145,7 +146,8 @@ public class BattleUI : MonoBehaviour ...@@ -145,7 +146,8 @@ public class BattleUI : MonoBehaviour
public void NextLevel() public void NextLevel()
{ {
m_successObj.SetActive(false); m_successObj.SetActive(false);
BattleCtrl.instance.levelManager.LoadNextLevel(); //BattleCtrl.instance.levelManager.LoadNextLevel();
onNextBtn?.Invoke();
} }
//选择关卡 //选择关卡
void SelectLevel() void SelectLevel()
...@@ -162,6 +164,11 @@ public class BattleUI : MonoBehaviour ...@@ -162,6 +164,11 @@ public class BattleUI : MonoBehaviour
m_startLogoObj.SetActive(false); m_startLogoObj.SetActive(false);
//SetBattleObjState(true); //SetBattleObjState(true);
//SettingBtnState(false); //SettingBtnState(false);
m_bSelectToMain = true;
m_bMainToSelect = false;
m_bfadeState = false;
m_startIndex++;
} }
//设置 //设置
void SettingBtn() void SettingBtn()
...@@ -229,7 +236,7 @@ public class BattleUI : MonoBehaviour ...@@ -229,7 +236,7 @@ public class BattleUI : MonoBehaviour
//胜利 //胜利
public void OnBattleWin() public void OnBattleWin()
{ {
Invoke("DelayWin", 1.0f); Invoke("DelayWin", 0.2f);
//string varKey = BattleCtrl.instance.levelManager.CurLevelIndex.ToString(); //string varKey = BattleCtrl.instance.levelManager.CurLevelIndex.ToString();
//if (LocalRecord.HasKey(varKey)) //if (LocalRecord.HasKey(varKey))
//{ //{
...@@ -617,12 +624,10 @@ public class BattleUI : MonoBehaviour ...@@ -617,12 +624,10 @@ public class BattleUI : MonoBehaviour
m_goodText.gameObject.SetActive(true); m_goodText.gameObject.SetActive(true);
} }
} }
void StartFade() void MoveFinish()
{ {
m_bSelectToMain = true; m_startBtn.gameObject.SetActive(true);
m_bMainToSelect = false; m_startLogoObj.SetActive(true);
m_bfadeState = false;
m_startIndex++;
} }
//从主场景换到选择关卡界面 //从主场景换到选择关卡界面
public void ChangeMainToSelectScene() public void ChangeMainToSelectScene()
...@@ -681,9 +686,6 @@ public class BattleUI : MonoBehaviour ...@@ -681,9 +686,6 @@ public class BattleUI : MonoBehaviour
{ {
m_bfadeState = true; m_bfadeState = true;
m_fadeAlpha = 1f; m_fadeAlpha = 1f;
m_startBtn.gameObject.SetActive(true);
m_startLogoObj.SetActive(true);
m_successObj.SetActive(false);
SetBattleObjState(false); SetBattleObjState(false);
SettingBtnState(true); SettingBtnState(true);
GlobalConfig.SetActiveFruitState(false); GlobalConfig.SetActiveFruitState(false);
...@@ -698,6 +700,7 @@ public class BattleUI : MonoBehaviour ...@@ -698,6 +700,7 @@ public class BattleUI : MonoBehaviour
{ {
m_fadeAlpha = 0.0f; m_fadeAlpha = 0.0f;
m_bMainToSelect = false; m_bMainToSelect = false;
OnBattleWin();
} }
} }
} }
......
...@@ -136,10 +136,6 @@ public class LevelManager : MonoBehaviour ...@@ -136,10 +136,6 @@ public class LevelManager : MonoBehaviour
{ {
m_selectLevel.BackToScene(); m_selectLevel.BackToScene();
} }
else
{
m_selectLevel.ShowEffect();
}
} }
//隐藏当前关卡 //隐藏当前关卡
public void HideCurLevel() public void HideCurLevel()
......
...@@ -22,6 +22,7 @@ public class SelectLevelCtrl : MonoBehaviour ...@@ -22,6 +22,7 @@ public class SelectLevelCtrl : MonoBehaviour
private string m_idle3 = "TK_idle3"; private string m_idle3 = "TK_idle3";
private string m_walk = "TK_walk1"; private string m_walk = "TK_walk1";
private Sequence m_sq;
public Action onMoveFinish; public Action onMoveFinish;
// Start is called before the first frame update // Start is called before the first frame update
...@@ -37,78 +38,62 @@ public class SelectLevelCtrl : MonoBehaviour ...@@ -37,78 +38,62 @@ public class SelectLevelCtrl : MonoBehaviour
m_girlStartPos = m_girlTrans.position; m_girlStartPos = m_girlTrans.position;
m_girlStartRotation = m_girlTrans.rotation; m_girlStartRotation = m_girlTrans.rotation;
BattleCtrl.instance.battleUI.onStartBtn += StartRotate; BattleCtrl.instance.battleUI.onNextBtn += NextStart;
} }
void StartRotate() void NextStart()
{ {
m_effectObj.SetActive(false); m_effectObj.SetActive(false);
if(BattleCtrl.instance.levelManager.curLevel)
{
if (BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelOneIndex) if (BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelOneIndex)
{
m_boyTrans.DORotateQuaternion(Quaternion.Euler(0, 90, 0), 0.5f).onComplete = delegate () {
StartMove();
};
}
else if (BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelTwoIndex)
{ {
m_girlTrans.DORotateQuaternion(Quaternion.Euler(0, 90, 0), 0.5f).onComplete = delegate () { m_girlTrans.DORotateQuaternion(Quaternion.Euler(0, 90, 0), 0.5f).onComplete = delegate () {
StartMove(); StartMove();
}; };
} }
} else if (BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelTwoIndex)
else
{ {
m_girlTrans.DORotateQuaternion(Quaternion.Euler(0, 90, 0), 0.5f).onComplete = delegate () { m_boyTrans.DORotateQuaternion(Quaternion.Euler(0, 90, 0), 0.5f).onComplete = delegate () {
StartMove(); StartMove();
}; };
} }
} }
void StartMove() void StartMove()
{ {
if (BattleCtrl.instance.levelManager.curLevel) m_girlAni.Play(m_walk);
{ m_boyAni.Play(m_walk);
if (BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelOneIndex) if (BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelOneIndex)
{ {
m_boyAni.Play(m_walk); m_sq = DOTween.Sequence();
m_boyTrans.DOMoveX(0.5f, 2.0f).onComplete = delegate () { m_sq.Append(m_girlTrans.DOMoveX(0.5f, 2.0f));
onMoveFinish?.Invoke(); m_sq.Join(m_boyTrans.DOMove(m_girlStartPos, 2.0f));
}; m_sq.AppendCallback(MoveFinish);
} }
else if (BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelTwoIndex) else if (BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelTwoIndex)
{ {
m_girlAni.Play(m_walk); m_sq = DOTween.Sequence();
m_girlTrans.DOMoveX(0.5f, 2.0f).onComplete = delegate () { m_sq.Append(m_boyTrans.DOMoveX(0.5f, 2.0f));
onMoveFinish?.Invoke(); m_sq.Join(m_girlTrans.DOMove(m_girlStartPos, 2.0f));
}; m_sq.AppendCallback(MoveFinish);
} }
} }
else //走完后
void MoveFinish()
{ {
m_girlAni.Play(m_walk); m_effectObj.SetActive(true);
m_girlTrans.DOMoveX(0.5f, 2.0f).onComplete = delegate () { if (BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelOneIndex)
onMoveFinish?.Invoke(); {
}; m_boyAni.Play(m_idle3);
}
} }
//显示特效 else if (BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelTwoIndex)
public void ShowEffect()
{ {
m_effectObj.SetActive(true); m_girlAni.Play(m_idle3);
}
onMoveFinish?.Invoke();
} }
//回到选择场景 //回到选择场景
public void BackToScene() public void BackToScene()
{ {
if(BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelOneIndex) if(BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelOneIndex)
{
m_boyTrans.position = m_girlStartPos;
m_boyTrans.rotation = m_girlStartRotation;
m_girlTrans.position = m_boyStartPos;
m_girlTrans.rotation = m_boyStartRotation;
m_boyAni.Play(m_idle3);
m_girlAni.Play(m_idle1);
}
else if(BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelTwoIndex)
{ {
m_boyTrans.position = m_boyStartPos; m_boyTrans.position = m_boyStartPos;
m_boyTrans.rotation = m_boyStartRotation; m_boyTrans.rotation = m_boyStartRotation;
...@@ -117,12 +102,22 @@ public class SelectLevelCtrl : MonoBehaviour ...@@ -117,12 +102,22 @@ public class SelectLevelCtrl : MonoBehaviour
m_boyAni.Play(m_idle1); m_boyAni.Play(m_idle1);
m_girlAni.Play(m_idle3); m_girlAni.Play(m_idle3);
} }
else if(BattleCtrl.instance.levelManager.CurLevelIndex == LevelEnum.levelTwoIndex)
{
m_boyTrans.position = m_girlStartPos;
m_boyTrans.rotation = m_girlStartRotation;
m_girlTrans.position = m_boyStartPos;
m_girlTrans.rotation = m_boyStartRotation;
m_boyAni.Play(m_idle3);
m_girlAni.Play(m_idle1);
}
} }
private void OnDestroy() private void OnDestroy()
{ {
if(BattleCtrl.instance.battleUI) if(BattleCtrl.instance.battleUI)
{ {
BattleCtrl.instance.battleUI.onStartBtn -= StartRotate; BattleCtrl.instance.battleUI.onNextBtn -= NextStart;
} }
m_sq.Kill();
} }
} }
...@@ -13746,7 +13746,7 @@ GameObject: ...@@ -13746,7 +13746,7 @@ GameObject:
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
m_IsActive: 0 m_IsActive: 1
--- !u!224 &6064464677757260073 --- !u!224 &6064464677757260073
RectTransform: RectTransform:
m_ObjectHideFlags: 0 m_ObjectHideFlags: 0
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment