using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
|
using LitJson;
|
using UnityEngine;
|
|
namespace vnxbqy.UI
|
{
|
|
|
public class DungeonAssistModel : Model, IBeforePlayerDataInitialize, IAfterPlayerDataInitialize, IPlayerLoginOk
|
{
|
//public string helpInfoLocalSave { get; private set; }
|
public List<string> helpInfolist { get; private set; }
|
public Dictionary<string, AssistInfo> assistInfoDict = new Dictionary<string, AssistInfo>();
|
public event Action UpdateResultEvent;
|
FairyModel fairyModel { get { return ModelCenter.Instance.GetModel<FairyModel>(); } }
|
FriendsModel friendsModel { get { return ModelCenter.Instance.GetModel<FriendsModel>(); } }
|
DailyQuestModel dailyQuestModel { get { return ModelCenter.Instance.GetModel<DailyQuestModel>(); } }
|
TeamModel teamModel { get { return ModelCenter.Instance.GetModel<TeamModel>(); } }
|
DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
FindPreciousModel findPreciousModel { get { return ModelCenter.Instance.GetModel<FindPreciousModel>(); } }
|
CrossServerBossModel crossServerBossModel { get { return ModelCenter.Instance.GetModel<CrossServerBossModel>(); } }
|
|
#region 正在协助中数据
|
public string assistGUID = string.Empty; //只要记录guid即可 后续优化
|
public string assistGUIDTemp = string.Empty; //临时打开确认框使用
|
public int assistActiveCnt = 0; //协助可获得的活跃令
|
|
public bool isClickAssist = false; //用于等待B003回包后才可以前往协助,会因为分流问题导致无法在同1线
|
|
#endregion
|
public HB004_tagGCUseAssistThanksGiftPreview assistThanksGift = new HB004_tagGCUseAssistThanksGiftPreview();
|
public HB005_tagGCGetAssistThanksGiftPreview receiveAssistThanksGift = new HB005_tagGCGetAssistThanksGiftPreview();
|
|
public override void Init()
|
{
|
ParseFuncConfig();
|
ParseDunegonHelpConfig();
|
}
|
|
public void OnBeforePlayerDataInitialize()
|
{
|
FuncOpen.Instance.OnFuncStateChangeEvent -= UpdateFuncState;
|
PlayerDatas.Instance.playerDataRefreshEvent -= playerDataRefreshEvent;
|
assistInfoDict.Clear();
|
assistResults.Clear();
|
assistRefreshNum = 0;
|
IsCheckInOk = false;
|
IsRegisterToday = false;
|
assistPlayerDict.Clear();
|
SetRedpoint();
|
}
|
|
|
public void OnAfterPlayerDataInitialize()
|
{
|
int playerId = (int)PlayerDatas.Instance.baseData.PlayerID;
|
//helpInfoLocalSave = StringUtility.Contact("HelpInfoLocalSave", playerId);
|
//GetLocalSaveData();
|
}
|
|
public void OnPlayerLoginOk()
|
{
|
|
FuncOpen.Instance.OnFuncStateChangeEvent += UpdateFuncState;
|
PlayerDatas.Instance.playerDataRefreshEvent += playerDataRefreshEvent;
|
UpdateRedpoint();
|
//UpdateMainAssistRedpoint();
|
//自动登记助战
|
if (PlayerDatas.Instance.baseData.LV > 30 && !IsCheckInOk)
|
{
|
SendAssistCheckIn();
|
}
|
}
|
|
public override void UnInit()
|
{
|
|
}
|
|
public bool IsCheckIn
|
{
|
get
|
{
|
return checkInRedpoint.state == RedPointState.Simple;
|
}
|
}
|
|
public int ThanksGiftCount
|
{
|
get { return main_ThanksRedpoint.count; }
|
}
|
|
|
private void UpdateFuncState(int funcId)
|
{
|
if (funcId != 151) return;
|
|
UpdateRedpoint();
|
UpdateMainAssistRedpoint();
|
}
|
|
public bool TryGetFreeRefresh(out int remainNum)
|
{
|
if (assistRefreshNum < freeRefreshNum)
|
{
|
remainNum = freeRefreshNum - assistRefreshNum;
|
}
|
else
|
{
|
remainNum = (freeRefreshNum + goldRefreshNum) - assistRefreshNum;
|
}
|
return assistRefreshNum < freeRefreshNum;
|
}
|
|
public bool TryGetRewardAdd(out int addCoins)
|
{
|
addCoins = 0;
|
foreach (var key in assistPlayerDict.Keys)
|
{
|
var info = assistPlayerDict[key];
|
if (info.IsAssist)
|
{
|
addCoins += info.GetAddCoins();
|
}
|
}
|
|
return addCoins > 0;
|
}
|
|
public bool TryGetRemainAssistNum(int mapId, out int remainNum)
|
{
|
remainNum = 0;
|
var dungeonConfig = DungeonOpenTimeConfig.Get(mapId);
|
if (dungeonConfig == null) return false;
|
|
var mission = dungeonModel.mission;
|
remainNum = dungeonConfig.DayHelpCountMax - mission.helpCount;
|
return remainNum > 0;
|
}
|
|
public bool TryGetCurVipAddRatio(out string addRatioStr)
|
{
|
addRatioStr = string.Empty;
|
int vipLv = PlayerDatas.Instance.baseData.VIPLv;
|
var vipDict = VipPrivilegeConfig.GetVipPrivilegeDic(VipPrivilegeType.AssistXianYuanCoinsRatioAdd);
|
if (vipDict == null || vipLv < 1) return false;
|
List<int> vipLvlist = vipDict.Keys.ToList();
|
vipLvlist.Sort();
|
for (int i = vipLvlist.Count - 1; i > -1; i--)
|
{
|
var lv = vipLvlist[i];
|
var addRatio = vipDict[lv];
|
if (vipLv >= lv && addRatio > 0)
|
{
|
var ratio = (float)addRatio / 100;
|
addRatioStr = StringUtility.Contact(ratio, "%");
|
return true;
|
}
|
}
|
return false;
|
}
|
|
public bool TryGetCurVipAddCoins(out int addCoins)
|
{
|
addCoins = 0;
|
int vipLv = PlayerDatas.Instance.baseData.VIPLv;
|
var vipDict = VipPrivilegeConfig.GetVipPrivilegeDic(VipPrivilegeType.AssistXianYuanCoinsAdd);
|
if (vipDict == null || vipLv < 1) return false;
|
List<int> vipLvlist = vipDict.Keys.ToList();
|
vipLvlist.Sort();
|
for (int i = vipLvlist.Count - 1; i > -1; i--)
|
{
|
var lv = vipLvlist[i];
|
var coins = vipDict[lv];
|
if (vipLv >= lv && coins > 0)
|
{
|
addCoins = coins;
|
return true;
|
}
|
}
|
return false;
|
}
|
|
public bool IsMaxAssistCoinsAddByVip(out int nextVipLv, out int coins)
|
{
|
nextVipLv = 0;
|
coins = 0;
|
var vipDict = VipPrivilegeConfig.GetVipPrivilegeDic(VipPrivilegeType.AssistXianYuanCoinsAdd);
|
if (vipDict == null) return false;
|
|
int vipLv = PlayerDatas.Instance.baseData.VIPLv;
|
int vipMaxLv = GetMaxVipPrivilegeEffectLv(VipPrivilegeType.AssistXianYuanCoinsAdd);
|
bool isMaxVipLv = vipLv >= vipMaxLv ? true : false;
|
List<int> vipLvlist = vipDict.Keys.ToList();
|
vipLvlist.Sort();
|
int curAddCoins = 0;
|
if (vipDict.ContainsKey(vipLv))
|
{
|
curAddCoins = vipDict[vipLv];
|
}
|
|
if (!isMaxVipLv)
|
{
|
for (int i = 0; i < vipLvlist.Count; i++)
|
{
|
var lv = vipLvlist[i];
|
var addCoins = vipDict[lv];
|
if (lv > vipLv && addCoins > curAddCoins)
|
{
|
nextVipLv = lv;
|
coins = addCoins;
|
return false;
|
}
|
}
|
}
|
else
|
{
|
nextVipLv = vipLv;
|
coins = vipDict[vipMaxLv];
|
return true;
|
}
|
return false;
|
}
|
|
public bool IsMaxAssistCoinsRatioAddByVip(out int nextVipLv, out float ratio)
|
{
|
nextVipLv = 0;
|
ratio = 0;
|
var vipDict = VipPrivilegeConfig.GetVipPrivilegeDic(VipPrivilegeType.AssistXianYuanCoinsRatioAdd);
|
if (vipDict == null) return false;
|
|
int vipLv = PlayerDatas.Instance.baseData.VIPLv;
|
int vipMaxLv = GetMaxVipPrivilegeEffectLv(VipPrivilegeType.AssistXianYuanCoinsRatioAdd);
|
bool isMaxVipLv = vipLv >= vipMaxLv ? true : false;
|
List<int> vipLvlist = vipDict.Keys.ToList();
|
vipLvlist.Sort();
|
int curAddRatio = 0;
|
if (vipDict.ContainsKey(vipLv))
|
{
|
curAddRatio = vipDict[vipLv];
|
}
|
|
if (!isMaxVipLv)
|
{
|
for (int i = 0; i < vipLvlist.Count; i++)
|
{
|
var lv = vipLvlist[i];
|
var addRatio = vipDict[lv];
|
if (lv > vipLv && addRatio > curAddRatio)
|
{
|
nextVipLv = lv;
|
ratio = (float)addRatio / 100;
|
return false;
|
}
|
}
|
}
|
else
|
{
|
nextVipLv = vipMaxLv;
|
ratio = (float)vipDict[vipMaxLv] / 100;
|
return true;
|
}
|
return false;
|
}
|
|
public int GetMaxVipPrivilegeEffectLv(VipPrivilegeType type)
|
{
|
var vipDict = VipPrivilegeConfig.GetVipPrivilegeDic(type);
|
if (vipDict == null) return 0;
|
|
int recordEffect = 0;
|
List<int> vipLvlist = vipDict.Keys.ToList();
|
vipLvlist.Sort();
|
for (int i = vipLvlist.Count - 1; i > -1; i--)
|
{
|
int vipLv = vipLvlist[i];
|
int effect = vipDict[vipLv];
|
if (effect >= recordEffect)
|
{
|
recordEffect = effect;
|
}
|
else
|
{
|
return vipLv + 1;
|
}
|
}
|
return 0;
|
}
|
|
public RelatedToPlayer GetRelatedToPlayer(int playerId)
|
{
|
bool isFriend = friendsModel.GetFirendInfo((uint)playerId, (byte)GroupType.Friend) != null;
|
bool isAlly = fairyModel.InSameFairy(playerId);
|
|
if (isFriend && isAlly) return RelatedToPlayer.Friend;
|
if (isFriend) return RelatedToPlayer.Friend;
|
if (isAlly) return RelatedToPlayer.Ally;
|
|
return RelatedToPlayer.None;
|
}
|
|
public int GetNewAssistInfoNum()
|
{
|
if (assistInfoDict == null) return 0;
|
if (assistInfoDict.Keys.Count() == 1)
|
{
|
foreach (var assistInfo in assistInfoDict.Values)
|
{
|
if (UIHelper.ServerStringTrim(assistInfo.playerName) == UIHelper.ServerStringTrim(PlayerDatas.Instance.baseData.PlayerName))
|
{
|
//如果只有1个协助信息 且是自己发起的则不计数
|
return 0;
|
}
|
}
|
}
|
return assistInfoDict.Keys.Count();
|
}
|
|
#region 本地数据
|
public Dictionary<string, DungeonHelpBattleConfig> helpBattleDict { get; private set; }
|
private void ParseDunegonHelpConfig()
|
{
|
helpBattleDict = new Dictionary<string, DungeonHelpBattleConfig>();
|
var helpBattles = DungeonHelpBattleConfig.GetValues();
|
for (int i = 0; i < helpBattles.Count; i++)
|
{
|
var helpBattle = helpBattles[i];
|
string key = StringUtility.Contact(helpBattle.DataMapID, helpBattle.LineID);
|
helpBattleDict.Add(key, helpBattle);
|
}
|
|
}
|
|
public int assistCoolTime { get; private set; }
|
public int goldAssistPlayer { get; private set; }
|
public int freeRefreshNum { get; private set; }
|
public int goldRefreshNum { get; private set; }
|
public int refreshCostMoney { get; private set; }
|
public int maxXianYuanCoins { get; private set; }
|
public int checkInTotalTime { get; private set; }
|
public int assistRobotId { get; private set; }
|
public Dictionary<int, List<int>> assistCoinsDict { get; private set; }
|
private void ParseFuncConfig()
|
{
|
FuncConfigConfig HelpBattleCall = FuncConfigConfig.Get("HelpBattleCall");
|
assistCoolTime = int.Parse(HelpBattleCall.Numerical4);
|
goldAssistPlayer = int.Parse(HelpBattleCall.Numerical5);
|
FuncConfigConfig HelpBattleRefresh = FuncConfigConfig.Get("HelpBattleRefresh");
|
freeRefreshNum = int.Parse(HelpBattleRefresh.Numerical1);
|
goldRefreshNum = int.Parse(HelpBattleRefresh.Numerical2);
|
refreshCostMoney = int.Parse(HelpBattleRefresh.Numerical3);
|
FuncConfigConfig HelpBattlePoint = FuncConfigConfig.Get("HelpBattlePoint");
|
maxXianYuanCoins = int.Parse(HelpBattlePoint.Numerical1);
|
JsonData assistReward = JsonMapper.ToObject(HelpBattlePoint.Numerical2);
|
assistCoinsDict = new Dictionary<int, List<int>>();
|
foreach (var type in assistReward.Keys)
|
{
|
List<int> rewards = new List<int>();
|
assistCoinsDict.Add(int.Parse(type), rewards);
|
JsonData rewardData = assistReward[type];
|
if (rewardData.IsArray)
|
{
|
for (int i = 0; i < rewardData.Count; i++)
|
{
|
rewards.Add(int.Parse(rewardData[i].ToString()));
|
}
|
}
|
|
}
|
FuncConfigConfig HelpBattleCheckIn = FuncConfigConfig.Get("HelpBattleCheckIn");
|
checkInTotalTime = int.Parse(HelpBattleCheckIn.Numerical1);
|
FuncConfigConfig HelpBattleRobot = FuncConfigConfig.Get("HelpBattleRobot");
|
assistRobotId = int.Parse(HelpBattleRobot.Numerical1);
|
}
|
|
/// <summary>
|
/// 1-好友,2-盟友
|
/// </summary>
|
/// <param name="type"></param>
|
/// <returns></returns>
|
public int GetAssistReward(int type, bool isSelf = true)
|
{
|
List<int> rewards = null;
|
assistCoinsDict.TryGetValue(type, out rewards);
|
if (rewards != null && rewards.Count > 1)
|
{
|
return isSelf ? rewards[0] : rewards[1];
|
}
|
return 0;
|
}
|
|
public DungeonHelpBattleConfig GetHelpBattleConfig(int mapId, int lineId)
|
{
|
DungeonHelpBattleConfig battleConfig = null;
|
string key = StringUtility.Contact(mapId, lineId);
|
helpBattleDict.TryGetValue(key, out battleConfig);
|
return battleConfig;
|
}
|
|
//private void GetLocalSaveData()
|
//{
|
// string[] helpInfos = LocalSave.GeStringArray(helpInfoLocalSave);
|
// helpInfolist = helpInfos == null ? new List<string>() : helpInfos.ToList();
|
//}
|
|
public void SetHelpInfoLocalSave(string createDate, string info, bool isNew, bool isSelf)
|
{
|
//helpInfolist = helpInfolist == null ? new List<string>() : helpInfolist;
|
//if (helpInfolist.Count >= 20)
|
//{
|
// helpInfolist.RemoveAt(helpInfolist.Count - 1);
|
//}
|
//info = StringUtility.Contact(createDate,"$",info, "$", isNew,"$",isSelf);
|
//helpInfolist.Insert(0,info);
|
//LocalSave.SetStringArray(helpInfoLocalSave, helpInfolist.ToArray());
|
if (UpdateResultEvent != null)
|
{
|
UpdateResultEvent();
|
}
|
//UpdateMainAssistRedpoint();
|
}
|
|
public bool TryGetAssistResult(string _info, out string _date, out string _result, out bool _isNew, out bool _isSelf)
|
{
|
string[] array = _info.Split('$');
|
_isNew = false;
|
_date = string.Empty;
|
_result = string.Empty;
|
_isSelf = false;
|
|
if (array.Length > 3)
|
{
|
_date = array[0];
|
_result = array[1];
|
bool.TryParse(array[2], out _isNew);
|
bool.TryParse(array[3], out _isSelf);
|
return true;
|
}
|
return false;
|
}
|
|
public void SetHelpInfoRead()
|
{
|
if (helpInfolist == null || helpInfolist.Count < 1) return;
|
|
for (int i = 0; i < helpInfolist.Count; i++)
|
{
|
string[] infos = helpInfolist[i].Split('$');
|
if (infos != null && infos.Length >= 4)
|
{
|
bool isNew = true;
|
bool.TryParse(infos[2], out isNew);
|
if (isNew)
|
{
|
helpInfolist[i] = StringUtility.Contact(infos[0], "$", infos[1], "$", false, "$", infos[3]);
|
}
|
}
|
}
|
//UpdateMainAssistRedpoint();
|
//LocalSave.DeleteKey(helpInfoLocalSave);
|
//LocalSave.SetStringArray(helpInfoLocalSave, helpInfolist.ToArray());
|
}
|
#endregion
|
|
#region 协议
|
|
#region 助战召唤
|
public event Action UpdataAssistPlayerListEvent;
|
private Dictionary<int, AssistPlayerInfo> assistPlayerDict = new Dictionary<int, AssistPlayerInfo>();
|
public int assistRefreshNum { get; private set; }
|
public void UpdateAssistList(HB207_tagMCHelpBattleList battleList)
|
{
|
assistPlayerDict.Clear();
|
List<AssistPlayerInfo> playerInfos = new List<AssistPlayerInfo>();
|
assistRefreshNum = battleList.RefreshCount;
|
for (int i = 0; i < battleList.HelpCount; i++)
|
{
|
var info = battleList.HelpPlayerList[i];
|
AssistPlayerInfo playerInfo = new AssistPlayerInfo(info);
|
playerInfos.Add(playerInfo);
|
|
}
|
playerInfos.Sort(CompareByFightPower);
|
for (int i = 0; i < playerInfos.Count; i++)
|
{
|
var playerInfo = playerInfos[i];
|
assistPlayerDict.Add(playerInfo.PlayerID, playerInfo);
|
}
|
|
if (UpdataAssistPlayerListEvent != null)
|
{
|
UpdataAssistPlayerListEvent();
|
}
|
|
if (!WindowCenter.Instance.IsOpen<DungeonAssistPlayerWin>())
|
{
|
WindowCenter.Instance.Open<DungeonAssistPlayerWin>();
|
}
|
}
|
|
public int CompareByFightPower(AssistPlayerInfo start, AssistPlayerInfo end)
|
{
|
int x = start.FightPower;
|
int y = end.FightPower;
|
if (x.CompareTo(y) != 0) return -x.CompareTo(y);
|
return 0;
|
}
|
|
public event Action<int> UpdataAssistPlayerEvent;
|
public void UpdataAssistPlayer(HB206_tagMCHelpBattleCallResult callResult)
|
{
|
AssistPlayerInfo playerInfo = GetAssistPlayerInfo((int)callResult.PlayerID);
|
if (playerInfo != null)
|
{
|
playerInfo.SetObjID((int)callResult.ObjID);
|
if (GetAlreadyAssistNum() >= 3)
|
{
|
if (WindowCenter.Instance.IsOpen<DungeonAssistPlayerWin>())
|
{
|
WindowCenter.Instance.Close<DungeonAssistPlayerWin>();
|
}
|
}
|
else
|
{
|
if (UpdataAssistPlayerEvent != null)
|
{
|
UpdataAssistPlayerEvent(playerInfo.PlayerID);
|
}
|
}
|
}
|
|
}
|
|
public AssistPlayerInfo GetAssistPlayerInfo(int playerId)
|
{
|
AssistPlayerInfo playerInfo = null;
|
assistPlayerDict.TryGetValue(playerId, out playerInfo);
|
return playerInfo;
|
}
|
|
public List<AssistPlayerInfo> GetAssistPlayerInfos()
|
{
|
return assistPlayerDict.Values.ToList();
|
}
|
|
public int GetAlreadyAssistNum()
|
{
|
int num = 0;
|
foreach (var key in assistPlayerDict.Keys)
|
{
|
var info = assistPlayerDict[key];
|
if (info.IsAssist)
|
{
|
num += 1;
|
}
|
}
|
return num;
|
}
|
|
#endregion
|
|
public void SendAssistCheckIn()
|
{
|
CB105_tagCMHelpBattleCheckIn checkIn = new CB105_tagCMHelpBattleCheckIn();
|
GameNetSystem.Instance.SendInfo(checkIn);
|
}
|
|
public void SendPlayerAssist(int isOneKey, int playerId = 0, int isGold = 0)
|
{
|
CB106_tagCMHelpBattleCall helpBattleCall = new CB106_tagCMHelpBattleCall();
|
helpBattleCall.IsOneKeyCall = (byte)isOneKey;
|
helpBattleCall.PlayerID = (uint)playerId;
|
helpBattleCall.IsGoldCall = (byte)isGold;
|
GameNetSystem.Instance.SendInfo(helpBattleCall);
|
}
|
|
public void SendAssistRefresh()
|
{
|
CB107_tagCMHelpBattleRefresh battleRefresh = new CB107_tagCMHelpBattleRefresh();
|
GameNetSystem.Instance.SendInfo(battleRefresh);
|
}
|
|
#region 助战登记
|
// 20191216 自己的助战信息改成他人请求协助列表,保留助战登记
|
public bool IsCheckInOk { get; private set; }
|
public bool IsRegisterToday { get; private set; }
|
public event Action UpdateCheckInResultEvent;
|
public void UpdateAssistCheckInResult(HB205_tagMCHelpBattleCheckInResult checkInResult)
|
{
|
IsCheckInOk = checkInResult.IsOK == 1;
|
IsRegisterToday = checkInResult.IsLogin == 1;
|
if (UpdateCheckInResultEvent != null)
|
{
|
UpdateCheckInResultEvent();
|
}
|
UpdateRedpoint();
|
}
|
private List<AssistResult> assistResults = new List<AssistResult>();
|
public void UpdateAssistResultNotify(HB211_tagMCHelpBattleRecordList recordList)
|
{
|
for (int i = 0; i < recordList.RecordCount; i++)
|
{
|
var recordInfo = recordList.RecordList[i];
|
AssistResult assistResult = new AssistResult();
|
assistResult.assistType = 2;
|
assistResult.callPlayerId = (int)recordInfo.CallPlayerID;
|
assistResult.callPlayerName = recordInfo.CallPlayerName;
|
assistResult.mapId = (int)recordInfo.MapID;
|
assistResult.funcLineId = recordInfo.FuncLineID;
|
assistResult.addXianyuanCoins = recordInfo.XianyuanCoinAdd;
|
assistResult.relatedToPlayer = (RelatedToPlayer)recordInfo.Relation;
|
assistResult.vipLv = recordInfo.VIPLV;
|
assistResult.isSweep = false;
|
assistResult.createTime = recordInfo.HelpTime;
|
assistResult.noGetReason = 2;
|
assistResult.SetNotifyResult();
|
assistResults.Add(assistResult);
|
}
|
}
|
|
public void UpdateAssistResultNotify(HB208_tagMCAddXianyuanCoinMsg msg)
|
{
|
AssistResult assistResult = new AssistResult();
|
assistResult.assistType = 1;
|
assistResult.callPlayerId = (int)msg.CallPlayerID;
|
assistResult.callPlayerName = msg.CallPlayerName;
|
assistResult.mapId = (int)msg.MapID;
|
assistResult.funcLineId = msg.FuncLineID;
|
assistResult.addXianyuanCoins = msg.XianyuanCoinAdd;
|
assistResult.relatedToPlayer = (RelatedToPlayer)msg.Relation;
|
assistResult.addCoins = msg.RelationCoinAdd;
|
assistResult.vipLv = PlayerDatas.Instance.baseData.VIPLv;
|
assistResult.isSweep = msg.IsSweep == 1;
|
assistResult.createTime = TimeUtility.ServerNow.ToString("yyyy-MM-dd HH:mm:ss");
|
assistResult.noGetReason = msg.Reason;
|
assistResult.SetNotifyResult();
|
assistResults.Add(assistResult);
|
}
|
#endregion
|
|
// 盟内请求协助列表
|
public event Action UpdateAssistInfo;
|
// 新增协助
|
public void UpdateAssistInfoByPack(HB001_tagGCAssistInfoList assistPack)
|
{
|
for (int i = 0; i < assistPack.Count; i++)
|
{
|
assistInfoDict[assistPack.AssistInfoList[i].AssistGUID] = new AssistInfo() {
|
guid = assistPack.AssistInfoList[i].AssistGUID,
|
playerName = UIHelper.ServerStringTrim(assistPack.AssistInfoList[i].PlayerName),
|
job = assistPack.AssistInfoList[i].Job,
|
lv = assistPack.AssistInfoList[i].LV,
|
realmLV = assistPack.AssistInfoList[i].RealmLV,
|
mapID = assistPack.AssistInfoList[i].MapID,
|
lineID = assistPack.AssistInfoList[i].LineID,
|
npcID = assistPack.AssistInfoList[i].NPCID,
|
exData = assistPack.AssistInfoList[i].ExData,
|
playerID = assistPack.AssistInfoList[i].PlayerID,
|
Face = assistPack.AssistInfoList[i].Face,
|
FacePic = assistPack.AssistInfoList[i].FacePic,
|
};
|
}
|
UpdateMainAssistRedpoint();
|
if (UpdateAssistInfo != null)
|
UpdateAssistInfo();
|
|
}
|
|
// 删除某个(他人)协助请求
|
public void DelAssistInfoByPack(HB002_tagGCClearAssist ClearAssist)
|
{
|
if (assistInfoDict.ContainsKey(ClearAssist.AssistGUID))
|
{
|
assistInfoDict.Remove(ClearAssist.AssistGUID);
|
}
|
UpdateMainAssistRedpoint();
|
if (UpdateAssistInfo != null)
|
UpdateAssistInfo();
|
}
|
|
public event Action UpdateAssisting;
|
public void OnAssisting(HB003_tagGCAssistingInfo pack)
|
{
|
assistGUID = pack.AssistGUID;
|
if (UpdateAssisting != null)
|
UpdateAssisting();
|
|
if (isClickAssist)
|
{
|
if (assistInfoDict.ContainsKey(assistGUID))
|
{
|
var assistInfo = assistInfoDict[assistGUID];
|
if (assistInfo.mapID != 32020 && assistInfo.mapID != 32080)
|
{
|
GotoKillBoss(assistInfo);
|
}
|
else
|
{
|
GotoKillCrossServerBoss(assistInfo);
|
}
|
}
|
isClickAssist = false;
|
}
|
}
|
|
// B0 05 接收协助感谢礼物预览 #tagGCGetAssistThanksGiftPreview
|
public void OnGetAssistThanksGiftPreview(HB005_tagGCGetAssistThanksGiftPreview pack)
|
{
|
receiveAssistThanksGift = pack;
|
if (!WindowCenter.Instance.IsOpen<ReceiveAssistThanksWin>())
|
{
|
WindowCenter.Instance.Open<ReceiveAssistThanksWin>();
|
}
|
}
|
|
public void OnGetAssistThanksGiftCount(HB006_tagGCCanGetAssistThanksGiftCount pack)
|
{
|
main_ThanksRedpoint.count = pack.CanGetCount;
|
if (pack.CanGetCount > 0)
|
{
|
main_ThanksRedpoint.state = RedPointState.Simple;
|
}
|
else
|
{
|
main_ThanksRedpoint.state = RedPointState.None;
|
}
|
if (UpdateRedpointEvent != null)
|
{
|
UpdateRedpointEvent();
|
}
|
}
|
|
// B0 10 发起者请求协助Boss
|
public void SendRequestAssistBoss(uint npcObjID)
|
{
|
GActor actore = GAMgr.Instance.GetBySID(npcObjID);
|
var send = new CB010_tagCMRequestAssistBoss();
|
send.ObjID = npcObjID;
|
send.NPCID = (uint)(actore as GActorNpcFight).NpcConfig.NPCID;
|
if (CrossServerUtility.IsCrossServer())
|
{
|
GameNetSystem.Instance.SendToCrossServer(send);
|
}
|
else
|
{
|
GameNetSystem.Instance.SendInfo(send);
|
}
|
}
|
|
public void SendTeamAssist(int mapID, int lineID)
|
{
|
var send = new CB011_tagCMRequestAssistTeamFB();
|
send.MapID = (ushort)mapID;
|
send.LineID = (ushort)lineID;
|
GameNetSystem.Instance.SendInfo(send);
|
}
|
|
// B0 12 开始协助Boss #tagCGStartAssistBoss
|
public void SendStartAssistBoss(string guid)
|
{
|
var send = new CB012_tagCGStartAssistBoss();
|
send.AssistGUID = guid;
|
GameNetSystem.Instance.SendInfo(send);
|
}
|
|
// B0 13 取消协助Boss #tagCGCancelAssistBoss
|
public void SendStopAssistBoss()
|
{
|
if (assistGUID == string.Empty) return;
|
|
var send = new CB013_tagCGCancelAssistBoss();
|
send.AssistGUID = assistGUID;
|
if (CrossServerUtility.IsCrossServer())
|
{
|
GameNetSystem.Instance.SendToCrossServer(send);
|
}
|
else
|
{
|
GameNetSystem.Instance.SendInfo(send);
|
}
|
assistGUID = string.Empty;
|
}
|
|
// B0 15 接收协助感谢礼物 #tagCGGetAssistThanksGift
|
public void GetAssistThanksGift(byte isPreview)
|
{
|
var send = new CB015_tagCGGetAssistThanksGift();
|
send.IsPreview = isPreview;
|
GameNetSystem.Instance.SendInfo(send);
|
}
|
|
// B0 04 使用协助感谢礼盒预览 #tagGCUseAssistThanksGiftPreview
|
public void OnUseAssistThanksGiftPreview(HB004_tagGCUseAssistThanksGiftPreview pack)
|
{
|
assistThanksGift = pack;
|
if (!WindowCenter.Instance.IsOpen<AssistThanksWin>())
|
{
|
WindowCenter.Instance.Open<AssistThanksWin>();
|
}
|
}
|
|
public int m_TodayAssistMoney = 0; //今日已获得活跃令,不含社交加成
|
public int m_SocialMoney = 0; //社交额外加成
|
public event Action UpdateTodayAssistMoney;
|
public void OnTodayAssistMoneyInfo(HB007_tagMCTodayAssistMoneyInfo pack)
|
{
|
m_TodayAssistMoney = pack.TodayAssistMoney;
|
m_SocialMoney = pack.SocialMoney;
|
if (UpdateTodayAssistMoney != null)
|
{
|
UpdateTodayAssistMoney();
|
}
|
}
|
|
private void playerDataRefreshEvent(PlayerDataType type)
|
{
|
if (type == PlayerDataType.Family && PlayerDatas.Instance.baseData.FamilyId == 0)
|
{
|
assistInfoDict.Clear();
|
UpdateMainAssistRedpoint();
|
if (UpdateAssistInfo != null)
|
UpdateAssistInfo();
|
}
|
else if (type == PlayerDataType.LV && PlayerDatas.Instance.baseData.LV == 30)
|
{
|
//前期自动登记助战
|
if (!IsCheckInOk)
|
{
|
SendAssistCheckIn();
|
}
|
}
|
}
|
|
//发布方退出
|
//BossAssistOver Boss协助结束
|
//FBAssistOver 副本协助结束
|
//TJGLogin 脱机上线
|
//LeaveFamily 退出/被踢出仙盟
|
//LeaveMap 退出协助地图
|
//AttackNewBoss 攻击了其他boss
|
//StartAssistBoss 开始协助其他玩家
|
|
//协助方退出
|
//LeaveFamily 退出/被踢出仙盟
|
//LeaveMap 退出协助地图
|
//AttackNewBoss 攻击了其他boss
|
//ClientCancel 主动取消
|
//StartNewAssistBoss 变更协助目标
|
public int AssistOverState = 0; //0 失败,1成功 2.等待
|
public event Action UpdateAssistOver;
|
public void OnAssistOver(HB008_tagGCAssistOver pack)
|
{
|
string reason = UIHelper.ServerStringTrim(pack.Reason);
|
if (reason == "StartNewAssistBoss")
|
{
|
AssistOverState = 2;
|
}
|
else if (reason == "BossAssistOver" || reason == "FBAssistOver")
|
{
|
AssistOverState = 1;
|
}
|
else
|
{
|
AssistOverState = 0;
|
}
|
|
if (MapConfig.Get(PlayerDatas.Instance.baseData.MapID).MapFBType != (int)MapType.OpenCountry && AssistOverState == 0)
|
{
|
dungeonModel.ExitCurrentDungeon();
|
}
|
|
if (AssistOverState == 0)
|
{
|
SysNotifyMgr.Instance.ShowTip("AssistFail");
|
}
|
if (UpdateAssistOver != null)
|
UpdateAssistOver();
|
|
|
}
|
#endregion
|
// 在副本中同目标允许切换协助目标
|
public bool isSameAssitTag(string guid)
|
{
|
if (assistGUID == String.Empty)
|
{
|
return true;
|
}
|
var assistInfo = assistInfoDict[assistGUID];
|
var otherAssistInfo = assistInfoDict[guid];
|
if (assistInfo.npcID == otherAssistInfo.npcID && assistInfo.lineID == otherAssistInfo.lineID &&
|
assistInfo.mapID == otherAssistInfo.mapID)
|
{
|
return true;
|
}
|
return false;
|
}
|
|
|
#region 红点
|
public const int AssistCheckInRedPoint = 7800001;
|
public Redpoint main_ThanksRedpoint = new Redpoint(7800002);
|
public Redpoint main_AssistRedpoint = new Redpoint(51);//(7800002);
|
public Redpoint checkInRedpoint { get; private set; }
|
public event Action UpdateRedpointEvent;
|
|
public void SetRedpoint()
|
{
|
if(checkInRedpoint != null)
|
{
|
checkInRedpoint.state = RedPointState.None;
|
}
|
|
if (checkInRedpoint == null)
|
{
|
//DailyQuestData questData = null;
|
//if (dailyQuestModel.TryGetDailyQuest((int)DailyQuestType.DungeonAssist, out questData) )
|
//{
|
// checkInRedpoint = new Redpoint(questData.redpoint.id, AssistCheckInRedPoint);
|
//}
|
checkInRedpoint = new Redpoint(51, AssistCheckInRedPoint);
|
}
|
}
|
|
public void UpdateRedpoint()
|
{
|
checkInRedpoint.state = RedPointState.None;
|
if (!FuncOpen.Instance.IsFuncOpen(151)) return;
|
|
if(IsCheckInOk)
|
{
|
checkInRedpoint.state = RedPointState.None;
|
}
|
else
|
{
|
checkInRedpoint.state = RedPointState.Simple;
|
}
|
}
|
|
public void UpdateMainAssistRedpoint()
|
{
|
main_AssistRedpoint.state = RedPointState.None;
|
if (!FuncOpen.Instance.IsFuncOpen(151)) return;
|
|
int newInfoNum = GetNewAssistInfoNum();
|
main_AssistRedpoint.count = newInfoNum;
|
if (newInfoNum > 0)
|
{
|
main_AssistRedpoint.state = RedPointState.Quantity;
|
}
|
else
|
{
|
main_AssistRedpoint.state = RedPointState.None;
|
}
|
|
|
}
|
#endregion
|
|
public void GotoKillBoss(AssistInfo assistInfo)
|
{
|
var error = 0;
|
int npcID = (int)assistInfo.npcID;
|
if (TestGotoKillBoss(npcID, out error))
|
{
|
if (assistInfo.mapID == DemonJarModel.DATA_MAPID && PlayerDatas.Instance.baseData.MapID != DemonJarModel.DATA_MAPID)
|
{
|
var send = new C0321_tagCEnterFbGameEvent();
|
send.MapID = (ushort)assistInfo.mapID;
|
send.LineID = (ushort)assistInfo.lineID;
|
GameNetSystem.Instance.SendInfo(send);
|
}
|
else
|
{
|
WindowJumpMgr.Instance.ClearJumpData();
|
MapTransferUtility.Instance.MoveToNPC(npcID);
|
}
|
}
|
else
|
{
|
ProcessGotoKillBossError(npcID, error);
|
}
|
}
|
private void ProcessGotoKillBossError(int npcID, int _error)
|
{
|
switch (_error)
|
{
|
case 1:
|
var dataMapId = dungeonModel.GetDataMapIdByMapId(PlayerDatas.Instance.baseData.MapID);
|
var config = DungeonOpenTimeConfig.Get(dataMapId);
|
var tip = Language.Get(config.ExitDescription);
|
|
|
ConfirmCancel.ShowPopConfirm(
|
Language.Get("Mail101"),
|
tip,
|
(bool _ok) =>
|
{
|
if (_ok)
|
{
|
WindowCenter.Instance.Close<FindPreciousFrameWin>();
|
MapTransferUtility.Instance.MoveToNPC(npcID);
|
}
|
}
|
);
|
break;
|
case 2:
|
SysNotifyMgr.Instance.ShowTip("InDungeon_CantGo");
|
break;
|
case 3:
|
SysNotifyMgr.Instance.ShowTip("CrossMap10");
|
break;
|
case 4:
|
SysNotifyMgr.Instance.ShowTip("BossRealmHint2", RealmConfig.Get(NPCConfig.Get(npcID).Realm).LvLarge);
|
break;
|
}
|
}
|
private bool TestGotoKillBoss(int npcID, out int _error)
|
{
|
if (!findPreciousModel.IsBossUnlock(npcID))
|
{
|
_error = 4;
|
return false;
|
}
|
|
_error = 0;
|
return true;
|
}
|
|
public void GotoKillCrossServerBoss(AssistInfo assistInfo)
|
{
|
crossServerBossModel.selectedBoss = (int)assistInfo.npcID;
|
if (assistInfo.mapID == CrossServerBossModel.DATA_MAPID)
|
{
|
var error = 0;
|
if (crossServerBossModel.CanEnter(out error))
|
{
|
if (PlayerDatas.Instance.baseData.MapID == CrossServerBossModel.DATA_MAPID)
|
{
|
MapTransferUtility.Instance.MoveToNPC(crossServerBossModel.selectedBoss);
|
}
|
else
|
{
|
crossServerBossModel.RequestEnter();
|
}
|
}
|
else
|
{
|
crossServerBossModel.ProcessEnterError(error);
|
}
|
}
|
else if (assistInfo.mapID == 32080)
|
{
|
CrossServerMHBossModel.Instance.GotoKillBoss();
|
}
|
|
}
|
|
|
public class AssistResult
|
{
|
public int assistType; // 1 真实的自己 2 自己的镜像
|
public int callPlayerId;
|
public string callPlayerName;
|
public int mapId;
|
public int funcLineId;
|
public int addXianyuanCoins;// 增加的仙缘币,0代表已达上限
|
public int addXianyuanCoinsTheory; // 理论增加的仙缘币
|
public RelatedToPlayer relatedToPlayer;
|
public int vipLv;
|
public bool isSweep;
|
public string createTime;
|
public ResultType resultType;
|
public string info;
|
public int noGetReason;//仙缘币为0时的原因:1-助战次数上限;2-每日获得上限
|
public int addCoins; // 社交加成(真人进入副本)
|
private int addRatioVipLv;
|
private int addRatio;
|
private string addRatioStr;
|
public bool isNew { get; private set;}
|
public bool isSelf { get; private set;}
|
|
public bool IsAssistOther
|
{
|
get { return callPlayerId != 0; }
|
}
|
public bool IsGetAllAssistCoins { get { return addXianyuanCoins >= addXianyuanCoinsTheory && addXianyuanCoins > 0; } }
|
public bool IsVipAddRatio { get { return addRatioVipLv > 0; } }
|
public bool IsRealmDungeon { get { return mapId == 31110; } }
|
|
DungeonAssistModel assistModel { get { return ModelCenter.Instance.GetModel<DungeonAssistModel>(); } }
|
DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
|
public void SetNotifyResult()
|
{
|
info = string.Empty;
|
int lineId = mapId == 31110 ? 1 : funcLineId;
|
int dungeonId = dungeonModel.GetDungeonId(mapId,lineId);
|
DungeonConfig dungeonConfig = dungeonConfig = DungeonConfig.Get(dungeonId);
|
if (dungeonConfig == null) return;
|
|
string fbName = dungeonConfig.FBName;
|
string realmName = string.Empty;
|
fbName = dungeonConfig.FBName;
|
if (mapId == 31110)
|
{
|
int realmLv = funcLineId + 1;
|
RealmConfig realmConfig = RealmConfig.Get(realmLv);
|
realmName = realmConfig != null ? realmConfig.Name : string.Empty;
|
if(!string.IsNullOrEmpty(realmName))
|
{
|
realmName = StringUtility.Contact("【", realmName, "】");
|
realmName = UIHelper.GetRealmColorByLv(realmLv, realmName, true);
|
}
|
}
|
GetCurVipAddRatio();
|
SetAddXianyuanCoinsTheory();
|
resultType = GetResultType();
|
SetResultIsNew(true);
|
string sumAddStr = string.Empty;
|
|
if(IsAssistOther)
|
{
|
switch (relatedToPlayer)
|
{
|
case RelatedToPlayer.Friend:
|
sumAddStr = Language.Get("DungeonAssist111", assistModel.GetAssistReward(1));
|
break;
|
case RelatedToPlayer.Ally:
|
sumAddStr = Language.Get("DungeonAssist112", assistModel.GetAssistReward(2));
|
break;
|
}
|
}
|
|
if (IsVipAddRatio)
|
{
|
if(sumAddStr.Length > 0)
|
{
|
sumAddStr = StringUtility.Contact(sumAddStr, ",", Language.Get("DungeonAssist110", addRatioVipLv, addRatioStr));
|
}
|
else
|
{
|
sumAddStr = Language.Get("DungeonAssist110", addRatioVipLv,addRatioStr);
|
}
|
}
|
isSelf = false;
|
callPlayerName = UIHelper.ServerStringTrim(callPlayerName);
|
switch (resultType)
|
{
|
case ResultType.SelfGetScore:
|
isSelf = true;
|
info = Language.Get("DungeonAssist101",fbName,addXianyuanCoins);
|
break;
|
case ResultType.SelfGetPartScore:
|
isSelf = true;
|
info = Language.Get("DungeonAssist100", fbName, addXianyuanCoins);
|
break;
|
case ResultType.SelfNoGetScoreReason2:
|
isSelf = true;
|
info = Language.Get("DungeonAssist102",fbName);
|
break;
|
case ResultType.SelfNoGetScoreReason1:
|
isSelf = true;
|
info = Language.Get("DungeonAssist113", fbName);
|
break;
|
case ResultType.SelfGetExtraScore:
|
isSelf = true;
|
string selfGetExtra = string.Empty;
|
if(addCoins > 0)
|
{
|
selfGetExtra = Language.Get("DungeonAssist115",addCoins);
|
if (!string.IsNullOrEmpty(sumAddStr))
|
{
|
selfGetExtra = StringUtility.Contact(selfGetExtra,",",sumAddStr);
|
}
|
}
|
else
|
{
|
selfGetExtra = sumAddStr;
|
}
|
info = Language.Get("DungeonAssist103",fbName,addXianyuanCoins, selfGetExtra);
|
break;
|
case ResultType.AssistGetScore:
|
info = Language.Get("DungeonAssist104",callPlayerName,callPlayerId,fbName,addXianyuanCoins);
|
break;
|
case ResultType.AssistGetPartScore:
|
info = Language.Get("DungeonAssist116", callPlayerName, callPlayerId, fbName, addXianyuanCoins);
|
break;
|
case ResultType.AssistNoGetScoreReason2:
|
info = Language.Get("DungeonAssist105", callPlayerName, callPlayerId,fbName);
|
break;
|
case ResultType.AssistGetExtraScore:
|
info = Language.Get("DungeonAssist106", callPlayerName, callPlayerId,fbName, addXianyuanCoins,sumAddStr);
|
break;
|
case ResultType.TeamAssistGetScore:
|
info = Language.Get("DungeonAssist107",callPlayerName, callPlayerId,fbName, addXianyuanCoins);
|
break;
|
case ResultType.TeamAssistGetPartScore:
|
info = Language.Get("DungeonAssist117", callPlayerName, callPlayerId, fbName, addXianyuanCoins);
|
break;
|
case ResultType.TeamAssistNoGetScoreReason2:
|
info = Language.Get("DungeonAssist108", callPlayerName, callPlayerId, fbName);
|
break;
|
case ResultType.TeamAssistNoGetScoreReason1:
|
info = Language.Get("DungeonAssist114", callPlayerName, callPlayerId, fbName);
|
break;
|
case ResultType.TeamAssistGetExtraScore:
|
info = Language.Get("DungeonAssist109", callPlayerName, callPlayerId, fbName, addXianyuanCoins,sumAddStr);
|
break;
|
case ResultType.SweepingGetScore:
|
isSelf = true;
|
info = Language.Get("DungeonAssist148", fbName, addXianyuanCoins);
|
break;
|
case ResultType.SweepingGetPartScore:
|
isSelf = true;
|
info = Language.Get("DungeonAssist151", fbName, addXianyuanCoins);
|
break;
|
case ResultType.SweepingNoGetScoreReason2:
|
isSelf = true;
|
info = Language.Get("DungeonAssist149", fbName);
|
break;
|
case ResultType.SweepingNoGetScoreReason1:
|
isSelf = true;
|
info = Language.Get("DungeonAssist152", fbName);
|
break;
|
case ResultType.SweepingGetExtraScore:
|
isSelf = true;
|
string sweepGetExtra = string.Empty;
|
if (addCoins > 0)
|
{
|
sweepGetExtra = Language.Get("DungeonAssist115", addCoins);
|
if (!string.IsNullOrEmpty(sumAddStr))
|
{
|
sweepGetExtra = StringUtility.Contact(sweepGetExtra, ",", sumAddStr);
|
}
|
}
|
else
|
{
|
sweepGetExtra = sumAddStr;
|
}
|
info = Language.Get("DungeonAssist150", fbName, addXianyuanCoins, sweepGetExtra);
|
break;
|
case ResultType.SelfRealmGetScore:
|
isSelf = true;
|
info = Language.Get("DungeonAssist153",fbName,realmName, addXianyuanCoins);
|
break;
|
case ResultType.SelfRealmGetPartScore:
|
isSelf = true;
|
info = Language.Get("DungeonAssist156", fbName,realmName, addXianyuanCoins);
|
break;
|
case ResultType.SelfRealmNoGetScoreReason2:
|
isSelf = true;
|
info = Language.Get("DungeonAssist154", fbName,realmName);
|
break;
|
case ResultType.SelfRealmNoGetScoreReason1:
|
isSelf = true;
|
info = Language.Get("DungeonAssist161", fbName,realmName);
|
break;
|
case ResultType.SelfRealmGetExtraScore:
|
isSelf = true;
|
string selfRealmGetExtra = string.Empty;
|
if (addCoins > 0)
|
{
|
selfRealmGetExtra = Language.Get("DungeonAssist115", addCoins);
|
if (!string.IsNullOrEmpty(sumAddStr))
|
{
|
selfRealmGetExtra = StringUtility.Contact(selfRealmGetExtra, ",", sumAddStr);
|
}
|
}
|
else
|
{
|
selfRealmGetExtra = sumAddStr;
|
}
|
info = Language.Get("DungeonAssist155", fbName,realmName,addXianyuanCoins, selfRealmGetExtra);
|
break;
|
case ResultType.AssistRealmGetScore:
|
info = Language.Get("DungeonAssist157", callPlayerName, callPlayerId, fbName,realmName,addXianyuanCoins);
|
break;
|
case ResultType.AssistRealmGetPartScore:
|
info = Language.Get("DungeonAssist160", callPlayerName, callPlayerId, fbName, realmName,addXianyuanCoins);
|
break;
|
case ResultType.AssistRealmNoGetScoreReason2:
|
info = Language.Get("DungeonAssist158", callPlayerName, callPlayerId, fbName,realmName);
|
break;
|
case ResultType.AssistRealmGetExtraScore:
|
info = Language.Get("DungeonAssist159", callPlayerName, callPlayerId, fbName,realmName,addXianyuanCoins, sumAddStr);
|
break;
|
}
|
|
assistModel.SetHelpInfoLocalSave(createTime,info,isNew,isSelf);
|
}
|
|
public void SetResultIsNew(bool _isNew)
|
{
|
this.isNew = _isNew;
|
}
|
|
public void SetAddXianyuanCoinsTheory()
|
{
|
var dungeonOpenTime = DungeonOpenTimeConfig.Get(mapId);
|
int socialAdd = 0;
|
|
switch (assistType)
|
{
|
case 1:
|
socialAdd = addCoins;
|
if(IsAssistOther)
|
{
|
addXianyuanCoinsTheory = Mathf.RoundToInt((dungeonOpenTime.HelpPoint + socialAdd) * (1 + addRatio * 0.01f));
|
}
|
else
|
{
|
addXianyuanCoinsTheory = Mathf.RoundToInt((dungeonOpenTime.FBPoint + socialAdd) * (1 + addRatio * 0.01f));
|
}
|
break;
|
case 2:
|
switch (relatedToPlayer)
|
{
|
case RelatedToPlayer.Friend:
|
case RelatedToPlayer.FriendAndAlly:
|
socialAdd = assistModel.GetAssistReward(1);
|
break;
|
case RelatedToPlayer.Ally:
|
socialAdd = assistModel.GetAssistReward(2);
|
break;
|
}
|
|
addXianyuanCoinsTheory = Mathf.RoundToInt((dungeonOpenTime.HelpPoint + socialAdd) * (1 + addRatio*0.01f));
|
break;
|
}
|
|
}
|
|
public ResultType GetResultType()
|
{
|
if(isSweep)
|
{
|
if (IsGetAllAssistCoins)
|
{
|
if (IsVipAddRatio || addCoins > 0)
|
{
|
return ResultType.SweepingGetExtraScore;
|
}
|
else
|
{
|
return ResultType.SweepingGetScore;
|
}
|
}
|
else
|
{
|
if (addXianyuanCoins > 0)
|
{
|
return ResultType.SweepingGetPartScore;
|
}
|
else
|
{
|
switch (noGetReason)
|
{
|
case 0:
|
case 2:
|
return ResultType.SweepingNoGetScoreReason2;
|
case 1:
|
return ResultType.SweepingNoGetScoreReason1;
|
}
|
}
|
}
|
}
|
else
|
{
|
if (assistType == 1)
|
{
|
if (IsAssistOther)
|
{
|
if (IsGetAllAssistCoins)
|
{
|
switch (relatedToPlayer)
|
{
|
case RelatedToPlayer.None:
|
return IsVipAddRatio ? ResultType.TeamAssistGetExtraScore : ResultType.TeamAssistGetScore;
|
case RelatedToPlayer.Friend:
|
case RelatedToPlayer.Ally:
|
return ResultType.TeamAssistGetExtraScore;
|
}
|
}
|
else
|
{
|
if (addXianyuanCoins > 0)
|
{
|
return ResultType.TeamAssistGetPartScore;
|
}
|
else
|
{
|
switch (noGetReason)
|
{
|
case 0:
|
case 2:
|
return ResultType.TeamAssistNoGetScoreReason2;
|
case 1:
|
return ResultType.TeamAssistNoGetScoreReason1;
|
}
|
}
|
|
}
|
}
|
else
|
{
|
if (IsGetAllAssistCoins)
|
{
|
if (IsVipAddRatio || addCoins > 0)
|
{
|
return IsRealmDungeon ? ResultType.SelfRealmGetExtraScore : ResultType.SelfGetExtraScore;
|
}
|
else
|
{
|
return IsRealmDungeon ? ResultType.SelfRealmGetScore : ResultType.SelfGetScore;
|
}
|
}
|
else
|
{
|
if (addXianyuanCoins > 0)
|
{
|
return IsRealmDungeon ? ResultType.SelfRealmGetPartScore : ResultType.SelfGetPartScore;
|
}
|
else
|
{
|
switch (noGetReason)
|
{
|
case 0:
|
case 2:
|
return IsRealmDungeon ? ResultType.SelfRealmNoGetScoreReason2 : ResultType.SelfNoGetScoreReason2;
|
case 1:
|
return IsRealmDungeon ? ResultType.SelfRealmNoGetScoreReason1 : ResultType.SelfNoGetScoreReason1;
|
}
|
}
|
}
|
}
|
}
|
else
|
{
|
if (IsGetAllAssistCoins)
|
{
|
switch (relatedToPlayer)
|
{
|
case RelatedToPlayer.None:
|
if(IsVipAddRatio)
|
{
|
return IsRealmDungeon ? ResultType.AssistRealmGetExtraScore : ResultType.AssistGetExtraScore;
|
}
|
else
|
{
|
return IsRealmDungeon ? ResultType.AssistRealmGetScore : ResultType.AssistGetScore;
|
}
|
case RelatedToPlayer.Friend:
|
case RelatedToPlayer.Ally:
|
return IsRealmDungeon ? ResultType.AssistRealmGetExtraScore : ResultType.AssistGetExtraScore;
|
}
|
}
|
else
|
{
|
if (addXianyuanCoins > 0)
|
{
|
return IsRealmDungeon ? ResultType.AssistRealmGetPartScore : ResultType.AssistGetPartScore;
|
}
|
else
|
{
|
return IsRealmDungeon ? ResultType.AssistRealmNoGetScoreReason2 : ResultType.AssistNoGetScoreReason2;
|
}
|
}
|
}
|
}
|
|
return ResultType.None;
|
}
|
|
public void GetCurVipAddRatio()
|
{
|
addRatioVipLv = 0;
|
var vipDict = VipPrivilegeConfig.GetVipPrivilegeDic(VipPrivilegeType.AssistXianYuanCoinsRatioAdd);
|
if (vipDict == null) return;
|
List<int> vipLvlist = vipDict.Keys.ToList();
|
vipLvlist.Sort();
|
for (int i = vipLvlist.Count - 1; i > -1; i--)
|
{
|
var lv = vipLvlist[i];
|
var ratio = vipDict[lv];
|
if(vipLv >= lv)
|
{
|
addRatioVipLv = lv;
|
addRatio = ratio / 100;
|
addRatioStr = StringUtility.Contact(addRatio,"%");
|
break;
|
}
|
}
|
}
|
|
public enum ResultType
|
{
|
None,
|
SelfGetScore,
|
SelfGetPartScore,
|
SelfNoGetScoreReason1,
|
SelfNoGetScoreReason2,
|
SelfGetExtraScore,
|
AssistGetScore,
|
AssistGetPartScore,
|
AssistNoGetScoreReason2,
|
AssistGetExtraScore,
|
TeamAssistGetScore,
|
TeamAssistGetPartScore,
|
TeamAssistNoGetScoreReason1,
|
TeamAssistNoGetScoreReason2,
|
TeamAssistGetExtraScore,
|
SweepingGetScore,
|
SweepingGetPartScore,
|
SweepingNoGetScoreReason1,
|
SweepingNoGetScoreReason2,
|
SweepingGetExtraScore,
|
SelfRealmGetScore,
|
SelfRealmGetPartScore,
|
SelfRealmNoGetScoreReason1,
|
SelfRealmNoGetScoreReason2,
|
SelfRealmGetExtraScore,
|
AssistRealmGetScore,
|
AssistRealmGetPartScore,
|
AssistRealmNoGetScoreReason2,
|
AssistRealmGetExtraScore,
|
//后续IL开发添加预设
|
default1,
|
default2,
|
default3,
|
default4,
|
default5,
|
default6,
|
default7,
|
default8,
|
default9,
|
default10,
|
}
|
}
|
|
public class AssistPlayerInfo
|
{
|
public int ObjID { get; private set; } // 实例ID, 0代表未召唤
|
public int Job { get; private set; } // 玩家职业, 如果是机器人,则职业有值,服务端控制
|
public int Face { get; private set; }
|
public int FacePic { get; private set; }
|
public int PlayerID { get; private set; } // 助战镜像ID, 大于1小于100代表机器人,如果是机器人,没有以下信息,相关信息自己读配置
|
public string Name { get; private set; } // 玩家名,size = NameLen
|
public int LV { get; private set; } // 玩家等级
|
public int RealmLV { get; private set; } // 玩家境界等级
|
public int FightPower { get; private set; } // 玩家战力
|
public int IsNeedGold { get; private set; } // 是否需要仙玉召唤
|
public RelatedToPlayer relatedToPlayer { get; private set;} //与玩家的关系
|
|
public bool IsAssist
|
{
|
get
|
{
|
return ObjID != 0;
|
}
|
}
|
|
public bool IsGoldAssist
|
{
|
get
|
{
|
return IsNeedGold != 0;
|
}
|
}
|
|
DungeonAssistModel assistModel { get { return ModelCenter.Instance.GetModel<DungeonAssistModel>(); }}
|
|
public AssistPlayerInfo(HB207_tagMCHelpBattleList.tagMCHelpBattlePlayer battlePlayer)
|
{
|
ObjID = (int)battlePlayer.ObjID;
|
Job = battlePlayer.Job;
|
Face = (int)battlePlayer.Face;
|
FacePic = (int)battlePlayer.FacePic;
|
PlayerID = (int)battlePlayer.PlayerID;
|
bool isMirror = PlayerID > 100 ? true : false;
|
if(isMirror)
|
{
|
Name = battlePlayer.Name;
|
LV = battlePlayer.LV;
|
RealmLV = battlePlayer.RealmLV;
|
FightPower = (int)battlePlayer.FightPower;
|
IsNeedGold = battlePlayer.IsNeedGold;
|
relatedToPlayer = (RelatedToPlayer)battlePlayer.Relation;
|
}
|
else
|
{
|
NPCConfig nPCConfig = NPCConfig.Get(assistModel.assistRobotId);
|
Name = nPCConfig.charName;
|
relatedToPlayer = RelatedToPlayer.None;
|
int mapId = PlayerDatas.Instance.baseData.MapID;
|
int lineId = 0;
|
if(mapId != 31110)
|
{
|
lineId = PlayerDatas.Instance.baseData.dungeonLineId;
|
}
|
else
|
{
|
lineId = PlayerDatas.Instance.baseData.realmLevel;
|
}
|
var battleConfig = assistModel.GetHelpBattleConfig(mapId,lineId);
|
if(battleConfig != null)
|
{
|
LV = battleConfig.RobotLV;
|
RealmLV = battleConfig.RobotRealmLV;
|
FightPower = battleConfig.RobotFightPower;
|
IsNeedGold = 0;
|
}
|
}
|
}
|
|
public void SetObjID(int _objId)
|
{
|
ObjID = _objId;
|
}
|
|
public int GetAddCoins()
|
{
|
int addCoins = 0;
|
switch (relatedToPlayer)
|
{
|
case RelatedToPlayer.Friend:
|
addCoins = assistModel.GetAssistReward(1);
|
break;
|
case RelatedToPlayer.Ally:
|
addCoins = assistModel.GetAssistReward(2);
|
break;
|
}
|
return addCoins;
|
}
|
}
|
|
public enum RelatedToPlayer
|
{
|
None = 0,//没关系
|
Friend = 1, //好友
|
Ally = 2, //盟友
|
FriendAndAlly = 3, //既是好友又是盟友
|
//后续IL开发添加预设
|
default1,
|
default2,
|
default3,
|
default4,
|
default5,
|
default6,
|
default7,
|
default8,
|
default9,
|
default10,
|
}
|
|
// 请求者协助信息
|
public struct AssistInfo
|
{
|
public string guid;
|
public string playerName; //请求者
|
public int job;
|
public int lv;
|
public int realmLV;
|
public uint mapID;
|
public uint lineID;
|
public uint npcID;
|
public string exData;
|
public uint playerID;
|
public uint Face; //基本脸型
|
public uint FacePic; //头像框
|
}
|
|
public struct AssistThanksGift
|
{
|
public uint ItemID; //礼盒ID
|
public uint MapID;
|
public uint LineID;
|
public uint NPCID;
|
public ushort ExDataLen;
|
public string ExData; //其他自定义数据
|
public byte AssistPlayerCount;
|
}
|
|
}
|
}
|