using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using UnityEngine; public class MapProxy : ProxyBase { #region ` constructor ` public MapProxy() => this.opeCode = OpeCode.map; #endregion /// /// 7504 解锁据点 /// /// 据点的mapid /// 回掉 public void UnlockMap(int mapId, Action callback) { Post(CmdCode.map_UnlockMap, new object[] { mapId }, ret => { UserProxy.Instance.player.newMap = ret; // 更新下地图数据 callback?.Invoke(); }); } /// /// 7501 进入据点 /// /// 据点id /// 回调 public void EntryMap(int mapId, Action callback) { Post(CmdCode.map_EnterFootHold, new object[] { mapId }, ret => { var p = UserProxy.Instance.player; p.newMap = ret.newMap; p.baseInfo.tili = ret.tili; p.PrivateState.TiliTime = ret.time; p.newMap.curMapId = mapId; callback?.Invoke(); }); } /// /// 7502 开启传送阵 /// public void FixUpTransmision() { // todo: 待完善 } /// /// 7503 更新探索度 /// public void UpdateExplorationProgress() { // todo: 待完善 } /// /// 【7505】 保存mapid下已经解锁的区域、npc等等 /// /// /// public void UnlockInfoSva(string unlockStr, Action callback) { Post(CmdCode.map_unlockInfoSva, new object[] { unlockStr }, ret => { var p = UserProxy.Instance.player; // 更新下地图数据; p.newMap = ret.newMap; p.baseInfo.xp = ret.exp; p.baseInfo.level = ret.level; callback?.Invoke(ret.num); }); } /// /// 获取mapid下已经解锁的列表 /// /// /// public List getMapUnlockInfoList(int mapid) { List list = new List(); Dictionary> typeList = UserProxy.Instance.player.newMap.unlockMapTypeList; if (typeList.ContainsKey(mapid)) { return typeList[mapid]; } return list; } /// /// 【7506】领取探索奖励 /// /// /// public void reviceExplorerReward(int mapid, Action callback) { Post(CmdCode.map_reviceExplorerReward, new object[] { mapid }, ret => { var p = UserProxy.Instance.player; // 更新下地图数据; p.newMap = ret.newMap; string[] list = ret.cost.Split(','); if (int.Parse(list[0]) == (int)EItemSubType.Gold) { p.baseInfo.gold += int.Parse(list[1]); } else if (int.Parse(list[0]) == (int)EItemSubType.Gem) { p.baseInfo.cash += int.Parse(list[1]); } callback?.Invoke(); }); } /// /// 7507 回城券使用 /// /// /// public void huichengQuanUse(int mapId, float x, float y, float z, Action callback) { Post(CmdCode.map_huichengQuanUse, new object[] { mapId, x, y, z }, ret => { UserProxy.Instance.player.newMap = ret.newMap; // 更新下地图数据; callback?.Invoke(); }); } /// /// 7508 /// /// /// public void huichengQuanEnd(Action callback) { Post(CmdCode.map_huichengQuanEnd, new object[] { }, ret => { UserProxy.Instance.player.newMap = ret.newMap; // 更新下地图数据; callback?.Invoke(); }); } #region ret vo class Ret_NewMap { public Info_NewMap newMap; } class Ret_ExploreRwd : Ret_NewMap { public string cost; } class Ret_EntryMap : Ret_NewMap { public int tili; public long time; } class Ret_unlockSav : Ret_NewMap { public int num; public int exp; public int level; } #endregion #region UI VO /// /// 大地图UI所需数据接口 /// public class UI_BigMap { /// /// 快速访问 玩家数据 /// private Player player; /// /// 构造函数 /// /// 需要传入玩家数据 public UI_BigMap(Player user) => this.player = user; /// /// 当前所在据点mapId /// int CurMapId => player.newMap.curMapId; /// /// 当前所在据点数据 /// public Ins_FootHold CurMap => player.newMap.unlockedFootholds[CurMapId]; /// /// 当前据点所属的区域数据(区域相关内容待细化) /// public int ZoneId { get { int zoneid = 501007; Dictionary gate_zone = GameConfigData.Ins.gate_zone; foreach (KeyValuePair kv in gate_zone) { string[] slist = kv.Value.contains.Split(','); if (slist.Contains(this.CurMapId.ToString())) { zoneid = this.CurMapId; break; } } return zoneid; } } /// /// 当前大地图所有据点数据信息(含有常量数据和实例数据) /// //public Dictionary FootHoldList => GameConfigData.Ins.map_scene.Where(kv => kv.Value.zoneId == ZoneId) // .ToList().ConvertAll(kv => new KeyValuePair(kv.Key, new UIVO_FootHoldInfo(player, kv.Value))).ToDictionary(kv => kv.Key, kv => kv.Value); public Dictionary FootHoldList { get { Dictionary FootHoldList = new Dictionary(); int zoneid = 501007; Dictionary gate_zone = GameConfigData.Ins.gate_zone; foreach (KeyValuePair kv in gate_zone) { string[] slist = kv.Value.contains.Split(','); if (slist.Contains(this.CurMapId.ToString())) { zoneid = kv.Key; break; } } string[] list = GameConfigData.Ins.Getgate_zoneMo(zoneid).contains.Split(','); foreach (string id in list) { sm_gate mo = sm_gate.GetMoById(int.Parse(id)); UIVO_FootHoldInfo vo = new UIVO_FootHoldInfo(this.player, mo); FootHoldList[int.Parse(id)] = vo; } return FootHoldList; } } /// /// map所有的区id集合 /// public List mapZoneList { get { List mapZoneList = new List(); mapZoneList.Add(501007); mapZoneList.Add(501008); return mapZoneList; } } /// /// 新手村和言灵学院的所有小地图信息 /// public Dictionary> AllFootHoldList { get { Dictionary> allFootHoldList = new Dictionary>(); List mapZoneList = this.mapZoneList; foreach (int zid in mapZoneList) { sm_gate_zone zoneMo = sm_gate_zone.GetMoById(zid); string[] sList = zoneMo.contains.Split(','); Dictionary dic = new Dictionary(); foreach (string mapid in sList) { sm_gate mo = sm_gate.GetMoById(int.Parse(mapid)); UIVO_FootHoldInfo vo = new UIVO_FootHoldInfo(this.player, mo); dic[int.Parse(mapid)] = vo; } allFootHoldList.Add(zid,dic); } return allFootHoldList; } } /// /// 据点信息 /// public class UIVO_FootHoldInfo { private Player player { get; } /// /// 构造函数 /// /// 玩家信息 /// 常量 public UIVO_FootHoldInfo(Player user, sm_gate mo) { player = user; Mo = mo; } /// /// 配置数据 /// public sm_gate Mo { get; } /// /// 此据点是否已经解锁 /// public bool IsUnLocked => player.newMap.unlockedFootholds.ContainsKey(Mo.gateId); /// /// 显示有主线任务图标 /// public bool HasMainTaskIcon { get { var flag = false; player.collectTaskCard.GetActivingCards().ForEach(tk => { if ((int)Enum_TaskCardType.Main == tk.mo.type // 是主线任务 && Enum_TaskCardStateType.finish == tk.state // 且, 可领奖 && tk.FinialSteps().Exists(stp => stp.IsInMap(Mo.gateId)) // 且, 最终步骤处于当前地图 ) { flag = true; } }); return flag; } } /// /// 显示可能接取到主线任务图标 /// public bool MayGetMainTask { get { var flag = false; player.collectTaskCard.GetAllCards().ForEach(tk => // 遍历背包看有没有能开展的任务卡 { if ((int)Enum_TaskCardType.Main == tk.mo.type // 是主线任务 && tk.mo.tasksteps.Split(',').ToList().ConvertAll(s => sm_task_step.GetMoByID(int.Parse(s))).Exists(mo => mo.IsInMap(Mo.gateId))) // 且, 初始步骤处于当前据点 { flag = true; } }); return flag; } } /// /// 显示支线任务图标 /// public bool HasBranchTaskIcon { get { #warning 支线任务类型还未细化细节(以前的分类有主线、日常、学院、悬赏). 2022.3.15 return false; } } /// /// 显示可能接取到支线任务图标 /// public bool MayGetBranchTaskIcon { get { #warning 支线任务类型还未细化细节(以前的分类有主线、日常、学院、悬赏). 2022.3.15 return false; } } /// /// 显示我的位置指示图标 /// public bool HasMyLocationIcon => player.newMap.curMapId == Mo.gateId; /// /// 显示其他队员位置指示图标 /// public bool HasOthersLocationIcon { get { #warning 这里其他队员位置设定尚未细化,2022.3.15 return false; } } /// /// 运行时实例数据, 任何编码均需注意防范 null 值, 可在逻辑前先判断IsUnlocked值 /// public Ins_FootHold Ins => IsUnLocked ? player.newMap.unlockedFootholds[Mo.gateId] : null; } } #endregion }