UnityCommon/Role/Fun.cs

119 lines
3.0 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;
2024-12-23 22:31:00 +08:00
using Random = System.Random;
2024-12-04 02:09:23 +08:00
public enum DamageType
{
2024-12-05 16:25:46 +08:00
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD>
/// </summary>
physicalDamage,
/// <summary>
/// ħ<><C4A7><EFBFBD>˺<EFBFBD>
/// </summary>
magicDamage,
/// <summary>
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD>
/// </summary>
noAttributeDamage,
2024-12-04 02:09:23 +08:00
}
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>ֵ
2024-12-23 22:31:00 +08:00
public BuffTypeState buffTypeState = 0;
2024-12-04 02:09:23 +08:00
2024-12-23 22:31:00 +08:00
public bool hasfalg(BuffTypeState fag)
2024-12-04 02:09:23 +08:00
{
2024-12-23 22:31:00 +08:00
return (buffTypeState & fag) == fag;
2024-12-04 02:09:23 +08:00
}
2024-12-12 17:06:08 +08:00
2024-12-23 22:31:00 +08:00
}
2024-12-12 17:06:08 +08:00
2024-12-23 22:31:00 +08:00
public enum BuffTypeState
{
}
public class Fun : Base
{
2024-12-04 02:09:23 +08:00
/// <summary>
2024-12-18 20:43:54 +08:00
/// <20><>Ѫ <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Ŀ<><C4BF>,<2C>˺<EFBFBD>ֵ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ʹ<><CAB9><EFBFBD>ߣ<EFBFBD><DFA3>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD><EFBFBD><EFBFBD>0<EFBFBD><30><EFBFBD>ұߣ<D2B1>1<EFBFBD><31><EFBFBD><EFBFBD><EFBFBD>ߣ<EFBFBD>
2024-12-04 02:09:23 +08:00
/// </summary>
/// <param name="objects"></param>
2024-12-18 20:43:54 +08:00
public void bloodLoss(object[] objects,int direction=1)//Ŀ<><C4BF>,<2C>˺<EFBFBD>ֵ,<2C><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>,ʹ<><CAB9><EFBFBD><EFBFBD>,<2C>ӵ<EFBFBD><D3B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>
2024-12-04 02:09:23 +08:00
{
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;
2024-12-18 20:43:54 +08:00
targetAudience.HurtDirectin = direction;
2024-12-04 02:09:23 +08:00
}
2024-12-24 10:30:02 +08:00
2024-12-04 02:09:23 +08:00
2024-12-23 22:31:00 +08:00
/// <summary>
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD>٣<EFBFBD>ѣ<EFBFBD>Σ<EFBFBD> Buff
/// </summary>
/// <param name="duration">ѣ<>γ<EFBFBD><CEB3><EFBFBD>ʱ<EFBFBD><CAB1></param>
/// <param name="probability"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʣ<EFBFBD>0<EFBFBD><30><31>䣩</param>
public Action<Role> CreateDecelerationBuff(float duration, float probability)
{
2024-12-24 10:30:02 +08:00
Debug.Log("!!!!!!!!!!!!!!!!!!!!!!!!!!");
2024-12-23 22:31:00 +08:00
return (Role targetRole) =>
{
2024-12-24 10:30:02 +08:00
Debug.Log("@@@@@@@@@@@@@@@@@@@@@@@@");
2024-12-23 22:31:00 +08:00
float temp = UnityEngine.Random.Range(0f, 1f);
2024-12-24 10:30:02 +08:00
Debug.LogWarning("temp="+temp);
Debug.LogWarning("duration="+duration);
Debug.LogWarning("probability=" + probability);
2024-12-23 22:31:00 +08:00
if (temp <= probability)
{
2024-12-24 10:30:02 +08:00
// ִ<><D6B4>ѣ<EFBFBD><D1A3>Ч<EFBFBD><D0A7>
2024-12-23 22:31:00 +08:00
targetRole.Navigation.StopPathDoTween(duration);
2024-12-24 10:30:02 +08:00
Debug.LogWarning(targetRole.name + <><D6B4>ѣ<EFBFBD><D1A3>Ч<EFBFBD><D0A7>");
2024-12-24 16:43:25 +08:00
Debug.LogWarning($"Ӧ<>ü<EFBFBD><C3BC><EFBFBD> {duration} <20><> {targetRole.name}.");
2024-12-23 22:31:00 +08:00
}
else
{
2024-12-24 16:43:25 +08:00
Debug.Log($"<22><><EFBFBD><EFBFBD>buffδ<66><CEB4><EFBFBD><EFBFBD> on {targetRole.name}.");
2024-12-23 22:31:00 +08:00
}
};
}
2024-12-04 02:09:23 +08:00
}