Files
taptap2024_GJ_chidouren/Assets/Scripts/Views/SuccessPanel.cs
2024-10-27 21:16:31 +08:00

209 lines
6.6 KiB
C#

using System;
using System.Collections.Generic;
using Coffee.UIEffects;
using Cysharp.Threading.Tasks;
using Framework.Audio;
using Framework.Timer;
using Framework.UI;
using Game;
using Game.Component;
using Game.EventDefine;
using UnityEngine;
using UnityEngine.UI;
using IcecreamView;
using MintAnimation.Core;
using AudioType = Framework.Audio.AudioType;
namespace Views{
public class SuccessPanel : IcecreamView.IC_AbstractModule
{
public UIDissolve[] TopFragments;
public UIDissolve[] LeftFragments;
public UIDissolve[] RightFragments;
public GameObject redPoint;
public GameObject greenPoint;
public GameObject bluePoint;
public GameObject lastFragment;
public ObjectShake Shake;
public Button nextBtn;
public override async void OnOpenView(IC_ViewData parameters)
{
MapContent.Instance.PlayerEntity.gameObject.SetActive (false);
this.nextBtn.gameObject.SetActive (false);
var index = parameters.GetValue<int> ();
this.lastFragment.SetActive (false);
this.redPoint.SetActive (false);
this.greenPoint.SetActive (false);
this.bluePoint.SetActive (false);
foreach (var topFragment in this.TopFragments)
{
topFragment.effectFactor = 1;
}
foreach (var leftFragment in this.LeftFragments)
{
leftFragment.effectFactor = 1;
}
foreach (var rightFragment in this.RightFragments)
{
rightFragment.effectFactor = 1;
}
UpdateAnim (index);
}
public override void OnCloseView()
{
}
public override void OnInitView ()
{
this.nextBtn.onClick.AddListener (() =>
{
if (RoomManager.Instance.PartIndex < 3)
{
UIManager.Instance.OpenLoading (() =>
{
this.ViewConnector.CloseView ();
{
Destroy (MapContent.Instance.ScenePart.gameObject);
MapContent.Instance.ScenePart = null;
RoomManager.Instance.PartIndex++;
GameEventDefine.ChangeGameFsm.SendMessage (GameState.StartGame);
}
});
}
else
{
}
});
}
// #if UNITY_EDITOR
// private bool tempLock;
// private async void Update ()
// {
// if (this.tempLock)
// {
// return;
// }
//
// if (Input.GetKeyDown (KeyCode.A))
// {
// this.tempLock = true;
// UpdateAnim (1);
// await UniTask.Delay (5000);
// this.tempLock = false;
// }
// if (Input.GetKeyDown (KeyCode.S))
// {
// this.tempLock = true;
// UpdateAnim (2);
// await UniTask.Delay (5000);
// this.tempLock = false;
// }
// if (Input.GetKeyDown (KeyCode.D))
// {
// this.tempLock = true;
// UpdateAnim (3);
// await UniTask.Delay (5000);
// this.tempLock = false;
// }
// }
// #endif
public async void UpdateAnim (int index)
{
lastFragment.SetActive (false);
foreach (var topFragment in this.TopFragments)
{
topFragment.effectFactor = index > 1 ? 0 : 1;
}
foreach (var leftFragment in this.LeftFragments)
{
leftFragment.effectFactor = index > 2 ? 0 : 1;
}
foreach (var rightFragment in this.RightFragments)
{
rightFragment.effectFactor = index > 3 ? 0 : 1;
}
this.redPoint.SetActive (index > 1);
this.greenPoint.SetActive (index > 2);
this.bluePoint.SetActive (index > 3);
UIDissolve[] effects = index switch
{
1 => this.TopFragments,
2 => this.LeftFragments,
3 => this.RightFragments,
_ => null
};
GameObject point = index switch
{
1 => this.redPoint,
2 => this.greenPoint,
3 => this.bluePoint,
_ => null
};
await UniTask.Delay (500);
await AnimOpen (effects , point);
if (index >= 3)
{
this.lastFragment.SetActive (true);
Shake.ShakeFor (0.25f , 0.75f);
CameraImpulseUtils.Instance.UniformImpulseCamera (0.5f , 4);
GameManager.Instance.Vibrator (VibratorScale.Normal);
ToBossCG ();
return;
}
this.nextBtn.gameObject.SetActive (true);
}
private void ToBossCG ()
{
this.ViewConnector.CloseView ();
AudioManager.Instance.StopPlayers (AudioType.BGM , 1f);
Destroy (MapContent.Instance.ScenePart.gameObject);
MapContent.Instance.ScenePart = null;
RoomManager.Instance._BossSceneDirector.stopped += director =>
{
UIManager.Instance.OpenView (UIPanel.EndAboutPanel);
};
//播放结尾gc动画
RoomManager.Instance._BossSceneDirector.Play();
UIManager.Instance.OpenView (UIPanel.BossTouchPanel);
}
private async UniTask AnimOpen (UIDissolve[] effects , GameObject point)
{
var taskTracker = GameUpdateMgr.Instance.CreateTask ();
GameUpdateMgr.Instance.CreateTimer (1.25f , taskTracker.ListenerAction , progress =>
{
var f = MintEaseAction.InQuart (0 , 1 ,progress);
foreach (var uiEffect in effects)
{
uiEffect.effectFactor = 1 - f;
}
});
await taskTracker.Task;
Shake.ShakeFor (0.15f , 0.35f);
GameManager.Instance.Vibrator (VibratorScale.Small);
CameraImpulseUtils.Instance.UniformImpulseCamera (0.5f , 2);
point.SetActive (true);
point.transform.GetChild (0).gameObject.SetActive (true);
await UniTask.Delay (2000);
}
}
}