| | |
| | | using System; |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using UnityEngine; |
| | | using UnityEngine.UI; |
| | | |
| | |
| | | [SerializeField] Button autoSaveBtn; |
| | | |
| | | [SerializeField] Button changeCostBtn; |
| | | [SerializeField] Text costText; |
| | | [SerializeField] Image costArrow; |
| | | [SerializeField] Text costText; |
| | | [SerializeField] Text costTip; |
| | | [SerializeField] ScrollerController costScroll; |
| | | |
| | |
| | | |
| | | [SerializeField] Toggle betterEquipToggle; |
| | | |
| | | [SerializeField] Toggle autoChallengeBossToggle; |
| | | [SerializeField] Button tryChallengeBtn; |
| | | [SerializeField] Text tryChallengeText; |
| | | [SerializeField] Image tryChallengeArrow; |
| | | [SerializeField] ScrollerController tryChallengeScroll; |
| | | [SerializeField] Button tryChallengeTipBtn; |
| | | |
| | | [SerializeField] Toggle autoFinishTaskToggle; |
| | | [SerializeField] Button autoFinishTaskTipBtn; |
| | | |
| | | bool isOpenCostScroll = false; |
| | | bool isOpenSpeedScroll = false; |
| | | bool isOpenTryChallengeScroll = false; |
| | | |
| | | protected override void InitComponent() |
| | | { |
| | | autoStartBtn.AddListener(OnClickAutoStart); |
| | | autoStopBtn.AddListener(OnClickAutoStop); |
| | | autoSaveBtn.AddListener(OnClickAutoStart); |
| | | tryChallengeTipBtn.AddListener(() => |
| | | { |
| | | DislayTip("AutoFight15", tryChallengeTipBtn.transform.position); |
| | | }); |
| | | |
| | | autoFinishTaskTipBtn.AddListener(() => |
| | | { |
| | | DislayTip("AutoFight16",autoFinishTaskTipBtn.transform.position); |
| | | }); |
| | | |
| | | changeCostBtn.AddListener(() => |
| | | { |
| | |
| | | costArrow.transform.localRotation = Quaternion.Euler(0, 0, isOpenCostScroll ? 180 : 0); |
| | | AutoFightModel.Instance.ClickCostRed(); |
| | | }); |
| | | |
| | | changeSpeedBtn.AddListener(() => |
| | | { |
| | | isOpenSpeedScroll = !isOpenSpeedScroll; |
| | |
| | | AutoFightModel.Instance.ClickSpeedRed(); |
| | | }); |
| | | |
| | | tryChallengeBtn.AddListener(() => |
| | | { |
| | | isOpenTryChallengeScroll = !isOpenTryChallengeScroll; |
| | | tryChallengeScroll.SetActive(isOpenTryChallengeScroll); |
| | | tryChallengeArrow.transform.localRotation = Quaternion.Euler(0, 0, isOpenTryChallengeScroll ? 180 : 0); |
| | | AutoFightModel.Instance.ClickSpeedRed(); |
| | | }); |
| | | betterEquipToggle.AddListener((bool value) => |
| | | { |
| | | betterEquipToggle.isOn = value; |
| | | }); |
| | | |
| | | autoChallengeBossToggle.AddListener((bool value) => |
| | | { |
| | | if (!IsOpenTryChallenge(out int needtaskCount)) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("autofight2", needtaskCount); |
| | | autoChallengeBossToggle.SetIsOnWithoutNotify(false); |
| | | return; |
| | | } |
| | | autoChallengeBossToggle.isOn = value; |
| | | }); |
| | | |
| | | autoFinishTaskToggle.AddListener((bool value) => |
| | | { |
| | | if (!IsOpenAutoFinishTask(out int needtaskCount)) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("autofight2", needtaskCount); |
| | | autoFinishTaskToggle.SetIsOnWithoutNotify(false); |
| | | return; |
| | | } |
| | | autoFinishTaskToggle.isOn = value; |
| | | }); |
| | | |
| | | costScroll.GetComponent<ClickScreenOtherSpace>().AddListener(() => |
| | |
| | | isOpenSpeedScroll = false; |
| | | speedArrow.transform.localRotation = Quaternion.Euler(0, 0, 0); |
| | | }); |
| | | |
| | | tryChallengeScroll.GetComponent<ClickScreenOtherSpace>().AddListener(() => |
| | | { |
| | | isOpenTryChallengeScroll = false; |
| | | tryChallengeArrow.transform.localRotation = Quaternion.Euler(0, 0, 0); |
| | | }); |
| | | } |
| | | |
| | | protected override void OnPreOpen() |
| | | { |
| | | costScroll.OnRefreshCell += OnRefreshCostCell; |
| | | speedScroll.OnRefreshCell += OnRefreshSpeedCell; |
| | | tryChallengeScroll.OnRefreshCell += OnRefreshTryChallengeCell; |
| | | Display(); |
| | | } |
| | | |
| | |
| | | { |
| | | costScroll.OnRefreshCell -= OnRefreshCostCell; |
| | | speedScroll.OnRefreshCell -= OnRefreshSpeedCell; |
| | | tryChallengeScroll.OnRefreshCell -= OnRefreshTryChallengeCell; |
| | | } |
| | | bool IsOpenTryChallenge(out int needtaskCount) |
| | | { |
| | | needtaskCount = TaskManager.Instance.GetNeedFinishTaskCount(AutoFightModel.Instance.openAutoChallengeBossMissionID); |
| | | return needtaskCount <= 0; |
| | | } |
| | | |
| | | bool IsOpenAutoFinishTask(out int needtaskCount) |
| | | { |
| | | needtaskCount = TaskManager.Instance.GetNeedFinishTaskCount(AutoFightModel.Instance.openAutoChallengeBossMissionID); |
| | | return needtaskCount <= 0; |
| | | } |
| | | |
| | | void DislayTip(string key, Vector3 worldPos) |
| | | { |
| | | SmallTipWin.showText = Language.Get(key); |
| | | SmallTipWin.worldPos = worldPos; |
| | | SmallTipWin.isDownShow = false; |
| | | UIManager.Instance.OpenWindow<SmallTipWin>(); |
| | | } |
| | | |
| | | void Display() |
| | | { |
| | | costText.text = AutoFightModel.Instance.fightCost.ToString(); |
| | | speedText.text = AutoFightModel.Instance.fightSpeed.ToString(); |
| | | tryChallengeText.text = AutoFightModel.Instance.tryChallengeCount.ToString(); |
| | | betterEquipToggle.isOn = AutoFightModel.Instance.isStopFightByBetterEquip; |
| | | autoChallengeBossToggle.isOn = AutoFightModel.Instance.isAutoChallengeBoss; |
| | | autoFinishTaskToggle.isOn = AutoFightModel.Instance.isAutoFinishTask; |
| | | costTip.text = Language.Get("AutoFight2", ItemConfig.Get(GeneralDefine.MoneyDisplayModel[41]).ItemName, AutoFightModel.Instance.fightCost); |
| | | |
| | | if (AutoFightModel.Instance.isAutoAttackSet) |
| | |
| | | usingAutoObj.SetActive(false); |
| | | autoStartBtn.SetActive(true); |
| | | } |
| | | |
| | | |
| | | costScroll.SetActive(false); |
| | | speedScroll.SetActive(false); |
| | | tryChallengeScroll.SetActive(false); |
| | | costArrow.transform.localRotation = Quaternion.Euler(0, 0, 0); |
| | | speedArrow.transform.localRotation = Quaternion.Euler(0, 0, 0); |
| | | |
| | | tryChallengeArrow.transform.localRotation = Quaternion.Euler(0, 0, 0); |
| | | CreateCostScroll(); |
| | | CreateSpeedScroll(); |
| | | |
| | | CreateTryChallengeScroll(); |
| | | } |
| | | |
| | | |
| | |
| | | costScroll.JumpIndex(2); |
| | | } |
| | | } |
| | | |
| | | |
| | | void CreateSpeedScroll() |
| | | { |
| | | speedScroll.Refresh(); |
| | |
| | | speedScroll.Restart(); |
| | | } |
| | | |
| | | void CreateTryChallengeScroll() |
| | | { |
| | | tryChallengeScroll.Refresh(); |
| | | for (int i = 0; i < AutoFightModel.Instance.maxTryChallengeCount; i++) |
| | | { |
| | | tryChallengeScroll.AddCell(ScrollerDataType.Header, i + 1); |
| | | } |
| | | tryChallengeScroll.Restart(); |
| | | } |
| | | |
| | | void OnRefreshCostCell(ScrollerDataType type, CellView cell) |
| | | { |
| | |
| | | |
| | | |
| | | var cntText = cell.GetComponentInChildren<Text>(); |
| | | |
| | | |
| | | if (AutoFightModel.Instance.autoCostWithBlessLV[cell.index - 1] <= BlessLVManager.Instance.m_TreeLV) |
| | | { |
| | | { |
| | | cntText.text = UIHelper.AppendColor(TextColType.LightWhite, cell.index.ToString()); |
| | | } |
| | | else |
| | |
| | | var needtaskCount = TaskManager.Instance.GetNeedFinishTaskCount(AutoFightModel.Instance.speed2UnlockMissionID); |
| | | bool isbuy = InvestModel.Instance.IsActiveFightSpeed(3); |
| | | bool isActiveSpeed2 = needtaskCount <= 0 || isbuy; |
| | | |
| | | |
| | | btn.AddListener(() => |
| | | { |
| | | if (cell.index == 2) |
| | |
| | | speedScroll.SetActive(false); |
| | | speedArrow.transform.localRotation = Quaternion.Euler(0, 0, 0); |
| | | speedText.text = cell.index.ToString(); |
| | | }); |
| | | }); |
| | | |
| | | var cntText = cell.GetComponentInChildren<Text>(); |
| | | if (cell.index == 2) |
| | |
| | | } |
| | | } |
| | | |
| | | void OnRefreshTryChallengeCell(ScrollerDataType type, CellView cell) |
| | | { |
| | | bool isOpen = IsOpenTryChallenge(out int needtaskCount); |
| | | bool isbuy = InvestModel.Instance.IsInvested(InvestModel.monthCardType); |
| | | var btn = cell.GetComponent<Button>(); |
| | | btn.AddListener(() => |
| | | { |
| | | if (cell.index != 1) |
| | | { |
| | | if (!isOpen) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("autofight2", needtaskCount); |
| | | return; |
| | | } |
| | | if (!isbuy) |
| | | { |
| | | SysNotifyMgr.Instance.ShowTip("autofight3"); |
| | | return; |
| | | } |
| | | } |
| | | isOpenTryChallengeScroll = false; |
| | | tryChallengeScroll.SetActive(false); |
| | | tryChallengeArrow.transform.localRotation = Quaternion.Euler(0, 0, 0); |
| | | tryChallengeText.text = cell.index.ToString(); |
| | | }); |
| | | var cntText = cell.GetComponentInChildren<Text>(); |
| | | if (cell.index != 1) |
| | | { |
| | | cntText.text = UIHelper.AppendColor(!isOpen || !isbuy ? TextColType.Gray : TextColType.LightWhite, cell.index.ToString()); |
| | | } |
| | | else |
| | | { |
| | | cntText.text = cell.index.ToString(); |
| | | } |
| | | } |
| | | void OnClickAutoStart() |
| | | { |
| | | AutoFightModel.Instance.isAutoAttackSet = true; |
| | | AutoFightModel.Instance.fightCost = int.Parse(costText.text); |
| | | AutoFightModel.Instance.fightSpeed = int.Parse(speedText.text); |
| | | AutoFightModel.Instance.isStopFightByBetterEquip = betterEquipToggle.isOn; |
| | | AutoFightModel.Instance.isAutoChallengeBoss = autoChallengeBossToggle.isOn; |
| | | AutoFightModel.Instance.nowChallengeCount = 0; |
| | | AutoFightModel.Instance.tryChallengeCount = int.Parse(tryChallengeText.text); |
| | | AutoFightModel.Instance.isAutoFinishTask = autoFinishTaskToggle.isOn; |
| | | AutoFightModel.Instance.SaveAutoFightSetting(); |
| | | CloseWindow(); |
| | | SysNotifyMgr.Instance.ShowTip("autofight1"); |
| | |
| | | AutoFightModel.Instance.fightCost = int.Parse(costText.text); |
| | | AutoFightModel.Instance.fightSpeed = int.Parse(speedText.text); |
| | | AutoFightModel.Instance.isStopFightByBetterEquip = betterEquipToggle.isOn; |
| | | AutoFightModel.Instance.isAutoChallengeBoss = autoChallengeBossToggle.isOn; |
| | | AutoFightModel.Instance.tryChallengeCount = int.Parse(tryChallengeText.text); |
| | | AutoFightModel.Instance.isAutoFinishTask = autoFinishTaskToggle.isOn; |
| | | AutoFightModel.Instance.SaveAutoFightSetting(); |
| | | CloseWindow(); |
| | | } |