54 lines
1.9 KiB
C#
54 lines
1.9 KiB
C#
|
using Games.LogicObj;
|
|||
|
using GCGame.Table;
|
|||
|
using Module.Log;
|
|||
|
using UnityEngine;
|
|||
|
|
|||
|
// 保存SkillButton的几个通用接口
|
|||
|
public abstract class SkillButtonBase : MonoBehaviour
|
|||
|
{
|
|||
|
public GameObject clickeffObj; //粒子特效
|
|||
|
protected GameObject clickEffectClone;
|
|||
|
|
|||
|
protected SkillCastableCheckResult UseSkill(Vector2 attackPoint = default(Vector2), int? skillIndex = null)
|
|||
|
{
|
|||
|
var result = SkillCastableCheckResult.FailOther;
|
|||
|
//正在采集的话打断
|
|||
|
if (CollectItemSliderLogic.Instance())
|
|||
|
CollectItemSliderLogic.Instance().BreakCollectState();
|
|||
|
var mainPlayer = Singleton<ObjManager>.GetInstance().MainPlayer;
|
|||
|
if (mainPlayer == null)
|
|||
|
LogModule.WarningLog("_mainPlayer is Null");
|
|||
|
else
|
|||
|
{
|
|||
|
|
|||
|
if (skillIndex == null)
|
|||
|
result = mainPlayer.TryStartSimpleAttack();
|
|||
|
else
|
|||
|
{
|
|||
|
var ownSkill = mainPlayer.OwnSkillInfo[skillIndex.Value];
|
|||
|
//ownSkill.UpdateCombo();
|
|||
|
result = mainPlayer.TryStartTargetSkill(ownSkill, attackPoint);
|
|||
|
}
|
|||
|
if (result == SkillCastableCheckResult.Success)
|
|||
|
{
|
|||
|
if (clickEffectClone != null)
|
|||
|
clickEffectClone.SetActive(true);
|
|||
|
else
|
|||
|
clickEffectClone = CloneEffectObj(clickeffObj);
|
|||
|
}
|
|||
|
}
|
|||
|
return result;
|
|||
|
}
|
|||
|
|
|||
|
protected GameObject CloneEffectObj(GameObject cloneObj)
|
|||
|
{
|
|||
|
var newObj = Instantiate(cloneObj);
|
|||
|
newObj.transform.SetParent(gameObject.transform);
|
|||
|
newObj.transform.localScale = Vector3.one;
|
|||
|
newObj.transform.localPosition = Vector3.zero;
|
|||
|
newObj.transform.localRotation = Quaternion.identity;
|
|||
|
newObj.EnsureComponent<DisableGameObj>().DisableObjTimeSpace = 0.35f;
|
|||
|
newObj.EnsureComponent<UIParticleScaler>();
|
|||
|
return newObj;
|
|||
|
}
|
|||
|
}
|