using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using LitJson;
|
|
namespace vnxbqy.UI
|
{
|
//开服活动BOSS首杀
|
public class BossFirstBloodWin : Window
|
{
|
[SerializeField] Button m_Goto;
|
[SerializeField] Button m_GetAward;
|
[SerializeField] UIEffect m_EffectGet;
|
[SerializeField] ScrollerController m_BossCtrl;
|
[SerializeField] RawImage m_MonsterPortrait;
|
[SerializeField] Transform m_HorizontaFirstBlood;
|
[SerializeField] Transform m_HorizontaKill;
|
[SerializeField] Text m_NPCNameLV;
|
[SerializeField] Text m_PlayerName;
|
[SerializeField] Text m_KillTime;
|
[SerializeField] UIEffect m_Effect;
|
[SerializeField] Button m_RedPack;
|
[SerializeField] Text m_RedMoney;
|
[SerializeField] RedpointBehaviour redPonint;
|
|
BossFirstBloodModel model
|
{
|
get
|
{
|
return ModelCenter.Instance.GetModel<BossFirstBloodModel>();
|
}
|
}
|
FindPreciousModel findPreciousModel { get { return ModelCenter.Instance.GetModel<FindPreciousModel>(); } }
|
DungeonModel dungeonModel { get { return ModelCenter.Instance.GetModel<DungeonModel>(); } }
|
protected override void AddListeners()
|
{
|
|
}
|
|
private void OnRefreshCell(ScrollerDataType type, CellView cell)
|
{
|
if (type == ScrollerDataType.Header)
|
RefreshNPCCell(cell as BossFirstBloodCell);
|
|
}
|
private void RefreshNPCCell(BossFirstBloodCell _cell)
|
{
|
int npcID = _cell.info.Value.infoInt1;
|
_cell.ShowIcon(npcID, _cell.index == model.selectIndex);
|
_cell.funcBtn.onClick.RemoveAllListeners();
|
_cell.funcBtn.onClick.AddListener(() =>
|
{
|
OnBossIconClick(npcID, _cell.index);
|
});
|
|
}
|
private void GotoKillBoss(int npcID)
|
{
|
var error = 0;
|
if (TestGotoKillBoss(npcID, out error))
|
{
|
WindowJumpMgr.Instance.ClearJumpData();
|
WindowCenter.Instance.Close<OpenServerActivityRankWin>();
|
|
GAStaticDefine.NPCLocation _npcLocation;
|
var _findLocation = GAStaticDefine.TryGetMapNPCLocation(npcID, out _npcLocation);
|
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;
|
}
|
|
var mapId = PlayerDatas.Instance.baseData.MapID;
|
var dataMapId = MapUtility.GetDataMapId(mapId);
|
if (dataMapId == ElderGodAreaModel.ELDERGODAREA_MAPID)
|
{
|
_error = 1;
|
return false;
|
}
|
|
var mapConfig = MapConfig.Get(mapId);
|
if (mapConfig.MapFBType != (int)MapType.OpenCountry && mapId != 31020)
|
{
|
_error = 2;
|
return false;
|
}
|
|
if (CrossServerUtility.IsCrossServer() || ClientCrossServerOneVsOne.isClientCrossServerOneVsOne)
|
{
|
_error = 3;
|
return false;
|
}
|
|
_error = 0;
|
return true;
|
}
|
|
private void SendGetAward(int npcID, int awardType)
|
{
|
var pak = new CA901_tagCGGetBossFirstKillAward();
|
pak.NPCID = (uint)npcID;
|
pak.AwardType = (byte)awardType;
|
GameNetSystem.Instance.SendInfo(pak);
|
}
|
|
|
|
private void OnBossIconClick(int npcID, int index)
|
{
|
var npcConfig = NPCConfig.Get(npcID);
|
if (!m_MonsterPortrait.gameObject.activeSelf)
|
m_MonsterPortrait.SetActive(true);
|
UI3DModelExhibition.Instance.ShowNPC(npcID, npcConfig.UIModeLOffset, npcConfig.UIModelRotation, m_MonsterPortrait);
|
model.selectIndex = index;
|
model.selectNPCID = npcID;
|
m_BossCtrl.m_Scorller.RefreshActiveCellViews();
|
|
m_NPCNameLV.text = npcConfig.charName + " LV." + npcConfig.NPCLV;
|
|
//首杀 未击杀红包正常亮,已击杀未领取显示特效红点,已领取置灰
|
redPonint.redpointId = model.GetNPCRedPackPointID(npcID);
|
model.UpdateRedPackPoint(npcID);
|
ShowKillInfo(npcID);
|
|
m_RedPack.RemoveAllListeners();
|
m_RedPack.AddListener(() =>
|
{
|
ClickRedPack(npcID);
|
});
|
|
}
|
|
private void ClickRedPack(int npcID)
|
{
|
var state = model.GetBossKillAwardState(npcID);
|
|
if (state == 1)
|
{
|
SendGetAward(npcID, 0);
|
return;
|
}
|
var npcConfig = NPCConfig.Get(npcID);
|
if (state == 0)
|
SysNotifyMgr.Instance.ShowTip("NoBossFirstKill", npcConfig.charName);
|
else if (state == 2)
|
SysNotifyMgr.Instance.ShowTip("GetBossFirstKillAwardYet", npcConfig.charName);
|
}
|
|
public void ShowKillInfo(int npcID)
|
{
|
if (model.selectNPCID != npcID)
|
return;
|
var fkInfo = BOSSFirstKillConfig.Get(npcID);
|
bool isAlreadyFirstKill = model.IsAlreadyFirstKill(npcID);
|
int killStateSelf = model.GetPersonalKillAwardState(npcID);
|
|
m_Goto.RemoveAllListeners();
|
m_GetAward.RemoveAllListeners();
|
if (killStateSelf == 1)
|
{
|
m_GetAward.SetActive(true);
|
m_EffectGet.Play();
|
m_Goto.SetActive(false);
|
m_GetAward.AddListener(() =>
|
{
|
SendGetAward(npcID, 1);
|
});
|
|
}
|
else
|
{
|
m_GetAward.SetActive(false);
|
m_EffectGet.Stop();
|
m_Goto.SetActive(true);
|
m_Goto.AddListener(() =>
|
{
|
GotoKillBoss(npcID);
|
});
|
}
|
if (isAlreadyFirstKill)
|
{
|
m_PlayerName.text = Language.Get("FirstKill1") + model.firstKillTimeInfo[npcID].name;
|
m_KillTime.text = Language.Get("FirstKill2") + model.firstKillTimeInfo[npcID].time;
|
}
|
else
|
{
|
m_PlayerName.text = Language.Get("FirstKill3");
|
m_KillTime.text = string.Empty;
|
}
|
|
|
//首杀奖励
|
for (int i = 0; i < m_HorizontaFirstBlood.childCount; i++)
|
{
|
m_HorizontaFirstBlood.GetChild(i).SetActive(false);
|
}
|
var fkitemsArray = JsonMapper.ToObject<int[][]>(fkInfo.ServerFirstKillPlayerAward);
|
|
for (int type = 0; type < fkitemsArray.Length; type++)
|
{
|
if (type < m_HorizontaFirstBlood.childCount)
|
{
|
int itemId = fkitemsArray[type][0];
|
var Item_Info = m_HorizontaFirstBlood.GetChild(type);
|
Item_Info.SetActive(true);
|
BossFirstBloodItemInfo firstBItemInfo = Item_Info.GetComponent<BossFirstBloodItemInfo>();
|
|
firstBItemInfo.AlreadyGetImage.SetActive(isAlreadyFirstKill);
|
var ItemCell = firstBItemInfo.Item_Cell;
|
var Item = ItemConfig.Get(itemId);
|
ItemCellModel cellModel = new ItemCellModel(itemId, true, (ulong)fkitemsArray[type][1]);
|
ItemCell.Init(cellModel);
|
ItemCell.button.RemoveAllListeners();
|
ItemCell.button.AddListener(() =>
|
{
|
ItemTipUtility.Show(itemId);
|
});
|
}
|
}
|
|
|
//击杀奖励
|
for (int i = 0; i < m_HorizontaKill.childCount; i++)
|
{
|
m_HorizontaKill.GetChild(i).SetActive(false);
|
}
|
var itemsArray = JsonMapper.ToObject<int[][]>(fkInfo.PersonFirstKillAward);
|
|
for (int type = 0; type < itemsArray.Length; type++)
|
{
|
if (type < m_HorizontaKill.childCount)
|
{
|
int itemId = itemsArray[type][0];
|
var Item_Info = m_HorizontaKill.GetChild(type);
|
Item_Info.SetActive(true);
|
BossFirstBloodItemInfo itemInfo = Item_Info.GetComponent<BossFirstBloodItemInfo>();
|
|
itemInfo.AlreadyGetImage.SetActive(killStateSelf == 2);
|
|
var ItemCell = itemInfo.Item_Cell;
|
var Item = ItemConfig.Get(itemId);
|
ItemCellModel cellModel = new ItemCellModel(itemId, true, (ulong)itemsArray[type][1]);
|
ItemCell.Init(cellModel);
|
ItemCell.button.RemoveAllListeners();
|
ItemCell.button.AddListener(() =>
|
{
|
ItemTipUtility.Show(itemId);
|
});
|
}
|
}
|
// 红包状态
|
var state = model.GetBossKillAwardState(npcID);
|
m_RedMoney.SetActive(false);
|
if (state == 0)
|
{
|
m_RedPack.SetColorful(null, true);
|
m_Effect.Stop();
|
}
|
else if (state == 1)
|
{
|
m_RedPack.SetColorful(null, true);
|
m_Effect.Play();
|
}
|
else if (state == 2)
|
{
|
m_RedPack.SetColorful(null, false);
|
m_RedMoney.SetActive(true);
|
m_Effect.Stop();
|
}
|
|
}
|
protected override void BindController()
|
{
|
}
|
|
protected override void OnAfterClose()
|
{
|
}
|
|
protected override void OnAfterOpen()
|
{
|
|
JumpNpcByIndex(model.GetFirstNPCRedPoint());
|
}
|
|
protected override void OnPreClose()
|
{
|
m_BossCtrl.OnRefreshCell -= OnRefreshCell;
|
model.UpdatePersonnalKillEvent -= ShowKillInfo;
|
UI3DModelExhibition.Instance.StopShow();
|
}
|
|
protected override void OnPreOpen()
|
{
|
m_BossCtrl.OnRefreshCell += OnRefreshCell;
|
model.UpdatePersonnalKillEvent += ShowKillInfo;
|
CreateNPCScroll();
|
if (WindowCenter.Instance.IsOpen<ImpactRankWin>())
|
WindowCenter.Instance.Close<ImpactRankWin>();
|
}
|
private void CreateNPCScroll()
|
{
|
int i = 0;
|
m_BossCtrl.Refresh();
|
foreach (string npcID in model.npcIDConfig)
|
{
|
CellInfo info = new CellInfo();
|
info.infoInt1 = int.Parse(npcID);
|
m_BossCtrl.AddCell(ScrollerDataType.Header, i, info);
|
i++;
|
}
|
m_BossCtrl.Restart();
|
m_BossCtrl.m_Scorller.RefreshActiveCellViews();
|
}
|
|
public void JumpNpcByIndex(Int2 npcInfo)
|
{
|
int index = npcInfo.x;
|
int npcID = npcInfo.y;
|
m_BossCtrl.JumpIndex(npcInfo.x);
|
CellView cell = m_BossCtrl.GetActiveCellView(index);
|
if (cell != null)
|
// 此处取的是显示的index,npcindex比这个大取到是空的
|
npcID = cell.info.Value.infoInt1;
|
OnBossIconClick(npcID, index);
|
}
|
|
}
|
}
|