You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
3.8 KiB
113 lines
3.8 KiB
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
|
|
public abstract class Skill : MonoBehaviour
|
|
{
|
|
protected Character self;
|
|
public int manaCost;
|
|
public int movementCost;
|
|
public int damage;
|
|
protected SkillManager skillManager;
|
|
protected BuffManager buffManager;
|
|
protected List<Character> alliesInRange = new List<Character>();
|
|
protected List<Character> enemiesInRange = new List<Character>();
|
|
protected CharacterUIManager characterUIManager;
|
|
public string description;
|
|
public string skillName;
|
|
private void Awake()
|
|
{
|
|
self = transform.parent.parent.GetComponent<Character>();
|
|
skillManager = transform.parent.GetComponent<SkillManager>();
|
|
buffManager = self.transform.Find("BuffManager").GetComponent<BuffManager>();
|
|
characterUIManager = transform.parent.parent.Find("CharacterUI").GetComponent<CharacterUIManager>();
|
|
Revise();
|
|
}
|
|
public void SetRotation(Vector2 direction)
|
|
{
|
|
if(direction == Vector2.up)
|
|
transform.localEulerAngles = new Vector3(0,0,180);
|
|
if(direction == Vector2.right)
|
|
transform.localEulerAngles = new Vector3(0,0,90);
|
|
if(direction == Vector2.down)
|
|
transform.localEulerAngles = new Vector3(0,0,0);
|
|
if(direction == Vector2.left)
|
|
transform.localEulerAngles = new Vector3(0,0,-90);
|
|
}
|
|
protected void Update()
|
|
{
|
|
if(Input.GetKeyDown("c"))
|
|
{
|
|
gameObject.SetActive(false);
|
|
transform.parent.Find("SkillsGUI").gameObject.SetActive(true);
|
|
}
|
|
if(Input.GetKeyDown("z"))
|
|
{
|
|
if(ApplyRequestion())
|
|
{
|
|
self.ChangeMovement(-movementCost);
|
|
self.ChangeMana(-manaCost);
|
|
skillManager.currentSkill.RemoveSkillState();
|
|
ApplySkill();
|
|
ApplySkillState();
|
|
}
|
|
else
|
|
characterUIManager.FloatingString("状态不满足");
|
|
gameObject.SetActive(false);
|
|
self.SetIsUsingSkill(false);
|
|
self.weaponManager.gameObject.SetActive(true);
|
|
}
|
|
}
|
|
//关闭显示攻击范围
|
|
protected void OnTriggerExit2D(Collider2D other)
|
|
{
|
|
if(other.gameObject.layer == 8)
|
|
{
|
|
Cell cell = other.gameObject.GetComponent<Cell>();
|
|
cell.SetMask(false);
|
|
if(cell.currentCharacter != null)
|
|
{
|
|
if(self.groupNumber != cell.currentCharacter.groupNumber)
|
|
enemiesInRange.Remove(cell.currentCharacter);
|
|
else
|
|
alliesInRange.Remove(cell.currentCharacter);
|
|
}
|
|
}
|
|
}
|
|
protected void OnTriggerEnter2D(Collider2D other)
|
|
{
|
|
if(other.gameObject.layer == 8)
|
|
{
|
|
Cell cell = other.gameObject.GetComponent<Cell>();
|
|
if(cell.currentCharacter != null)
|
|
{
|
|
if(self.groupNumber != cell.currentCharacter.groupNumber)
|
|
enemiesInRange.Add(cell.currentCharacter);
|
|
else
|
|
alliesInRange.Add(cell.currentCharacter);
|
|
}
|
|
}
|
|
}
|
|
protected void OnTriggerStay2D(Collider2D other)
|
|
{
|
|
//技能有不同的攻击范围,选中角色时,可显示技能的攻击范围
|
|
//显示攻击范围
|
|
if(other.gameObject.layer == 8)
|
|
{
|
|
other.gameObject.GetComponent<Cell>().SetMask(true);
|
|
}
|
|
|
|
}
|
|
protected virtual bool ApplyRequestion()
|
|
{
|
|
if(enemiesInRange != null && self.GetCurrentMovement() >= movementCost
|
|
&& self.GetCurrentMana() >= manaCost)
|
|
return true;
|
|
return false;
|
|
}
|
|
public abstract void ApplySkill();
|
|
public abstract void ApplySkillState();
|
|
public abstract void RemoveSkillState();
|
|
protected abstract void Revise();
|
|
}
|