289 lines
9.1 KiB
C#
289 lines
9.1 KiB
C#
using UnityEngine;
|
|
using System.Collections;
|
|
using Games.GlobeDefine;
|
|
using System.Collections.Generic;
|
|
using Games.LogicObj;
|
|
using System;
|
|
|
|
public class PVPData
|
|
{
|
|
public struct OpponentInfo
|
|
{
|
|
public OpponentInfo(ulong _guid, string _name, CharacterDefine.PROFESSION _profession, int _level,
|
|
int _power, int _range, int _winSpirit, int _loseSpirit, int _winReputation, int _loseReputation)
|
|
{
|
|
guid = _guid;
|
|
name = _name;
|
|
profession = _profession;
|
|
level = _level;
|
|
fightPower = _power;
|
|
range = _range;
|
|
winSpirit = _winSpirit;
|
|
loseSpirit = _loseSpirit;
|
|
winReputation = _winReputation;
|
|
loseReputation = _loseReputation;
|
|
}
|
|
|
|
public bool IsValid( )
|
|
{
|
|
return (guid != Games.GlobeDefine.GlobeVar.INVALID_GUID);
|
|
}
|
|
|
|
public void Clear()
|
|
{
|
|
guid = Games.GlobeDefine.GlobeVar.INVALID_GUID;
|
|
}
|
|
|
|
public ulong guid;
|
|
public string name;
|
|
public CharacterDefine.PROFESSION profession;
|
|
public int level;
|
|
public int fightPower;
|
|
public int winSpirit;
|
|
public int loseSpirit;
|
|
public int winReputation;
|
|
public int loseReputation;
|
|
public int range;
|
|
}
|
|
|
|
public static int MyPVPRange {set;get;}
|
|
public static int LeftFightTime {set;get;}
|
|
public static int Power {set;get;} // zhenqi
|
|
|
|
public static Dictionary<ulong, OpponentInfo> OpponentMap = new Dictionary<ulong, OpponentInfo>();
|
|
|
|
public delegate void UpdateOpponentDelegate();
|
|
public static UpdateOpponentDelegate delUpdateOpponent;
|
|
public static int NeedCostYuanBao { set; get; }
|
|
public static void UpdateOpponentInfo(GC_OPPONENT_LIST data)
|
|
{
|
|
OpponentMap.Clear();
|
|
if (data.HasNeedCost)
|
|
{
|
|
NeedCostYuanBao = data.NeedCost;
|
|
}
|
|
else
|
|
{
|
|
NeedCostYuanBao = 0;
|
|
}
|
|
for (int i = 0; i < data.userGuidCount; i++)
|
|
{
|
|
|
|
OpponentMap.Add((ulong)i,
|
|
new OpponentInfo(data.GetUserGuid(i), data.GetName(i),
|
|
(CharacterDefine.PROFESSION)data.GetProfession(i),
|
|
data.GetLevel(i), data.GetCombatNum(i),
|
|
data.GetRankPos(i) + 1,
|
|
data.GetWinSpirit(i), data.GetLoseSpirit(i), data.GetWinReputataion(i), data.GetLoseReputataion(i)));
|
|
}
|
|
|
|
if (null != delUpdateOpponent) delUpdateOpponent();
|
|
}
|
|
|
|
public delegate void UpdateMyDataDelegate();
|
|
public static UpdateMyDataDelegate delUpdateMyData;
|
|
public static void UpdateMyData(GC_CHALLENGE_MYDATA data)
|
|
{
|
|
MyPVPRange = data.RankPos;
|
|
Power = data.SpiritVal;
|
|
LeftFightTime = data.ChallengeTimes;
|
|
if (null != delUpdateMyData) delUpdateMyData();
|
|
|
|
}
|
|
|
|
//-----------------------------------------------------------------------------------
|
|
public struct HistroyData
|
|
{
|
|
public HistroyData(ulong _guid, int _pos, uint _occurTime, int _lose, int _active,string name )
|
|
{
|
|
guid = _guid;
|
|
rankPos = _pos;
|
|
occurTime = _occurTime;
|
|
isLose = _lose;
|
|
isActive = _active;
|
|
opponentName = name;
|
|
}
|
|
|
|
public ulong guid;
|
|
public int rankPos;
|
|
public uint occurTime;
|
|
public int isLose;
|
|
public int isActive;
|
|
public string opponentName;
|
|
}
|
|
public static List<HistroyData> ChallengeHistory = new List<HistroyData>();
|
|
public delegate void UpdatePvPRecordListDelegate();
|
|
public static UpdatePvPRecordListDelegate delegateUpdatePvPRecordList;
|
|
public static void UpdateChallengeHistory(GC_CHALLENGE_HISTORY data)
|
|
{
|
|
ChallengeHistory.Clear();
|
|
for (int i = 0; i < data.userGuidCount; i++)
|
|
{
|
|
ChallengeHistory.Add(new HistroyData(data.GetUserGuid(i), data.GetRankPos(i), data.GetOccurTime(i), data.GetIsLose(i), data.GetIsActive(i), data.GetName(i)));
|
|
}
|
|
if (delegateUpdatePvPRecordList != null)
|
|
delegateUpdatePvPRecordList();
|
|
}
|
|
|
|
//------------------------------------------------------
|
|
public static int ChallengeIsLose { set; get; }
|
|
public static int ChallengeSpirit { set; get; }
|
|
public static int ChallengeReputation { set; get; }
|
|
public static bool ChallengeAutoShow { set; get; }
|
|
public static void UpdateChallengeReward(GC_CHALLENGE_REWARD data)
|
|
{
|
|
Obj_MainPlayer mainPlayer = Singleton<ObjManager>.GetInstance().MainPlayer;
|
|
if (mainPlayer != null && data.IsLose > 0)
|
|
{
|
|
long nPlayerMaxHP = mainPlayer.BaseAttr.MaxHP;
|
|
|
|
}
|
|
|
|
// TT7092
|
|
// if (data.IsLose != 1)
|
|
ChallengeAutoShow = false;
|
|
|
|
|
|
ChallengeIsLose = data.IsLose;
|
|
ChallengeSpirit = data.SpiritVal;
|
|
ChallengeReputation = 0;
|
|
if (data.HasReputationVal)
|
|
{
|
|
ChallengeReputation = data.ReputationVal;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public static void CheckAutoShowChallengeUI()
|
|
{
|
|
if (PVPData.ChallengeAutoShow == true)
|
|
{
|
|
PVPData.ChallengeAutoShow = false;
|
|
if (null != ActivityController.Instance())
|
|
{
|
|
//ActivityController.Instance().ChangeToPvP();
|
|
}
|
|
else
|
|
{
|
|
UIManager.ShowUI(UIInfo.Activity, OnActiveShowActiviController);
|
|
}
|
|
}
|
|
}
|
|
|
|
static void OnActiveShowActiviController(bool bSuccess, object param)
|
|
{
|
|
//ActivityController.Instance().ChangeToPvP();
|
|
}
|
|
|
|
//------------------------------------------------------
|
|
#region PvP排行榜
|
|
public struct PvPRankListItemInfo
|
|
{
|
|
public PvPRankListItemInfo(ulong _id, string _name, int _pos, int _com, int _level, int _profession, int _zhenqi)
|
|
{
|
|
id = _id;
|
|
name = _name;
|
|
pos = _pos;
|
|
com = _com;
|
|
level = _level;
|
|
profession = _profession;
|
|
zhenqi = _zhenqi;
|
|
score = 0;
|
|
}
|
|
|
|
public ulong id;
|
|
public string name;
|
|
public int score;
|
|
public int pos;
|
|
public int com;
|
|
public int level;
|
|
public int profession;
|
|
public int zhenqi;
|
|
}
|
|
|
|
public static int PvPRankCurPage { set; get; }
|
|
public static int PvPRankTotalPage { set; get; }
|
|
public static List<PVPData.PvPRankListItemInfo> PvPRankList = new List<PVPData.PvPRankListItemInfo>();
|
|
public delegate void UpdatePvPRankListDelegate();
|
|
public static UpdatePvPRankListDelegate delegateUpdatePvPRankList;
|
|
public static void UpdatePvPRankList(GC_CHALLENGERANKLIST packet)
|
|
{
|
|
PvPRankList.Clear();
|
|
PvPRankCurPage = packet.Page;
|
|
PvPRankTotalPage = packet.Totalpage;
|
|
for (int i = 0; i < packet.userGuidCount; i++)
|
|
{
|
|
PvPRankList.Add(new PvPRankListItemInfo(
|
|
packet.GetUserGuid(i), packet.GetName(i), packet.GetPos(i),
|
|
packet.GetCombatNum(i), packet.GetLevel(i), packet.GetProfession(i), packet.GetZhenqi(i)));
|
|
}
|
|
if( delegateUpdatePvPRankList != null) delegateUpdatePvPRankList();
|
|
}
|
|
#endregion
|
|
|
|
public struct RankDataItem
|
|
{
|
|
public RankDataItem(UInt64 Guid = GlobeVar.INVALID_GUID, string s1 = "", string s2 = "", string s3 = "", string s4 = "", string s5 = "", string s6 = "")
|
|
{
|
|
m_Guid = Guid;
|
|
str1 = s1;
|
|
str2 = s2;
|
|
str3 = s3;
|
|
str4 = s4;
|
|
str5 = s5;
|
|
str6 = s6;
|
|
}
|
|
|
|
public UInt64 m_Guid;
|
|
public string str1;
|
|
public string str2;
|
|
public string str3;
|
|
public string str4;
|
|
public string str5;
|
|
public string str6;
|
|
}
|
|
|
|
public static List<PVPData.RankDataItem> RankDataList = new List<PVPData.RankDataItem>();
|
|
public static string meRank { set; get; }
|
|
public static int RankTotalPage { set; get; }
|
|
public static int RankCurPage { set; get; }
|
|
public static int RankType { set; get; }
|
|
public static bool RankIsPage { set; get; }
|
|
|
|
public static void ClearRankData()
|
|
{
|
|
RankDataList.Clear();
|
|
meRank = "";
|
|
RankTotalPage = 1;
|
|
RankCurPage = 0;
|
|
RankIsPage = false;
|
|
RankType = (int)GameDefine_Globe.RANKTYPE.TYPE_CANGJINGGE;
|
|
}
|
|
|
|
public static void AddRankDataItem( UInt64 oGuid = GlobeVar.INVALID_GUID, string s1 = "", string s2 = "", string s3 = "", string s4 = "", string s5 = "", string s6 = "")
|
|
{
|
|
PVPData.RankDataList.Add(new RankDataItem(oGuid, s1, s2, s3, s4, s5, s6));
|
|
}
|
|
|
|
public static void ShowRank()
|
|
{
|
|
UIManager.ShowUI(UIInfo.RankRoot, OnOpenRankWindow);
|
|
}
|
|
|
|
static void OnOpenRankWindow(bool bSuccess, object param)
|
|
{
|
|
if (RankWindow.Instance() != null)
|
|
{
|
|
RankWindow.Instance().isRankDataReturn = true;
|
|
RankWindow.Instance().RankDataCallBack(RankType);
|
|
|
|
RankWindow.Instance().SetTotalPage(PVPData.RankTotalPage, PVPData.RankCurPage);
|
|
|
|
RankWindow.Instance().isRankDataReturn = false;
|
|
}
|
|
}
|
|
|
|
|
|
}
|