| | |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using System.Linq; |
| | | using System.Text; |
| | | using Snxxz.UI; |
| | | using UnityEngine; |
| | | using TableConfig; |
| | | using System.Collections; |
| | | |
| | | public class SettingEffectMgr : SingletonMonobehaviour<SettingEffectMgr> |
| | | { |
| | | private bool _isAutoHangUp = false; |
| | | private ItemConfig _tagItemModel; |
| | | private FuncConfigConfig _tagFuncModel; |
| | | private StoreConfig _tagShopModel; |
| | | private int[] shopIdlist; |
| | | |
| | | PlayerPetDatas m_petModel; |
| | | PlayerPetDatas petmodel |
| | | { |
| | | get |
| | | { |
| | | return m_petModel ?? (m_petModel = ModelCenter.Instance.GetModel<PlayerPetDatas>()); |
| | | } |
| | | } |
| | | |
| | | PackModelInterface _modelInterface; |
| | | PackModelInterface modelInterface |
| | | { |
| | | get { return _modelInterface ?? (_modelInterface = ModelCenter.Instance.GetModel<PackModelInterface>()); } |
| | | } |
| | | |
| | | PlayerPackModel _playerPack; |
| | | PlayerPackModel playerPack |
| | | { |
| | | get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); } |
| | | } |
| | | |
| | | PlayerDeadModel _deadModel; |
| | | PlayerDeadModel DeadModel |
| | | { |
| | | get { return _deadModel ?? (_deadModel = ModelCenter.Instance.GetModel<PlayerDeadModel>()); } |
| | | } |
| | | |
| | | StoreModel _storeModel; |
| | | StoreModel m_storeModel |
| | | { |
| | | get { return _storeModel ?? (_storeModel = ModelCenter.Instance.GetModel<StoreModel>()); } |
| | | } |
| | | |
| | | public bool isPlayerDie { get; private set; } |
| | | |
| | | private float delayTime = 2f; |
| | | private bool isGetNewItem = false; |
| | | |
| | | private void Awake() |
| | | { |
| | | isGetNewItem = false; |
| | | isPlayerDie = false; |
| | | delayTime = 2; |
| | | HeroBehaviour.OnStartHandupAI -= OnStartHandupAI; |
| | | HeroBehaviour.OnStopHandupAI -= OnStopHandupAI; |
| | | playerPack.ItemCntAddAct -= RefreshItemCnt; |
| | | DeadModel.playerDieEvent -= OnPlayerDie; |
| | | m_storeModel.RefreshBuyResultEvent -= RefreshBuySuccess; |
| | | DeadModel.CloseRebornWinEvent -= PlayerRebornSuccess; |
| | | HeroBehaviour.OnStartHandupAI += OnStartHandupAI; |
| | | HeroBehaviour.OnStopHandupAI += OnStopHandupAI; |
| | | playerPack.ItemCntAddAct += RefreshItemCnt; |
| | | DeadModel.playerDieEvent += OnPlayerDie; |
| | | m_storeModel.RefreshBuyResultEvent += RefreshBuySuccess; |
| | | DeadModel.CloseRebornWinEvent += PlayerRebornSuccess; |
| | | } |
| | | |
| | | public void Begin() |
| | | { |
| | | |
| | | } |
| | | |
| | | float secondTimer = 0; |
| | | float halfSecondTimer = 0; |
| | | private void LateUpdate() |
| | | { |
| | | secondTimer += Time.deltaTime; |
| | | halfSecondTimer += Time.deltaTime; |
| | | if(halfSecondTimer >= 0.5f) |
| | | { |
| | | halfSecondTimer = 0f; |
| | | if (!isPlayerDie) |
| | | { |
| | | bool isCool; |
| | | KnapsackTimeCDMgr.Instance.GetItemCoolByCDType(1, out isCool); |
| | | if (!isCool) |
| | | { |
| | | AutoDrugSetting(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (secondTimer > 1f) |
| | | { |
| | | secondTimer = 0f; |
| | | if (isGetNewItem) |
| | | { |
| | | delayTime -= 1; |
| | | if (delayTime <= 0) |
| | | { |
| | | isGetNewItem = false; |
| | | delayTime = 2f; |
| | | DealBagItem(); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void PlayerRebornSuccess() |
| | | { |
| | | isPlayerDie = false; |
| | | } |
| | | |
| | | |
| | | public bool GetSettingEffect() |
| | | { |
| | | return _isAutoHangUp; |
| | | } |
| | | |
| | | private void OnStartHandupAI() |
| | | { |
| | | DesignDebug.Log("OnStartHandupAI"); |
| | | _isAutoHangUp = true; |
| | | RefreshBagItem(); |
| | | } |
| | | |
| | | private void OnStopHandupAI() |
| | | { |
| | | DesignDebug.Log("OnStopHandupAI"); |
| | | _isAutoHangUp = false; |
| | | } |
| | | |
| | | private void RefreshBuySuccess(int obj) |
| | | { |
| | | if (shopIdlist != null) |
| | | { |
| | | if (shopIdlist.Contains(obj)) |
| | | { |
| | | AutoDrugSetting(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | private void RefreshItemCnt(PackType type, int index, int id) |
| | | { |
| | | RefreshBagItem(); |
| | | } |
| | | |
| | | public void RefreshBagItem() |
| | | { |
| | | if (!_isAutoHangUp) |
| | | { |
| | | DesignDebug.Log("请开启自动挂机,否则无法出售"); |
| | | return; |
| | | } |
| | | |
| | | isGetNewItem = true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 背包小于5格处理物品 |
| | | /// </summary> |
| | | private void DealBagItem() |
| | | { |
| | | if (playerPack.GetReaminGridCount(PackType.rptItem) < 5) |
| | | { |
| | | if (HangUpSetModel.Instance.GetBool(HangUpAutoBoolType.isAutoDevour)) |
| | | { |
| | | if (playerPack.GetCanDevourModellist().Count > 0) |
| | | { |
| | | playerPack.SendEquipdevourQuest(); |
| | | } |
| | | } |
| | | |
| | | if (HangUpSetModel.Instance.GetBool(HangUpAutoBoolType.isAutoSell)) |
| | | { |
| | | modelInterface.SendOneKeySellQuest(modelInterface.GetSellItemList()); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 自动吃药和买药的逻辑判断 |
| | | /// </summary> |
| | | private void AutoDrugSetting() |
| | | { |
| | | |
| | | float hpPercent = Mathf.RoundToInt((float)PlayerDatas.Instance.baseData.HP / PlayerDatas.Instance.extersion.MaxHP * 100); |
| | | if (hpPercent <= HangUpSetModel.Instance.GetHpSet()) |
| | | { |
| | | SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptItem); |
| | | if (singlePack == null) |
| | | return; |
| | | |
| | | _tagFuncModel = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("AutoBuyDrug"); |
| | | shopIdlist = ConfigParse.GetMultipleStr<int>(_tagFuncModel.Numerical1); |
| | | int i = 0; |
| | | int length = shopIdlist.Length; |
| | | for (i = length - 1; i > -1; i--) |
| | | { |
| | | _tagShopModel = ConfigManager.Instance.GetTemplate<StoreConfig>(shopIdlist[i]); |
| | | _tagItemModel = ConfigManager.Instance.GetTemplate<ItemConfig>(_tagShopModel.ItemID); |
| | | if (PlayerDatas.Instance.baseData.LV >= _tagItemModel.LV) |
| | | { |
| | | List<ItemModel> list = null; |
| | | if (singlePack.GetItemCountByID(_tagItemModel.ID,out list) > 0) |
| | | { |
| | | PackSendQuestMgr.Instance.SendUseItemQuest(ItemWinBtnType.makeUse, list[0].itemInfo.ItemPlace); |
| | | break; |
| | | } |
| | | else |
| | | { |
| | | if(HangUpSetModel.Instance.GetBool(HangUpAutoBoolType.isAutoBuyDrug) && playerPack.GetReaminGridCount(PackType.rptItem) > 0) |
| | | { |
| | | if (m_storeModel.MoneyIsEnough(_tagShopModel.MoneyType, (ulong)_tagShopModel.MoneyNumber)) |
| | | { |
| | | m_storeModel.SendBuyShopItem(_tagShopModel, 1); |
| | | break; |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | private int[] RebornConditions; |
| | | private int rebornPrice; |
| | | private void OnPlayerDie() |
| | | { |
| | | if (WindowCenter.Instance.CheckOpen<FunctionForecastWin>()) |
| | | { |
| | | WindowCenter.Instance.Close<FunctionForecastWin>(); |
| | | } |
| | | isPlayerDie = true; |
| | | |
| | | |
| | | if (!_isAutoHangUp || !HangUpSetModel.Instance.GetBool(HangUpAutoBoolType.isAutoReborn) |
| | | || !DeadModel.IsCanReborn || IsDungeon()) |
| | | return; |
| | | |
| | | _tagFuncModel = ConfigManager.Instance.GetTemplate<FuncConfigConfig>("RebornArguments"); |
| | | RebornConditions = ConfigParse.GetMultipleStr<int>(_tagFuncModel.Numerical1); |
| | | rebornPrice = RebornConditions[2]; |
| | | StartCoroutine(PlayerReborn(5)); |
| | | } |
| | | |
| | | private bool IsDungeon() |
| | | { |
| | | var mapId = PlayerDatas.Instance.baseData.MapID; |
| | | var mapConfig = ConfigManager.Instance.GetTemplate<MapConfig>(mapId); |
| | | return mapConfig != null && mapConfig.MapFBType != 0; |
| | | } |
| | | |
| | | IEnumerator PlayerReborn(float time) |
| | | { |
| | | while(true) |
| | | { |
| | | DesignDebug.Log("PlayerReborn"); |
| | | time -= 1; |
| | | if (time <= 0 && DeadModel.playerIsDie) |
| | | { |
| | | if(DeadModel.IsRebornCoinsEnough()) |
| | | { |
| | | DeadModel.SendRebornQuest(3); |
| | | } |
| | | else |
| | | { |
| | | if (DeadModel.IsCanInplaceReborn(rebornPrice)) |
| | | { |
| | | DeadModel.SendRebornQuest(2); |
| | | } |
| | | } |
| | | |
| | | break; |
| | | } |
| | | yield return new WaitForSeconds(1); |
| | | } |
| | | } |
| | | |
| | | private int CompareID(int start, int end) |
| | | { |
| | | return -start.CompareTo(end); |
| | | } |
| | | |
| | | private int CompareDrugLv(ItemModel start, ItemModel next) |
| | | { |
| | | _tagItemModel = ConfigManager.Instance.GetTemplate<ItemConfig>((int)start.itemInfo.ItemID); |
| | | int lv1 = _tagItemModel.LV; |
| | | _tagItemModel = ConfigManager.Instance.GetTemplate<ItemConfig>((int)next.itemInfo.ItemID); |
| | | int lv2 = _tagItemModel.LV; |
| | | return -lv1.CompareTo(lv2); |
| | | } |
| | | |
| | | |
| | | } |
| | | using System;
|
| | | using System.Collections.Generic;
|
| | | using System.Linq;
|
| | | using System.Text;
|
| | | using Snxxz.UI;
|
| | | using UnityEngine;
|
| | | using TableConfig;
|
| | | using System.Collections;
|
| | |
|
| | | public class SettingEffectMgr : SingletonMonobehaviour<SettingEffectMgr>
|
| | | {
|
| | | private bool _isAutoHangUp = false;
|
| | | private ItemConfig _tagItemModel;
|
| | | private FuncConfigConfig _tagFuncModel;
|
| | | private StoreConfig _tagShopModel;
|
| | | private int[] shopIdlist;
|
| | |
|
| | | PlayerPetDatas m_petModel;
|
| | | PlayerPetDatas petmodel
|
| | | {
|
| | | get
|
| | | {
|
| | | return m_petModel ?? (m_petModel = ModelCenter.Instance.GetModel<PlayerPetDatas>());
|
| | | }
|
| | | }
|
| | |
|
| | | PackModelInterface _modelInterface;
|
| | | PackModelInterface modelInterface
|
| | | {
|
| | | get { return _modelInterface ?? (_modelInterface = ModelCenter.Instance.GetModel<PackModelInterface>()); }
|
| | | }
|
| | |
|
| | | PlayerPackModel _playerPack;
|
| | | PlayerPackModel playerPack
|
| | | {
|
| | | get { return _playerPack ?? (_playerPack = ModelCenter.Instance.GetModel<PlayerPackModel>()); }
|
| | | }
|
| | |
|
| | | PlayerDeadModel _deadModel;
|
| | | PlayerDeadModel DeadModel
|
| | | {
|
| | | get { return _deadModel ?? (_deadModel = ModelCenter.Instance.GetModel<PlayerDeadModel>()); }
|
| | | }
|
| | |
|
| | | StoreModel _storeModel;
|
| | | StoreModel m_storeModel
|
| | | {
|
| | | get { return _storeModel ?? (_storeModel = ModelCenter.Instance.GetModel<StoreModel>()); }
|
| | | }
|
| | |
|
| | | public bool isPlayerDie { get; private set; }
|
| | |
|
| | | private float delayTime = 2f;
|
| | | private bool isGetNewItem = false;
|
| | |
|
| | | private void Awake()
|
| | | {
|
| | | isGetNewItem = false;
|
| | | isPlayerDie = false;
|
| | | delayTime = 2;
|
| | | HeroBehaviour.OnStartHandupAI -= OnStartHandupAI;
|
| | | HeroBehaviour.OnStopHandupAI -= OnStopHandupAI;
|
| | | playerPack.ItemCntAddAct -= RefreshItemCnt;
|
| | | DeadModel.playerDieEvent -= OnPlayerDie;
|
| | | m_storeModel.RefreshBuyResultEvent -= RefreshBuySuccess;
|
| | | DeadModel.CloseRebornWinEvent -= PlayerRebornSuccess;
|
| | | HeroBehaviour.OnStartHandupAI += OnStartHandupAI;
|
| | | HeroBehaviour.OnStopHandupAI += OnStopHandupAI;
|
| | | playerPack.ItemCntAddAct += RefreshItemCnt;
|
| | | DeadModel.playerDieEvent += OnPlayerDie;
|
| | | m_storeModel.RefreshBuyResultEvent += RefreshBuySuccess;
|
| | | DeadModel.CloseRebornWinEvent += PlayerRebornSuccess;
|
| | | }
|
| | |
|
| | | public void Begin()
|
| | | {
|
| | |
|
| | | }
|
| | |
|
| | | float secondTimer = 0;
|
| | | float halfSecondTimer = 0;
|
| | | private void LateUpdate()
|
| | | {
|
| | | if (!(StageManager.Instance.CurrentStage is DungeonStage))
|
| | | {
|
| | | return;
|
| | | }
|
| | |
|
| | | secondTimer += Time.deltaTime;
|
| | | halfSecondTimer += Time.deltaTime;
|
| | | if(halfSecondTimer >= 0.5f)
|
| | | {
|
| | | halfSecondTimer = 0f;
|
| | | if (!isPlayerDie)
|
| | | {
|
| | | bool isCool;
|
| | | KnapsackTimeCDMgr.Instance.GetItemCoolByCDType(1, out isCool);
|
| | | if (!isCool)
|
| | | {
|
| | | AutoDrugSetting();
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | if (secondTimer > 1f)
|
| | | {
|
| | | if(isGetNewItem)
|
| | | {
|
| | | secondTimer = 0f;
|
| | | delayTime -= 1;
|
| | | if (delayTime <= 0)
|
| | | {
|
| | | isGetNewItem = false;
|
| | | delayTime = 2f;
|
| | | DealBagItem();
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void PlayerRebornSuccess()
|
| | | {
|
| | | isPlayerDie = false;
|
| | | }
|
| | |
|
| | |
|
| | | public bool GetSettingEffect()
|
| | | {
|
| | | return _isAutoHangUp;
|
| | | }
|
| | |
|
| | | private void OnStartHandupAI()
|
| | | {
|
| | | DebugEx.Log("OnStartHandupAI");
|
| | | _isAutoHangUp = true;
|
| | | RefreshBagItem();
|
| | | }
|
| | | |
| | | private void OnStopHandupAI()
|
| | | {
|
| | | DebugEx.Log("OnStopHandupAI");
|
| | | _isAutoHangUp = false;
|
| | | }
|
| | |
|
| | | private void RefreshBuySuccess(int obj)
|
| | | {
|
| | | if (shopIdlist != null)
|
| | | {
|
| | | if (shopIdlist.Contains(obj))
|
| | | {
|
| | | AutoDrugSetting();
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private void RefreshItemCnt(PackType type, int index, int id)
|
| | | {
|
| | | RefreshBagItem();
|
| | | }
|
| | |
|
| | | public void RefreshBagItem()
|
| | | {
|
| | | if (!_isAutoHangUp)
|
| | | {
|
| | | DebugEx.Log("请开启自动挂机,否则无法出售");
|
| | | return;
|
| | | }
|
| | |
|
| | | DealBagItem();
|
| | | isGetNewItem = true;
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 背包小于5格处理物品
|
| | | /// </summary>
|
| | | private void DealBagItem()
|
| | | {
|
| | | if (playerPack.GetReaminGridCount(PackType.rptItem) < 5)
|
| | | {
|
| | | if (HangUpSetModel.Instance.GetBool(HangUpAutoBoolType.isAutoDevour))
|
| | | {
|
| | | List<ItemModel> list = playerPack.GetCanDevourModellist();
|
| | | if (list != null && list.Count > 0)
|
| | | {
|
| | | playerPack.SendEquipdevourQuest();
|
| | | return;
|
| | | }
|
| | | }
|
| | |
|
| | | if (HangUpSetModel.Instance.GetBool(HangUpAutoBoolType.isAutoSell) && modelInterface.GetSellItemList().Count > 0)
|
| | | {
|
| | | modelInterface.SendOneKeySellQuest(modelInterface.GetSellItemList());
|
| | | return;
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /// <summary>
|
| | | /// 自动吃药和买药的逻辑判断
|
| | | /// </summary>
|
| | | private void AutoDrugSetting()
|
| | | {
|
| | |
|
| | | float hpPercent = Mathf.RoundToInt((float)PlayerDatas.Instance.baseData.HP / PlayerDatas.Instance.extersion.MaxHP * 100);
|
| | | if (hpPercent <= HangUpSetModel.Instance.GetHpSet())
|
| | | {
|
| | | SinglePackModel singlePack = playerPack.GetSinglePackModel(PackType.rptItem);
|
| | | if (singlePack == null)
|
| | | return;
|
| | |
|
| | | _tagFuncModel = Config.Instance.Get<FuncConfigConfig>("AutoBuyDrug");
|
| | | shopIdlist = ConfigParse.GetMultipleStr<int>(_tagFuncModel.Numerical1);
|
| | | int i = 0;
|
| | | int length = shopIdlist.Length;
|
| | | for (i = length - 1; i > -1; i--)
|
| | | {
|
| | | _tagShopModel = Config.Instance.Get<StoreConfig>(shopIdlist[i]);
|
| | | _tagItemModel = Config.Instance.Get<ItemConfig>(_tagShopModel.ItemID);
|
| | | if (PlayerDatas.Instance.baseData.LV >= _tagItemModel.LV)
|
| | | {
|
| | | List<ItemModel> list = null;
|
| | | if (singlePack.GetItemCountByID(_tagItemModel.ID,out list) > 0)
|
| | | {
|
| | | PackSendQuestMgr.Instance.SendUseItemQuest(ItemWinBtnType.makeUse, list[0].itemInfo.ItemPlace);
|
| | | break;
|
| | | }
|
| | | else
|
| | | {
|
| | | if(HangUpSetModel.Instance.GetBool(HangUpAutoBoolType.isAutoBuyDrug) && playerPack.GetReaminGridCount(PackType.rptItem) > 0)
|
| | | {
|
| | | if (m_storeModel.MoneyIsEnough(_tagShopModel.MoneyType, (ulong)_tagShopModel.MoneyNumber))
|
| | | {
|
| | | m_storeModel.SendBuyShopItem(_tagShopModel, 1);
|
| | | break;
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | private int[] RebornConditions;
|
| | | private int rebornPrice;
|
| | | private void OnPlayerDie()
|
| | | {
|
| | | if (WindowCenter.Instance.CheckOpen<FunctionForecastWin>())
|
| | | {
|
| | | WindowCenter.Instance.Close<FunctionForecastWin>();
|
| | | }
|
| | | isPlayerDie = true;
|
| | |
|
| | |
|
| | | if (!_isAutoHangUp || !HangUpSetModel.Instance.GetBool(HangUpAutoBoolType.isAutoReborn)
|
| | | || !DeadModel.IsCanReborn || IsDungeon())
|
| | | return;
|
| | |
|
| | | _tagFuncModel = Config.Instance.Get<FuncConfigConfig>("RebornArguments");
|
| | | RebornConditions = ConfigParse.GetMultipleStr<int>(_tagFuncModel.Numerical1);
|
| | | rebornPrice = RebornConditions[2];
|
| | | StartCoroutine(PlayerReborn(5));
|
| | | }
|
| | |
|
| | | private bool IsDungeon()
|
| | | {
|
| | | var mapId = PlayerDatas.Instance.baseData.MapID;
|
| | | var mapConfig = Config.Instance.Get<MapConfig>(mapId);
|
| | | return mapConfig != null && mapConfig.MapFBType != 0;
|
| | | }
|
| | |
|
| | | IEnumerator PlayerReborn(float time)
|
| | | {
|
| | | while(true)
|
| | | {
|
| | | DebugEx.Log("PlayerReborn");
|
| | | time -= 1;
|
| | | if (time <= 0 && DeadModel.playerIsDie)
|
| | | {
|
| | | if(DeadModel.IsRebornCoinsEnough())
|
| | | {
|
| | | DeadModel.SendRebornQuest(3);
|
| | | }
|
| | | else
|
| | | {
|
| | | if (DeadModel.IsCanInplaceReborn(rebornPrice))
|
| | | {
|
| | | DeadModel.SendRebornQuest(2);
|
| | | }
|
| | | }
|
| | |
|
| | | break;
|
| | | }
|
| | | yield return new WaitForSeconds(1);
|
| | | }
|
| | | }
|
| | |
|
| | | private int CompareID(int start, int end)
|
| | | {
|
| | | return -start.CompareTo(end);
|
| | | }
|
| | |
|
| | | private int CompareDrugLv(ItemModel start, ItemModel next)
|
| | | {
|
| | | _tagItemModel = Config.Instance.Get<ItemConfig>((int)start.itemInfo.ItemID);
|
| | | int lv1 = _tagItemModel.LV;
|
| | | _tagItemModel = Config.Instance.Get<ItemConfig>((int)next.itemInfo.ItemID);
|
| | | int lv2 = _tagItemModel.LV;
|
| | | return -lv1.CompareTo(lv2);
|
| | | }
|
| | |
|
| | |
|
| | | }
|