hch
2025-08-28 16a90aa94d8579cc120c9962d389b59bda5e7398
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using LitJson;
 
using UnityEngine;
public class AutoFightModel : GameSystemManager<AutoFightModel>
{
    //战斗倍数:值越大越快,影响战斗表现,掉落速度等
    public int fightSpeed
    {
        get
        {
            int value = QuickSetting.Instance.GetQuickSettingValue<int>(QuickSettingType.AutoFight_Speed, 0);
            return Math.Min(Math.Max(value, 1), maxSpeed);
        }
        set
        {
            QuickSetting.Instance.SetQuickSetting(QuickSettingType.AutoFight_Speed, value);
        }
    }
 
    //消耗倍数
    public int fightCost
    {
        get
        {
            int value = QuickSetting.Instance.GetQuickSettingValue<int>(QuickSettingType.AutoFight_Cost, 0);
            return Math.Min(Math.Max(value, 1), maxCost);
        }
        set
        {
            QuickSetting.Instance.SetQuickSetting(QuickSettingType.AutoFight_Cost, value);
        }
    }
 
    //自动模式, 真正点击战锤消耗开启,和休息(或无材料)停止
    public bool isAutoAttack = false;
 
    //是否开启自动战斗设置
    public bool isAutoAttackSet
    {
        get
        {
            return QuickSetting.Instance.GetQuickSettingBool(QuickSettingType.AutoFight_Open, 0);
        }
        set
        {
            QuickSetting.Instance.SetQuickSetting(QuickSettingType.AutoFight_Open, value);
        }
    }
 
    //更好装备停止战斗
    public bool isStopFightByBetterEquip
    {
        get
        {
            return QuickSetting.Instance.GetQuickSettingBool(QuickSettingType.AutoFight_FightPower, 0);
        }
        set
        {
            QuickSetting.Instance.SetQuickSetting(QuickSettingType.AutoFight_FightPower, value);
        }
    }
 
 
    public event Action ChangeAutoEvent;
 
    public int maxSpeed = 3; //最高速度
    public int maxCost; //最高消耗
    public int[] autoCostWithBlessLV; //自动战斗消耗倍数关联祝福等级
    public int speed2UnlockMissionID;
    public int speed3UnlockCTGID;
    public override void Init()
    {
        ParseConfig();
        DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent += OnPlayerLoginOk;
    }
 
    public override void Release()
    {
        DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk;
    }
 
    void ParseConfig()
    {
        var config = FuncConfigConfig.Get("AutoGuaji");
        autoCostWithBlessLV = JsonMapper.ToObject<int[]>(config.Numerical1);
        speed2UnlockMissionID = int.Parse(config.Numerical2);
        speed3UnlockCTGID = int.Parse(config.Numerical3);
        maxCost = autoCostWithBlessLV.Length;
    }
 
    void OnPlayerLoginOk()
    {
        //登录时有装备的处理
    }
 
    public void SaveAutoFightSetting()
    {
        QuickSetting.Instance.SendPackage();
        ChangeAutoEvent?.Invoke();
    }
 
 
    //自动处理装备,需要等待穿戴返回false,其他情况返回true
    public bool TryAutoFightDoEquip(ItemModel item)
    {
        if (!isAutoAttack)
            return false;
            
        if (item == null)
            return true;
 
        long showFightPower = FightPowerManager.Instance.GetFightPowerChange(item);
 
        if (showFightPower < 0)
        {
            EquipModel.Instance.SendEquipOP(new ushort[] { (ushort)item.gridIndex }, 1);
            return true;
        }
        else
        {
            if (isStopFightByBetterEquip)
                return false;
            
            EquipModel.Instance.SendEquipOP(new ushort[] { (ushort)item.gridIndex }, 1);
            return true;
 
        }
        
    }
}