using vnxbqy.UI;
|
using System;
|
using System.Collections;
|
using System.Collections.Generic;
|
using UnityEngine;
|
using UnityEngine.UI;
|
|
public class CrossServerBattleFieldResourceBehaviour : ILBehaviour
|
{
|
List<Button> crystalBtns = new List<Button>();
|
List<Image> crystalFlag = new List<Image>();
|
List<Image> crystalImg = new List<Image>();
|
List<UIAlphaTween> crystalAlpha = new List<UIAlphaTween>();
|
List<Text> resRate = new List<Text>();
|
Button buffBtn;
|
Image buffImg;
|
Button tyBossBtn;
|
Text tyBossTxt;
|
Button jfqBtn;
|
Button jfghBtn;
|
Text jfghCD;
|
|
protected override void Awake()
|
{
|
for (int i = 0; i < 3; i++)
|
{
|
crystalBtns.Add(proxy.GetWidgtEx<Button>("Btn_Point" + i));
|
crystalFlag.Add(proxy.GetWidgtEx<Image>("Btn_Point" + i));
|
crystalImg.Add(proxy.GetWidgtEx<Image>("Crystal" + i));
|
crystalAlpha.Add(proxy.GetWidgtEx<UIAlphaTween>("Crystal" + i));
|
resRate.Add(proxy.GetWidgtEx<Text>("Rate" + i));
|
}
|
buffBtn = proxy.GetWidgtEx<Button>("SkillBottom3");
|
buffImg = proxy.GetWidgtEx<Image>("Buff3");
|
tyBossBtn = proxy.GetWidgtEx<Button>("Btn_tyboss");
|
tyBossTxt = proxy.GetWidgtEx<Text>("Text1");
|
jfqBtn = proxy.GetWidgtEx<Button>("Btn_jfq");
|
jfghBtn = proxy.GetWidgtEx<Button>("Btn_jfgh");
|
jfghCD = proxy.GetWidgtEx<Text>("Text2");
|
|
for (int i = 0; i < 3; i++)
|
{
|
int index = i;
|
crystalBtns[i].SetListener(() => {
|
OnClickCrystalIcon(index);
|
});
|
}
|
}
|
|
|
protected override void OnEnable()
|
{
|
ILCrossServerModel.Instance.WorldInfoEvent += WorldInfoEvent;
|
ILCrossServerModel.Instance.FactionInfEvent += FactionInfEvent;
|
GlobalTimeEvent.Instance.secondEvent += OnSecondEvent;
|
GameEvent.playerDataRefreshEvent += OnPlayerDataRefreshEvent;
|
|
Display();
|
}
|
|
protected override void OnDisable()
|
{
|
ILCrossServerModel.Instance.WorldInfoEvent -= WorldInfoEvent;
|
ILCrossServerModel.Instance.FactionInfEvent -= FactionInfEvent;
|
GlobalTimeEvent.Instance.secondEvent -= OnSecondEvent;
|
GameEvent.playerDataRefreshEvent -= OnPlayerDataRefreshEvent;
|
}
|
|
|
public void Display()
|
{
|
WorldInfoEvent();
|
FactionInfEvent();
|
OnSecondEvent();
|
}
|
|
void WorldInfoEvent()
|
{
|
var faction = Math.Max(PlayerDatas.Instance.baseData.faction, 1);
|
for (int i = 0; i < 3; i++)
|
{
|
int npcID = ILCrossServerModel.Instance.crystalSortFaction[faction - 1][i];
|
int _camp = 0;
|
ILCrossServerModel.Instance.warCrystalDict.TryGetValue(npcID, out _camp);
|
crystalFlag[i].SetSprite(_camp == 0 ? "GreyBottom" : _camp == 2 ? "RedBottom" : "BlueBottom");
|
crystalImg[i].SetSprite(_camp == 0 ? "GrayCrystal" : _camp == 2 ? "RedCrystal" : "BlueCrystal");
|
crystalAlpha[i].SetStartState();
|
crystalAlpha[i].enabled = false;
|
|
if (ILCrossServerModel.Instance.crystalAtkedList.Contains(npcID))
|
{
|
crystalAlpha[i].enabled = true;
|
}
|
|
}
|
|
|
if (ILCrossServerModel.Instance.factionBuffNPCInfo.Count != 0)
|
{
|
buffBtn.SetActiveIL(true);
|
var skillID = NPCConfig.Get(ILCrossServerModel.Instance.factionBuffNPCInfo[0]).Skill1;
|
buffImg.SetSprite(SkillConfig.Get(skillID).IconName);
|
int posX = ILCrossServerModel.Instance.factionBuffNPCInfo[1];
|
int posY = ILCrossServerModel.Instance.factionBuffNPCInfo[2];
|
buffBtn.SetListener(() =>
|
{
|
MoveToPos(posX, posY);
|
});
|
}
|
else
|
{
|
buffBtn.SetActiveIL(false);
|
}
|
|
tyBossBtn.SetActiveIL(ILCrossServerModel.Instance.eventNPCID == ILCrossServerModel.Instance.CrossBattlefieldBossID);
|
jfqBtn.SetActiveIL(ILCrossServerModel.Instance.eventNPCID == ILCrossServerModel.Instance.CrossBattlefieldScoreWallID);
|
jfghBtn.SetActiveIL(ILCrossServerModel.Instance.eventNPCID == ILCrossServerModel.Instance.CrossBattlefieldScoreAuraID);
|
|
int eventPosX = 0;
|
int eventPosY = 0;
|
if (ILCrossServerModel.Instance.eventNPCPos.Count == 2)
|
{
|
eventPosX = ILCrossServerModel.Instance.eventNPCPos[0];
|
eventPosY = ILCrossServerModel.Instance.eventNPCPos[1];
|
}
|
tyBossBtn.SetListener(() => {
|
MoveToPos(eventPosX, eventPosY, true);
|
});
|
jfqBtn.SetListener(() => {
|
MoveToPos(eventPosX, eventPosY);
|
});
|
jfghBtn.SetListener(() => {
|
MoveToPos(eventPosX, eventPosY);
|
});
|
}
|
|
//buff资源加成 boss归属
|
void FactionInfEvent()
|
{
|
var faction = Math.Max(PlayerDatas.Instance.baseData.faction, 1);
|
bool isAddBuff = false;
|
|
if (faction == 1)
|
{
|
isAddBuff = ILCrossServerModel.Instance.factionInfo_1.factionBuffInfo.Contains(7005);
|
}
|
else if (faction == 2)
|
{
|
isAddBuff = ILCrossServerModel.Instance.factionInfo_2.factionBuffInfo.Contains(7005);
|
}
|
|
for (int i = 0; i < 3; i++)
|
{
|
int npcID = ILCrossServerModel.Instance.crystalSortFaction[faction - 1][i];
|
int _camp = 0;
|
ILCrossServerModel.Instance.warCrystalDict.TryGetValue(npcID, out _camp);
|
|
if (_camp == faction && isAddBuff)
|
{
|
resRate[i].SetActiveIL(true);
|
resRate[i].text = "Buff 100%";
|
}
|
else
|
{
|
resRate[i].SetActiveIL(false);
|
}
|
|
}
|
|
if (ILCrossServerModel.Instance.eventNPCID == ILCrossServerModel.Instance.CrossBattlefieldBossID)
|
{
|
int owner = 0;
|
if (ILCrossServerModel.Instance.factionInfo_1.hurtBossValue > ILCrossServerModel.Instance.factionInfo_2.hurtBossValue)
|
{
|
owner = 1;
|
}
|
else if (ILCrossServerModel.Instance.factionInfo_1.hurtBossValue < ILCrossServerModel.Instance.factionInfo_2.hurtBossValue)
|
{
|
owner = 2;
|
}
|
tyBossTxt.text = Language.Get("CrossBattleField65") + Language.Get(owner == 0 ? "CrossBattleField37" : ("CrossBattleField20_" + owner));
|
|
}
|
}
|
|
//积分光环倒计时
|
void OnSecondEvent()
|
{
|
if (ILCrossServerModel.Instance.eventNPCID == ILCrossServerModel.Instance.CrossBattlefieldScoreAuraID)
|
{
|
var passTime = ((int)Time.time - ILCrossServerModel.Instance.startAuraTime);
|
jfghCD.text = TimeUtility.SecondsToMS(Math.Max(ILCrossServerModel.Instance.eventEndTick / 1000 - passTime, 0));
|
}
|
}
|
|
void OnPlayerDataRefreshEvent(PlayerDataType dataType)
|
{
|
if (dataType != PlayerDataType.Faction)
|
{
|
return;
|
}
|
Display();
|
}
|
|
//等待时间还未分配阵营
|
void OnClickCrystalIcon(int index)
|
{
|
var faction = PlayerDatas.Instance.baseData.faction;
|
if (faction == 0) return;
|
int npcID = ILCrossServerModel.Instance.crystalSortFaction[faction - 1][index];
|
|
//水晶有客户端挖洞的障碍点处理
|
var destX = ILCrossServerModel.Instance.crystaPosDict[npcID][0];
|
var destY = ILCrossServerModel.Instance.crystaPosDict[npcID][1];
|
int pos1 = PlayerDatas.Instance.baseData.PosX;
|
int pos2 = PlayerDatas.Instance.baseData.PosY;
|
var posXFix = PlayerDatas.Instance.baseData.PosX > destX ? destX + 3 : destX - 3;
|
var posYFix = PlayerDatas.Instance.baseData.PosY > destY ? destY + 3 : destY - 3;
|
|
MoveToPos(posXFix, posYFix);
|
}
|
|
void MoveToPos(int posX, int posY, bool startAuto = false)
|
{
|
Vector2 vec = HeroControler.Instance.GetClientPos(posX, posY);
|
PlayerDatas.Instance.hero.Behaviour.StopHandupAI(true);
|
PlayerDatas.Instance.hero.IdleImmediate();
|
PlayerDatas.Instance.hero.StopPathFind();
|
|
if (startAuto)
|
{
|
PlayerDatas.Instance.hero.OnPathFindStop -= PathFindStop;
|
PlayerDatas.Instance.hero.OnPathFindStop += PathFindStop;
|
}
|
MapTransferUtility.Instance.MoveToLocalMapPosition(vec);
|
|
}
|
|
|
void PathFindStop()
|
{
|
PlayerDatas.Instance.hero.OnPathFindStop -= PathFindStop;
|
PlayerDatas.Instance.hero.Behaviour.StartHandupAI();
|
}
|
}
|