lcy
2026-01-15 00efb8f79701e48d3e441f220b1ad6c4c395a8d8
Main/System/Main/AutoFightWin.cs
@@ -1,6 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -13,8 +11,8 @@
    [SerializeField] Button autoSaveBtn;
    [SerializeField] Button changeCostBtn;
    [SerializeField] Text costText;
    [SerializeField] Image costArrow;
    [SerializeField] Text costText;
    [SerializeField] Text costTip;
    [SerializeField] ScrollerController costScroll;
@@ -25,14 +23,34 @@
    [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(() =>
        {
@@ -41,6 +59,7 @@
            costArrow.transform.localRotation = Quaternion.Euler(0, 0, isOpenCostScroll ? 180 : 0);
            AutoFightModel.Instance.ClickCostRed();
        });
        changeSpeedBtn.AddListener(() =>
        {
            isOpenSpeedScroll = !isOpenSpeedScroll;
@@ -49,9 +68,38 @@
            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(() =>
@@ -65,12 +113,19 @@
            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();
    }
@@ -78,14 +133,36 @@
    {
        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)
@@ -98,15 +175,16 @@
            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();
    }
@@ -123,7 +201,7 @@
            costScroll.JumpIndex(2);
        }
    }
    void CreateSpeedScroll()
    {
        speedScroll.Refresh();
@@ -134,6 +212,15 @@
        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)
    {
@@ -157,9 +244,9 @@
        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
@@ -175,7 +262,7 @@
        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)
@@ -198,7 +285,7 @@
            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)
@@ -215,12 +302,51 @@
        }
    }
    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");
@@ -238,6 +364,9 @@
                    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();
                }