91 lines
2.0 KiB
C#
91 lines
2.0 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
|
|
|
|
public class Palye : Fun
|
|
{
|
|
[Header("血量")] public float hp = 100f;//血量
|
|
[Header("掉落")] public float gold = 10f;
|
|
public float Hp
|
|
{
|
|
get => hp;
|
|
set
|
|
{
|
|
hp = value;
|
|
|
|
}
|
|
}
|
|
|
|
[Header("物理护甲")] public int physicalArmor = 10;//物理护甲
|
|
[Header("魔法护甲")] public int magicArmor = 5;//魔法护甲
|
|
|
|
public List<BUff> buffList = new List<BUff>();
|
|
|
|
|
|
//public List<>;
|
|
// Start is called before the first frame update
|
|
async void Start()
|
|
{
|
|
UpdateBuff();
|
|
}
|
|
/// <summary>
|
|
/// 角色死亡
|
|
/// </summary>
|
|
public virtual void die()
|
|
{
|
|
Debug.Log(gameObject.name + "死亡");
|
|
Destroy(gameObject);
|
|
Debug.Log("死亡");
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 单位更新buff
|
|
/// </summary>
|
|
async void UpdateBuff()//单位buff更新
|
|
{
|
|
while (true)
|
|
{
|
|
List<BUff> deleteArr = new List<BUff>();
|
|
foreach (BUff buffItem in buffList)
|
|
{
|
|
if (buffItem.executionInterval <= 0)
|
|
{
|
|
buffItem.executionInterval = buffItem.executionInterval_max;
|
|
buffItem.Funaction.Invoke(buffItem.value);
|
|
}
|
|
|
|
buffItem.executionInterval -= 0.1f;
|
|
buffItem.timeLeft -= 0.1f;
|
|
if (buffItem.timeLeft <= 0)
|
|
{
|
|
deleteArr.Add(buffItem);
|
|
|
|
}
|
|
}
|
|
foreach (BUff item in deleteArr)
|
|
{
|
|
buffList.Remove(item);
|
|
}
|
|
await Task.Delay(100);//buff检测最小时间0.1秒执行一次
|
|
}
|
|
|
|
}
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (hp <= 0)
|
|
{
|
|
die();
|
|
if(Progress_Display.Instance==null) return;
|
|
|
|
Progress_Display.Instance.huadongClick(gold);
|
|
|
|
}
|
|
}
|
|
}
|