using System;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
|
// 群英挑战
|
public class QYFighterCell : MonoBehaviour
|
{
|
[SerializeField] HorseController model;
|
[SerializeField] OfficialTitleCell officialTitleCell;
|
[SerializeField] Text fightPowerText;
|
[SerializeField] Text nameText;
|
[SerializeField] Text serverText;
|
[SerializeField] Button queryPlayerBtn; //后续添加点击查看玩家详情
|
[SerializeField] Text rankText;
|
[SerializeField] Transform myMark;
|
[SerializeField] Button challengeBtn;
|
[SerializeField] Transform quickObj;
|
[SerializeField] Button quickChallengeBtn;
|
[SerializeField] Button quickChallengeMoreBtn;
|
[SerializeField] Text quickChallengeMoreText;
|
|
|
|
QunyingMatchInfo matchInfo;
|
void Start()
|
{
|
challengeBtn.SetListener(() =>
|
{
|
if (matchInfo == null)
|
return;
|
if (!UIHelper.CheckMoneyCount(QunyingManager.challengeMoneyType, 1, 1))
|
{
|
StoreModel.Instance.ShowBuyItem(QunyingManager.challengeShopID, -1);
|
return;
|
}
|
QunyingManager.Instance.atkPlayerId = matchInfo.PlayerID;
|
QunyingManager.Instance.tagRank = matchInfo.Rank;
|
BattleManager.Instance.SendTurnFight(QunyingManager.DataMapID, 0, 1, matchInfo.PlayerID, new uint[] { matchInfo.Rank, 0 });
|
});
|
|
queryPlayerBtn.AddListener(() =>
|
{
|
if (GeneralDefine.IsRobot((int)matchInfo.PlayerID)) return;
|
AvatarHelper.TryViewOtherPlayerInfo((int)matchInfo.PlayerID, viewPlayerLineupType: (int)BattlePreSetType.Qunying);
|
});
|
|
quickChallengeBtn.AddListener(() =>
|
{
|
if (matchInfo == null)
|
return;
|
if (!UIHelper.CheckMoneyCount(QunyingManager.challengeMoneyType, 1, 1))
|
{
|
StoreModel.Instance.ShowBuyItem(QunyingManager.challengeShopID, -1);
|
return;
|
}
|
QunyingManager.Instance.atkPlayerId = matchInfo.PlayerID;
|
BattleManager.Instance.SendTurnFight(QunyingManager.DataMapID, 0, 1, matchInfo.PlayerID, new uint[] { matchInfo.Rank, 1 }, false);
|
});
|
|
quickChallengeMoreBtn.AddListener(() =>
|
{
|
if (matchInfo == null)
|
return;
|
|
//最低显示两次,但可以最低挑战1次
|
var cnt = Math.Max(1, Math.Min(5, UIHelper.GetMoneyCnt(QunyingManager.challengeMoneyType)));
|
if (!UIHelper.CheckMoneyCount(QunyingManager.challengeMoneyType, cnt, 1))
|
{
|
StoreModel.Instance.ShowBuyItem(QunyingManager.challengeShopID, -1);
|
return;
|
}
|
QunyingManager.Instance.atkPlayerId = matchInfo.PlayerID;
|
BattleManager.Instance.SendTurnFight(QunyingManager.DataMapID, 0, 1, matchInfo.PlayerID, new uint[] { matchInfo.Rank, (uint)cnt }, false);
|
});
|
}
|
|
public void Display(int index)
|
{
|
var myMatch = QunyingManager.Instance.GetMyMatchInfo(out int myIndex);
|
var list = QunyingManager.Instance.matchInfoList;
|
if (list.IsNullOrEmpty() || index < 0 || index >= list.Count)
|
{
|
if (myMatch != null)
|
{
|
this.SetActive(false);
|
return;
|
}
|
if (myMatch == null && index != 4)
|
{
|
this.SetActive(false);
|
return;
|
}
|
//自己未上版的 在第5位补
|
|
}
|
|
this.SetActive(true);
|
|
if (myMatch == null && index == 4)
|
{
|
//填充自己的
|
matchInfo = new QunyingMatchInfo
|
{
|
Rank = 0,
|
PlayerID = PlayerDatas.Instance.baseData.PlayerID,
|
PlayerName = PlayerDatas.Instance.baseData.PlayerName,
|
LV = PlayerDatas.Instance.baseData.LV,
|
RealmLV = PlayerDatas.Instance.baseData.realmLevel,
|
FightPower = (ulong)PlayerDatas.Instance.baseData.FightPower,
|
TitleID = (uint)PlayerDatas.Instance.baseData.TitleID,
|
ModelMark = (uint)PlayerDatas.Instance.baseData.modelMark,
|
EquipShowSwitch = PlayerDatas.Instance.baseData.equipShowSwitch,
|
ServerID = (uint)ServerListCenter.Instance.currentServer.region_flag,
|
};
|
}
|
else
|
{
|
matchInfo = list[index];
|
}
|
|
|
|
if (GeneralDefine.IsRobot((int)matchInfo.PlayerID))
|
{
|
serverText.text = Language.Get("Qunying15");
|
}
|
else
|
{
|
serverText.text = ServerListCenter.Instance.GetServerName((int)matchInfo.ServerID);
|
}
|
|
|
|
int heroSkinID = 0;
|
if (matchInfo.ModelMark == 0)
|
{
|
heroSkinID = QunyingManager.Instance.robotModelIDs[matchInfo.PlayerID % QunyingManager.Instance.robotModelIDs.Length];
|
}
|
else
|
{
|
heroSkinID = PhantasmPavilionManager.Instance.GetModelSkinID((int)matchInfo.ModelMark);
|
}
|
|
if (matchInfo.PlayerID == PlayerDatas.Instance.baseData.PlayerID)
|
{
|
fightPowerText.text = UIHelper.ReplaceLargeArtNum(PlayerDatas.Instance.baseData.FightPower);
|
nameText.text = UIHelper.ServerStringTrim(PlayerDatas.Instance.baseData.PlayerName);
|
|
var skinConfig = HorseSkinConfig.Get(HorseManager.Instance.GetUsingHorseSkinID());
|
model.Create(skinConfig.SkinID, PhantasmPavilionManager.Instance.GetMyModelSkinID(), 0.9f);
|
officialTitleCell.InitUI(PlayerDatas.Instance.baseData.realmLevel, PlayerDatas.Instance.baseData.TitleID);
|
}
|
else
|
{
|
fightPowerText.text = UIHelper.ReplaceLargeArtNum(matchInfo.FightPower);
|
nameText.text = UIHelper.ServerStringTrim(matchInfo.PlayerName);
|
model.Create((int)matchInfo.EquipShowSwitch % 1000, heroSkinID, 0.9f);
|
officialTitleCell.InitUI(matchInfo.RealmLV, (int)matchInfo.TitleID);
|
}
|
|
|
rankText.text = matchInfo.Rank > 0 ? $"{matchInfo.Rank}" : Language.Get("L1125");
|
myMark.SetActive(matchInfo.PlayerID == PlayerDatas.Instance.baseData.PlayerID);
|
|
var ticketCnt = Math.Max(2, Math.Min(5, UIHelper.GetMoneyCnt(QunyingManager.challengeMoneyType)));
|
if (myMatch != null && myMatch.Rank < matchInfo.Rank)
|
{
|
//低于自己的
|
quickObj.SetActive(true);
|
challengeBtn.SetActive(false);
|
quickChallengeMoreText.text = Language.Get("Qunying9", ticketCnt);
|
}
|
else if ((myMatch == null && index == 4) || (myMatch != null && myMatch.Rank == matchInfo.Rank))
|
{
|
//是自己,分是否上榜情况
|
quickObj.SetActive(false);
|
challengeBtn.SetActive(false);
|
}
|
else
|
{
|
quickObj.SetActive(false);
|
challengeBtn.SetActive(true);
|
}
|
}
|
|
|
|
}
|