先修复一下,错误的场景 删除不必要的钓场资产 修复into场景 update:更新meta文件,修复报错 update:修复资源 修复第一章节建造 修复建造第三章 update:删除多余内容 update:更新README.md update:还原图标 update:更新README update:更新配置
1385 lines
46 KiB
C#
1385 lines
46 KiB
C#
using asap.core;
|
||
using DG.Tweening;
|
||
using game;
|
||
using GameCore;
|
||
using TMPro;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
using UniRx;
|
||
using cfg;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
public class BuildingData
|
||
{
|
||
public float upgradeTime;
|
||
public int curStep;
|
||
public string CurrentPrefab;
|
||
|
||
public int areaStepCount;
|
||
public int areaIndex;
|
||
public int turnOffTimeScale;
|
||
/// <summary>
|
||
/// 以下是下一步的数据
|
||
/// </summary>
|
||
public bool isConstructionCost;
|
||
public int required;
|
||
public ulong NextUpgradeCost;
|
||
public List<int> benefitsLevel;
|
||
public string Icon;
|
||
public string Title_l10n_key;
|
||
public List<int> DisplaySwitch;
|
||
public int Rewards;
|
||
public int NextStep;
|
||
public int NextStepCount;
|
||
public int NextTimelineId;
|
||
public float NextStartTime;
|
||
public float NextDuration;
|
||
public string NextPrefab;
|
||
public int NextOffTimeScale;
|
||
|
||
}
|
||
|
||
public class CampPanel : BasePanel
|
||
{
|
||
private PlayerData _playerData;
|
||
private CampDataMM _campData;
|
||
private Tables _table;
|
||
private IUIService _uiService;
|
||
private ILoadResourceService _loadResourceService;
|
||
private BuffDataCenter _buffDataCenter;
|
||
private PlayerItemData _playerItemData;
|
||
private GuideDataCenter _guideDataCenter;
|
||
private PlayerShopData _playerShopData;
|
||
private IUserService _userService;
|
||
// MMTService removed - A/B test switch defaults to false
|
||
|
||
private CanvasGroup canvasGroup;
|
||
private Animator animator;
|
||
public TextMeshProUGUI areaInfo;
|
||
|
||
public TextMeshProUGUI text_progress;
|
||
private string text_progress_string = "0/0";
|
||
public TextMeshProUGUI cost;
|
||
private GameObject costRoot;
|
||
private TMP_Text text_cost_buff;
|
||
private TMP_Text text_old;
|
||
private TMP_Text text_info;
|
||
TMP_Text text_info2;
|
||
public RewardItemNew[] bg_reward;
|
||
private Image[] rewardBg;
|
||
public Image costIcon;
|
||
private GameObject barGo1;
|
||
private GameObject barGo2;
|
||
private GameObject barGo3;
|
||
private Image bar1;
|
||
private Image bar2;
|
||
private Image bar3;
|
||
public Image currentBar;
|
||
private CanvasGroup DownPanel;
|
||
private UIButton upgradeButton;
|
||
private GameObject tip_fast;
|
||
private GameObject btn_icon;
|
||
private GameObject btn_fix;
|
||
private Animator upButtonAni;
|
||
public UIDrag uiDrag;
|
||
public Button btn_close;
|
||
private Button btn_right;
|
||
private Animation camp_target;
|
||
|
||
private CanvasGroup top_area_canvas;
|
||
UITopArea top_area;
|
||
private float _upgradeTime;
|
||
private bool _isUpgrading;
|
||
private ulong _upgradeCost;
|
||
ulong _curGold;
|
||
private bool isStart = false;
|
||
private bool isdrag = false;
|
||
private bool fixIng = false;
|
||
private GameObject particle;
|
||
private GameObject kuang;
|
||
private bool isAutoBuilding = false;
|
||
private bool isAutoQuickBuilding = false;
|
||
/// <summary> 本轮长按是否曾进入极速建造 UI(镜头/全屏 loop);不能仅用 IsAutoQuickBuilding(),因金币不足会先清 isAutoBuilding,或某步 turnOffTimeScale 会清 isAutoQuickBuilding。 </summary>
|
||
private bool _quickBuildFxSessionActive = false;
|
||
private bool isHolding = false;
|
||
private Coroutine startTimer;
|
||
private Coroutine _fastBuildScreenLoopFxRoutine;
|
||
|
||
private GameObject fx_autofastbuild_button_hold;
|
||
private GameObject fx_autofastbuild_screen_loop;
|
||
|
||
private TMP_Text text_name;
|
||
private Button btn_go;
|
||
private GameObject btn_p_text;
|
||
private GameObject btn_text_confirm;
|
||
private bool isCampPanel_fade = false;
|
||
private List<ItemData> levelItemDatas;
|
||
private float buildingSpeed = 1;
|
||
private float maxSpeed = 1.5f;
|
||
/// <summary> 快速建造时镜头 360° 旋转一圈时长(秒),可配置 </summary>
|
||
private float FastBuildCameraRotationDuration => _table.TbGlobalConfig.RotationDuration;
|
||
/// <summary> 极速 UI 渐隐后再播全屏 loop 特效的延迟(秒),与 CampPanel_fade_fastauto 节奏对齐 </summary>
|
||
[SerializeField] private float _fastAutoScreenLoopFxDelaySeconds = 1f;
|
||
/// <summary> 快速建造结束后,进度条匀速增长的速度(填充量/秒),值越大进度条跑得越快 </summary>
|
||
private int rewardLen = 0;
|
||
|
||
private Queue<BuildingData> buildingDatas = new Queue<BuildingData>();
|
||
private int _currentBuildingAreaIndex = -1;
|
||
private void Awake()
|
||
{
|
||
// 一次性解析所有需要的依赖
|
||
ResolveDependencies();
|
||
var topArea = transform.Find("top_area");
|
||
top_area_canvas = topArea.GetComponent<CanvasGroup>();
|
||
top_area = topArea.GetComponent<UITopArea>();
|
||
particle = topArea.Find("particle").gameObject;
|
||
|
||
maxSpeed = 1 + _table.TbGlobalConfig.TimeScalePerStep * _table.TbGlobalConfig.AccMaxStep;
|
||
canvasGroup = GetComponent<CanvasGroup>();
|
||
animator = GetComponent<Animator>();
|
||
|
||
var safearea = transform.Find("safearea");
|
||
uiDrag = safearea.Find("Image").GetComponent<UIDrag>();
|
||
|
||
var middlePanel = safearea.Find("MiddlePanel");
|
||
text_name = middlePanel.Find("completed/text_name").GetComponent<TMP_Text>();
|
||
var campTarget = middlePanel.Find("camp_target");
|
||
camp_target = campTarget.GetComponent<Animation>();
|
||
bg_reward = campTarget.Find("reward").GetComponentsInChildren<RewardItemNew>();
|
||
rewardBg = new Image[bg_reward.Length];
|
||
for (int i = 0; i < bg_reward.Length; i++)
|
||
{
|
||
rewardBg[i] = bg_reward[i].transform.Find("bg").GetComponent<Image>();
|
||
}
|
||
var bgBar = campTarget.Find("bg_bar");
|
||
areaInfo = bgBar.Find("text_areaInfo").GetComponent<TextMeshProUGUI>();
|
||
text_progress = bgBar.Find("bg_progress/text_progress").GetComponent<TextMeshProUGUI>();
|
||
barGo1 = bgBar.Find("bar1").gameObject;
|
||
barGo2 = bgBar.Find("bar2").gameObject;
|
||
barGo3 = bgBar.Find("bar3").gameObject;
|
||
bar1 = barGo1.transform.Find("bar").GetComponent<Image>();
|
||
bar2 = barGo2.transform.Find("bar").GetComponent<Image>();
|
||
bar3 = barGo3.transform.Find("bar").GetComponent<Image>();
|
||
|
||
var downPanel = safearea.Find("DownPanel");
|
||
DownPanel = downPanel.GetComponent<CanvasGroup>();
|
||
btn_close = downPanel.Find("btn_close").GetComponent<Button>();
|
||
btn_right = downPanel.Find("btn_right").GetComponent<Button>();
|
||
var btnConstruct = downPanel.Find("btn_construct");
|
||
upgradeButton = btnConstruct.GetComponent<UIButton>();
|
||
upButtonAni = btnConstruct.GetComponent<Animator>();
|
||
tip_fast = btnConstruct.Find("tip_fast/tip_fast").gameObject;
|
||
btn_icon = btnConstruct.Find("icon").gameObject;
|
||
btn_fix = btnConstruct.Find("fix").gameObject;
|
||
kuang = btnConstruct.Find("kuang_glow").gameObject;
|
||
text_info = btnConstruct.Find("text_info").GetComponent<TMP_Text>();
|
||
text_info2 = btnConstruct.Find("text_info2").GetComponent<TMP_Text>();
|
||
var costRootTr = btnConstruct.Find("CostRoot");
|
||
costRoot = costRootTr.gameObject;
|
||
cost = costRootTr.Find("text_cost").GetComponent<TextMeshProUGUI>();
|
||
costIcon = costRootTr.Find("text_cost/icon_cost").GetComponent<Image>();
|
||
text_cost_buff = costRootTr.Find("text_cost_buff").GetComponent<TMP_Text>();
|
||
text_old = text_cost_buff.transform.Find("text_old").GetComponent<TMP_Text>();
|
||
var btnGreen = downPanel.Find("reward/btn_go/btn_green");
|
||
btn_go = btnGreen.GetComponent<Button>();
|
||
var aniContainer = btnGreen.Find("Ani_Container");
|
||
btn_p_text = aniContainer.Find("p_text").gameObject;
|
||
btn_text_confirm = aniContainer.Find("text_confirm").gameObject;
|
||
|
||
fx_autofastbuild_button_hold = transform.Find("safearea/DownPanel/btn_construct/fx_ui_autofastbuild_button_hold")?.gameObject;
|
||
fx_autofastbuild_screen_loop = transform.Find("safearea/DownPanel/fx_ui_autofastbuild_screen_loop")?.gameObject;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 集中解析所有依赖
|
||
/// </summary>
|
||
private void ResolveDependencies()
|
||
{
|
||
_table = GContext.container.Resolve<cfg.Tables>();
|
||
_playerData = GContext.container.Resolve<PlayerData>();
|
||
_campData = GContext.container.Resolve<CampDataMM>();
|
||
_uiService = GContext.container.Resolve<IUIService>();
|
||
_loadResourceService = GContext.container.Resolve<ILoadResourceService>();
|
||
_buffDataCenter = GContext.container.Resolve<BuffDataCenter>();
|
||
_playerItemData = GContext.container.Resolve<PlayerItemData>();
|
||
_guideDataCenter = GContext.container.Resolve<GuideDataCenter>();
|
||
_playerShopData = GContext.container.Resolve<PlayerShopData>();
|
||
_userService = GContext.container.Resolve<IUserService>();
|
||
// MMTService removed
|
||
}
|
||
|
||
private void OnEnable()
|
||
{
|
||
GContext.container.RegisterInstance(this);
|
||
// 替换原有Resolve
|
||
btn_icon.SetActive(!_campData.IsFix);
|
||
btn_fix.SetActive(_campData.IsFix);
|
||
upgradeButton.interactable = true;
|
||
_curGold = _playerData.gold;
|
||
GContext.Publish(new OnEventTriggerGuide(GetType().Name));
|
||
}
|
||
|
||
public void SetAlpha()
|
||
{
|
||
canvasGroup.alpha = DeBugPanel.isShow ? 1 : 0;
|
||
if (!DeBugPanel.isShow)
|
||
{
|
||
OnUpgradClick();
|
||
}
|
||
}
|
||
|
||
protected override void Start()
|
||
{
|
||
base.Start();
|
||
uiDrag.OnBeginDragCall = () =>
|
||
{
|
||
if (_isUpgrading)
|
||
{
|
||
return;
|
||
}
|
||
#if UNITY_EDITOR
|
||
if (Input.GetMouseButton(0))
|
||
#else
|
||
if (Input.touchCount == 1)
|
||
#endif
|
||
{
|
||
GContext.Publish(new SwitchVirtualCameraEvent() { type = 1, isDrag = _campData.constructionArea?.TurnOffFreeLook != 1 });
|
||
}
|
||
OnDraging();
|
||
};
|
||
|
||
upgradeButton.onDown.AddListener(StartClick);
|
||
upgradeButton.onUp.AddListener(EndClick);
|
||
btn_close.onClick.AddListener(OnCloseClick);
|
||
btn_go.onClick.AddListener(OnGoto);
|
||
SetAlpha();
|
||
|
||
GContext.OnEvent<ChangeLanguageEvent>().Subscribe(OnChangeLanguage).AddTo(disposables);
|
||
GContext.OnEvent<GetUIAsyncEvent>().Subscribe(GetUIAsyncEvent).AddTo(disposables);
|
||
GContext.OnEvent<RewardPanelClose>().Subscribe(OnRewardPanelClose).AddTo(disposables);
|
||
|
||
GContext.OnEvent<RestartShowHomeUIEvent>().Subscribe(_ =>
|
||
{
|
||
canvasGroup.alpha = 1;
|
||
canvasGroup.blocksRaycasts = true;
|
||
}).AddTo(disposables);
|
||
|
||
GContext.OnEvent<HideHomePanelEvent>().Subscribe(_ =>
|
||
{
|
||
canvasGroup.alpha = 0;
|
||
canvasGroup.blocksRaycasts = false;
|
||
}).AddTo(disposables);
|
||
|
||
GContext.OnEvent<ShowRewardPopupTop>().Subscribe(x =>
|
||
{
|
||
x.isHide = true;
|
||
}).AddTo(disposables);
|
||
|
||
transform.SetAsFirstSibling();
|
||
isStart = true;
|
||
BuildingData buildingData = new BuildingData();
|
||
buildingData.CurrentPrefab = _campData.CurrentPrefab;
|
||
UpdataData(buildingData);
|
||
UpdateAccount(buildingData);
|
||
UpdateDataInfo(buildingData);
|
||
isStart = false;
|
||
btn_right.onClick.AddListener(ToCampSkyscraper);
|
||
Input.multiTouchEnabled = true;
|
||
}
|
||
|
||
private void GetUIAsyncEvent(GetUIAsyncEvent data)
|
||
{
|
||
if (!data.show)
|
||
{
|
||
return;
|
||
}
|
||
if (IsAutoQuickBuilding()) return;
|
||
if (data.uIType != UITypes.RewardPopupPanel.Name
|
||
&& data.uIType != UITypes.VipPopupPanel.Name)
|
||
{
|
||
EndOutUpgrade();
|
||
}
|
||
}
|
||
|
||
private void OnDraging()
|
||
{
|
||
isdrag = true;
|
||
EndOutUpgrade();
|
||
}
|
||
|
||
protected override void OnDestroy()
|
||
{
|
||
base.OnDestroy();
|
||
DOTween.Kill(currentBar);
|
||
Input.multiTouchEnabled = false;
|
||
}
|
||
|
||
private void OnChangeLanguage(ChangeLanguageEvent changeLanguageEvent = null)
|
||
{
|
||
text_name.text = LocalizationMgr.GetText(_campData.Name);
|
||
var area = _campData.constructionArea;
|
||
if (area != null)
|
||
{
|
||
string AreaName = LocalizationMgr.GetText(area.Name_l10n_key) + LocalizationMgr.GetText(area.NameIndex_l10n_key);
|
||
areaInfo.text = AreaName;
|
||
}
|
||
text_progress.text = LocalizationMgr.GetFormatTextValue("UI_CampPanel_9", text_progress_string);
|
||
}
|
||
|
||
/// <summary>
|
||
/// 建造相关显示数据
|
||
/// </summary>
|
||
/// <param name="buildingData"></param>
|
||
private void UpdataData(BuildingData buildingData)
|
||
{
|
||
var step_info = _campData.StepInfo;
|
||
buildingData.NextTimelineId = _campData.TimelineId;
|
||
buildingData.NextStartTime = _campData.StepInfo.StartTime;
|
||
buildingData.NextDuration = _campData.StepInfo.PlayTime;
|
||
buildingData.NextPrefab = _campData.CurrentPrefab;
|
||
buildingData.NextOffTimeScale = _campData.constructionArea?.TurnOffTimeScale ?? 0;
|
||
_upgradeTime = step_info.PlayTime;
|
||
var buffTimeData = _buffDataCenter.GetWeelyBuffTimeData<ConstructionCost>();
|
||
buildingData.isConstructionCost = buffTimeData != null;
|
||
if (_campData.IsFix)
|
||
{
|
||
buildingData.required = step_info.FixRequired;
|
||
}
|
||
else
|
||
{
|
||
buildingData.required = step_info.BuildRequired;
|
||
}
|
||
if (buildingData.isConstructionCost)
|
||
{
|
||
_upgradeCost = (ulong)(buildingData.required * (1 - buffTimeData.Param));
|
||
}
|
||
else
|
||
{
|
||
_upgradeCost = (ulong)buildingData.required;
|
||
}
|
||
buildingData.NextUpgradeCost = _upgradeCost;
|
||
buildingData.NextStep = _campData.AreaStep;
|
||
buildingData.NextStepCount = _campData.AreaStepCount;
|
||
|
||
if (!IsAutoQuickBuilding())
|
||
{
|
||
UpdateButtonInfo(buildingData);
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 等级奖励相关显示数据
|
||
/// </summary>
|
||
/// <param name="buildingData"></param>
|
||
private void UpdateAccount(BuildingData buildingData)
|
||
{
|
||
Account account = _playerData.nextAccountData;
|
||
buildingData.Icon = account.Icon;
|
||
buildingData.Title_l10n_key = account.Title_l10n_key;
|
||
buildingData.DisplaySwitch = account.DisplaySwitch;
|
||
buildingData.Rewards = account.Rewards;
|
||
buildingData.benefitsLevel = new List<int>
|
||
{
|
||
account.CashMag,
|
||
account.CashMagLimited,
|
||
account.EnergyLimit,
|
||
account.EnergyRecover,
|
||
account.EventFishCashMag,
|
||
account.EventFishDamage,
|
||
account.AquariumLimit,
|
||
account.AquariumCashMag,
|
||
};
|
||
}
|
||
|
||
/// <summary>
|
||
/// 刷新按钮显示
|
||
/// </summary>
|
||
/// <param name="buildingData"></param>
|
||
private void UpdateButtonInfo(BuildingData buildingData)
|
||
{
|
||
costRoot.gameObject.SetActive(true);
|
||
text_cost_buff.gameObject.SetActive(buildingData.isConstructionCost);
|
||
cost.gameObject.SetActive(!buildingData.isConstructionCost);
|
||
bool atLastBuildingStep = buildingData.NextStep >= buildingData.NextStepCount;
|
||
bool showFast = !atLastBuildingStep && CanShowFastBuildTip();
|
||
tip_fast.SetActive(showFast);
|
||
RefreshTextInfo(showFast);
|
||
if (showFast)
|
||
{
|
||
_guideDataCenter.TriggerGuide(GroupName.FastAutoBuild.ToString(), "CampPanel", false);
|
||
}
|
||
if (buildingData.isConstructionCost)
|
||
{
|
||
text_cost_buff.text = ConvertTools.GetNumberString(buildingData.NextUpgradeCost);
|
||
text_old.text = ConvertTools.GetNumberString(buildingData.required);
|
||
}
|
||
else
|
||
{
|
||
cost.text = ConvertTools.GetNumberString(buildingData.required);
|
||
}
|
||
}
|
||
|
||
private void RefreshTextInfo(bool showFast)
|
||
{
|
||
text_info.text = showFast
|
||
? LocalizationMgr.GetText("UI_CampPanel_24")
|
||
: LocalizationMgr.GetText("UI_CampPanel_1");
|
||
text_info2.text = showFast
|
||
? LocalizationMgr.GetText("UI_CampPanel_25")
|
||
: LocalizationMgr.GetText("UI_CampPanel_2");
|
||
}
|
||
|
||
private bool CanShowFastBuildTip()
|
||
{
|
||
if (true) // MMTService removed: MMTFastAutoBuildSwitchValue defaults to false
|
||
{
|
||
return false;
|
||
}
|
||
if (_campData.IsFix || _playerData.lv <= _table.TbGlobalConfig.AutoBuildUnlock || _playerData.lv < _table.TbGlobalConfig.FastAutoBuildUnlockParam)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
if (_campData.AreaIndex >= _campData.AreaList.Count || _campData.AreaStepList == null || _campData.AreaStep >= _campData.AreaStepList.Count)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
if (_campData.constructionArea?.TurnOffTimeScale == 1)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
int required = _campData.GetStepRequired(_table.TbGlobalConfig.FastAutoBuildUnlockLevel);
|
||
return required > 0 && (ulong)required <= _playerData.gold;
|
||
}
|
||
|
||
private void RefreshButtonInfoAfterAutoBuild()
|
||
{
|
||
if (_campData.AreaIndex >= _campData.AreaList.Count || _campData.StepInfo == null)
|
||
{
|
||
tip_fast.SetActive(false);
|
||
RefreshTextInfo(false);
|
||
return;
|
||
}
|
||
|
||
var buildingData = new BuildingData();
|
||
UpdataData(buildingData);
|
||
}
|
||
|
||
private bool IsAutoQuickBuilding()
|
||
{
|
||
return isAutoBuilding && isAutoQuickBuilding;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 刷新建造步骤 等级奖励两部分
|
||
/// </summary>
|
||
/// <param name="buildingData"></param>
|
||
private void UpdateDataInfo(BuildingData buildingData)
|
||
{
|
||
_uiService.SetImageSprite(costIcon, _table.GetItemIconName(1002), PanelName);
|
||
|
||
if (buildingData.Rewards > 0)
|
||
{
|
||
levelItemDatas = _playerItemData.GetItemDataByDropIdLureInflation(null, buildingData.Rewards);
|
||
}
|
||
else
|
||
{
|
||
levelItemDatas = null;
|
||
}
|
||
UpdateUIInfo(buildingData);
|
||
if (buildingData.NextStep >= buildingData.NextStepCount)
|
||
{
|
||
EndOutUpgrade();
|
||
#if AGG
|
||
using (var e = GEvent.GameEvent("open_new"))
|
||
{
|
||
e.AddContent("open_type", 2)
|
||
.AddContent("buliding_id", _campData.NextMapID);
|
||
|
||
}
|
||
#endif
|
||
}
|
||
}
|
||
void UpdateUIInfo(BuildingData buildingData)
|
||
{
|
||
text_name.text = LocalizationMgr.GetText(_campData.Name);
|
||
var area = _campData.constructionArea;
|
||
if (area != null)
|
||
areaInfo.text = LocalizationMgr.GetText(area.Name_l10n_key) + LocalizationMgr.GetText(area.NameIndex_l10n_key);
|
||
rewardLen = 0;
|
||
if (!string.IsNullOrEmpty(buildingData.Icon))
|
||
{
|
||
_uiService.SetImageSprite(rewardBg[rewardLen], "bg_shop_gift1");
|
||
bg_reward[rewardLen].SetData(buildingData.Icon, LocalizationMgr.GetText(buildingData.Title_l10n_key), LocalizationMgr.GetText("UI_PlayerGradePanel_1"));
|
||
rewardLen++;
|
||
}
|
||
var DisplaySwitch = buildingData.DisplaySwitch;
|
||
|
||
var levels = buildingData.benefitsLevel;
|
||
|
||
int id;
|
||
Item item;
|
||
for (int i = 0; i < DisplaySwitch.Count; i++)
|
||
{
|
||
if (rewardLen >= bg_reward.Length || i >= levels.Count)
|
||
{
|
||
break;
|
||
}
|
||
if (DisplaySwitch[i] > 0)
|
||
{
|
||
id = 12001 + i;
|
||
item = _table.TbItem.GetOrDefault(id);
|
||
_uiService.SetImageSprite(rewardBg[rewardLen], "bg_grade_benefit");
|
||
bg_reward[rewardLen].SetData(item, levels[i], true);
|
||
rewardLen++;
|
||
}
|
||
}
|
||
if (buildingData.Rewards > 0)
|
||
{
|
||
// 替换原有Resolve
|
||
var levelItemDatas = _playerItemData.GetItemDataByDropIdLureInflation(null, buildingData.Rewards);
|
||
if (levelItemDatas != null)
|
||
{
|
||
for (int i = 0; i < levelItemDatas.Count; i++)
|
||
{
|
||
if (rewardLen >= bg_reward.Length)
|
||
{
|
||
break;
|
||
}
|
||
_uiService.SetImageSprite(rewardBg[rewardLen], "bg_shop_gift1");
|
||
bg_reward[rewardLen].SetData(levelItemDatas[i], true, true);
|
||
rewardLen++;
|
||
}
|
||
}
|
||
}
|
||
for (int i = rewardLen; i < bg_reward.Length; i++)
|
||
{
|
||
bg_reward[i].gameObject.SetActive(false);
|
||
}
|
||
|
||
barGo1.SetActive(rewardLen >= 3);
|
||
barGo2.SetActive(rewardLen == 2);
|
||
barGo3.SetActive(rewardLen == 1);
|
||
currentBar = rewardLen >= 3 ? bar1 : rewardLen == 2 ? bar2 : bar3;
|
||
text_progress_string = $"{buildingData.NextStep}/{buildingData.NextStepCount}";
|
||
text_progress.text = LocalizationMgr.GetFormatTextValue("UI_CampPanel_9", text_progress_string);
|
||
currentBar.fillAmount = (float)(buildingData.NextStep) / buildingData.NextStepCount;
|
||
_uiService.SetImageSprite(costIcon, _table.GetItemIconName(1002), PanelName);
|
||
|
||
if (buildingData.NextStep >= buildingData.NextStepCount)
|
||
{
|
||
bool isNext = _campData.NextMapID != -1;
|
||
if (isNext)
|
||
{
|
||
isNext = _table.TbConstruction.DataMap.ContainsKey(_campData.NextMapID);
|
||
}
|
||
btn_p_text.SetActive(isNext);
|
||
btn_text_confirm.SetActive(!isNext);
|
||
text_name.text = LocalizationMgr.GetText(_campData.Name);
|
||
|
||
OnLastBuilding();
|
||
}
|
||
btn_right.gameObject.SetActive(_campData.IsOpenSkyscraper);
|
||
}
|
||
private void OnLastBuilding()
|
||
{
|
||
canvasGroup.blocksRaycasts = false;
|
||
if (isStart)
|
||
{
|
||
animator.Play("CampPanel_show2");
|
||
canvasGroup.blocksRaycasts = true;
|
||
}
|
||
else
|
||
{
|
||
CurRewardQCount curRewardQCount = new CurRewardQCount();
|
||
GContext.Publish(curRewardQCount);
|
||
if (curRewardQCount.count > 0)
|
||
{
|
||
isCampPanel_fade = true;
|
||
}
|
||
else
|
||
{
|
||
CampPanel_show2();
|
||
}
|
||
}
|
||
}
|
||
|
||
private async void CampPanel_show2()
|
||
{
|
||
GContext.Publish(new SwitchVirtualCameraEvent() { type = 11, isDrag = true });
|
||
await UIManager.Instance.ShowUI(UITypes.TravelMapCampPhotoPanel);
|
||
UIManager.Instance.DestroyUI(UITypes.CampPanel);
|
||
}
|
||
|
||
private async void OnGoto()
|
||
{
|
||
canvasGroup.blocksRaycasts = false;
|
||
var mapData = _table.TbMapData.DataMap[_playerData.lastMapId];
|
||
bool isCanEnter = await _loadResourceService.Load(mapData.EnvName);
|
||
if (isCanEnter)
|
||
{
|
||
EnterMap();
|
||
}
|
||
else
|
||
{
|
||
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
||
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, EnterMap, OnCloseClick, false);
|
||
canvasGroup.blocksRaycasts = true;
|
||
}
|
||
}
|
||
|
||
private void EnterMap()
|
||
{
|
||
canvasGroup.blocksRaycasts = false;
|
||
if (_campData.NextMapID != -1)
|
||
{
|
||
_campData.ChangeNextCampID();
|
||
GContext.Publish(new ConditionTypeEvent(ConditionType.MapUnlocked, _campData.Id));
|
||
}
|
||
_playerData.SetCurrentMapId(_playerData.lastMapId);
|
||
OnCloseClick();
|
||
}
|
||
|
||
public void OnCloseClick()
|
||
{
|
||
if (IsAutoQuickBuilding())
|
||
{
|
||
upgradeButton.Up();
|
||
EndOutUpgrade();
|
||
return;
|
||
}
|
||
if (isAutoBuilding)
|
||
{
|
||
upgradeButton.Up();
|
||
EndOutUpgrade();
|
||
}
|
||
if (_isUpgrading) return;
|
||
GContext.Publish(new UnloadActToNextAct());
|
||
}
|
||
|
||
private void StartClick()
|
||
{
|
||
if (!isAutoBuilding)
|
||
{
|
||
upButtonAni.Play("clicked", -1, 0);
|
||
if (_guideDataCenter.curDefine == null ||
|
||
_guideDataCenter.curDefine.fingerType == FingerType.None)
|
||
{
|
||
buildingSpeed = 1;
|
||
|
||
bool canAuto = OnClickUp();
|
||
if (canAuto && _playerData.lv > _table.TbGlobalConfig.AutoBuildUnlock && !_campData.IsFix)
|
||
{
|
||
if (!_isUpgrading)
|
||
{
|
||
return;
|
||
}
|
||
|
||
if (CanShowFastBuildTip())
|
||
PlayEffect(fx_autofastbuild_button_hold);
|
||
|
||
startTimer = StartCoroutine(StartTimer());
|
||
}
|
||
}
|
||
else if (_playerData.lv > _table.TbGlobalConfig.AutoBuildUnlock && !_campData.IsFix)
|
||
{
|
||
startTimer = StartCoroutine(StartTimer());
|
||
}
|
||
}
|
||
else
|
||
{
|
||
EndOutUpgrade();
|
||
}
|
||
}
|
||
|
||
private void EndClick()
|
||
{
|
||
isHolding = false;
|
||
if (!isAutoBuilding)
|
||
{
|
||
StopEffect(fx_autofastbuild_button_hold);
|
||
StopCoroutineTimer();
|
||
if (DownPanel.blocksRaycasts)
|
||
upButtonAni.Play("Normal", -1, 0);
|
||
}
|
||
}
|
||
|
||
private void StopCoroutineTimer()
|
||
{
|
||
isHolding = false;
|
||
|
||
if (startTimer != null)
|
||
{
|
||
StopCoroutine(startTimer);
|
||
startTimer = null;
|
||
}
|
||
}
|
||
|
||
private void PlayEffect(GameObject fx)
|
||
{
|
||
if (fx == null) return;
|
||
fx.SetActive(false);
|
||
fx.SetActive(true);
|
||
}
|
||
|
||
private void StopEffect(GameObject fx)
|
||
{
|
||
if (fx != null) fx.SetActive(false);
|
||
}
|
||
|
||
private IEnumerator StartTimer()
|
||
{
|
||
kuang.SetActive(false);
|
||
|
||
StopCoroutineTimer();
|
||
isHolding = true;
|
||
|
||
float HoldIntervalGeneral = _table.TbGlobalConfig.HoldIntervalGeneral;
|
||
|
||
yield return new WaitForSeconds(HoldIntervalGeneral);
|
||
buildingSpeed = 1;
|
||
StartOutUpgrade();
|
||
}
|
||
|
||
private async void PlayFix()
|
||
{
|
||
fixIng = true;
|
||
if (_playerData.gold > _upgradeCost)
|
||
_playerData.SetGold(_playerData.gold - _upgradeCost);
|
||
else
|
||
{
|
||
_playerData.SetGold(0);
|
||
}
|
||
GContext.Publish(new ResAddEvent(1002));
|
||
OnUpgradeBuildingFix onUpgradeBuildingFix = new OnUpgradeBuildingFix();
|
||
GContext.Publish(onUpgradeBuildingFix);
|
||
bool fix = await onUpgradeBuildingFix.ts.Task;
|
||
if (fix)
|
||
{
|
||
isdrag = true;
|
||
}
|
||
btn_icon.SetActive(!_campData.IsFix);
|
||
btn_fix.SetActive(_campData.IsFix);
|
||
BuildingData buildingData = new BuildingData();
|
||
buildingData.CurrentPrefab = _campData.CurrentPrefab;
|
||
UpdataData(buildingData);
|
||
UpdateAccount(buildingData);
|
||
UpdateDataInfo(buildingData);
|
||
OnUpgradeComplete(buildingData);
|
||
fixIng = false;
|
||
}
|
||
|
||
public bool CheckIsCanUpgrading(bool clickUp = false)
|
||
{
|
||
bool isCanUpgrading = true;
|
||
if (_curGold > _playerData.gold)
|
||
{
|
||
_curGold = _playerData.gold;
|
||
}
|
||
ulong curGold = _curGold;
|
||
if (!IsAutoQuickBuilding() || clickUp)
|
||
{
|
||
curGold = _playerData.gold;
|
||
}
|
||
if (curGold < _upgradeCost)
|
||
{
|
||
GContext.Publish(new VibrationData(HapticTypes.Failure));
|
||
#if AGG
|
||
using (var e = GEvent.GameEvent("lack_resources"))
|
||
{
|
||
e.AddContent("item_id", 1002)
|
||
.AddContent("lv", _playerData.lv);
|
||
}
|
||
#endif
|
||
if (_playerShopData.IsShopOpen)
|
||
{
|
||
bool isGuide = _guideDataCenter.TriggerGuide(_table.TbGlobalConfig.FixedGuidance, "CampPanel", false);
|
||
ToastPanel.Show(LocalizationMgr.GetText("UI_CampPanel_8"));
|
||
}
|
||
else
|
||
{
|
||
_guideDataCenter.TriggerGuide(_table.TbGlobalConfig.FixedGuidance, "CampPanel");
|
||
}
|
||
isCanUpgrading = false;
|
||
}
|
||
return isCanUpgrading;
|
||
}
|
||
|
||
private bool OnClickUp()
|
||
{
|
||
if (_campData.AreaIndex >= _campData.AreaList.Count)
|
||
{
|
||
GameDebug.Log("当前建造达最大等级");
|
||
return false;
|
||
}
|
||
|
||
if (!CheckIsCanUpgrading(true))
|
||
{
|
||
return false;
|
||
}
|
||
//修复
|
||
if (_campData.IsFix)
|
||
{
|
||
_isUpgrading = true;
|
||
_campData.SetIsFix(false);
|
||
PlayFix();
|
||
return false;
|
||
}
|
||
else if (!fixIng)
|
||
{
|
||
if (_isUpgrading && _currentBuildingAreaIndex != _campData.AreaIndex)
|
||
return true;
|
||
int remainingSteps = _campData.AreaStepCount - _campData.AreaStep;
|
||
if (_isUpgrading && remainingSteps + buildingDatas.Count < _table.TbGlobalConfig.TapMinSteps - 1)
|
||
return true;
|
||
|
||
AddBuildingData();
|
||
bool isSub = OnUpgradClick();
|
||
bool isMax = _isUpgrading && buildingDatas.Count >= _table.TbGlobalConfig.TapMinSteps - (isSub ? 0 : 1) && remainingSteps == 1;
|
||
if (isMax)
|
||
{
|
||
EndClick();
|
||
EndOutUpgrade();
|
||
DownPanel.blocksRaycasts = false;
|
||
upButtonAni.Play("Disabled", 0, 0);
|
||
costRoot.gameObject.SetActive(false);
|
||
}
|
||
return !isMax;
|
||
}
|
||
return false;
|
||
}
|
||
|
||
private void OneBuildingData()
|
||
{
|
||
if (_campData.AreaIndex >= _campData.AreaList.Count)
|
||
{
|
||
GameDebug.Log("当前建造达最大等级");
|
||
return;
|
||
}
|
||
|
||
if (!CheckIsCanUpgrading())
|
||
{
|
||
upButtonAni.Play("Normal", -1, 0);
|
||
isAutoBuilding = false;
|
||
return;
|
||
}
|
||
if (buildingDatas.Count == 0)
|
||
{
|
||
AddBuildingData();
|
||
}
|
||
}
|
||
|
||
private void AddBuildingData()
|
||
{
|
||
BuildingData buildingData = new BuildingData();
|
||
buildingData.upgradeTime = _upgradeTime;
|
||
buildingData.turnOffTimeScale = _campData.constructionArea?.TurnOffTimeScale ?? 0;
|
||
buildingData.curStep = _campData.AreaStep + 1;
|
||
buildingData.CurrentPrefab = _campData.CurrentPrefab;
|
||
buildingData.areaStepCount = _campData.AreaStepCount;
|
||
buildingData.areaIndex = _campData.AreaIndex;
|
||
_currentBuildingAreaIndex = _campData.AreaIndex;
|
||
buildingDatas.Enqueue(buildingData);
|
||
|
||
_curGold -= _upgradeCost;
|
||
if (_playerData.gold > _upgradeCost)
|
||
{
|
||
_playerData.SetGold(_playerData.gold - _upgradeCost);
|
||
}
|
||
else
|
||
{
|
||
_playerData.SetGold(0);
|
||
}
|
||
GContext.Publish(new ResAddEvent(1002));
|
||
_campData.NextStep();
|
||
UpdataData(buildingData);
|
||
}
|
||
|
||
public bool OnUpgradClick()
|
||
{
|
||
if (_isUpgrading)
|
||
{
|
||
return false;
|
||
}
|
||
|
||
if (buildingDatas.Count > 0)
|
||
{
|
||
_isUpgrading = true;
|
||
top_area_canvas.blocksRaycasts = false;
|
||
BuildingData buildingData = buildingDatas.Dequeue();
|
||
if (buildingData.turnOffTimeScale == 1)
|
||
{
|
||
isAutoQuickBuilding = false;
|
||
}
|
||
StartCoroutine(Upgrad(buildingData));
|
||
if (isdrag)
|
||
{
|
||
GContext.Publish(new SwitchVirtualCameraEvent() { type = 0, isDrag = _campData.constructionArea?.TurnOffFreeLook != 1 });
|
||
isdrag = false;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
EndOutUpgrade();
|
||
}
|
||
return true;
|
||
}
|
||
|
||
public IEnumerator Upgrad(BuildingData buildingData)
|
||
{
|
||
if (isdrag)
|
||
{
|
||
yield return Awaiters.Seconds(0.8f);
|
||
}
|
||
//升级
|
||
SetReward();
|
||
if (buildingData.turnOffTimeScale == 1)
|
||
{
|
||
buildingSpeed = 1;
|
||
}
|
||
if (IsAutoQuickBuilding())
|
||
{
|
||
buildingSpeed = _table.TbGlobalConfig.TimelineScale;
|
||
}
|
||
GEventBuild();
|
||
UpdateAccount(buildingData);
|
||
buildingData.upgradeTime = buildingData.upgradeTime / buildingSpeed;
|
||
if (!IsAutoQuickBuilding())
|
||
{
|
||
particle.SetActive(false);
|
||
particle.SetActive(true);
|
||
GContext.Publish(new VibrationData(HapticTypes.MediumImpact));
|
||
}
|
||
|
||
var fill_amount_target = (float)(buildingData.curStep) / buildingData.areaStepCount;
|
||
currentBar.DOFillAmount(fill_amount_target, buildingData.upgradeTime);
|
||
var upgradeEvt = UpgradeBuildingEvent(buildingData);
|
||
while (!upgradeEvt.CanContinue)
|
||
{
|
||
yield return null;
|
||
}
|
||
text_progress_string = $"{buildingData.curStep}/{buildingData.areaStepCount}";
|
||
text_progress.text = LocalizationMgr.GetFormatTextValue("UI_CampPanel_9", text_progress_string);
|
||
if (fill_amount_target > 0.999f)
|
||
{
|
||
if (IsAutoQuickBuilding())
|
||
{
|
||
currentBar.DOKill();
|
||
currentBar.fillAmount = 0;
|
||
text_progress_string = $"0/{_campData.AreaStepCount}";
|
||
text_progress.text = LocalizationMgr.GetFormatTextValue("UI_CampPanel_9", text_progress_string);
|
||
}
|
||
else
|
||
{
|
||
camp_target.Play("camp_target");
|
||
}
|
||
}
|
||
|
||
NextEvent(buildingData);
|
||
if (!IsAutoQuickBuilding() && buildingData.curStep == buildingData.areaStepCount)
|
||
{
|
||
_campData.ShowReward();
|
||
yield return Awaiters.Seconds(0.5f);
|
||
}
|
||
UpdateDataInfo(buildingData);
|
||
OnUpgradeComplete(buildingData);
|
||
}
|
||
OnUpgradeBuildingData UpgradeBuildingEvent(BuildingData buildingData)
|
||
{
|
||
var upgradeEvt = new OnUpgradeBuildingData(EBuildingType.UpgradeBuilding, false);
|
||
upgradeEvt.Speed = buildingSpeed;
|
||
upgradeEvt.NextPrefab = buildingData.NextPrefab;
|
||
upgradeEvt.CurrentPrefab = buildingData.CurrentPrefab;
|
||
GContext.Publish(upgradeEvt);
|
||
return upgradeEvt;
|
||
}
|
||
void NextEvent(BuildingData buildingData)
|
||
{
|
||
OnUpgradeBuildingData upgradeBuildingData = new OnUpgradeBuildingData(EBuildingType.Next);
|
||
upgradeBuildingData.TimelineId = buildingData.NextTimelineId;
|
||
upgradeBuildingData.StartTime = buildingData.NextStartTime;
|
||
upgradeBuildingData.Duration = buildingData.NextDuration;
|
||
upgradeBuildingData.NextPrefab = buildingData.NextPrefab;
|
||
upgradeBuildingData.CurrentPrefab = buildingData.CurrentPrefab;
|
||
GContext.Publish(upgradeBuildingData);
|
||
}
|
||
void GEventBuild()
|
||
{
|
||
#if AGG
|
||
using (var e = GEvent.GameEvent("build_upgrade", gaSend: false))
|
||
{
|
||
e.AddContent("building_id", _campData.Id)
|
||
.AddContent("charge_count", _playerShopData.GetBuyPaymentAmount())
|
||
.AddContent("is_auto", isAutoBuilding)
|
||
.AddContent("is_autofast", IsAutoQuickBuilding())
|
||
.AddContent("hook_count", _playerData.GetEnergyRM());
|
||
|
||
if (_campData.IsUpdataArea && levelItemDatas != null)
|
||
{
|
||
for (int i = 0; i < levelItemDatas.Count; i++)
|
||
{
|
||
if (levelItemDatas[i].id == 1001)
|
||
{
|
||
e.AddContent("reward_hook", levelItemDatas[i].count)
|
||
.AddContent("hook_origin", levelItemDatas[i].origin);
|
||
}
|
||
else if (levelItemDatas[i].id == 1002)
|
||
{
|
||
e.AddContent("reward_cash", levelItemDatas[i].count);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
#endif
|
||
}
|
||
|
||
private void OnUpgradeComplete(BuildingData buildingData)
|
||
{
|
||
bool guide = _guideDataCenter.IsGuide("CampPanel");
|
||
_isUpgrading = false;
|
||
top_area_canvas.blocksRaycasts = true;
|
||
if (!IsAutoQuickBuilding())
|
||
{
|
||
CurRewardQCount curRewardQCount = new CurRewardQCount();
|
||
GContext.Publish(curRewardQCount);
|
||
int rewardQCount = DeBugPanel.isShow ? curRewardQCount.count : 0;
|
||
if (rewardQCount > 0)
|
||
{
|
||
upgradeButton.Up();
|
||
return;
|
||
}
|
||
IsShowGuidance isShowGuidance = new IsShowGuidance();
|
||
GContext.Publish(isShowGuidance);
|
||
if (guide || isShowGuidance.isShow)
|
||
{
|
||
upgradeButton.Up();
|
||
EndOutUpgrade();
|
||
}
|
||
}
|
||
if (buildingDatas.Count > 0)
|
||
{
|
||
buildingSpeed += _table.TbGlobalConfig.TapTimeScale;
|
||
float max = 1 + _table.TbGlobalConfig.TapTimeScale * _table.TbGlobalConfig.TapScaleMaxStep;
|
||
if (buildingSpeed > max)
|
||
{
|
||
buildingSpeed = max;
|
||
}
|
||
OnUpgradClick();
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
DownPanel.blocksRaycasts = true;
|
||
}
|
||
if (IsAutoQuickBuilding() && buildingData.NextOffTimeScale == 1)
|
||
{
|
||
EndOutUpgrade();
|
||
return;
|
||
}
|
||
//如果upgradeButton处于长安状态继续升级
|
||
if (isAutoBuilding || isHolding)
|
||
{
|
||
buildingSpeed += _table.TbGlobalConfig.TimeScalePerStep;
|
||
if (buildingSpeed > maxSpeed)
|
||
{
|
||
buildingSpeed = maxSpeed;
|
||
}
|
||
OneBuildingData();
|
||
OnUpgradClick();
|
||
}
|
||
else
|
||
{
|
||
upButtonAni.Play("Normal");
|
||
costRoot.gameObject.SetActive(true);
|
||
}
|
||
}
|
||
|
||
void SetReward()
|
||
{
|
||
int isRewards = 0;
|
||
string Img = "";
|
||
List<int> DisplaySwitch = null;
|
||
int nextAccountDataID = 0;
|
||
var account = _playerData.nextAccountData;
|
||
if (_playerData.lv < account.ID && _playerData.lv + 1 >= account.ID)
|
||
{
|
||
isRewards = account.Rewards;
|
||
Img = account.Img;
|
||
nextAccountDataID = account.ID;
|
||
DisplaySwitch = account.DisplaySwitch;
|
||
}
|
||
|
||
var inflationRate = _playerData.InflationRate;
|
||
_playerData.SetLv(_playerData.lv + 1);
|
||
|
||
if (DisplaySwitch != null)
|
||
{
|
||
var table = GContext.container.Resolve<cfg.Tables>();
|
||
int id;
|
||
for (int i = 0; i < DisplaySwitch.Count; i++)
|
||
{
|
||
if (DisplaySwitch[i] > 0 && _playerData.benefitsLevel[i] > 0 && i < _playerData.benefitsLevel.Count)
|
||
{
|
||
id = 12001 + i;
|
||
List<ItemData> itemData = new List<ItemData>() { new ItemData { id = id, count = _playerData.benefitsLevel[i] } };
|
||
AddShowData(new ShowData(itemData, RewardType.BenefitUpgrade));
|
||
}
|
||
}
|
||
}
|
||
if (!string.IsNullOrEmpty(Img))
|
||
{
|
||
//开启系统
|
||
AddShowData(new ShowData(RewardType.FeaturesUnlock, nextAccountDataID));
|
||
}
|
||
if (isRewards != 0)
|
||
{
|
||
List<ItemData> itemData = GContext.container.Resolve<PlayerItemData>().AddItemByDropLureInflation(inflationRate, isRewards, null, false);
|
||
AddShowData(new ShowData(itemData));
|
||
}
|
||
}
|
||
List<ShowData> BenefitUpgrade = new List<ShowData>();
|
||
List<ShowData> FeaturesUnlock = new List<ShowData>();
|
||
List<ItemData> Normal = new List<ItemData>();
|
||
void AddShowData(ShowData showData)
|
||
{
|
||
if (IsAutoQuickBuilding())
|
||
{
|
||
switch (showData.rewardType)
|
||
{
|
||
case RewardType.Normal:
|
||
Normal.AddRange(showData.itemDatas);
|
||
break;
|
||
case RewardType.FeaturesUnlock:
|
||
FeaturesUnlock.Add(showData);
|
||
break;
|
||
case RewardType.BenefitUpgrade:
|
||
BenefitUpgrade.Add(showData);
|
||
break;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
GContext.Publish(showData);
|
||
}
|
||
}
|
||
|
||
async void UpdateShowDatas()
|
||
{
|
||
canvasGroup.blocksRaycasts = false;
|
||
top_area.curGold = _curGold;
|
||
top_area.text_gold.text = ConvertTools.GetNumberString2(top_area.curGold);
|
||
bool isShowReward = false;
|
||
if (Normal.Count > 0)
|
||
{
|
||
GContext.Publish(new ShowData(new List<ItemData>(Normal)));
|
||
Normal.Clear();
|
||
isShowReward = true;
|
||
}
|
||
if (BenefitUpgrade.Count > 0)
|
||
{
|
||
for (int i = 0; i < BenefitUpgrade.Count; i++)
|
||
{
|
||
GContext.Publish(BenefitUpgrade[i]);
|
||
}
|
||
BenefitUpgrade.Clear();
|
||
isShowReward = true;
|
||
}
|
||
if (FeaturesUnlock.Count > 0)
|
||
{
|
||
for (int i = 0; i < FeaturesUnlock.Count; i++)
|
||
{
|
||
GContext.Publish(FeaturesUnlock[i]);
|
||
}
|
||
FeaturesUnlock.Clear();
|
||
isShowReward = true;
|
||
}
|
||
if (!isShowReward)
|
||
{
|
||
canvasGroup.blocksRaycasts = true;
|
||
}
|
||
else
|
||
{
|
||
await Awaiters.Seconds(_fastAutoScreenLoopFxDelaySeconds);
|
||
GContext.Publish(new ShowData());
|
||
}
|
||
}
|
||
|
||
private async void OnRewardPanelClose(RewardPanelClose data)
|
||
{
|
||
canvasGroup.blocksRaycasts = true;
|
||
DownPanel.blocksRaycasts = true;
|
||
costRoot.gameObject.SetActive(true);
|
||
await Awaiters.NextFrame;
|
||
bool isGuide = _guideDataCenter.InspectTriggerGuide("CampPanel");
|
||
if (isGuide)
|
||
{
|
||
EndOutUpgrade();
|
||
return;
|
||
}
|
||
|
||
if (isAutoBuilding)
|
||
{
|
||
OneBuildingData();
|
||
OnUpgradClick();
|
||
}
|
||
else
|
||
{
|
||
upButtonAni.Play("Normal");
|
||
}
|
||
if (isCampPanel_fade)
|
||
{
|
||
CampPanel_show2();
|
||
}
|
||
}
|
||
|
||
private void StartOutUpgrade()
|
||
{
|
||
StopEffect(fx_autofastbuild_button_hold);
|
||
kuang.SetActive(true);
|
||
startTimer = null;
|
||
GContext.Publish(new VibrationData(HapticTypes.MediumImpact));
|
||
isAutoBuilding = true;
|
||
_curGold = _playerData.gold;
|
||
if (_campData.IsFix || _campData.constructionArea?.TurnOffTimeScale == 1 || _playerData.lv < _table.TbGlobalConfig.FastAutoBuildUnlockParam) // MMTService removed
|
||
{
|
||
isAutoQuickBuilding = false;
|
||
}
|
||
else
|
||
{
|
||
int required = _campData.GetStepRequired(_table.TbGlobalConfig.FastAutoBuildUnlockLevel - 1);
|
||
isAutoQuickBuilding = required > 0 && (ulong)required <= _playerData.gold;
|
||
}
|
||
upButtonAni.Play("Pressed", -1, 0);
|
||
|
||
|
||
if (_guideDataCenter.curDefine != null &&
|
||
_guideDataCenter.curDefine.fingerType != FingerType.None &&
|
||
_guideDataCenter.curDefine.panelName == "CampPanel")
|
||
{
|
||
OneBuildingData();
|
||
OnUpgradClick();
|
||
}
|
||
if (IsAutoQuickBuilding())
|
||
{
|
||
FadeOutQuickBuildUI();
|
||
}
|
||
GContext.Publish(new GuideNextEvent());
|
||
}
|
||
|
||
private IEnumerator PlayFastBuildScreenLoopFxDelayed()
|
||
{
|
||
yield return Awaiters.Seconds(_fastAutoScreenLoopFxDelaySeconds);
|
||
_fastBuildScreenLoopFxRoutine = null;
|
||
if (!_quickBuildFxSessionActive)
|
||
yield break;
|
||
PlayEffect(fx_autofastbuild_screen_loop);
|
||
}
|
||
|
||
private void FadeOutQuickBuildUI()
|
||
{
|
||
_quickBuildFxSessionActive = true;
|
||
|
||
if (_fastBuildScreenLoopFxRoutine != null)
|
||
{
|
||
StopCoroutine(_fastBuildScreenLoopFxRoutine);
|
||
_fastBuildScreenLoopFxRoutine = null;
|
||
}
|
||
_fastBuildScreenLoopFxRoutine = StartCoroutine(PlayFastBuildScreenLoopFxDelayed());
|
||
GContext.Publish(new FastBuildCameraEvent { Enable = true, RotationDurationSeconds = FastBuildCameraRotationDuration });
|
||
|
||
animator.Play("CampPanel_fade_fastauto");
|
||
btn_go.gameObject.SetActive(false);
|
||
}
|
||
|
||
private void FadeInQuickBuildUI()
|
||
{
|
||
_quickBuildFxSessionActive = false;
|
||
StopEffect(fx_autofastbuild_screen_loop);
|
||
GContext.Publish(new FastBuildCameraEvent { Enable = false });
|
||
animator.Play("CampPanel_show_fastauto");
|
||
btn_go.gameObject.SetActive(true);
|
||
}
|
||
|
||
private void EndOutUpgrade()
|
||
{
|
||
bool wasQuick = _quickBuildFxSessionActive;
|
||
if (_fastBuildScreenLoopFxRoutine != null)
|
||
{
|
||
StopCoroutine(_fastBuildScreenLoopFxRoutine);
|
||
_fastBuildScreenLoopFxRoutine = null;
|
||
}
|
||
if (!DownPanel.blocksRaycasts)
|
||
{
|
||
DownPanel.blocksRaycasts = true;
|
||
}
|
||
upButtonAni.Play("Normal", -1, 0);
|
||
StopCoroutineTimer();
|
||
isAutoBuilding = false;
|
||
isAutoQuickBuilding = false;
|
||
RefreshButtonInfoAfterAutoBuild();
|
||
if (wasQuick)
|
||
{
|
||
FadeInQuickBuildUI();
|
||
}
|
||
if (Normal.Count > 0 || BenefitUpgrade.Count > 0 || FeaturesUnlock.Count > 0)
|
||
{
|
||
UpdateShowDatas();
|
||
}
|
||
}
|
||
|
||
private async void ToCampSkyscraper()
|
||
{
|
||
if (isAutoBuilding)
|
||
{
|
||
upgradeButton.Up();
|
||
EndOutUpgrade();
|
||
}
|
||
if (_isUpgrading) return;
|
||
canvasGroup.blocksRaycasts = false;
|
||
|
||
bool isCanEnter = await _loadResourceService.Load("InfiniteBuildingAct");
|
||
if (isCanEnter)
|
||
{
|
||
GContext.Publish(new UnloadActToNextAct("InfiniteBuildingAct"));
|
||
}
|
||
else
|
||
{
|
||
var panel = await UIManager.Instance.ShowUI(UITypes.CloudTransitionPanel);
|
||
panel.GetComponent<CloudTransitionPanel>().SetBtn(true, () => GContext.Publish(new UnloadActToNextAct("InfiniteBuildingAct")));
|
||
}
|
||
canvasGroup.blocksRaycasts = true;
|
||
}
|
||
|
||
|
||
|
||
private void OnDisable()
|
||
{
|
||
GContext.container.Unregister<CampPanel>();
|
||
_userService.SetPlayerLv(_userService.UserId, _playerData.lv);
|
||
_userService.UpdateProfileLv();
|
||
}
|
||
|
||
#if UNITY_EDITOR
|
||
private void Update()
|
||
{
|
||
if (Input.GetKey(KeyCode.X) && Input.GetKeyDown(KeyCode.Alpha1))
|
||
{
|
||
DeBugPanel.isShow = !DeBugPanel.isShow;
|
||
SetAlpha();
|
||
}
|
||
if (Input.GetKey(KeyCode.F))
|
||
{
|
||
if (!_isUpgrading)
|
||
{
|
||
_campData.SetIsFix(true);
|
||
btn_icon.SetActive(!_campData.IsFix);
|
||
btn_fix.SetActive(_campData.IsFix);
|
||
GContext.Publish(new OnUpgradeBuildingData(EBuildingType.OpenFix));
|
||
}
|
||
}
|
||
}
|
||
#endif
|
||
} |