| | |
| | | using UnityEngine; |
| | | public class AutoFightModel : GameSystemManager<AutoFightModel> |
| | | { |
| | | //战斗倍数:值越大越快,影响战斗表现,掉落速度等 |
| | | //战斗倍数:值越大越快,影响战斗表现,掉落速度等,这里的倍数是索引,对应配置里的实际速率 |
| | | public int fightSpeed |
| | | { |
| | | get |
| | |
| | | } |
| | | set |
| | | { |
| | | QuickSetting.Instance.SetQuickSetting(QuickSettingType.AutoFight_Speed, value); |
| | | var num = Math.Max(1, value); |
| | | BattleManager.Instance.storyBattleField.SetSpeedRatio(BattleManager.Instance.speedGear[num - 1]); |
| | | QuickSetting.Instance.SetQuickSetting(QuickSettingType.AutoFight_Speed, num); |
| | | } |
| | | } |
| | | |
| | |
| | | } |
| | | |
| | | //自动模式, 真正点击战锤消耗开启,和休息(或无材料)停止 |
| | | public bool isAutoAttack = false; |
| | | public bool isPause = false; //如打BOSS的情况,暂停自动战斗 后续可以补充每X秒检测下是否有异常 |
| | | bool m_IsAutoAttack = false; |
| | | public bool isAutoAttack |
| | | { |
| | | get |
| | | { |
| | | return m_IsAutoAttack; |
| | | } |
| | | set |
| | | { |
| | | if (m_IsAutoAttack == value) |
| | | return; |
| | | m_IsAutoAttack = value; |
| | | Debug.Log("isAutoAttack:" + m_IsAutoAttack); |
| | | } |
| | | } |
| | | |
| | | //是否开启自动战斗设置 |
| | | public bool isAutoAttackSet |
| | |
| | | |
| | | public event Action ChangeAutoEvent; |
| | | |
| | | public int maxSpeed = 3; //最高速度 |
| | | 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; |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent += BeforePlayerInit; |
| | | BattleManager.Instance.onBattleFieldCreate += OnCreateBattleField; |
| | | |
| | | EventBroadcast.Instance.AddListener<string, SkillConfig, TeamHero>(EventName.BATTLE_CAST_SKILL, OnSkillCast); |
| | | |
| | | } |
| | | |
| | | public override void Release() |
| | | { |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk; |
| | | BattleManager.Instance.onBattleFieldCreate -= OnCreateBattleField; |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= BeforePlayerInit; |
| | | |
| | | |
| | | } |
| | | |
| | |
| | | maxCost = autoCostWithBlessLV.Length; |
| | | } |
| | | |
| | | void OnPlayerLoginOk() |
| | | { |
| | | //登录时有装备的处理 |
| | | } |
| | | |
| | | void BeforePlayerInit() |
| | | { |
| | |
| | | if (storyBattleField != null && storyBattleField.GetBattleMode() != BattleMode.Stop) |
| | | { |
| | | //战斗中改变模式 |
| | | isAutoAttack = isAutoAttackSet; |
| | | storyBattleField.AutoSetBattleMode(); |
| | | } |
| | | |
| | |
| | | return; |
| | | } |
| | | |
| | | if (!ItemLogicUtility.CheckCurrencyCount(41, PlayerDatas.Instance.baseData.UseHarmerCount, 2)) |
| | | if (!UIHelper.CheckMoneyCount(41, PlayerDatas.Instance.baseData.UseHarmerCount, 2)) |
| | | { |
| | | if (storyBattleField.GetBattleMode() != BattleMode.Stop) |
| | | storyBattleField.HaveRest(); |
| | | return; |
| | | } |
| | | |
| | | if (isAutoAttackSet) |
| | | { |
| | | isAutoAttack = true; |
| | | } |
| | | BattleManager.Instance.storyBattleField.SetSpeedRatio(BattleManager.Instance.speedGear[fightSpeed - 1]); |
| | | isAutoAttack = isAutoAttackSet; |
| | | |
| | | //手动会一直进入这个逻辑, 自动触发一次 |
| | | storyBattleField.AutoSetBattleMode(); |
| | |
| | | if (!string.IsNullOrEmpty(guid)) |
| | | return; |
| | | |
| | | //防范回收报错 |
| | | if (teamHero == null) |
| | | return; |
| | | |
| | | //只通知玩家武将的战斗 |
| | | if (teamHero.NPCID != 0) |
| | | return; |