备份CatanBuilding瘦身独立工程
This commit is contained in:
246
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeBox.cs
Normal file
246
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeBox.cs
Normal file
@@ -0,0 +1,246 @@
|
||||
using System;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Castle.Core.Internal;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 挂在脚本,方便额外的处理
|
||||
/// </summary>
|
||||
|
||||
public enum CBoxState
|
||||
{
|
||||
Locked = 0,
|
||||
UnLocking = 1, // 解锁中
|
||||
UnLocked = 2, // 已解锁
|
||||
Attacking = 3, // 袭击中
|
||||
Broken = 4 // 破碎
|
||||
}
|
||||
|
||||
|
||||
public class ChallengeBox : MonoBehaviour
|
||||
{
|
||||
[Header("Timeline配置")]
|
||||
public PlayableDirector AppearTimeline;//出现表现timeline
|
||||
public PlayableDirector BreakTimeline;//销毁表现timeline
|
||||
|
||||
[Header("头像运动参数")]
|
||||
public float AppearJumpDelay = 4f;//播放出现表现timeline同时,延迟多久播放头像动画
|
||||
|
||||
[Header("被破坏的箱子")]
|
||||
private ChallengeBox box;
|
||||
|
||||
[Header("箱子破碎,被鳄鱼袭击特效")]
|
||||
[SerializeField]
|
||||
private ParticleSystem psBoxBroken;
|
||||
|
||||
// 断开藤曼,同时播放吗
|
||||
[Header("断开藤曼")]
|
||||
[SerializeField]
|
||||
private Animation aniKnife;
|
||||
[SerializeField]
|
||||
private ParticleSystem psKnife;
|
||||
|
||||
// 藤曼退开,可以跳跃
|
||||
[Header("藤曼退开,箱子可供站立")]
|
||||
[SerializeField]
|
||||
private Animation aniBoxOn;
|
||||
private float _speed = 1.0f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (psBoxBroken)
|
||||
{
|
||||
psBoxBroken.Stop();
|
||||
}
|
||||
|
||||
if (psKnife)
|
||||
{
|
||||
psKnife.Stop();
|
||||
}
|
||||
|
||||
if (aniBoxOn)
|
||||
{
|
||||
aniBoxOn.Stop();
|
||||
}
|
||||
|
||||
if (aniKnife)
|
||||
{
|
||||
aniKnife.Stop();
|
||||
// aniKnife.gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
// if (challengeKiller)
|
||||
// {
|
||||
// challengeKiller.OnIdle();
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
// AppearTimeline.initialTime = 0;
|
||||
// AppearTimeline.Evaluate();
|
||||
// // AppearTimeline.playOnAwake();
|
||||
// IdleTimeline.initialTime = 0;
|
||||
// IdleTimeline.Evaluate();
|
||||
// BreakTimeline.initialTime = 0;
|
||||
// BreakTimeline.Evaluate();
|
||||
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public void Log(object t)
|
||||
{
|
||||
// Debug.Log("");
|
||||
}
|
||||
|
||||
public float GetSpeed()
|
||||
{
|
||||
return _speed;
|
||||
}
|
||||
|
||||
public float SpeedUpSeconds(float seconds)
|
||||
{
|
||||
return _speed * seconds;
|
||||
}
|
||||
|
||||
public void UpdateTimeController(ChallengeSetAnimationEvent e)
|
||||
{
|
||||
_speed = e.speed;
|
||||
// _timeForUnlocking = e.timeForUnlocking;
|
||||
// _timeForUnlockingEnd = e.timeForUnLockingEnd;
|
||||
// _timeForAttackStart = e.timeForAttackStart;
|
||||
// _timeForAttacking1 = e.timeForAttacking_1;
|
||||
// _timeForAttacking2 = e.timeForAttacking_2;
|
||||
// _timeForAttackEnd = e.timeForAttackEnd;
|
||||
// _timeForAttackEndWait = e.timeForAttackEndWait;
|
||||
}
|
||||
public void SnapToEnd(Animation anim, string clipName = null)
|
||||
{
|
||||
if (!anim) return;
|
||||
if (clipName == null)
|
||||
{
|
||||
clipName = anim.clip?.name;
|
||||
}
|
||||
|
||||
if (clipName == null)
|
||||
return;
|
||||
|
||||
if (anim[clipName] == null)
|
||||
{
|
||||
Log($"动画片段 {clipName} 不存在");
|
||||
return;
|
||||
}
|
||||
|
||||
// 方法1:直接设置时间并采样
|
||||
anim[clipName].time = anim[clipName].length;
|
||||
anim.Play(clipName);
|
||||
anim.Sample();
|
||||
anim.Stop(clipName);
|
||||
|
||||
}
|
||||
|
||||
public void SnapToStart(Animation anim)
|
||||
{
|
||||
if (!anim || !anim.clip ) return;
|
||||
var clipName = anim.clip.name;
|
||||
if (anim[clipName] == null)
|
||||
{
|
||||
Log($"动画片段 {clipName} 不存在");
|
||||
return;
|
||||
}
|
||||
// var speed = anim[clipName].speed;
|
||||
anim.Play(clipName);
|
||||
anim[clipName].time = 0f;
|
||||
anim.Sample();
|
||||
// anim[clipName].speed = 0f;
|
||||
anim.Stop(clipName);
|
||||
// anim[clipName].time = speed;
|
||||
|
||||
}
|
||||
//
|
||||
private async Task OnUnLocking()
|
||||
{
|
||||
Log("OnUnlocking");
|
||||
// aniKnife.gameObject.SetActive(true);
|
||||
// var knifeName = (from AnimationState state in aniKnife select state.name).FirstOrDefault();
|
||||
// aniKnife.Play(knifeName);
|
||||
// // 注意时间是自己调的,有时间最好协助回调中
|
||||
// await Awaiters.Seconds(SpeedUpSeconds(_timeForUnlocking));
|
||||
// aniBoxOn.Play();
|
||||
// await Awaiters.Seconds(SpeedUpSeconds(_timeForUnlockingEnd));
|
||||
|
||||
// aniKnife.gameObject.SetActive(true);
|
||||
AppearTimeline.initialTime = 0;
|
||||
AppearTimeline.Play();
|
||||
// AppearTimeline.playableGraph.GetRootPlayable(0).SetSpeed(2.0f);
|
||||
await Awaiters.Seconds(SpeedUpSeconds(AppearJumpDelay));
|
||||
}
|
||||
|
||||
private async Task OnAttacking()
|
||||
{
|
||||
Log("OnAttacking");
|
||||
BreakTimeline.initialTime = 0;
|
||||
BreakTimeline?.Play();
|
||||
}
|
||||
|
||||
public void OnLocked()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
|
||||
AppearTimeline.initialTime = 0;
|
||||
AppearTimeline.Evaluate();
|
||||
AppearTimeline.Stop();
|
||||
|
||||
}
|
||||
private void OnUnlocked()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
|
||||
AppearTimeline.initialTime = AppearTimeline.duration;
|
||||
AppearTimeline.Evaluate();
|
||||
AppearTimeline.Stop();
|
||||
|
||||
}
|
||||
private void OnBroken()
|
||||
{
|
||||
Log("OnBroken");
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
///////
|
||||
public async Task UpdateState(CBoxState state)
|
||||
{
|
||||
Log($"UpdateState({state})");
|
||||
switch (state)
|
||||
{
|
||||
case CBoxState.UnLocked:
|
||||
OnUnlocked();
|
||||
break;
|
||||
case CBoxState.Broken:
|
||||
OnBroken();
|
||||
break;
|
||||
case CBoxState.Locked:
|
||||
OnLocked();
|
||||
break;
|
||||
case CBoxState.UnLocking:
|
||||
await OnUnLocking();
|
||||
break;
|
||||
case CBoxState.Attacking:
|
||||
await OnAttacking();
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException(nameof(state), state, null);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: fc1140f992414538bad245ce04d3fbb6
|
||||
timeCreated: 1754313414
|
||||
61
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeKiller.cs
Normal file
61
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeKiller.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using PlayFab.Internal;
|
||||
using UnityEngine;
|
||||
|
||||
/// <summary>
|
||||
/// 挂在到鳄鱼或者其他东西身上
|
||||
/// </summary>
|
||||
///
|
||||
public class ChallengeKiller : MonoBehaviour
|
||||
{
|
||||
|
||||
[Header("下沉上浮动画")]
|
||||
[SerializeField]
|
||||
private Animation aniOnOrOff;
|
||||
[SerializeField]
|
||||
private string startActionName;
|
||||
[SerializeField]
|
||||
private string endActionName;
|
||||
|
||||
|
||||
[Header("Eye眨眼动画")]
|
||||
[SerializeField] private Animation aniEye;
|
||||
//
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
Log("Awake");
|
||||
}
|
||||
|
||||
public async Task OnAttackingStart(float actionTime = 0.3f)
|
||||
{
|
||||
if (aniOnOrOff)
|
||||
{
|
||||
aniOnOrOff.Play(startActionName);
|
||||
}
|
||||
await Awaiters.Seconds(actionTime);
|
||||
}
|
||||
|
||||
public async Task OnAttackingEnd(float actionTime = 0.3f)
|
||||
{
|
||||
if (aniOnOrOff)
|
||||
{
|
||||
aniOnOrOff.Play(endActionName);
|
||||
}
|
||||
await Awaiters.Seconds(actionTime);
|
||||
}
|
||||
public void OnIdle()
|
||||
{
|
||||
if (aniEye)
|
||||
{
|
||||
aniEye.Play();
|
||||
}
|
||||
}
|
||||
|
||||
private void Log(object t)
|
||||
{
|
||||
Debug.Log($"Killer -> {t}");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c85ccfc62ebe40bfac5102be7962f23b
|
||||
timeCreated: 1754313533
|
||||
103
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeMatchScene.cs
Normal file
103
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeMatchScene.cs
Normal file
@@ -0,0 +1,103 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Playables;
|
||||
using UniRx;
|
||||
|
||||
|
||||
// 不要删,下个可直接拿来用
|
||||
public class ChallengeMatchPlayEvent
|
||||
{
|
||||
public int step;//当前步骤减一
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
public class ChallengeMatchPlayGMEvent
|
||||
{
|
||||
public int step;//当前步骤减一
|
||||
}
|
||||
|
||||
#endif
|
||||
public class ChallengeMatchScene : MonoBehaviour
|
||||
{
|
||||
public PlayableDirector playableDirector;
|
||||
double _targetTime;
|
||||
bool _isPlaying;
|
||||
protected CompositeDisposable disposables = new CompositeDisposable();
|
||||
private void Start()
|
||||
{
|
||||
playableDirector.played += OnTimelinePlayed;
|
||||
playableDirector.paused += OnTimelinePaused;
|
||||
playableDirector.stopped += OnTimelineStopped;
|
||||
}
|
||||
void OnEnable()
|
||||
{
|
||||
_isPlaying = false;
|
||||
GContext.OnEvent<ChallengeMatchPlayEvent>().Subscribe(e => { OnPlay(e.step); }).AddTo(disposables);
|
||||
#if UNITY_EDITOR
|
||||
GContext.OnEvent<ChallengeMatchPlayGMEvent>().Subscribe(e => { OnGMPlay(e.step); }).AddTo(disposables);
|
||||
#endif
|
||||
|
||||
|
||||
// FishingChallengeCenter FCC = GContext.container.Resolve<FishingChallengeCenter>();
|
||||
var fishingChallengeManager = GContext.container.Resolve<FishingChallengeManager>();
|
||||
int step = fishingChallengeManager.fishingChallengeData.step - 1;
|
||||
if (step < 0)
|
||||
{
|
||||
step = 0;
|
||||
}
|
||||
playableDirector.initialTime = step * 1.5f;
|
||||
playableDirector.Evaluate();
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
void OnGMPlay(int step)
|
||||
{
|
||||
step = step - 1;
|
||||
if (step < 0)
|
||||
{
|
||||
step = 0;
|
||||
}
|
||||
playableDirector.Stop();
|
||||
playableDirector.initialTime = step * 1.5f;
|
||||
playableDirector.Evaluate();
|
||||
}
|
||||
#endif
|
||||
void OnPlay(int step)
|
||||
{
|
||||
playableDirector.Play();
|
||||
_targetTime = step * 1.5f;
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (_isPlaying)
|
||||
{
|
||||
if (playableDirector.time >= _targetTime)
|
||||
{
|
||||
playableDirector.Pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
void OnTimelinePlayed(PlayableDirector director)
|
||||
{
|
||||
_isPlaying = true;
|
||||
}
|
||||
|
||||
void OnTimelinePaused(PlayableDirector director)
|
||||
{
|
||||
_isPlaying = false;
|
||||
}
|
||||
|
||||
void OnTimelineStopped(PlayableDirector director)
|
||||
{
|
||||
_isPlaying = false;
|
||||
}
|
||||
void OnDisable()
|
||||
{
|
||||
disposables?.Dispose();
|
||||
disposables = null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 11854fd50c96b0a43b84db5b0473aea7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
247
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeMatchScene1.cs
Normal file
247
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeMatchScene1.cs
Normal file
@@ -0,0 +1,247 @@
|
||||
using System.Threading.Tasks;
|
||||
using asap.core;
|
||||
using Cinemachine;
|
||||
using UniRx;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
public class ChallengeCleanStageEvent
|
||||
{
|
||||
public int stage;
|
||||
public readonly TaskCompletionSource<bool> Tcs = new ();
|
||||
}
|
||||
|
||||
public class ChallengeBrokeStepEvent
|
||||
{
|
||||
public int step;
|
||||
public float dealyTime;
|
||||
public readonly TaskCompletionSource<bool> Tcs = new();
|
||||
}
|
||||
|
||||
public class ChallengeInitStepEvent
|
||||
{
|
||||
public int step;
|
||||
}
|
||||
|
||||
public class ChallengeSetAnimationEvent
|
||||
{
|
||||
public float speed;
|
||||
public float timeForUnlocking;
|
||||
public float timeForUnLockingEnd;
|
||||
public float timeForAttacking_1;
|
||||
public float timeForAttacking_2;
|
||||
public float timeForAttackStart;
|
||||
public float timeForAttackEnd;
|
||||
public float timeForAttackEndWait;
|
||||
}
|
||||
|
||||
|
||||
public class ChallengeMatchScene1 : MonoBehaviour
|
||||
{
|
||||
|
||||
// private Transform _challengeStatic;
|
||||
// private Transform _challengeDynamic;
|
||||
private Transform _camera;
|
||||
// 想法是以后绑定一个 大奖 + 台子区域的点 到 当前的场景Node,或者直接坐在 场景Prefab 中,看看是否可实现
|
||||
// private Transform _rewardNode;
|
||||
// 管卡容器
|
||||
[SerializeField] private ChallengeBox[] boxNodeContainer;
|
||||
|
||||
|
||||
[Header("设计宽高以及分辨率")]
|
||||
|
||||
|
||||
|
||||
[SerializeField] private float designMinWidth = 1080f;
|
||||
[SerializeField] private float designMinHeight = 2160f;
|
||||
[SerializeField] private float designMaxWidth = 1080f;
|
||||
[SerializeField] private float designMaxHeight = 1920f;
|
||||
[SerializeField] private float designOrthoSize = 5f;
|
||||
|
||||
//
|
||||
private int _lastWidth;
|
||||
private int _lastHeight;
|
||||
|
||||
|
||||
// 修改平行和投影视图
|
||||
private CinemachineVirtualCamera _vCam;
|
||||
// 数据管理
|
||||
private FishingChallengeManager _fishingChallengeManager;
|
||||
//
|
||||
private CompositeDisposable _disposables = new();
|
||||
|
||||
// 当前 的Step
|
||||
private int _curStep;
|
||||
// private int _curScore;
|
||||
|
||||
public float CalcOrthographicSize()
|
||||
{
|
||||
// if (_camera == null) return;
|
||||
// 计算设计宽高比和当前宽高比
|
||||
float designMinAspect = designMinWidth/designMinHeight;
|
||||
float designMaxAspect = designMaxWidth/designMaxHeight;
|
||||
float currentAspect = Screen.width/(float)Screen.height ;
|
||||
|
||||
currentAspect = Mathf.Clamp(currentAspect, designMinAspect, designMaxAspect);
|
||||
var size = designOrthoSize * designMaxAspect/currentAspect;
|
||||
|
||||
Log($"CalcOrthographicSize ->{size}");
|
||||
return size;
|
||||
}
|
||||
|
||||
private void ApplyCameraScale()
|
||||
{
|
||||
if (Screen.width == _lastWidth && Screen.height == _lastHeight) return;
|
||||
_vCam.m_Lens.OrthographicSize = CalcOrthographicSize();
|
||||
_lastWidth = Screen.width;
|
||||
_lastHeight = Screen.height;
|
||||
}
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
// Log("Awake -> ");
|
||||
// _challengeStatic = transform.Find("challenge_static");
|
||||
// _challengeDynamic = transform.Find("challenge_dynamic");
|
||||
_camera = transform.Find("CameraRoot/Camera");
|
||||
// _rewardNode = transform.Find("RewardNode");
|
||||
|
||||
_vCam = _camera.GetComponent<CinemachineVirtualCamera>();
|
||||
// _vCam.m_Lens.Orthographic = true;
|
||||
// _vCam.m_Lens.OrthographicSize = CalcOrthographicSize(); // 设置所需大小
|
||||
_fishingChallengeManager = GContext.container.Resolve<FishingChallengeManager>();
|
||||
// 当前场景的阶段
|
||||
_curStep = _fishingChallengeManager.fishingChallengeData.step;
|
||||
// _curScore = _fishingChallengeManager.fishingChallengeData.Score;
|
||||
OnAddEvents();
|
||||
}
|
||||
#if UNITY_EDITOR
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.N))
|
||||
{
|
||||
_curStep = (_curStep + 1) % (_fishingChallengeManager.GetFullStep() + 1);
|
||||
InitCurStep();
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.V))
|
||||
{
|
||||
var e = new ChallengeCleanStageEvent
|
||||
{
|
||||
stage = 1,
|
||||
};
|
||||
OnUpdateStage(e);
|
||||
}
|
||||
ApplyCameraScale();
|
||||
}
|
||||
private void OnGMInitStep(ChallengeInitStepEvent evt)
|
||||
{
|
||||
_curStep = evt.step;
|
||||
InitCurStep();
|
||||
}
|
||||
#endif
|
||||
void OnChallengeTimeEvent(ChallengeSetAnimationEvent e)
|
||||
{
|
||||
foreach (var box in boxNodeContainer)
|
||||
{
|
||||
box.UpdateTimeController(e);
|
||||
}
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
Log("Start");
|
||||
// _vCam.Priority = 0; // 设置低优先级使其他相机接管
|
||||
// #if UNITY_EDITOR
|
||||
// EditorApplication.QueuePlayerLoopUpdate();
|
||||
// #endif
|
||||
OnSceneStart();
|
||||
}
|
||||
//
|
||||
private void OnAddEvents()
|
||||
{
|
||||
GContext.OnEvent<ChallengeCleanStageEvent>().Subscribe(OnUpdateStage).AddTo(_disposables);
|
||||
GContext.OnEvent<ChallengeBrokeStepEvent>().Subscribe(OnBrokeStep).AddTo(_disposables);
|
||||
#if UNITY_EDITOR
|
||||
GContext.OnEvent<ChallengeInitStepEvent>().Subscribe(OnGMInitStep).AddTo(_disposables);
|
||||
#endif
|
||||
GContext.OnEvent<ChallengeSetAnimationEvent>().Subscribe(OnChallengeTimeEvent).AddTo(_disposables);
|
||||
|
||||
}
|
||||
private void OnSceneStart()
|
||||
{
|
||||
InitCurStep();
|
||||
}
|
||||
private void InitCurStep()
|
||||
{
|
||||
Log($"InitCurStep -> _curStep = {_curStep}");
|
||||
var curIndex = _curStep - 1;
|
||||
var maxNum = boxNodeContainer.Length;
|
||||
for (var i = curIndex + 1; i < maxNum; ++i)
|
||||
{
|
||||
_ = boxNodeContainer[i].UpdateState(CBoxState.Locked);
|
||||
}
|
||||
if (curIndex < 0 || curIndex > boxNodeContainer.Length)
|
||||
return;
|
||||
|
||||
for (var i = 0; i <= curIndex; ++i)
|
||||
{
|
||||
_ = boxNodeContainer[i].UpdateState(CBoxState.Broken);
|
||||
}
|
||||
_ = boxNodeContainer[curIndex].UpdateState(CBoxState.UnLocked);
|
||||
}
|
||||
private async void OnUpdateStage(ChallengeCleanStageEvent upStepEvent)
|
||||
{
|
||||
// Log("UpdateCurStep()");
|
||||
var stageIndex = upStepEvent.stage - 1;
|
||||
if (stageIndex >= 0)
|
||||
{
|
||||
await boxNodeContainer[stageIndex].UpdateState(CBoxState.UnLocking);
|
||||
// await Awaiters.Seconds(0.5f);
|
||||
}
|
||||
upStepEvent.Tcs.SetResult(true);
|
||||
}
|
||||
|
||||
private async void OnBrokeStep(ChallengeBrokeStepEvent brokeEvent)
|
||||
{
|
||||
var step = brokeEvent.step - 1;
|
||||
if (step >= 0 && step < boxNodeContainer.Length)
|
||||
{
|
||||
await Awaiters.Seconds(brokeEvent.dealyTime);
|
||||
await boxNodeContainer[step].UpdateState(CBoxState.Attacking);
|
||||
}
|
||||
brokeEvent.Tcs.SetResult(true);
|
||||
}
|
||||
//
|
||||
private void OnEnable()
|
||||
{
|
||||
Log("OnEnable");
|
||||
_vCam.m_Lens.Orthographic = true;
|
||||
_vCam.m_Lens.OrthographicSize = CalcOrthographicSize();; // 设置所需大小
|
||||
|
||||
|
||||
_lastWidth = Screen.width;
|
||||
_lastHeight = Screen.height;
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
if (_vCam)
|
||||
{
|
||||
_vCam.m_Lens.Orthographic = false;
|
||||
if (Camera.main != null)
|
||||
{
|
||||
var brain = Camera.main.GetComponent<CinemachineBrain>();
|
||||
brain?.ManualUpdate();
|
||||
}
|
||||
}
|
||||
_disposables?.Dispose();
|
||||
_disposables = null;
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
|
||||
}
|
||||
private void Log(object t)
|
||||
{
|
||||
Debug.Log($"<color=#00ff00> ChallengeMatchScene -> {t} </color>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3abf7b0d82faf4847bff62703ca1bb82
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
555
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeMatchSceneUI.cs
Normal file
555
Assets/Scripts/GampPlay/ChallengeMatch/ChallengeMatchSceneUI.cs
Normal file
@@ -0,0 +1,555 @@
|
||||
using asap.core;
|
||||
using GameCore;
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using UnityEngine;
|
||||
using UniRx;
|
||||
using UnityEngine.UI;
|
||||
using game;
|
||||
using System.Threading.Tasks;
|
||||
using DG.Tweening;
|
||||
using Game;
|
||||
using TMPro;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
|
||||
public class ChallengeShowPlayerEvent
|
||||
{
|
||||
public int oldStep;
|
||||
}
|
||||
public class ChallengePlayAniEvent
|
||||
{
|
||||
public int oldStep;
|
||||
public int newStep;
|
||||
public TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
|
||||
}
|
||||
public class ChallengeFailEvent
|
||||
{
|
||||
public int oldStep;
|
||||
public TaskCompletionSource<bool> tcs = new TaskCompletionSource<bool>();
|
||||
}
|
||||
|
||||
// 定义显示Tips
|
||||
//
|
||||
public class ChallengeLevelTipsEvent
|
||||
{
|
||||
public bool IsGm;
|
||||
public int oldScore;
|
||||
public int newScore;
|
||||
public TaskCompletionSource<bool> tcs = new();
|
||||
}
|
||||
|
||||
public class ShowResidueNumEvent
|
||||
{
|
||||
public int num;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// 比赛场景中显示头像奖励等的UI,挂载与比赛场景上
|
||||
public class ChallengeMatchSceneUI : MonoBehaviour
|
||||
{
|
||||
//
|
||||
private Transform icon_reward;
|
||||
private Transform text_title;
|
||||
private Transform _textNumCash;
|
||||
|
||||
|
||||
// 地点
|
||||
public ChallengeMatchSceneUIRegion[] uiRegion;
|
||||
|
||||
public GameObject[] tipPlaceHolder;
|
||||
|
||||
public GameObject eventChallengeHead;
|
||||
|
||||
private EventChallengeLevelTips _levelTipController;
|
||||
|
||||
private FishingChallengeManager _fishingChallengeManager;
|
||||
|
||||
private List<EventChallengeHead> _headList = new();
|
||||
|
||||
private EventChallengeHead _myHead;
|
||||
|
||||
private int count;
|
||||
|
||||
private CompositeDisposable _disposables = new();
|
||||
|
||||
|
||||
// 本人起跳间隔
|
||||
[Header("本人起跳到其他人开始起跳")]
|
||||
public float jumpIntervalMy = 0.1f;
|
||||
//起跳间隔
|
||||
[Header("其他人起跳开始间隔")]
|
||||
public float jumpInterval = 0.1f;
|
||||
// 最后一个起跳到淘汰时间
|
||||
[Header("最后一人起跳到开始落水")]
|
||||
public float jumpToEliminateTime = 0.6f;
|
||||
// 落水到平台下沉时间
|
||||
// [Header("开始落水到沉船")]
|
||||
// public float eliminateToPlatformTime = 0.5f;
|
||||
//int maxCount = 3;
|
||||
[Header("每个人落水间隔")] public float eliminateInterval = 0.01f;
|
||||
|
||||
[Header("跳水动画时长")] public float jumpDuration = 0.6f;
|
||||
|
||||
[Header("淘汰落水时长")] public float jumpDead = 0.2f;
|
||||
|
||||
[Header("箱子破坏前延时")] public float BreakDuration = 0.1f;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_fishingChallengeManager = GContext.container.Resolve<FishingChallengeManager>();
|
||||
GetComponent<Canvas>().worldCamera = Camera.main;
|
||||
_levelTipController = transform.Find("EventChallengeLevelTips").GetComponent<EventChallengeLevelTips>();
|
||||
// _levelTipController.SetSpeed(speed);
|
||||
// _levelTipController.UpdateControllerTime(uptime1, wait2, wait3);
|
||||
|
||||
// var evt = new ChallengeSetAnimationEvent()
|
||||
// {
|
||||
// speed = speed,
|
||||
// timeForUnlocking = _timeForUnlocking,
|
||||
// timeForUnLockingEnd = _timeForUnlockingEnd,
|
||||
// timeForAttacking_1 = _timeForAttacking_1,
|
||||
// timeForAttacking_2 = _timeForAttacking_2,
|
||||
// timeForAttackStart = _timeForAttackStart,
|
||||
// timeForAttackEnd = _timeForAttackEnd,
|
||||
// timeForAttackEndWait = _timeForAttackEndEnd,
|
||||
// };
|
||||
// GContext.Publish(evt);
|
||||
|
||||
|
||||
icon_reward = transform.Find("taizi_reward/icon_reward/icon_reward");
|
||||
text_title = transform.Find("taizi_reward/total_reward/text_title");
|
||||
_textNumCash = transform.Find("taizi_reward/total_reward/text_num_cash");
|
||||
|
||||
|
||||
|
||||
GContext.OnEvent<ChallengeShowPlayerEvent>().Subscribe(ShowPlayer).AddTo(_disposables);
|
||||
GContext.OnEvent<ChallengePlayAniEvent>().Subscribe(PlayAni).AddTo(_disposables);
|
||||
GContext.OnEvent<ChallengeFailEvent>().Subscribe(OnFail).AddTo(_disposables);
|
||||
GContext.OnEvent<ChallengeLevelTipsEvent>().Subscribe(OnShowLevelTips).AddTo(_disposables);
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
var listItemData = GContext.container.Resolve<PlayerItemData>().GetItemDataByDropId(_fishingChallengeManager.eventChallengeMain.WinnerReward);
|
||||
var totalCount = listItemData.Sum(itemData => itemData.count);
|
||||
_textNumCash.GetComponent<TMP_Text>().text = "x" + ConvertTools.GetNumberString(totalCount);
|
||||
InitLevelTip(_fishingChallengeManager.fishingChallengeData.ProcessedScore);
|
||||
}
|
||||
|
||||
public void InitLevelTip(int score )
|
||||
{
|
||||
var step = _fishingChallengeManager.GetStepByScore(score,true);
|
||||
if (step > tipPlaceHolder.Length - 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
_levelTipController.transform.localPosition = tipPlaceHolder[step].transform.localPosition;
|
||||
_levelTipController.gameObject.SetActive(true);
|
||||
_levelTipController.Init(score);
|
||||
}
|
||||
private void ShowPlayer(ChallengeShowPlayerEvent challengeShowPlayerEvent)
|
||||
{
|
||||
var oldStep = challengeShowPlayerEvent.oldStep;
|
||||
var robots = GContext.container.Resolve<cfg.Tables>().TbRobot.DataMap;
|
||||
var uiService = GContext.container.Resolve<IUIService>();
|
||||
var randomPos = uiRegion[oldStep];
|
||||
var posTran = randomPos.posTran;
|
||||
var myself = randomPos.myself;
|
||||
|
||||
if (_headList.Count > 0)
|
||||
{
|
||||
_headList.ForEach(x => Destroy(x.gameObject));
|
||||
_headList.Clear();
|
||||
Destroy(_myHead.gameObject);
|
||||
}
|
||||
var residual = posTran.Count;
|
||||
for (int i = 0; i < residual; i++)
|
||||
{
|
||||
GameObject go = Instantiate(eventChallengeHead.gameObject, posTran[i]);
|
||||
go.transform.localScale = Vector3.one;
|
||||
go.transform.localPosition = Vector3.zero;
|
||||
var head = go.GetComponent<EventChallengeHead>();
|
||||
if (robots.TryGetValue(_fishingChallengeManager.fishingChallengeData.robotAccountList[i], out cfg.Robot robot))
|
||||
{
|
||||
uiService.SetHeadImage(head.icon_head, robot.Avatar);
|
||||
}
|
||||
_headList.Add(head);
|
||||
}
|
||||
|
||||
_myHead = Instantiate(eventChallengeHead.gameObject, myself).GetComponent<EventChallengeHead>();
|
||||
_myHead.transform.localScale = Vector3.one;
|
||||
_myHead.transform.localPosition = Vector3.zero;
|
||||
_myHead.bg_head_myself.SetActive(true);
|
||||
uiService.SetHeadImage(_myHead.icon_head, GContext.container.Resolve<IUserService>().AvatarUrl);
|
||||
count = _headList.Count;
|
||||
}
|
||||
|
||||
////打乱headList顺序
|
||||
// void Shuffle(int curCount)
|
||||
// {
|
||||
// var newHeadList = new List<EventChallengeHead>();
|
||||
// var robotAccountList = new List<int>();
|
||||
// int index = 0;
|
||||
// for (int i = 0; i < curCount; i++)
|
||||
// {
|
||||
// newHeadList.Insert(index, _headList[i]);
|
||||
// robotAccountList.Insert(index, _fishingChallengeManager.fishingChallengeData.robotAccountList[i]);
|
||||
// index = UnityEngine.Random.Range(0, newHeadList.Count + 1);
|
||||
// }
|
||||
// _headList = newHeadList;
|
||||
// _fishingChallengeManager.fishingChallengeData.robotAccountList = robotAccountList;
|
||||
// }
|
||||
#if UNITY_EDITOR
|
||||
bool isShow;
|
||||
string oldStepStr, newStepStr;
|
||||
private string _scoreStr; // 添加到渔获的价值
|
||||
private int _level;
|
||||
string oldScoreStr, newScoreStr;
|
||||
private void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.K))
|
||||
{
|
||||
isShow = !isShow;
|
||||
}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.M))
|
||||
{
|
||||
_level = (_level + 1) % 7;
|
||||
// _tipController.transform.localPosition = tipPlaceHolder[_level].transform.localPosition;
|
||||
LocationLevelTips(_level);
|
||||
}
|
||||
|
||||
}
|
||||
private async void OnGUI()
|
||||
{
|
||||
|
||||
GUILayout.Label($"当前段位: {_fishingChallengeManager.eventChallengeMain.ID}");
|
||||
|
||||
if (!isShow)
|
||||
{
|
||||
return;
|
||||
}
|
||||
// Set the button width and height
|
||||
float buttonWidth = 300; // Replace with your desired width
|
||||
float buttonHeight = 70; // Replace with your desired height
|
||||
int fontSize = 40; // Replace with your desired font size
|
||||
|
||||
// Set the font size for text fields, buttons, and labels
|
||||
GUI.skin.textField.fontSize = fontSize;
|
||||
GUI.skin.button.fontSize = fontSize;
|
||||
GUI.skin.label.fontSize = fontSize;
|
||||
// 触发ChallengeShowPlayAniEvent 事件并能输入oldStep和newStep
|
||||
GUILayout.Label("oldStep:");
|
||||
oldStepStr = GUILayout.TextField(oldStepStr, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight));
|
||||
int.TryParse(oldStepStr, out int oldStep);
|
||||
if (GUILayout.Button("Fail"))
|
||||
{
|
||||
GContext.Publish(new ChallengeMatchPlayGMEvent() { step = oldStep });
|
||||
ShowPlayer(new ChallengeShowPlayerEvent { oldStep = oldStep });
|
||||
await Awaiters.Seconds(0.5f);
|
||||
ChallengeFailEvent challengeFailEvent = new ChallengeFailEvent();
|
||||
challengeFailEvent.oldStep = oldStep;
|
||||
OnFail(challengeFailEvent);
|
||||
}
|
||||
GUILayout.Label("newStep:");
|
||||
newStepStr = GUILayout.TextField(newStepStr, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight));
|
||||
int.TryParse(newStepStr, out int newStep);
|
||||
if (GUILayout.Button("PlayAni", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
|
||||
{
|
||||
GContext.Publish(new ChallengeMatchPlayGMEvent() { step = oldStep });
|
||||
ShowPlayer(new ChallengeShowPlayerEvent { oldStep = oldStep });
|
||||
await Awaiters.Seconds(0.5f);
|
||||
var challengePlayAniEvent = new ChallengePlayAniEvent();
|
||||
challengePlayAniEvent.oldStep = oldStep;
|
||||
challengePlayAniEvent.newStep = newStep;
|
||||
PlayAni(challengePlayAniEvent);
|
||||
}
|
||||
|
||||
GUILayout.Label("QualityScore:");
|
||||
_scoreStr = GUILayout.TextField(_scoreStr,GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight));
|
||||
int.TryParse(_scoreStr, out var score);
|
||||
_fishingChallengeManager.SetQualityScore(score);
|
||||
|
||||
|
||||
GUILayout.Label("oldScore:");
|
||||
oldScoreStr = GUILayout.TextField(oldScoreStr, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight));
|
||||
int.TryParse(oldScoreStr, out var oldScore);
|
||||
//
|
||||
GUILayout.Label("newScore:");
|
||||
newScoreStr = GUILayout.TextField(newScoreStr, GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight));
|
||||
int.TryParse(newScoreStr, out var newScore);
|
||||
//
|
||||
if (GUILayout.Button("RunNewPlay", GUILayout.Width(buttonWidth), GUILayout.Height(buttonHeight)))
|
||||
{
|
||||
// GContext.Publish(new ChallengeMatchPlayGMEvent() { step = oldStep });
|
||||
var nStep = _fishingChallengeManager.GetStepByScore(oldScore,true);
|
||||
var evt = new ChallengeInitStepEvent()
|
||||
{
|
||||
step = nStep
|
||||
};
|
||||
GContext.Publish(evt);
|
||||
await Awaiters.NextFrame;
|
||||
ShowPlayer(new ChallengeShowPlayerEvent { oldStep = nStep });
|
||||
await Awaiters.Seconds(0.5f);
|
||||
// 全部重置
|
||||
|
||||
var tipsEvent = new ChallengeLevelTipsEvent()
|
||||
{
|
||||
IsGm = true,
|
||||
oldScore = oldScore,
|
||||
newScore = newScore,
|
||||
};
|
||||
//OnShowLevelTips(tipsEvent);
|
||||
GContext.Publish(tipsEvent);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
private async void PlayAni(ChallengePlayAniEvent challengePlayAniEvent)
|
||||
{
|
||||
var oldStep = challengePlayAniEvent.oldStep;
|
||||
var newStep = challengePlayAniEvent.newStep;
|
||||
ChallengeMatchSceneUIRegion randomPos;
|
||||
List<Transform> posTran;
|
||||
Transform myself;
|
||||
|
||||
/// 更新剩余人数
|
||||
ShowResidueNumEvent showResidueNumEvent = new ShowResidueNumEvent();
|
||||
var eliminateNumber = _fishingChallengeManager.fishingChallengeData.eliminateNumber;
|
||||
var newEliminate = _fishingChallengeManager.CalcResidualNumber(oldStep);
|
||||
showResidueNumEvent.num = newEliminate;
|
||||
GContext.Publish(showResidueNumEvent);
|
||||
//
|
||||
|
||||
float speed = 1;
|
||||
if (newStep > oldStep + 1)
|
||||
{
|
||||
speed = 0.7f;
|
||||
}
|
||||
|
||||
//var uiRegionNum = uiRegion.Length;
|
||||
//从oldStep到newStep
|
||||
var brokeStepEvent = new ChallengeBrokeStepEvent
|
||||
{
|
||||
step = oldStep,
|
||||
dealyTime = BreakDuration,
|
||||
};
|
||||
for (int i = oldStep; i < newStep; i++)
|
||||
{
|
||||
var regionIdx = Math.Min(uiRegion.Length - 1, i + 1);
|
||||
randomPos = uiRegion[regionIdx];
|
||||
posTran = randomPos.posTran;
|
||||
myself = randomPos.myself;
|
||||
int residual = posTran.Count;
|
||||
// for (int j = 0; j < residual; j++)
|
||||
// {
|
||||
// _headList[j].rectTransform.SetParent(posTran[j]);
|
||||
// }
|
||||
// for (int j = residual; j < count; j++)
|
||||
// {
|
||||
// _headList[j].rectTransform.SetParent(posTran[residual - 1]);
|
||||
// }
|
||||
_myHead.rectTransform.SetParent(myself);
|
||||
_myHead.rectTransform.localScale = Vector3.one;
|
||||
_myHead.rectTransform.DOLocalMove(Vector3.zero,jumpDuration);
|
||||
_myHead.headAni.Play("fx_anim_eventchallengehead_jump_success_01");
|
||||
// 头狼起调
|
||||
var myJumpAudioName = uiRegion[i].myJumpAudioName;
|
||||
if (!string.IsNullOrEmpty(myJumpAudioName))
|
||||
{
|
||||
GContext.Publish(new EventUISound(myJumpAudioName));
|
||||
}
|
||||
await Awaiters.Seconds(jumpIntervalMy * speed);
|
||||
// 跟随起跳
|
||||
var followerJumpAudioName = uiRegion[i].followerJumpAudioName;
|
||||
if (!string.IsNullOrEmpty(myJumpAudioName))
|
||||
{
|
||||
GContext.Publish(new EventUISound(followerJumpAudioName));
|
||||
}
|
||||
for (int j = 0; j < residual; j++)
|
||||
{
|
||||
await Awaiters.Seconds(jumpInterval * speed);
|
||||
_headList[j].rectTransform.SetParent(posTran[j]);
|
||||
_headList[j].rectTransform.DOLocalMove(Vector3.zero, jumpDuration).SetEase(Ease.OutCubic);
|
||||
_headList[j].rectTransform.DOScale(Vector3.one, jumpDuration).SetEase(Ease.OutCubic);
|
||||
_headList[j].headAni.Play("fx_anim_eventchallengehead_jump_success_01");
|
||||
}
|
||||
var posTranRect = uiRegion[i].posTranRect;
|
||||
//淘汰动画
|
||||
await Awaiters.Seconds(jumpToEliminateTime * speed);
|
||||
// 播放动画声音
|
||||
var audioName = uiRegion[i].fallAudioName;
|
||||
if (!string.IsNullOrEmpty(audioName)){
|
||||
GContext.Publish(new EventUISound(audioName));
|
||||
}
|
||||
|
||||
//
|
||||
int tranCount = posTranRect.Count;
|
||||
RectTransform rectPos = posTranRect[0];
|
||||
float width = 0, height = 0;
|
||||
|
||||
if (residual >= count)
|
||||
{
|
||||
GContext.Publish(brokeStepEvent);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int j = residual; j < count; j++)
|
||||
{
|
||||
if (tranCount > j - residual)
|
||||
{
|
||||
rectPos = posTranRect[j - residual];
|
||||
width = rectPos.rect.width / 2;
|
||||
height = rectPos.rect.height / 2;
|
||||
}
|
||||
|
||||
Vector3 vector3 = new Vector3(UnityEngine.Random.Range(-width, width),
|
||||
UnityEngine.Random.Range(-height, height), 0);
|
||||
await Awaiters.Seconds(eliminateInterval * speed);
|
||||
_headList[j].rectTransform.SetParent(rectPos);
|
||||
_headList[j].rectTransform.DOScale(Vector3.one, jumpDead).SetEase(Ease.Linear);
|
||||
_headList[j].rectTransform.DOLocalMove(vector3, jumpDead).SetEase(Ease.Linear);
|
||||
_headList[j].headAni.Play("fx_anim_eventchallengehead_jump_defeat_01");
|
||||
if (j == residual)
|
||||
{
|
||||
// 播放破坏动画
|
||||
GContext.Publish(brokeStepEvent);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//从i到i+1平台,起点0不动
|
||||
if (i > 0)
|
||||
{
|
||||
// await Awaiters.Seconds(eliminateToPlatformTime * speed );
|
||||
GContext.Publish(new ChallengeMatchPlayEvent() { step = i });
|
||||
}
|
||||
|
||||
count = residual;
|
||||
newEliminate -= eliminateNumber[i];
|
||||
showResidueNumEvent.num = newEliminate;
|
||||
GContext.Publish(showResidueNumEvent);
|
||||
|
||||
// if (i < eliminateNumber.Count - 2)
|
||||
// {
|
||||
// _fishingChallengeManager.AddStageReward(i);
|
||||
// }
|
||||
|
||||
// 直接写添加奖品
|
||||
// var itemDataList = playerItemData.GetItemDataByDropId(eventChallengeMain.StageReward[newStep], fishingChallengeData.mapId);
|
||||
// playerItemData.AddItem(itemDataList);
|
||||
await Awaiters.Seconds(1f * speed);
|
||||
await brokeStepEvent.Tcs.Task; //
|
||||
}
|
||||
challengePlayAniEvent.tcs.SetResult(true);
|
||||
}
|
||||
private async void OnFail(ChallengeFailEvent challengeFailEvent)
|
||||
{
|
||||
int oldStep = challengeFailEvent.oldStep;
|
||||
var rectPos = uiRegion[oldStep].myselfRect;
|
||||
//淘汰动画
|
||||
float width = rectPos.rect.width / 2;
|
||||
float height = rectPos.rect.height / 2;
|
||||
Vector3 vector3 = new Vector3(UnityEngine.Random.Range(-width, width), UnityEngine.Random.Range(-height, height), 0);
|
||||
_myHead.rectTransform.SetParent(rectPos);
|
||||
_myHead.rectTransform.localScale = Vector3.one;
|
||||
_myHead.rectTransform.DOLocalMove(vector3, 0.2f).SetEase(Ease.Linear);
|
||||
_myHead.headAni.Play("fx_anim_eventchallengehead_jump_defeat_01");
|
||||
await Awaiters.Seconds(1f);
|
||||
challengeFailEvent.tcs.SetResult(true);
|
||||
}
|
||||
|
||||
// 注意多组的情况,根据分数算,可能要跳好多次
|
||||
private async void OnShowLevelTips(ChallengeLevelTipsEvent tipsEvent)
|
||||
{
|
||||
Log("OnShowLevelTips");
|
||||
var oldScore = tipsEvent.oldScore;
|
||||
var newScore = tipsEvent.newScore;
|
||||
var isGm = tipsEvent.IsGm;
|
||||
|
||||
if (oldScore == newScore)
|
||||
{
|
||||
InitLevelTip(oldScore);
|
||||
tipsEvent.tcs.SetResult(true);
|
||||
return;
|
||||
}
|
||||
var step = _fishingChallengeManager.GetStepByScore(oldScore,true);
|
||||
var maxScore = _fishingChallengeManager.GetMaxScoreByStep(step);
|
||||
if (_levelTipController && step >= 0 && step < tipPlaceHolder.Length )
|
||||
{
|
||||
LocationLevelTips(step);
|
||||
var curScore = await _levelTipController.ShowTips(oldScore,newScore);
|
||||
// 播放显示动画
|
||||
if (maxScore == curScore)
|
||||
{
|
||||
await _levelTipController.PlayInVisibleAni();
|
||||
await ReceiveStageReward(step);
|
||||
await JumpStage(step, curScore, newScore,isGm);
|
||||
}
|
||||
}
|
||||
tipsEvent.tcs.SetResult(true);
|
||||
}
|
||||
|
||||
private void LocationLevelTips(int step)
|
||||
{
|
||||
_levelTipController.transform.localPosition = tipPlaceHolder[step].transform.localPosition;
|
||||
_levelTipController.SetCurStep(step);
|
||||
_levelTipController.gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
|
||||
// 看看需要加什么动画类的东西么
|
||||
public async Task ReceiveStageReward(int step)
|
||||
{
|
||||
Log($"ReceiveStageReward {step}");
|
||||
_fishingChallengeManager.AddStageReward(step);
|
||||
}
|
||||
|
||||
private static async Task JumpStage(int step, int curScore, int newScore,bool isGm)
|
||||
{
|
||||
Log("JumpStage");
|
||||
// 清理下一个台子
|
||||
var cleanEvent = new ChallengeCleanStageEvent
|
||||
{
|
||||
stage = step + 1,
|
||||
};
|
||||
GContext.Publish(cleanEvent);
|
||||
await cleanEvent.Tcs.Task;
|
||||
|
||||
// 播放跳跃动画
|
||||
var cspe = new ChallengePlayAniEvent() { oldStep = step, newStep = step + 1 };
|
||||
GContext.Publish(cspe);
|
||||
await cspe.tcs.Task;
|
||||
|
||||
// // 播放破坏动画
|
||||
// var brokeStepEvent = new ChallengeBrokeStepEvent { step = step };
|
||||
// GContext.Publish(brokeStepEvent);
|
||||
// await brokeStepEvent.Tcs.Task;
|
||||
|
||||
// -- 进入下一个循环
|
||||
// if (curScore != newScore || newScore == maxScore)
|
||||
// {
|
||||
var nextStageEvent = new ChallengeLevelTipsEvent
|
||||
{
|
||||
oldScore = curScore,
|
||||
newScore = newScore,
|
||||
IsGm = isGm,
|
||||
};
|
||||
GContext.Publish(nextStageEvent);
|
||||
await nextStageEvent.tcs.Task;
|
||||
// }
|
||||
}
|
||||
|
||||
void OnDisable()
|
||||
{
|
||||
_disposables?.Dispose();
|
||||
_disposables = null;
|
||||
}
|
||||
|
||||
private static void Log(object message)
|
||||
{
|
||||
Debug.Log($"<color=orange>ChallengeMatchSceneUI => {message} </color>");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e73184c4395c5304fb7096669602544c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,55 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Serialization;
|
||||
|
||||
public class ChallengeMatchSceneUIRegion : MonoBehaviour
|
||||
{
|
||||
public List<Transform> posTran;
|
||||
public List<RectTransform> posTranRect;
|
||||
public Transform myself;
|
||||
public RectTransform myselfRect;
|
||||
|
||||
public string myJumpAudioName;
|
||||
public string followerJumpAudioName;
|
||||
public string fallAudioName;
|
||||
|
||||
private void Reset()
|
||||
{
|
||||
Init();
|
||||
}
|
||||
//private void Awake()
|
||||
//{
|
||||
|
||||
//}
|
||||
void Init()
|
||||
{
|
||||
myself = transform.Find("myself");
|
||||
var re = transform.Find("myself (1)");
|
||||
if (re)
|
||||
{
|
||||
myselfRect = re.GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
int count = transform.childCount;
|
||||
Transform pos;
|
||||
Transform posRect;
|
||||
for (int i = 1; i < count; i++)
|
||||
{
|
||||
pos = transform.Find(i.ToString());
|
||||
posRect = transform.Find(i.ToString() + " (1)");
|
||||
if (posRect != null)
|
||||
{
|
||||
posTranRect.Add(posRect.GetComponent<RectTransform>());
|
||||
}
|
||||
if (pos != null)
|
||||
{
|
||||
posTran.Add(pos);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 629538e6064fbbc4880911bdbcfa81c4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user