703 lines
24 KiB
C#
703 lines
24 KiB
C#
using Games.AI_Logic;
|
||
using Games.Events;
|
||
using Games.GlobeDefine;
|
||
using Games.ImpactModle;
|
||
using Games.Item;
|
||
using Games.LogicObj;
|
||
using Games.SkillModle;
|
||
using GCGame.Table;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using UnityEngine;
|
||
using UnityEngine.UI;
|
||
|
||
[System.Serializable]
|
||
public class UseItemInfo
|
||
{
|
||
public GameObject _ItemCountBG;
|
||
|
||
public bool isUseItem;
|
||
public Button m_ItemButton;
|
||
public Image m_ItemCDImage;
|
||
public Text m_ItemCountText;
|
||
public Image m_ItemIcon;
|
||
//public int m_ItemCDTime { get; set; }
|
||
|
||
//public void CleanUP()
|
||
//{
|
||
// m_ItemButton = null;
|
||
// m_ItemCDImage = null;
|
||
// m_ItemCDTime = 0;
|
||
// //isSetItem = false;
|
||
// m_ItemCountText.text = "";
|
||
// m_ItemIcon.gameObject.SetActive(false);
|
||
// _ItemCountBG.SetActive(false);
|
||
//}
|
||
}
|
||
|
||
public class SkillBarLogic : UIControllerBase<SkillBarLogic>
|
||
{
|
||
private float itemCdRemainTime;
|
||
|
||
private float itemTotalCdTime;
|
||
|
||
public UseItemInfo m_ItemInfo;
|
||
|
||
//public GameObject _AutoPanel;
|
||
//public GameObject m_BtnAutoBegin;
|
||
//public GameObject m_BtnAutoStop;
|
||
public RectTransform[] skillButtonRoots;
|
||
public SkillButton[] SkillButtons { get; private set; }
|
||
|
||
public PetSkillButton PetSkillMW;
|
||
public PetSkillButton PetSkillGY;
|
||
|
||
public void FightPetChange(object obj)
|
||
{
|
||
Games.Fellow.Fellow fellow = GameManager.gameManager.PlayerDataPool.FellowContainer.GetRealFightPet();
|
||
if (fellow == null)
|
||
{
|
||
PetSkillMW.Clear();
|
||
PetSkillGY.Clear();
|
||
return;
|
||
}
|
||
FightPetSkill();
|
||
}
|
||
|
||
public void FightPetSkill()
|
||
{
|
||
//Games.Fellow.Fellow fellow = GameManager.gameManager.PlayerDataPool.FellowContainer.GetRealFightPet();
|
||
//if (fellow.GetSkillData(0) != null && fellow.GetSkillData(0).IsValid())
|
||
// PetSkillMW.SetSkillIndex(0);
|
||
//else if (fellow.GetSkillData(1) != null && fellow.GetSkillData(1).IsValid())
|
||
// PetSkillMW.SetSkillIndex(1);
|
||
PetSkillMW.SetSkillIndex(0);
|
||
PetSkillGY.SetSkillIndex(1);
|
||
}
|
||
|
||
// Use this for initialization
|
||
private void Start()
|
||
{
|
||
UserConfigData._CurSkillPage = null;
|
||
|
||
if (GameManager.gameManager != null && GameManager.gameManager.PlayerDataPool != null &&
|
||
GameManager.gameManager.PlayerDataPool.HasInitOwnSkill)
|
||
RefreshSkillBarInfo();
|
||
|
||
//UpdateAutoFightBtnState();
|
||
SetSimpleAttackIcon();
|
||
|
||
//设置之前先同步Item的CD状态
|
||
ReqMyItemCDInfo(); //同步item的cd时间
|
||
|
||
if (GlobalData._IsRefreshShortcutItem)
|
||
{
|
||
GlobalData._IsRefreshShortcutItem = false;
|
||
SetUseItem();
|
||
}
|
||
|
||
FightPetChange(null);
|
||
UpdateComboTarget(null);
|
||
EventDispatcher.Instance.Add(EventId.LockSkillInput, UpdateComboTarget);
|
||
}
|
||
|
||
public void SetSimpleAttackIcon()
|
||
{
|
||
_SimpleAttackIcon.overrideSprite = _SimpleAttackIconLists[GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Profession];
|
||
}
|
||
|
||
public List<Sprite> _SimpleAttackIconLists;
|
||
public Image _SimpleAttackIcon;
|
||
private void Awake()
|
||
{
|
||
SetInstance(this);
|
||
SkillButtons = new SkillButton[skillButtonRoots.Length];
|
||
// 由Source文件复制技能按钮到各位置
|
||
var source = skillButtonRoots[0].parent.Find("Source");
|
||
for (var i = 0; i < skillButtonRoots.Length; i++)
|
||
{
|
||
var skillButtonTrans = Instantiate(source);
|
||
skillButtonTrans.SetParent(skillButtonRoots[i], false);
|
||
SkillButtons[i] = skillButtonTrans.GetComponent<SkillButton>();
|
||
SkillButtons[i].SkillBarIndex = i;
|
||
}
|
||
|
||
Destroy(source.gameObject);
|
||
RefreshShortCutItem();
|
||
Games.Events.EventDispatcher.Instance.Add(Games.Events.EventId.UPDATA_PET_CALLFIGHTINFO, FightPetChange);
|
||
}
|
||
|
||
private void OnDestroy()
|
||
{
|
||
Games.Events.EventDispatcher.Instance.Remove(Games.Events.EventId.UPDATA_PET_CALLFIGHTINFO, FightPetChange);
|
||
EventDispatcher.Instance.Remove(EventId.LockSkillInput, UpdateComboTarget);
|
||
StopAllCoroutines();
|
||
}
|
||
|
||
public void RefreshSkillBarInfo()
|
||
{
|
||
var _mainPlayer = Singleton<ObjManager>.GetInstance().MainPlayer;
|
||
if (_mainPlayer == null) return;
|
||
|
||
var skillActives = TableManager.GetSkillActive().Values;
|
||
var skillCount = 0;
|
||
foreach (var skill in skillActives)
|
||
if (skill.Profession == _mainPlayer.Profession)
|
||
skillCount++;
|
||
|
||
if (skillCount < 0)
|
||
return;
|
||
//清理无效技能
|
||
var hasSet = false;
|
||
//UserConfigData.LoadAllSkillPage(_mainPlayer.GUID.ToString());
|
||
|
||
//if (UserConfigData._CurSkillPage != null)
|
||
//{
|
||
// //_mainPlayer.ClearAutoSelSkillID();
|
||
// for (var i = 0; i < SkillButtons.Length; i++)
|
||
// SkillButtons[i].Clear();
|
||
|
||
// var _skillBarSetInfo = UserConfigData._CurSkillPage.SkillIdxs;
|
||
// Debug.LogError("_skillBarSetInfo.Length : " + _skillBarSetInfo.Length);
|
||
// for (var skillBarIndex = 0; skillBarIndex < _skillBarSetInfo.Length; skillBarIndex++)
|
||
// {
|
||
// if (skillBarIndex == 4)// || skillBarIndex == 5
|
||
// continue;
|
||
// var nSkillIndex = _skillBarSetInfo[skillBarIndex];
|
||
// if (nSkillIndex >= 0 && nSkillIndex < skillCount - 4) //排除两个绝技
|
||
// {
|
||
// if (_mainPlayer.OwnSkillInfo[nSkillIndex].SkillId != -1)
|
||
// {
|
||
// SetSkillBarInfo(skillBarIndex, nSkillIndex);
|
||
// //Singleton<ObjManager>.Instance.MainPlayer.SetAutoSelSkillID(nSkillIndex);
|
||
// hasSet = true;
|
||
// }
|
||
// else // 保存的技能不存在 清掉
|
||
// {
|
||
// _skillBarSetInfo[skillBarIndex] = -1;
|
||
// // 保存配置
|
||
// //UserConfigData.SaveSkillPages();
|
||
// }
|
||
// }
|
||
// else
|
||
// {
|
||
// SetSkillBarInfo(skillBarIndex, -1);
|
||
// hasSet = true;
|
||
// }
|
||
// }
|
||
//}
|
||
|
||
if (hasSet == false)
|
||
{
|
||
for (var i = 0; i < SkillButtons.Length; i++) SkillButtons[i].Clear();
|
||
for (var _skillIndex = 0; _skillIndex < skillCount - 4; _skillIndex++)
|
||
{
|
||
var ownSkill = _mainPlayer.OwnSkillInfo[_skillIndex];
|
||
|
||
if (ownSkill.SkillExTable == null)
|
||
continue;
|
||
|
||
if ((ownSkill.SkillBaseTable.SkillClass & (int)SKILLCLASS.SIMPLEATTACK) != 0)
|
||
continue;
|
||
|
||
if ((ownSkill.SkillBaseTable.SkillClass & (int)SKILLCLASS.AUTOREPEAT) == 0 &&
|
||
(ownSkill.SkillBaseTable.SkillClass & (int)SKILLCLASS.XP) == 0)
|
||
for (var _skillBarIndex = 0; _skillBarIndex < SkillButtons.Length; _skillBarIndex++)
|
||
if (SkillButtons != null && SkillButtons[_skillBarIndex].SkillIndex < 0 &&
|
||
_skillBarIndex != 4 && _skillBarIndex != 5)
|
||
{
|
||
SetSkillBarInfo(_skillBarIndex, _skillIndex);
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
|
||
if (skillCount < 2)
|
||
return;
|
||
|
||
//潜规则:索引12是90绝技,14是90绝技试用,13是120绝技,15是120绝技试用
|
||
if (GameManager.gameManager.PlayerDataPool.OwnSkillInfo[skillCount - 4].SkillId != -1)
|
||
SetSkillBarInfo(4, skillCount - 4);
|
||
else if (GameManager.gameManager.PlayerDataPool.OwnSkillInfo[skillCount - 2].SkillId != -1)
|
||
SetSkillBarInfo(4, skillCount - 2);
|
||
else
|
||
SetSkillBarInfo(4, -1);
|
||
|
||
if (GameManager.gameManager.PlayerDataPool.OwnSkillInfo[skillCount - 3].SkillId != -1)
|
||
SetSkillBarInfo(5, skillCount - 3);
|
||
else if (GameManager.gameManager.PlayerDataPool.OwnSkillInfo[skillCount - 1].SkillId != -1)
|
||
SetSkillBarInfo(5, skillCount - 1);
|
||
else
|
||
SetSkillBarInfo(5, -1);
|
||
}
|
||
|
||
public bool IsIndexHasSet(int index)
|
||
{
|
||
if (index == -1)
|
||
return false;
|
||
for (var i = 0; i < SkillButtons.Length; i++)
|
||
if (SkillButtons[i].SkillIndex == index)
|
||
return true;
|
||
|
||
return false;
|
||
}
|
||
|
||
public void SetSkillBarInfo(int _skillBarIndex, int _skillIndex)
|
||
{
|
||
if (IsIndexHasSet(_skillIndex))
|
||
return;
|
||
var _mainPlayer = Singleton<ObjManager>.GetInstance().MainPlayer;
|
||
if (_mainPlayer == null) return;
|
||
|
||
if (_skillBarIndex >= 0 && _skillBarIndex < SkillButtons.Length)
|
||
{
|
||
if (_skillIndex >= 0 && _skillIndex < _mainPlayer.OwnSkillInfo.Length)
|
||
{
|
||
var _skillBase = _mainPlayer.OwnSkillInfo[_skillIndex].SkillBaseTable;
|
||
if (_skillBase != null) SkillButtons[_skillBarIndex].SetSkillBarInfo(_skillIndex);
|
||
}
|
||
else
|
||
{
|
||
SkillButtons[_skillBarIndex].SetSkillBarInfo(-1);
|
||
}
|
||
}
|
||
}
|
||
|
||
public void GetItemCDInfo()
|
||
{
|
||
var _mainPlayer = Singleton<ObjManager>.GetInstance().MainPlayer;
|
||
if (_mainPlayer == null) return;
|
||
|
||
|
||
var itemId = PlayerPreferenceData.ShortCutItemId;
|
||
itemCdRemainTime = ItemCDInfoCtr.GetItemCDRemainTime(itemId);
|
||
|
||
var usableItem = TableManager.GetUsableItemByID(itemId, 0);
|
||
if (usableItem == null) return;
|
||
|
||
var coolDownTime = TableManager.GetCoolDownTimeByID(usableItem.CoolDownId, 0);
|
||
if (coolDownTime != null) itemTotalCdTime = coolDownTime.CDTime / 1000;
|
||
}
|
||
|
||
private void UpdateComboTarget(object args)
|
||
{
|
||
StopCoroutine(SetSkillComboTarget());
|
||
StartCoroutine(SetSkillComboTarget());
|
||
}
|
||
|
||
/// <summary>
|
||
/// 指定连击技能对应的按钮
|
||
/// </summary>
|
||
/// <returns></returns>
|
||
IEnumerator SetSkillComboTarget()
|
||
{
|
||
yield return new WaitForEndOfFrame(); //等待全局数据更新
|
||
while (Singleton<ObjManager>.GetInstance().MainPlayer == null || !GameManager.gameManager.PlayerDataPool.HasInitOwnSkill)
|
||
yield return new WaitForEndOfFrame();
|
||
if (Singleton<ObjManager>.GetInstance().MainPlayer != null)
|
||
{
|
||
var skillDatas = new Dictionary<int, OwnSkillData>();
|
||
for (int i = 0; i < SkillButtons.Length; i++)
|
||
{
|
||
var skillData = SkillButtons[i].SkillData;
|
||
skillDatas.Add(i, skillData);
|
||
}
|
||
|
||
for (int i = 0; i < skillDatas.Count; i++)
|
||
{
|
||
if (skillDatas[i] != null)
|
||
{
|
||
var comboSkill = skillDatas[i].GetComboSkill();
|
||
if (comboSkill != null)
|
||
{
|
||
var combo = from data in skillDatas where data.Value != null && data.Value.SkillId == comboSkill.SkillId select data;
|
||
foreach (var item in combo)
|
||
{
|
||
SkillButtons[i].ComboTarget = SkillButtons[item.Key];
|
||
SkillButtons[item.Key].gameObject.SetActive(false);
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
// Update is called once per frame
|
||
private void Update()
|
||
{
|
||
if (itemCdRemainTime > 0)
|
||
{
|
||
if (!m_ItemInfo.m_ItemCDImage.gameObject.activeInHierarchy)
|
||
m_ItemInfo.m_ItemCDImage.gameObject.SetActive(true);
|
||
|
||
if (!m_ItemInfo.isUseItem) m_ItemInfo.isUseItem = true;
|
||
|
||
itemCdRemainTime -= Time.deltaTime;
|
||
m_ItemInfo.m_ItemCDImage.fillAmount = itemCdRemainTime / itemTotalCdTime;
|
||
}
|
||
else
|
||
{
|
||
if (m_ItemInfo.m_ItemCDImage.gameObject.activeInHierarchy)
|
||
m_ItemInfo.m_ItemCDImage.gameObject.SetActive(false);
|
||
|
||
if (m_ItemInfo.isUseItem) m_ItemInfo.isUseItem = false;
|
||
}
|
||
|
||
// if (GameManager.gameManager.RunningScene == (int)GameDefine_Globe.SCENE_DEFINE.SCENE_GUANNING)
|
||
// {
|
||
// if (_AutoPanel.activeSelf)
|
||
// _AutoPanel.SetActive(false);
|
||
// }
|
||
// else
|
||
// {
|
||
// if (!_AutoPanel.activeSelf)
|
||
// _AutoPanel.SetActive(true);
|
||
// }
|
||
}
|
||
|
||
public void RefreshShortCutItem()
|
||
{
|
||
var itemId = PlayerPreferenceData.ShortCutItemId;
|
||
GameItem item = null;
|
||
if (itemId >= 0)
|
||
{
|
||
var backpack = GameManager.gameManager.PlayerDataPool.BackPack;
|
||
var itemList = ItemTool.ItemFilter(backpack, 0);
|
||
item = itemList.Find(a => a.DataID == itemId);
|
||
}
|
||
if (item == null)
|
||
{
|
||
m_ItemInfo._ItemCountBG.SetActive(false);
|
||
m_ItemInfo.m_ItemButton.gameObject.SetActive(false);
|
||
}
|
||
else
|
||
{
|
||
m_ItemInfo._ItemCountBG.gameObject.SetActive(true);
|
||
m_ItemInfo.m_ItemButton.gameObject.SetActive(true);
|
||
m_ItemInfo.m_ItemCountText.text = item.StackCount.ToString();
|
||
}
|
||
}
|
||
|
||
public void SetUseItem()
|
||
{
|
||
//判断初始化ID
|
||
var itemId = PlayerPreferenceData.ShortCutItemId;
|
||
if (itemId == -1)
|
||
{
|
||
//点击的时候打开选择药品的界面
|
||
//m_ItemInfo.isSetItem = false;
|
||
m_ItemInfo.m_ItemButton.gameObject.SetActive(false);
|
||
m_ItemInfo.m_ItemIcon.gameObject.SetActive(false);
|
||
m_ItemInfo._ItemCountBG.gameObject.SetActive(false);
|
||
if (m_ItemInfo.m_ItemCDImage.gameObject.activeInHierarchy)
|
||
m_ItemInfo.m_ItemCDImage.gameObject.SetActive(false);
|
||
}
|
||
else
|
||
{
|
||
var BackPack = GameManager.gameManager.PlayerDataPool.BackPack;
|
||
if (BackPack.GetItemCountByDataId(itemId) > 0)
|
||
{
|
||
m_ItemInfo._ItemCountBG.gameObject.SetActive(true);
|
||
m_ItemInfo.m_ItemCountText.text = BackPack.GetItemCountByDataId(itemId).ToString();
|
||
|
||
var commonItem = TableManager.GetCommonItemByID(itemId, 0);
|
||
if (commonItem != null)
|
||
{
|
||
m_ItemInfo.m_ItemButton.gameObject.SetActive(true);
|
||
m_ItemInfo.m_ItemIcon.gameObject.SetActive(true);
|
||
LoadAssetBundle.Instance.SetImageSprite(m_ItemInfo.m_ItemIcon, commonItem.Icon);
|
||
if (commonItem.QualityEffect > 0)
|
||
{
|
||
CommonItemContainerItem.ShowQualityEffect(true, commonItem.QualityEffect, m_ItemInfo.m_ItemIcon.transform);
|
||
}
|
||
else
|
||
{
|
||
CommonItemContainerItem.ShowQualityEffect(false, commonItem.QualityEffect, m_ItemInfo.m_ItemIcon.transform);
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
m_ItemInfo._ItemCountBG.gameObject.SetActive(false);
|
||
m_ItemInfo.m_ItemButton.gameObject.SetActive(false);
|
||
//m_ItemInfo.isSetItem = false;
|
||
PlayerPreferenceData.ShortCutItemId = -1;
|
||
}
|
||
}
|
||
|
||
//设置CD正在旋转的item到快捷使用栏的时候要刷新CD状态
|
||
ReqMyItemCDInfo();
|
||
}
|
||
|
||
public void ReqMyItemCDInfo()
|
||
{
|
||
//同步item的cd时间
|
||
var askPacket =
|
||
(CG_REQ_SEND_PACKET)PacketDistributed.CreatePacket(MessageID.PACKET_CG_REQ_SEND_PACKET);
|
||
askPacket.SetReqType(3); //3.请求物品CD
|
||
askPacket.SendPacket();
|
||
}
|
||
|
||
public void SyncMyItemInfo()
|
||
{
|
||
if (ItemCDInfoCtr.GetItemCDRemainTime(PlayerPreferenceData.ShortCutItemId) > 0) m_ItemInfo.isUseItem = true;
|
||
|
||
GetItemCDInfo(); //获取总CD时间 剩余时间 开始计时
|
||
}
|
||
|
||
public void UseShortCutItem()
|
||
{
|
||
if (m_ItemInfo.isUseItem)
|
||
{
|
||
//正在使用物品 物品处于CD状态
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{30001}"));
|
||
return;
|
||
}
|
||
|
||
if (!GlobalData.CanUseMedicItem(PlayerPreferenceData.ShortCutItemId)) return;
|
||
|
||
var m_itemId = PlayerPreferenceData.ShortCutItemId;
|
||
|
||
var BackPack = GameManager.gameManager.PlayerDataPool.BackPack;
|
||
var itemList = ItemTool.ItemFilter(BackPack, 0);
|
||
for (var index = 0; index < itemList.Count; index++)
|
||
if (itemList[index].DataID == m_itemId)
|
||
if (null != Singleton<ObjManager>.Instance.MainPlayer &&
|
||
Singleton<ObjManager>.Instance.MainPlayer.CheckUseItem(itemList[index]))
|
||
{
|
||
Singleton<ObjManager>.Instance.MainPlayer.UseItem(itemList[index]);
|
||
|
||
if (!m_ItemInfo.m_ItemCDImage.gameObject.activeInHierarchy)
|
||
m_ItemInfo.m_ItemCDImage.gameObject.SetActive(true);
|
||
ReqMyItemCDInfo();
|
||
break;
|
||
}
|
||
}
|
||
|
||
public void ShowItemList()
|
||
{
|
||
var m_PlayerLevel = GameManager.gameManager.PlayerDataPool.MainPlayerBaseAttr.Level;
|
||
var m_ShowList = new List<int>();
|
||
var m_AllItemDic = TableManager.GetUseDrugItem();
|
||
foreach (var item in m_AllItemDic)
|
||
{
|
||
var useDrugItem = TableManager.GetUseDrugItemByID(item.Key, 0);
|
||
if (useDrugItem != null)
|
||
if (m_PlayerLevel >= useDrugItem.NeedLevel)
|
||
m_ShowList.Add(item.Key);
|
||
}
|
||
|
||
UIManager.ShowUI(UIInfo.PopCanSelectItemPanel, delegate (bool bSucess, object param)
|
||
{
|
||
if (bSucess) PopCanSelectItemPanelCtr.Instance.SetMyShowList(m_ShowList, 2);
|
||
});
|
||
}
|
||
//切换目标
|
||
//public void SwitchTarget()
|
||
//{
|
||
// if (null != Singleton<ObjManager>.GetInstance().MainPlayer)
|
||
// {
|
||
// Singleton<ObjManager>.GetInstance().MainPlayer.SwitchTarget();
|
||
// }
|
||
//}
|
||
|
||
#region auto fight
|
||
|
||
// 直接调用自动战斗
|
||
public void OnDoAutoFightClick()
|
||
{
|
||
//组队跟随,不响应技能
|
||
if (GameManager.gameManager.PlayerDataPool.IsFollowTeam)
|
||
{
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{5128}"));
|
||
return;
|
||
}
|
||
|
||
var mainPalyer = Singleton<ObjManager>.Instance.MainPlayer;
|
||
if (null == mainPalyer) return;
|
||
|
||
var sceneInfo = TableManager.GetSceneClassByID(GameManager.gameManager.RunningScene, 0);
|
||
if (sceneInfo == null)
|
||
return;
|
||
if (sceneInfo.IsAutoFight == 0)
|
||
{
|
||
if (mainPalyer.isAutoCombat == false)
|
||
GUIData.AddNotifyData(StrDictionary.GetClientDictionaryString("#{9006}"));
|
||
return;
|
||
}
|
||
|
||
//if(mainPalyer.AdcaneMountId>0)
|
||
//{
|
||
// mainPalyer.AskUnMount();
|
||
// return;
|
||
//}
|
||
|
||
mainPalyer.EnterAutoCombat();
|
||
}
|
||
|
||
//public void OnDoAutoStopFightClick()
|
||
//{
|
||
// Obj_MainPlayer mainPalyer = Singleton<ObjManager>.Instance.MainPlayer;
|
||
// if (null == mainPalyer)
|
||
// {
|
||
// return;
|
||
// }
|
||
//
|
||
// mainPalyer.LeveAutoCombat();
|
||
//}
|
||
|
||
//public void UpdateAutoFightBtnState()
|
||
//{
|
||
// Obj_MainPlayer mainPalyer = Singleton<ObjManager>.Instance.MainPlayer;
|
||
// if (null == mainPalyer)
|
||
// {
|
||
// return;
|
||
// }
|
||
//
|
||
// m_BtnAutoStop.SetActive(mainPalyer.IsOpenAutoCombat);
|
||
// m_BtnAutoBegin.SetActive(!mainPalyer.IsOpenAutoCombat);
|
||
//}
|
||
|
||
#endregion
|
||
|
||
#region skill tooltips
|
||
|
||
public void ShowSkillTooltips(int skillBarIdx)
|
||
{
|
||
if (SkillButtons.Length > skillBarIdx)
|
||
SkillTooltipsLogic.ShowSkillToolTips(SkillButtons[skillBarIdx].SkillIndex, new Vector3(0, 0, 0));
|
||
}
|
||
|
||
public void HideSkillTooltips()
|
||
{
|
||
UIManager.CloseUI(UIInfo.SkillTooltipsRoot);
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 切换怪物相关功能
|
||
private readonly List<Obj_Character> _targetList = new List<Obj_Character>();
|
||
private const float _scanDistance = 8f;
|
||
private const float _scanResetDistance = 4f;
|
||
private Vector3? _lastPostion;
|
||
|
||
public void SwitchTarget()
|
||
{
|
||
var mainPlayer = ObjManager.Instance.MainPlayer;
|
||
if (mainPlayer == null)
|
||
return;
|
||
var aiPlayerCombat = mainPlayer.GetComponent<AI_PlayerCombat>();
|
||
if (aiPlayerCombat == null)
|
||
return;
|
||
if (_lastPostion == null ||
|
||
(_lastPostion.Value - mainPlayer.Position).sqrMagnitude > _scanResetDistance.ToSquare())
|
||
{
|
||
_lastPostion = mainPlayer.Position;
|
||
_targetList.Clear();
|
||
}
|
||
else
|
||
{
|
||
// Trim Target List
|
||
for (var i = _targetList.Count - 1; i >= 0; i--)
|
||
if (_targetList[i] == null)
|
||
_targetList.RemoveAt(i);
|
||
}
|
||
|
||
var currentTarget = mainPlayer.enemyTarget;
|
||
if (!Reputation.CanAttack(currentTarget))
|
||
currentTarget = null;
|
||
// If there's no preset target, recalculate target selector
|
||
if (currentTarget == null)
|
||
_targetList.Clear();
|
||
// If the player has manually selected a target
|
||
else if (_targetList.Count > 0 && _targetList[_targetList.Count - 1] != currentTarget)
|
||
{
|
||
_targetList.Clear();
|
||
_targetList.Add(currentTarget);
|
||
}
|
||
var target = GetMostThreatingTargetInList(mainPlayer, aiPlayerCombat, currentTarget);
|
||
// Completed one Cycle
|
||
if (target == null && _targetList.Count > 0)
|
||
{
|
||
_targetList.Clear();
|
||
target = GetMostThreatingTargetInList(mainPlayer, aiPlayerCombat, currentTarget);
|
||
}
|
||
// Current Target will be filtered
|
||
if (target != null)
|
||
{
|
||
_targetList.Add(target);
|
||
mainPlayer.SetSelectTarget(target);
|
||
}
|
||
}
|
||
|
||
private Obj_Character GetMostThreatingTargetInList(Obj_MainPlayer mainPlayer, AI_PlayerCombat aiPlayerCombat, Obj_Character currentTarget)
|
||
{
|
||
Obj_Character result = null;
|
||
var lastPriority = int.MinValue;
|
||
var targets = ObjManager.Instance.ObjPools.Values;
|
||
foreach (var obj in targets)
|
||
{
|
||
var character = obj as Obj_Character;
|
||
if (character != null &&
|
||
!character.IsDisableState(DISABLESTATE.Disable_BeSelect) &&
|
||
Reputation.CanAttack(character) &&
|
||
character != currentTarget)
|
||
{
|
||
if (character.ObjType == GameDefine_Globe.OBJ_TYPE.OBJ_FELLOW)
|
||
{
|
||
if (currentTarget != null &&
|
||
currentTarget.ObjType == GameDefine_Globe.OBJ_TYPE.OBJ_OTHER_PLAYER)
|
||
{
|
||
var fellow = character as Obj_Fellow;
|
||
if (fellow != null && fellow.OwnerObjId == currentTarget.ServerID)
|
||
{
|
||
result = fellow;
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (!_targetList.Contains(character) &&
|
||
mainPlayer.DistanceToAnotherEdge(character) < _scanDistance)
|
||
{
|
||
var priority = aiPlayerCombat.GetAttackPriority(character);
|
||
if (priority > 0)
|
||
{
|
||
var newTarget = false;
|
||
if (result == null || priority > lastPriority)
|
||
newTarget = true;
|
||
else if ((character.Position - mainPlayer.Position).RemoveY().sqrMagnitude <
|
||
(result.Position - mainPlayer.Position).RemoveY().sqrMagnitude)
|
||
newTarget = true;
|
||
if (newTarget)
|
||
{
|
||
result = character;
|
||
lastPriority = priority;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
return result;
|
||
}
|
||
#endregion
|
||
|
||
#region UIShowAnim
|
||
|
||
public Animator _ShowAnimator;
|
||
|
||
public void ShowSkillBar()
|
||
{
|
||
_ShowAnimator.Play("Show");
|
||
}
|
||
|
||
public void HideSkillBar()
|
||
{
|
||
_ShowAnimator.Play("Hide");
|
||
}
|
||
|
||
#endregion
|
||
} |