| | |
| | | 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); |
| | | BlessLVManager.Instance.OnBlessLVUpdateEvent += UpdateRedpint; |
| | | TaskManager.Instance.OnTaskUpdate += OnTaskUpdate; |
| | | InvestModel.Instance.onInvestUpdate += OnInvestUpdate; |
| | | |
| | | } |
| | | |
| | | public override void Release() |
| | | { |
| | | DTC0403_tagPlayerLoginLoadOK.playerLoginOkEvent -= OnPlayerLoginOk; |
| | | BattleManager.Instance.onBattleFieldCreate -= OnCreateBattleField; |
| | | DTC0102_tagCDBPlayer.beforePlayerDataInitializeEvent -= BeforePlayerInit; |
| | | EventBroadcast.Instance.RemoveListener<string, SkillConfig, TeamHero>(EventName.BATTLE_CAST_SKILL, OnSkillCast); |
| | | BlessLVManager.Instance.OnBlessLVUpdateEvent -= UpdateRedpint; |
| | | TaskManager.Instance.OnTaskUpdate -= OnTaskUpdate; |
| | | InvestModel.Instance.onInvestUpdate -= OnInvestUpdate; |
| | | |
| | | } |
| | | |
| | |
| | | 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() |
| | | { |
| | | //登录时有装备的处理 |
| | | } |
| | | |
| | | 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(); |
| | |
| | | |
| | | public int fightingHeroSkinID; //当前战斗的英雄皮肤ID |
| | | public string heroGuid; //战斗中的武将 |
| | | public event Action<bool> OnFightEvent; //是否战斗通知 |
| | | public event Action<bool> OnFightEvent; //战斗模式变更通知 战斗释放技能通知 |
| | | |
| | | |
| | | /// <summary> |
| | |
| | | void OnSkillCast(string guid, SkillConfig skillConfig, TeamHero teamHero) |
| | | { |
| | | if (!string.IsNullOrEmpty(guid)) |
| | | return; |
| | | |
| | | //防范回收报错 |
| | | if (teamHero == null) |
| | | return; |
| | | |
| | | //只通知玩家武将的战斗 |
| | |
| | | OnFightEvent?.Invoke(true); |
| | | } |
| | | |
| | | |
| | | |
| | | #endregion |
| | | |
| | | //新增消耗倍数红点 |
| | | Redpoint redpoint1 = new Redpoint(MainRedDot.RedPoint_AutoBattleKey, MainRedDot.RedPoint_AutoBattleKey * 10 + 1); |
| | | //新增战斗倍数红点 |
| | | Redpoint redpoint2 = new Redpoint(MainRedDot.RedPoint_AutoBattleKey, MainRedDot.RedPoint_AutoBattleKey * 10 + 2); |
| | | void UpdateRedpint() |
| | | { |
| | | //提示红点记录到第几个索引,每次解锁新的消耗红点都提示 |
| | | var costIndex = LocalSave.GetInt("redcost" + PlayerDatas.Instance.baseData.PlayerID); |
| | | if (costIndex + 1 < autoCostWithBlessLV.Length) |
| | | { |
| | | redpoint1.state = autoCostWithBlessLV[Math.Min(costIndex + 1, autoCostWithBlessLV.Length - 1)] <= BlessLVManager.Instance.m_TreeLV ? |
| | | RedPointState.Simple : RedPointState.None; |
| | | } |
| | | else |
| | | { |
| | | redpoint1.state = RedPointState.None; |
| | | } |
| | | |
| | | var speedIndex = LocalSave.GetInt("redspeed" + PlayerDatas.Instance.baseData.PlayerID); |
| | | redpoint2.state = RedPointState.None; |
| | | if (speedIndex == 0 && TaskManager.Instance.mainTask.TaskID > speed2UnlockMissionID && |
| | | !InvestModel.Instance.IsActiveFightSpeed(3)) |
| | | { |
| | | redpoint2.state = RedPointState.Simple; |
| | | } |
| | | else if (speedIndex < 2 && InvestModel.Instance.IsActiveFightSpeed(3)) |
| | | { |
| | | redpoint2.state = RedPointState.Simple; |
| | | } |
| | | } |
| | | |
| | | public void ClickCostRed() |
| | | { |
| | | int index = 0; |
| | | for (int i = 0; i < autoCostWithBlessLV.Length; i++) |
| | | { |
| | | if (autoCostWithBlessLV[i] <= BlessLVManager.Instance.m_TreeLV) |
| | | { |
| | | index = i; |
| | | } |
| | | else |
| | | { |
| | | break; |
| | | } |
| | | } |
| | | LocalSave.SetInt("redcost" + PlayerDatas.Instance.baseData.PlayerID, index); |
| | | UpdateRedpint(); |
| | | } |
| | | |
| | | public void ClickSpeedRed() |
| | | { |
| | | int index = 0; |
| | | if (!InvestModel.Instance.IsActiveFightSpeed(3)) |
| | | { |
| | | if (TaskManager.Instance.mainTask.TaskID > speed2UnlockMissionID) |
| | | { |
| | | index = 1; |
| | | } |
| | | } |
| | | else |
| | | { |
| | | index = 2; |
| | | } |
| | | LocalSave.SetInt("redspeed" + PlayerDatas.Instance.baseData.PlayerID, index); |
| | | UpdateRedpint(); |
| | | |
| | | } |
| | | |
| | | void OnTaskUpdate() |
| | | { |
| | | //任务刷新比较频繁 |
| | | if (TaskManager.Instance.mainTask.TaskID < speed2UnlockMissionID) |
| | | { |
| | | return; |
| | | } |
| | | if (LocalSave.GetInt("redspeed" + PlayerDatas.Instance.baseData.PlayerID) > 0) |
| | | return; |
| | | if (redpoint2.state == RedPointState.Simple) |
| | | return; |
| | | UpdateRedpint(); |
| | | } |
| | | |
| | | void OnInvestUpdate(int type) |
| | | { |
| | | if (type > 2) |
| | | return; |
| | | UpdateRedpint(); |
| | | } |
| | | } |