UnityCommon/Fun.cs
2024-12-04 02:09:23 +08:00

100 lines
2.5 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
public enum DamageType
{
physicalDamage,//物理伤害
magicDamage,//魔法伤害
noAttributeDamage,//无属性伤害
}
//public class prefabObjects
//{
// public string targetAudience = "targetAudience";
// public string myPalye = "myPalye";
//}
public class BUff
{
public float timeLeft = 0;//剩余时间
public float executionInterval = 0;//buff执行间隔
public float executionInterval_max = 100;//buff执行间隔
public Action<object[]> Funaction;//调用的函数
public object[] value;//调用函数的值
}
public class Fun : Base
{
//// 通过方法名调用对应的方法
//public void CallMethodByName(string methodName)
//{
// // 获取当前类的Type
// Type type = this.GetType();
// // 获取方法信息
// MethodInfo methodInfo = type.GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
// if (methodInfo != null)
// {
// // 调用该方法
// methodInfo.Invoke(this,null ); // null代表无参数
// }
// else
// {
// Debug.LogError("方法未找到: " + methodName);
// }
//}
/// <summary>
/// 中毒 //目标 // 自己
/// </summary>
/// <param name="objects"></param>
public void poisoning(object[] objects)
{
Palye targetAudience = (Palye)objects[0];
Palye myPalye = (Palye)objects[1];
Debug.Log("触发中毒");
Debug.Log(myPalye.name);
}
/// <summary>
/// 扣血 传入参数 目标,伤害值,攻击类型,使用者
/// </summary>
/// <param name="objects"></param>
public void bloodLoss(object[] objects)//目标,伤害值,攻击类型,使用者
{
Palye targetAudience = (Palye)objects[0];
float harm = (float)objects[1];
DamageType damageType = (DamageType)objects[2];
Palye UserObj = (Palye)objects[3];
float finalDamage = harm;
switch (damageType)
{
case DamageType.physicalDamage://物理伤害
finalDamage -= targetAudience.physicalArmor;
break;
case DamageType.magicDamage://魔法伤害
finalDamage -= targetAudience.magicArmor;
break;
case DamageType.noAttributeDamage://无属性伤害
finalDamage -= 0;
break;
}
if (finalDamage < 0)
{
finalDamage = 0;
}
targetAudience.Hp -= finalDamage;
}
}