| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using System.Text; |
| | | using LitJson; |
| | | |
| | | using UnityEngine; |
| | | public class AutoFightModel : GameSystemManager<AutoFightModel> |
| | | { |
| | | public int fightSpeed = 1; //战斗倍数:值越大越快,影响战斗表现,掉落速度等 |
| | | //战斗倍数:值越大越快,影响战斗表现,掉落速度等 |
| | | 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 bool isAutoAttack; //自动攻击 |
| | | //消耗倍数 |
| | | 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; |
| | | |
| | | } |
| | | |
| | | } |
| | | } |