| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using FSBuff;
- namespace FSRole {
- /*
- * 角色组件
- */
- public class Role : MonoBehaviour {
- // 角色原始属性
- public RoleAttr OriginAttr;
- // 角色当前属性
- public RoleAttr CurrentAttr;
- // 角色所挂载的BUFF数组,所有Buff都放在这里面
- public ArrayList buffs;
- // Use this for initialization
- void Start() {
- buffs = new ArrayList();
- }
- // Update is called once per frame
- void Update() {
- }
- /*
- * 添加角色的各个接口
- */
- /*
- * 受到伤害
- */
- public void GetDamage(int value) {
- CurrentAttr.Hp -= value;
- print("受到伤害");
- }
- /*
- * 消耗精力
- */
- public void CostEngine(int value) {
- CurrentAttr.Mp -= value;
- print("消耗精力");
- }
- /*
- * 增加防御力
- */
- public void Defense(int value) {
- CurrentAttr.Def += value;
- print("防御");
- }
- /*
- * 运行BUFF
- */
- public void BuffExecute() {
- print("运行角色Buff");
- // 遍历数组来运行BUFF
- foreach (Buff index in buffs) {
- print("角色的Buff ID 为 " + index.ID);
- index.Execute();
- }
- }
- /*
- * 添加Buff
- */
- public void AddBuff(Buff buff) {
- // 首先判断数组中是否已经存在此Buff
- // 未来还需要根据两个相同buff的属性来进行更新
- foreach (Buff index in buffs) {
- if (index.ID == buff.ID) {
- // 未来在这里做些什么
- return;
- }
- }
- // 往数组中添加数组
- buffs.Add(buff);
- }
- }
- }
|