UnityCommon/Role/Fun.cs

100 lines
2.5 KiB
C#
Raw Normal View History

2024-12-04 02:09:23 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using UnityEngine;
public enum DamageType
{
physicalDamage,//<2F><><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD>
magicDamage,//ħ<><C4A7><EFBFBD>˺<EFBFBD>
noAttributeDamage,//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD>
}
//public class prefabObjects
//{
// public string targetAudience = "targetAudience";
// public string myPalye = "myPalye";
//}
public class BUff
{
public float timeLeft = 0;//ʣ<><CAA3>ʱ<EFBFBD><CAB1>
public float executionInterval = 0;//buffִ<66>м<EFBFBD><D0BC><EFBFBD>
public float executionInterval_max = 100;//buffִ<66>м<EFBFBD><D0BC><EFBFBD>
public Action<object[]> Funaction;//<2F><><EFBFBD>õĺ<C3B5><C4BA><EFBFBD>
public object[] value;//<2F><><EFBFBD>ú<EFBFBD><C3BA><EFBFBD><EFBFBD><EFBFBD>ֵ
}
public class Fun : Base
{
//// ͨ<><CDA8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ö<EFBFBD>Ӧ<EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
//public void CallMethodByName(string methodName)
//{
// // <20><>ȡ<EFBFBD><C8A1>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>Type
// Type type = this.GetType();
// // <20><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
// MethodInfo methodInfo = type.GetMethod(methodName, BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
// if (methodInfo != null)
// {
// // <20><><EFBFBD>ø÷<C3B8><C3B7><EFBFBD>
// methodInfo.Invoke(this,null ); // null<6C><6C><EFBFBD><EFBFBD><EFBFBD>޲<EFBFBD><DEB2><EFBFBD>
// }
// else
// {
// Debug.LogError("<22><><EFBFBD><EFBFBD>δ<EFBFBD>ҵ<EFBFBD>: " + methodName);
// }
//}
/// <summary>
/// <20>ж<EFBFBD> //Ŀ<><C4BF> // <20>Լ<EFBFBD>
/// </summary>
/// <param name="objects"></param>
public void poisoning(object[] objects)
{
2024-12-04 05:50:39 +08:00
Role targetAudience = (Role)objects[0];
Role myPalye = (Role)objects[1];
2024-12-04 02:09:23 +08:00
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD>ж<EFBFBD>");
Debug.Log(myPalye.name);
}
/// <summary>
/// <20><>Ѫ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ŀ<><C4BF>,<2C>˺<EFBFBD>ֵ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ʹ<><CAB9><EFBFBD><EFBFBD>
/// </summary>
/// <param name="objects"></param>
public void bloodLoss(object[] objects)//Ŀ<><C4BF>,<2C>˺<EFBFBD>ֵ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ʹ<><CAB9><EFBFBD><EFBFBD>
{
2024-12-04 05:50:39 +08:00
Role targetAudience = (Role)objects[0];
2024-12-04 02:09:23 +08:00
float harm = (float)objects[1];
DamageType damageType = (DamageType)objects[2];
2024-12-04 05:50:39 +08:00
Role UserObj = (Role)objects[3];
2024-12-04 02:09:23 +08:00
float finalDamage = harm;
switch (damageType)
{
case DamageType.physicalDamage://<2F><><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD>
finalDamage -= targetAudience.physicalArmor;
break;
case DamageType.magicDamage://ħ<><C4A7><EFBFBD>˺<EFBFBD>
finalDamage -= targetAudience.magicArmor;
break;
case DamageType.noAttributeDamage://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD>
finalDamage -= 0;
break;
}
if (finalDamage < 0)
{
finalDamage = 0;
}
targetAudience.Hp -= finalDamage;
}
}