NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/UI/LevelFight/UIPassGameController.cs

1075 lines
29 KiB
C#
Raw Normal View History

using System.Collections.Generic;
2024-04-24 14:31:42 +08:00
using System.Linq;
2024-05-06 15:35:03 +08:00
using cfg.CharacterCfg;
using cfg.LevelCfg;
2024-04-02 15:21:30 +08:00
using Cysharp.Threading.Tasks;
using Framework;
using Gameplay;
using Gameplay.Character;
using Gameplay.Guide;
2023-10-19 15:00:19 +08:00
using Gameplay.Level;
using Gameplay.Net;
using Gameplay.Unit;
using NLDPB;
2023-08-22 19:08:45 +08:00
using TMPro;
using UnityEngine;
2024-04-02 15:21:30 +08:00
using UnityEngine.UI;
2023-08-22 19:08:45 +08:00
using Image = UnityEngine.UI.Image;
using DG.Tweening;
using Gameplay.Effect;
2024-09-20 18:33:26 +08:00
using System;
2024-09-26 19:25:46 +08:00
using Gameplay.Common;
2024-09-20 19:35:03 +08:00
using PhxhSDK;
2023-08-22 19:08:45 +08:00
2024-05-06 15:35:03 +08:00
public class UIPassGameController : UIWindow
{
2023-08-22 19:08:45 +08:00
//UI GameObj
///Auto Gen Start///
public Image Image_WinBG;
public Image Image_PosterLu;
public Image Image_TextRect;
public TMP_Text Text_Win;
public Image Image_BlueBar;
public TMP_Text Text_LevelNum;
public TMP_Text Text_LevelName;
public TMP_Text Text_FightTime;
public Image Image_Clock;
public TMP_Text Text_Time;
public TMP_Text Text_CharacterID;
public TMP_Text Text_CharacterLV;
public Image Image_EXEmpty;
public Image Image_EXFull;
public TMP_Text Text_EX;
public TMP_Text Text_LVUp;
public TMP_Text Text_Target;
public Image Image_DownShadow;
public TMP_Text Text_GeneralEX;
public Image Image_ELogo;
public TMP_Text Text_EXPHave;
public TMP_Text Text_EXPGet;
public TMP_Text Text_Mode;
///Auto Gen End///
2024-09-26 19:25:46 +08:00
private static bool _isPvPSuccess;
2024-09-20 18:33:26 +08:00
public static async UniTask<UIWindow> Open(ItemList itemList, bool isSweep)
2024-05-06 15:35:03 +08:00
{
2024-09-20 18:33:26 +08:00
ValueTuple<ItemList, bool> value = (itemList, isSweep);
return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UIPassGame, value);
2024-04-02 15:21:30 +08:00
}
2024-09-26 19:25:46 +08:00
public static async UniTask<UIWindow> PvPOpen(ItemList itemList, bool isSuccess)
{
ValueTuple<ItemList, bool> value = (itemList, false);
_isPvPSuccess = isSuccess;
return await UIManager.Instance.CreateAndOpenWindow(UINameConst.UIPassGame, value);
}
2024-04-02 15:21:30 +08:00
/// <summary>
/// 高斯模糊遮罩
/// </summary>
private RawImage rawImageGaussianBlurMask;
2024-04-28 17:01:49 +08:00
/// <summary>
/// 台词文本
/// </summary>
private TMP_Text textDialogue;
2024-05-06 15:35:03 +08:00
/// <summary>
/// 角色名
/// </summary>
private TMP_Text textName;
2024-04-02 15:21:30 +08:00
2024-05-06 15:35:03 +08:00
private List<Image> _imgWinStar;
private List<Image> _imageFailedStart;
private List<GameObject> _aimObjList;
private int _levelID;
private List<GameObject> _itemHeadList;
private List<uint> _charIDs;
private ItemList _itemList;
2024-09-20 18:33:26 +08:00
private bool isSweep;
private bool _isNormal;
private bool _isWar;
2024-09-26 14:46:49 +08:00
private bool _isPvP;
2024-09-26 19:25:46 +08:00
private Sequence _seqPvp;
private bool _isPlaying;
private PVPSettleData _settleData;
private PVPSettleData _newPVPData;
private GameObject _goCharDetail;
private GameObject _goMissionDetail;
2024-09-26 14:46:49 +08:00
private GameObject _goPvPDetail;
private GameObject _goWarDetail;
private RecycleView _scrollWar;
2024-04-28 17:01:49 +08:00
/// <summary>
/// 台词语音
/// </summary>
2024-07-22 19:59:13 +08:00
private AudioInst dialogueAudio;
2024-05-06 15:35:03 +08:00
/// <summary>
/// 是否正在播放台词语音
/// </summary>
public bool IsDialoguePlaying
{
get { return dialogueAudio != null && dialogueAudio.IsPlaying; }
}
2024-04-28 17:01:49 +08:00
private bool _isPlayingAnim; //是否正在播放升级动画
private int _playerLvUp; //获取到的升级
private float _playerExpUp; //需要最后涨的经验值
private Sequence _seq;
2024-10-18 14:04:34 +08:00
/// <summary>
/// 临时处理,保证只添加过一次升级动画
/// </summary>
private bool isAddUpAnim;
2024-09-20 19:35:03 +08:00
public override async void PreLoad(object data = null)
{
base.PreLoad(data);
2024-09-20 18:33:26 +08:00
if (data is ValueTuple<ItemList, bool> value)
{
2024-09-20 18:33:26 +08:00
_itemList = value.Item1;
isSweep = value.Item2;
2024-09-20 19:35:03 +08:00
if (isSweep)
{
2024-10-15 16:30:20 +08:00
Team team = LevelManager.Instance.SettleData.Team;
2024-10-11 15:22:03 +08:00
var teamCharacterIDs = team.GetAllCharacters();
for (int i = 0; i < teamCharacterIDs.Count; i++)
2024-09-20 19:35:03 +08:00
{
uint uid = teamCharacterIDs[i];
// 空位置不显示
if (uid == Team.NoneID) continue;
2024-09-20 19:35:03 +08:00
DataCharacterAttri cfg = TableManager.Instance.Tables.CharacterAttri.Get((int)uid);
if (null != cfg)
{
//TeamManager 内已经加载过头像,这里不需要再加载
2024-10-23 16:09:09 +08:00
var config = CharacterDataInfoManager.Instance.GetCharacterInfo((uint)cfg.RoleID);
string str = CommonUtils.GetCharacterPicPath(cfg.RoleID, CommonUtils.ECharacterPicPathType.HeadPic, (int)config.SkinID);//CommonUtils.GetDefaultHeadPathByUid((uint)cfg.RoleID);
2024-09-20 19:35:03 +08:00
string posterStr = CommonUtils.GetCharacterPicPath(cfg.RoleID, CommonUtils.ECharacterPicPathType.Poster);
2024-10-23 16:09:09 +08:00
await PostPreload<Sprite>(str);
2024-09-20 19:35:03 +08:00
await PostPreload<Sprite>(posterStr);
}
}
}
else
{
2024-09-26 19:25:46 +08:00
if (LevelManager.Instance.CurrentLevel.IsPvPLevel)
{
_isPvP = true;
_settleData = LevelManager.Instance.PvpSettleData;
_newPVPData = new PVPSettleData();
return;
}
_isWar = LevelManager.Instance.CurrentLevel.IsWar;
}
2024-09-20 18:33:26 +08:00
}
}
2023-08-22 19:08:45 +08:00
// Use this for initialization
2024-01-23 12:25:47 +08:00
public override void OnInit()
2023-08-22 19:08:45 +08:00
{
//bind UI GameObj
UIPassGameBinder.GetComponents(this);
2024-04-02 15:21:30 +08:00
Text_Mode = GetComponent<TMP_Text>("Image_WinBG/Text_Win/Text_Mode");
2024-05-06 15:35:03 +08:00
textName = GetComponent<TMP_Text>("Image_WinBG/Image_PosterLu/Image_ActorLineBG/Text_Name");
textDialogue = GetComponent<TMP_Text>("Image_WinBG/Image_PosterLu/Image_ActorLineBG/Text_Describe");
//rawImageGaussianBlurMask = GetComponent<RawImage>("GaussianBlurMask");
2024-04-02 15:21:30 +08:00
//rawImageGaussianBlurMask.texture = CommonUtils.GetScreenTexture2D();
_goCharDetail = FindObj("Image_WinBG/CharacterDetail");
_goMissionDetail = FindObj("Image_WinBG/MissionDetail");
_goWarDetail = FindObj("Image_WinBG/UI_WarLevel");
2024-09-26 14:46:49 +08:00
_goPvPDetail = FindObj("Image_WinBG/UI_PVP");
_scrollWar = GetComponent<RecycleView>("Image_WinBG/UI_WarLevel/Image_WarTarget/ScrollViewTarget");
2024-04-02 15:21:30 +08:00
2024-09-26 15:08:23 +08:00
BindButton("Button_Close", _OnClickClose);
2023-08-22 19:08:45 +08:00
_imgWinStar = new List<Image>();
_imageFailedStart = new List<Image>();
_aimObjList = new List<GameObject>();
_itemHeadList = new List<GameObject>();
_charIDs = new List<uint>();
for (int i = 0; i < 3; i++)
{
var img = GetComponent<Image>("Image_WinBG/MissionDetail/ImageMissionBar" + i + "/ImageWinStart");
var imgFail = GetComponent<Image>("Image_WinBG/MissionDetail/ImageMissionBar" + i + "/ImageFailedStart");
_imgWinStar.Add(img);
_imageFailedStart.Add(imgFail);
_aimObjList.Add(FindObj("Image_WinBG/MissionDetail/ImageMissionBar" + i));
}
2023-08-22 19:08:45 +08:00
for (int i = 0; i < 7; i++)
{
var go = FindObj("Image_WinBG/HeroLevelUp/Image_DownShadow/ItemHead" + i);
_itemHeadList.Add(go);
}
2024-10-18 14:04:34 +08:00
isAddUpAnim = false;
}
2023-08-22 19:08:45 +08:00
public override void OnRelease()
{
//AudioManager.Instance.AudioMgrObj.StopAllSounds();
2024-09-20 19:35:03 +08:00
if (_seq != null)
{
DOTween.Kill(_seq);
_seq = null;
}
2024-09-26 19:25:46 +08:00
if (_seqPvp != null)
{
DOTween.Kill(_seqPvp);
_seqPvp = null;
}
2024-09-20 19:35:03 +08:00
base.OnRelease();
}
2024-07-31 13:39:07 +08:00
private void _Refresh()
2023-11-08 15:50:08 +08:00
{
2024-10-15 16:30:20 +08:00
var team = _isPvP? TeamEditManager.Instance.GetSelectTeam() : LevelManager.Instance.SettleData.Team;
2024-10-11 15:22:03 +08:00
var charIDArray = team.GetAllCharacters();
for (int i = 0; i < charIDArray.Count; i++)
{
2024-10-15 16:30:20 +08:00
if (charIDArray[i] != Team.NoneID)
{
_charIDs.Add(charIDArray[i]);
}
}
2024-05-06 15:35:03 +08:00
_RefreshInfo();
_RefreshMissionDetail();
_RefreshWar();
2024-09-26 19:25:46 +08:00
_RefreshPvP();
_RefreshCommonExp();
_RefreshHeads();
2024-04-24 14:31:42 +08:00
if (charIDArray.Count() > 0)
2024-05-06 15:35:03 +08:00
{
int id = (int)charIDArray[0];
DataCharacterAttri dataCharacterAttri = TableManager.Instance.Tables.CharacterAttri.Get(id);
if (dataCharacterAttri == null)
{
DebugUtil.LogError($"获取角色配置失败id{id}");
return;
}
textName.text = CommonUtils.GetCharacterName(dataCharacterAttri.RoleID);
2024-07-31 13:39:07 +08:00
dialogueAudio = DialogueManager.Instance.PlayDiaogue(id,
2024-04-28 17:01:49 +08:00
cfg.DialogueCfg.E_DialogueType.LevelWin,
(content) => { textDialogue.text = content; });
2024-05-06 15:35:03 +08:00
}
2023-11-08 15:50:08 +08:00
}
2024-05-06 15:35:03 +08:00
2023-08-22 19:08:45 +08:00
//invoke when open window
protected override void OnShowWindow(object data)
2023-08-22 19:08:45 +08:00
{
2024-09-26 19:25:46 +08:00
_levelID = _isPvP? GLConfig.Inst.data.PVPLevelID : LevelManager.Instance.SettleData.LevelID;
2024-09-20 19:35:03 +08:00
_Refresh();
2024-09-23 17:57:10 +08:00
}
2024-05-06 15:35:03 +08:00
protected override void OnUpdate()
{
base.OnUpdate();
2024-04-28 17:01:49 +08:00
Image_TextRect.gameObject.IsScaleShow(IsDialoguePlaying);
2024-05-06 15:35:03 +08:00
}
2024-04-28 17:01:49 +08:00
public override async UniTask<bool> OnBack(object data = null)
{
return false;
}
2024-05-06 15:35:03 +08:00
protected override void OnHideWindow()
{
2024-09-23 17:57:10 +08:00
//AudioManager.Instance.AudioMgrObj.StopAllSounds();
2024-04-28 17:01:49 +08:00
2024-09-23 17:57:10 +08:00
base.OnHideWindow();
}
2024-05-06 15:35:03 +08:00
#region RefreshWindow
2024-04-28 17:01:49 +08:00
2024-05-06 15:35:03 +08:00
private void _RefreshInfo()
2023-08-22 19:08:45 +08:00
{
_RefreshMapDetail();
2023-08-22 19:08:45 +08:00
}
private void _RefreshMapDetail()
{
2024-11-05 15:53:08 +08:00
if (!_isPvP && !isSweep)
2024-10-31 14:37:12 +08:00
{
if (LevelManager.Instance == null || LevelManager.Instance.CurrentLevel == null)
return;
}
_RefreshTime();
_RefreshEv();
_RefreshLevelInfo();
_RefreshPlayerInfo();
}
private async void _RefreshEv()
{
var root = FindObj("Image_WinBG/MapDetail");
var imgDay = CommonUtils.GetComponent<Image>(root, "Image_Fight");
var txtDay = CommonUtils.GetComponent<TMP_Text>(root, "Image_Fight/Text_Fight");
var imgWeather = CommonUtils.GetComponent<Image>(root, "Enviroments/Image_Enviroment0");
var txtWeather = CommonUtils.GetComponent<TMP_Text>(root, "Enviroments/Image_Enviroment0/Text_Current");
var imgEv = CommonUtils.GetComponent<Image>(root, "Enviroments/Image_Enviroment1");
var txtEv = CommonUtils.GetComponent<TMP_Text>(root, "Enviroments/Image_Enviroment1/Text_Current");
2024-10-15 19:11:48 +08:00
LevelInfo levelInfo;
if (isSweep)
levelInfo = LevelManager.Instance.CurrLevel;
else
LevelManager.Instance.TryGetLevelInfoByID(LevelManager.Instance.CurrentLevel.ID, out levelInfo);
if (levelInfo != null)
{
var dayNightConfig = CommonUtils.GetDayNightConfig(levelInfo.Cfg.LevelTime);
imgDay.sprite = await LoadAssetAsync<Sprite>(dayNightConfig.Icon);
txtDay.text = CommonUtils.GetLocalizeText(dayNightConfig.NameLocal);
var weatherType = levelInfo.Cfg.LevelWeather;
var weatherConfig = CommonUtils.GetWeatherConfig(weatherType);
imgWeather.sprite = await LoadAssetAsync<Sprite>(weatherConfig.Icon);
txtWeather.text = CommonUtils.GetLocalizeText(weatherConfig.NameLocal);
var type = levelInfo.eLevelTerrain;
var environmentCfg = CommonUtils.GetEnvironmentConfig(type);
imgEv.sprite = await LoadAssetAsync<Sprite>(environmentCfg.Icon);
txtEv.text = CommonUtils.GetLocalizeText(environmentCfg.NameLocal);
}
}
private async void _RefreshLevelInfo()
{
var level = LevelManager.Instance.CurrLevel;
//var levelName = level.Name;
//Text_LevelName.text = levelName;
2024-09-26 19:25:46 +08:00
if (_isPvP)
{
2024-09-27 19:42:19 +08:00
Text_Mode.text = CommonUtils.GetLocalizeText("level_chapter_type_pvp");
Text_LevelNum.text = CommonUtils.GetLocalizeText("pvp_level_desc");
}
else if (_isWar)
{
Text_Mode.text = CommonUtils.GetLocalizeText("level_chapter_type_war");
Text_LevelNum.text = LevelManager.Instance.LevelIDToNum(level.Cfg.Id);
2024-09-26 19:25:46 +08:00
}
else
2024-09-27 19:42:19 +08:00
{
Text_Mode.text = CommonUtils.GetLocalizeText("level_chapter_type_normal");//CommonUtils.GetCurLevelTypeStr();
Text_LevelNum.text = LevelManager.Instance.LevelIDToNum(level.Cfg.Id);
}
}
2024-05-06 15:35:03 +08:00
private void _RefreshTime()
{
2024-09-20 18:33:26 +08:00
if (isSweep)
{
Text_Time.gameObject.IsScaleShow(false);
return;
}
var minutes = TeamManager.Instance.GetFightPastMinute();
var seconds = TeamManager.Instance.GetFightPastSecond();
var timeStr = "";
2024-05-06 15:35:03 +08:00
2024-07-04 14:43:55 +08:00
if (minutes >= 10)
{
timeStr += minutes;
}
else
{
timeStr += "0";
timeStr += minutes;
}
timeStr += ":";
2024-07-04 14:43:55 +08:00
if (seconds >= 10)
{
timeStr += seconds;
}
else
{
timeStr += "0";
timeStr += seconds;
}
Text_Time.text = timeStr;
2024-09-20 18:33:26 +08:00
Text_Time.gameObject.IsScaleShow(true);
}
private void _RefreshPlayerInfo()
{
2024-09-26 19:25:46 +08:00
if (_isPvP)
{
return;
}
2024-07-04 13:49:45 +08:00
var playerName = Actor.Instance.Base.Nickname;
var playerLv = Actor.Instance.Base.GetProp(ActorProp.Level);
2024-07-04 13:49:45 +08:00
Text_CharacterID.text = playerName;
2024-09-02 14:55:43 +08:00
if (GuideManager.Instance.IsGuiding && 100001 == LevelManager.Instance.CurrLevel.Cfg.Id)
Text_CharacterID.gameObject.IsScaleShow(false);
else
Text_CharacterID.gameObject.IsScaleShow(true);
2024-11-14 19:22:16 +08:00
Text_CharacterLV.text = CommonUtils.GetLocalizeText("level_desc_pre") + "." + playerLv;
var maxLevel = ActorLevelTableHelper.Instance.GetPlayerMaxLevel();
if (playerLv >= maxLevel)
{
Image_EXFull.fillAmount = 1;
Text_EX.text = CommonUtils.GetLocalizeText("player_level_max");
Text_LVUp.text = "";
return;
}
2024-07-11 19:58:19 +08:00
var max = ActorLevelTableHelper.Instance.GetLevelUpExp((int)playerLv);//actorCfg.Exp;
var cur = Actor.Instance.Base.GetProp(ActorProp.Exp);
var process = (float)cur / max;
2024-05-06 15:35:03 +08:00
var oldLvExp = LevelManager.Instance.SettleData.PlayerLvExp;
var lvDiff = playerLv - oldLvExp.Lv;
var oldLv = oldLvExp.Lv;
2024-01-22 13:45:43 +08:00
int add = _CalculateExp();
Image_EXFull.fillAmount = (float)oldLvExp.Exp / max;
2024-01-22 13:45:43 +08:00
Text_LVUp.text = "+" + add;
Text_EX.text = cur + "/" + max;
//Image_EXFull.fillAmount = process;
_playerLvUp = (int)lvDiff;
_PlayAnim(process);
2024-01-22 13:45:43 +08:00
}
private int _CalculateExp()
{
int retExp = 0;
var oldExp = LevelManager.Instance.SettleData.PlayerLvExp.Exp;
var oldLv = LevelManager.Instance.SettleData.PlayerLvExp.Lv;
2024-05-06 15:35:03 +08:00
2024-01-22 13:45:43 +08:00
var curLv = Actor.Instance.Base.GetProp(ActorProp.Level);
var curExp = Actor.Instance.Base.GetProp(ActorProp.Exp);
if (oldLv < curLv)
{
2024-07-11 19:58:19 +08:00
var oldActorLvExp = ActorLevelTableHelper.Instance.GetLevelUpExp((int)oldLv);//Cfg = ActorLevelTableHelper.Instance.Get((int)oldLv);
retExp += oldActorLvExp - (int)oldExp;
2024-01-22 13:45:43 +08:00
for (uint i = oldLv + 1; i < curLv; i++)
{
2024-07-11 19:58:19 +08:00
var curLvExp = ActorLevelTableHelper.Instance.GetLevelUpExp((int)i);
retExp += curLvExp;
}
2024-01-22 13:45:43 +08:00
retExp += (int)curExp;
}
else
{
2024-01-22 13:45:43 +08:00
retExp += (int)(curExp - oldExp);
}
2024-01-22 13:45:43 +08:00
return retExp;
}
private async void _RefreshWar()
{
if (!_isWar)
{
return;
}
2024-09-26 14:46:49 +08:00
_goMissionDetail.SetActive(false);
_goCharDetail.SetActive(false);
_goWarDetail.SetActive(true);
_goPvPDetail.SetActive(false);
2024-09-26 15:08:23 +08:00
_scrollWar.Init(_RefreshWarItem);
2024-09-26 14:46:49 +08:00
var levelInfo = LevelManager.Instance.CurrentLevel.GetLevelInfo();
var txtScore = CommonUtils.GetComponent<TMP_Text>(_goWarDetail, "Image_WarGrades/Text_Grades");
var imgRating = CommonUtils.GetComponent<Image>(_goWarDetail, "Image_WarGrades/Image_RatingLevelIcon");
txtScore.text = levelInfo.Score.ToString();
imgRating.sprite = await LoadAssetAsync<Sprite>(WarRating.WarRatingPath[levelInfo.WarRating]);
_scrollWar.ShowList(_GetScrollCount());
}
private void _RefreshWarItem(GameObject go, int index)
{
var complete = LevelManager.Instance.CurrentLevel.GetStarIsSuccess(index);
var rootComplete = CommonUtils.GetGameObject(go, "UI_Complete");
var rootInComplete = CommonUtils.GetGameObject(go, "UI_Incomplete");
rootComplete.SetActive(complete);
rootInComplete.SetActive(!complete);
var root = complete ? rootComplete : rootInComplete;
var txtScore = CommonUtils.GetComponent<TMP_Text>(root, "Text_PlusScore");
var txtDesc = CommonUtils.GetComponent<TMP_Text>(root, "Text_TargetMission");
var score = LevelManager.Instance.CurrentLevel.GetLevelInfo().GetScoreTarget(index);
var desc = LevelManager.Instance.CurrentLevel.GetScoreTargetLocalization(index);
txtScore.text = "+" + score;
txtDesc.text = desc;
}
private int _GetScrollCount()
{
var levelData = LevelManager.Instance.CurrentLevel.GetLevelData();
return levelData.scoreTarget.Count;
}
private void _RefreshMissionDetail()
{
2024-09-26 14:46:49 +08:00
if (_isWar || _isPvP)
{
return;
}
2024-09-26 14:46:49 +08:00
_goMissionDetail.SetActive(true);
_goCharDetail.SetActive(true);
_goWarDetail.SetActive(false);
_goPvPDetail.SetActive(false);
_RefreshStars();
_RefreshAimInfo();
}
private void _RefreshStars()
{
2024-09-20 19:00:18 +08:00
if (isSweep)
{
for (int i = 0; i < _imgWinStar.Count; i++)
{
_imgWinStar[i].gameObject.SetActive(true);
_imageFailedStart[i].gameObject.SetActive(false);
}
return;
2024-09-20 19:00:18 +08:00
}
for (int i = 0; i < _imgWinStar.Count; i++)
{
var isFinish = LevelManager.Instance.CurrentLevel.GetStarIsSuccess(i);
_imgWinStar[i].gameObject.SetActive(isFinish);
_imageFailedStart[i].gameObject.SetActive(!isFinish);
}
}
private void _RefreshAimInfo()
{
2024-08-06 13:40:53 +08:00
//var levelInfo = LevelManager.Instance.GetLevelInfoByID(_levelID);
2024-01-31 16:24:32 +08:00
var levelCfg = TableManager.Instance.Tables.Level.GetOrDefault(_levelID);
var levelRewardID = new List<List<int>>(3);
if (levelCfg != null)
{
levelRewardID.Add(new List<int>(levelCfg.StarRewardID1));
levelRewardID.Add(new List<int>(levelCfg.StarRewardID2));
levelRewardID.Add(new List<int>(levelCfg.StarRewardID3));
}
2024-05-06 15:35:03 +08:00
for (int i = 0; i < _aimObjList.Count; i++)
{
2024-08-06 13:40:53 +08:00
var txtContent = "";
var aimObj = _aimObjList[i];
aimObj.gameObject.SetActive(true);
2024-09-20 19:00:18 +08:00
var txtDesc = CommonUtils.GetComponent<TMP_Text>(aimObj, "TextDescribe");
var txtGetItem = CommonUtils.GetComponent<TMP_Text>(aimObj, "TextGetItem");
var txtGetItemFailed = CommonUtils.GetComponent<TMP_Text>(aimObj, "TextGetItemFailed");
bool isFinish = isSweep ? true : LevelManager.Instance.CurrentLevel.GetStarIsSuccess(i);
2024-08-06 13:40:53 +08:00
txtGetItem.gameObject.SetActive(isFinish);
txtGetItemFailed.gameObject.SetActive(!isFinish);
txtDesc.text = LevelManager.Instance.CurrLevel.GetStarTargetLocalizationText(i);
2024-01-31 16:24:32 +08:00
2024-08-06 13:40:53 +08:00
if (levelCfg != null)
{
var levelRewardL = levelRewardID[i];
if (levelRewardL.Count > 0)
{
var itemList = CommonUtils.GetFilterRewardItemList(levelRewardL);
for (int n = 0; n < itemList.Count; n++)
{
var list = itemList[n];
var itemID = list.ID;
var itemCfg = TableManager.Instance.Tables.Item.GetOrDefault(itemID);
if (itemCfg != null)
{
var name = CommonUtils.GetLocalizeText(itemCfg.NameLocal);
txtContent += name + "x" + list.Count;
}
}
}
}
2024-05-06 15:35:03 +08:00
2024-01-31 16:24:32 +08:00
txtGetItem.text = txtContent;
2024-08-06 13:40:53 +08:00
txtGetItemFailed.text = txtContent;
}
}
private void _RefreshCommonExp()
{
2024-09-26 19:25:46 +08:00
if (_isPvP)
{
Text_GeneralEX.gameObject.SetActive(false);
return;
}
var list = _itemList.Lists;
int itemCount = 0;
for (var i = ItemSource.LevelPassNormal; i <= ItemSource.LevelPassStar3; i++)
{
itemCount += _CalculateExpItemCount(list[(int)i]);
}
var settleData = LevelManager.Instance.SettleData;
Text_EXPHave.text = settleData.CommonExp.ToString();
Text_EXPGet.text = "+" + itemCount;
}
private int _CalculateExpItemCount(ItemCounts itemCounts)
{
int retCount = 0;
if (itemCounts.Ids.Count > 0)
{
var idx = itemCounts.Ids.IndexOf(3);
if (idx >= 0)
{
var count = itemCounts.Counts[idx];
retCount = (int)count;
}
}
2024-05-06 15:35:03 +08:00
return retCount;
}
private async void _RefreshHeads()
{
for (int i = 0; i < _itemHeadList.Count; i++)
{
_itemHeadList[i].IsScaleShow(false);
}
await AssetManager.Instance.WaitAllPreloads();
for (int i = 0; i < _itemHeadList.Count; i++)
{
_RefreshHead(i);
_itemHeadList[i].IsScaleShow(true);
}
}
2024-08-06 13:40:53 +08:00
private async void _RefreshHead(int idx)
{
var item = _itemHeadList[idx];
if (idx >= _charIDs.Count)
{
item.SetActive(false);
return;
}
item.SetActive(true);
var uid = _charIDs[idx];
var headNode = CommonUtils.GetComponent<UIHeadItemNode>(item, "HeadNode");
if (headNode)
{
var headInfo = new UIHeadInfo(uid);
headNode.SetData(headInfo);
headNode.Refresh(false);
}
2024-08-06 13:40:53 +08:00
var imgPro = CommonUtils.GetComponent<Image>(item, "ImageProfessionRect/ImageProfession");
var job = CommonUtils.GetProfessionByUid(uid);
var jobData = TableManager.Instance.Tables.JobAttri.GetOrDefault((int)job);
var spritePath = jobData.IconPath;
var sprite = await LoadAssetAsync<Sprite>(spritePath);
imgPro.sprite = sprite;
2024-09-26 19:25:46 +08:00
if (_isPvP)
{
CommonUtils.GetGameObject(item, "ImageFavorate").SetActive(false);
CommonUtils.GetGameObject(item, "ImageHeroEXpEmpty").SetActive(false);
CommonUtils.GetGameObject(item, "Image_SerialNumber").SetActive(false);
CommonUtils.GetGameObject(item, "TextHeroLV").SetActive(false);
return;
}
var txtTeamIdx = CommonUtils.GetComponent<TMP_Text>(item, "Image_SerialNumber/Text_Number");
var team = LevelManager.Instance.SettleData.Team;
var teamIdx = team.GetAllCharacterIdx(uid);//team.GetAllCharacters().IndexOf(uid);
txtTeamIdx.text = (teamIdx + 1).ToString();
2024-08-06 13:40:53 +08:00
var txtExpAdd = CommonUtils.GetComponent<TMP_Text>(item, "ImageHeroEXpEmpty/TextHeroEXPUp");
var imgExpProcess = CommonUtils.GetComponent<Image>(item, "ImageHeroEXpEmpty/ImageHeroEXpFull");
var txtLv = CommonUtils.GetComponent<TMP_Text>(item, "TextHeroLV");
var goMaxLevel = CommonUtils.GetGameObject(item, "Text_MaxLv");
bool isMaxLevel = CommonUtils.CheckIsCharacterMaxLevel(uid);
var addExp = _CalculateCharExpAdd(uid);
if (addExp > 0 && !isMaxLevel)
{
txtExpAdd.text = "+" + addExp;
}
else
{
txtExpAdd.text = "";
}
if (CharacterDataInfoManager.Instance.DataDic.TryGetValue(uid, out var charDataInfo))
{
if (isMaxLevel)
{
imgExpProcess.fillAmount = 1;
goMaxLevel.SetActiveEx(true);
2024-11-14 19:22:16 +08:00
txtLv.text = CommonUtils.GetLocalizeText("level_desc_pre") + " " + charDataInfo.Level;
}
else
{
goMaxLevel.SetActiveEx(false);
var cur = charDataInfo.Exp;
var cfg = TableManager.Instance.Tables.CharacterLevelExp.GetOrDefault((int)charDataInfo.Level + 1);
var process = (float)cur / cfg.EXP;
imgExpProcess.fillAmount = process;
2024-11-14 19:22:16 +08:00
txtLv.text = CommonUtils.GetLocalizeText("level_desc_pre") + " " + charDataInfo.Level;
}
}
2024-01-22 13:45:43 +08:00
var imgLikely = CommonUtils.GetComponent<Image>(item, "ImageFavorate");
var txtLikely = CommonUtils.GetComponent<TMP_Text>(item, "ImageFavorate/TextFavorateEXp");
var likely = _CalculateLikely(uid);
if (likely > 0)
{
txtLikely.text = "+" + likely;
imgLikely.gameObject.SetActive(true);
}
else
{
imgLikely.gameObject.SetActive(false);
}
}
#endregion
2024-01-22 13:45:43 +08:00
#region Data
2024-07-22 19:59:13 +08:00
private int _CalculateCharExpAdd(uint roleID)
{
2024-07-22 19:59:13 +08:00
int add = 0;
2024-01-22 13:45:43 +08:00
var lvExp = LevelManager.Instance.SettleData.ExpDic[roleID];
2024-05-06 15:35:03 +08:00
if (CharacterDataInfoManager.Instance.DataDic.TryGetValue(roleID, out var charDataInfo))
{
var oldLv = lvExp.Lv;
2024-07-22 19:59:13 +08:00
var oldExp = (int)lvExp.Exp;
var curLv = charDataInfo.Level;
2024-07-22 19:59:13 +08:00
var curExp = (int)charDataInfo.Exp;
if (curLv == TableManager.Instance.Tables.CharacterLevelExp.DataList.Count)
{
return 0;
}
if (oldLv < curLv)
{
2024-07-22 19:59:13 +08:00
var expCfg = TableManager.Instance.Tables.CharacterLevelExp.GetOrDefault((int)oldLv + 1);
add += (expCfg.EXP - oldExp);
2024-05-06 15:35:03 +08:00
for (uint i = oldLv + 1; i < curLv; i++)
{
var cfg = TableManager.Instance.Tables.CharacterLevelExp.GetOrDefault((int)i + 1);
2024-07-22 19:59:13 +08:00
add += cfg.EXP;
}
add += curExp;
}
else
{
add += curExp - oldExp;
}
}
return add;
}
2024-08-12 19:31:50 +08:00
private int _CalculateLikely(uint roleID)
2024-01-22 13:45:43 +08:00
{
2024-08-12 19:31:50 +08:00
int retCount = 0;
2024-01-22 13:45:43 +08:00
var lvExp = LevelManager.Instance.SettleData.FavorDic[roleID];
if (CharacterDataInfoManager.Instance.DataDic.TryGetValue(roleID, out var charDataInfo))
{
2024-08-12 19:31:50 +08:00
var oldExp = (int)lvExp.Exp;
var oldLv = (int)lvExp.Lv;
2024-05-06 15:35:03 +08:00
2024-08-12 19:31:50 +08:00
var curLv = (int)charDataInfo.LikelyLevel;
var curExp = (int)charDataInfo.LikelyExp;
2024-05-06 15:35:03 +08:00
2024-01-22 13:45:43 +08:00
if (oldLv < curLv)
{
2024-08-12 19:31:50 +08:00
var expCfg = TableManager.Instance.Tables.CharacterLikability.Get((int)roleID, oldLv + 1);
if (expCfg == null)
{
return 0;
}
retCount += expCfg.LikabilityExp - oldExp;
2024-05-06 15:35:03 +08:00
2024-08-12 19:31:50 +08:00
for (int i = oldLv + 1; i < curLv; i++)
2024-01-22 13:45:43 +08:00
{
2024-08-12 19:31:50 +08:00
var cfg = TableManager.Instance.Tables.CharacterLikability.Get((int)roleID, i + 1);
retCount += cfg.LikabilityExp;
2024-01-22 13:45:43 +08:00
}
retCount += curExp;
}
else
{
retCount += curExp - oldExp;
}
}
2024-05-06 15:35:03 +08:00
2024-01-22 13:45:43 +08:00
return retCount;
}
2024-05-06 15:35:03 +08:00
2024-01-22 13:45:43 +08:00
#endregion
private async void _OnClickClose()
{
2024-09-26 19:25:46 +08:00
if (_isPlayingAnim || _isPlaying)
return;
2024-08-13 14:29:50 +08:00
int rewardCnt = 0;
foreach(var item in _itemList.Lists)
{
rewardCnt += item.Counts.Count;
}
async void Cb()
{
await GameSceneHelper.Instance.UnLoadSceneForRt();
AudioManager.Instance.StopAll();
AudioManager.Instance.ReleaseAllAudios();
LevelManager.Instance.ExitLevelDirectly();
EffectManager.instance.rootObj.SetActive(true);
2024-10-18 12:52:11 +08:00
//PVPManager.Instance.RewardItemList = null;
CloseWindow();
}
2024-09-27 19:42:19 +08:00
if (_isPvP)
{
if (rewardCnt <= 0)
{
await GameSceneHelper.Instance.UnLoadSceneForRt();
2024-09-27 19:42:19 +08:00
AudioManager.Instance.StopAll();
AudioManager.Instance.ReleaseAllAudios();
LevelManager.Instance.ExitLevelDirectly();
EffectManager.instance.rootObj.SetActive(true);
2024-10-18 12:52:11 +08:00
//PVPManager.Instance.RewardItemList = null;
2024-09-27 19:42:19 +08:00
CloseWindow();
return;
}
await UI_GetItemWindowController.Open(_itemList, UI_GetItemWindowController.EShowType.StorySettle, Cb);
2024-09-27 19:42:19 +08:00
return;
}
if (rewardCnt > 0)
{
//await UI_GetItemSettleController.Open(_itemList);
await UI_GetItemWindowController.Open(_itemList, UI_GetItemWindowController.EShowType.StorySettle, cb: () =>
{
ExitFromLevel();
});
2024-09-23 18:00:15 +08:00
if (isSweep)
CloseWindow();
return;
}
2024-09-26 19:25:46 +08:00
await GameSceneHelper.Instance.UnLoadSceneForRt();
AudioManager.Instance.StopAll();
AudioManager.Instance.ReleaseAllAudios();
LevelManager.Instance.ExitLevelDirectly();
EffectManager.instance.rootObj.SetActive(true);
2024-09-26 19:25:46 +08:00
CloseWindow();
}
async void ExitFromLevel()
{
await GameSceneHelper.Instance.UnLoadSceneForRt();
AudioManager.Instance.StopAll();
2024-10-16 15:18:33 +08:00
AudioManager.Instance.ReleaseAllAudios();
LevelManager.Instance.ExitLevelDirectly();
EffectManager.instance.rootObj.SetActive(true);
UIManager.Instance.CloseWindow(UINameConst.UIMissionWin);
}
#region Anim
private async void _PlayAnim(float process)
{
if (!_isPlayingAnim)
{
_seq = DOTween.Sequence();
_isPlayingAnim = true;
//await UniTask.Delay(250);
_seq.AppendInterval(0.4f);
if (_playerLvUp > 0)
{
for (int i = 1; i <= _playerLvUp; i++)
{
_seq.Append(Image_EXFull.DOFillAmount(1, 0.8f));
_seq.AppendCallback(() =>
{
Image_EXFull.fillAmount = 0;
});
}
}
2024-10-18 14:04:34 +08:00
if (process > 0 && !isAddUpAnim)
{
2024-10-18 14:04:34 +08:00
isAddUpAnim = true;
_seq.Append(Image_EXFull.DOFillAmount(process, 0.5f));
_seq.AppendInterval(0.25f);
_seq.AppendCallback(_ShowLevelupWindow);
_seq.AppendInterval(0.25f);
_seq.AppendCallback(() =>
{
_isPlayingAnim = false;
});
}
2024-10-23 18:31:49 +08:00
else
{
_seq.AppendCallback(_ShowLevelupWindow);
_seq.AppendInterval(0.25f);
2024-10-23 18:31:49 +08:00
_seq.AppendCallback(() =>
{
_isPlayingAnim = false;
});
}
}
}
private async void _ShowLevelupWindow()
{
if (_playerLvUp < 1)
{
return;
}
2024-10-18 14:04:34 +08:00
var oldLvExp = LevelManager.Instance.SettleData.PlayerLvExp;
var curLv = Actor.Instance.Base.GetProp(ActorProp.Level);
await UI_PlayerLevelUpInfoController.Open((int)oldLvExp.Lv, (int)curLv);
}
#endregion
2024-09-26 19:25:46 +08:00
#region PVP
private void _RefreshPvP()
{
if (!_isPvP)
{
return;
}
_goMissionDetail.SetActive(false);
_goCharDetail.SetActive(false);
_goWarDetail.SetActive(false);
_goPvPDetail.SetActive(true);
_RefreshTitle();
_RefreshAnim();
}
private void _RefreshTitle()
{
if (_isPvPSuccess)
{
Text_Win.text = CommonUtils.GetLocalizeText("pvp_settle_title_suc");
return;
}
Text_Win.text = CommonUtils.GetLocalizeText("pvp_settle_title_defeat");
}
private void _RefreshAnim()
{
if (_seqPvp == null)
{
_seqPvp = DOTween.Sequence();
}
_RefreshPvPScore();
_RefreshPvPRank();
}
private void _RefreshPvPScore()
{
var old = _settleData.Score;
var now = _newPVPData.Score;
var add = now - old;
var txtScoreChange = CommonUtils.GetComponent<TMP_Text>(_goPvPDetail, "Image_Score/Text_Change");
var txtScore = CommonUtils.GetComponent<TMP_Text>(_goPvPDetail, "Image_Score/Text_Current");
var imgAdd = CommonUtils.GetComponent<Image>(_goPvPDetail, "Image_Score/Image_Increase");
var imgDecrease = CommonUtils.GetComponent<Image>(_goPvPDetail, "Image_Score/Image_Decrease");
if (add == 0)
txtScoreChange.text = "";
else
{
imgAdd.gameObject.SetActive(_isPvPSuccess);
imgDecrease.gameObject.SetActive(!_isPvPSuccess);
txtScoreChange.text = _isPvPSuccess? $"<color=#B9BC09>+{add}</color>" : $"<color=#C61D1B>{add}</color>";
2024-09-26 19:25:46 +08:00
}
_PlayScoreAnim(old, now, txtScore);
}
private void _RefreshPvPRank()
{
var old = _settleData.Rank;
var now = _newPVPData.Rank;
var add = old - now;
var txtRankChange = CommonUtils.GetComponent<TMP_Text>(_goPvPDetail, "Image_Ranking/Text_Change");
var txtScore = CommonUtils.GetComponent<TMP_Text>(_goPvPDetail, "Image_Ranking/Text_Current");
var imgAdd = CommonUtils.GetComponent<Image>(_goPvPDetail, "Image_Ranking/Image_Increase");
var imgDecrease = CommonUtils.GetComponent<Image>(_goPvPDetail, "Image_Ranking/Image_Decrease");
if (add == 0)
txtRankChange.text = "";
else
{
if (old <= 0 && add < 0)
{
add = -add;
}
imgAdd.gameObject.SetActive(_isPvPSuccess);
imgDecrease.gameObject.SetActive(!_isPvPSuccess);
txtRankChange.text = _isPvPSuccess? $"<color=#B9BC09>+{add}</color>" : $"<color=#C61D1B>{add}</color>";
2024-09-26 19:25:46 +08:00
}
_PlayRankAnim(old, now, txtScore);
}
private void _PlayScoreAnim(int old, int now, TMP_Text txt)
{
var tw = DOTween.To(() => old, value =>
{
_isPlaying = true;
txt.text = value.ToString();
}, now, 1.5f);
_seqPvp.Append(tw);
}
private void _PlayRankAnim(int old, int now, TMP_Text txt)
{
var tw = DOTween.To(() => old, value =>
{
txt.text = value.ToString();
}, now, 1.5f);
_seqPvp.Join(tw);
_seqPvp.AppendCallback(() =>
{
_isPlaying = false;
});
}
#endregion
2024-05-06 15:35:03 +08:00
}