UnityCommon/Role/Fun.cs
2024-12-18 20:43:54 +08:00

88 lines
2.1 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
public enum DamageType
{
/// <summary>
/// 物理伤害
/// </summary>
physicalDamage,
/// <summary>
/// 魔法伤害
/// </summary>
magicDamage,
/// <summary>
/// 无属性伤害
/// </summary>
noAttributeDamage,
}
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
{
/// <summary>
/// 中毒 //目标 // 自己
/// </summary>
/// <param name="objects"></param>
public void poisoning(object[] objects)
{
Role targetAudience = (Role)objects[0];
Role myPalye = (Role)objects[1];
Debug.Log("触发中毒");
Debug.Log(myPalye.name);
}
/// <summary>
/// 扣血 传入参数 目标,伤害值,攻击类型,使用者子弹射来的方向0是右边1是左边
/// </summary>
/// <param name="objects"></param>
public void bloodLoss(object[] objects,int direction=1)//目标,伤害值,攻击类型,使用者,子弹射来的方向
{
Role targetAudience = (Role)objects[0];
float harm = (float)objects[1];
DamageType damageType = (DamageType)objects[2];
Role UserObj = (Role)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;
targetAudience.HurtDirectin = direction;
}
}