UnityCommon/Role/Fun.cs

169 lines
4.5 KiB
C#
Raw Normal View History

2024-12-25 11:22:39 +08:00
using DG.Tweening;
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-25 16:38:05 +08:00
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>
2025-01-04 20:08:40 +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;
2025-01-04 20:08:40 +08:00
targetAudience.isMoFa = true;
Debug.Log(<><C4A7><EFBFBD>˺<EFBFBD>");
2024-12-04 02:09:23 +08:00
break;
case DamageType.noAttributeDamage://<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD>
finalDamage -= 0;
break;
}
if (finalDamage < 0)
{
finalDamage = 0;
}
2024-12-27 22:58:44 +08:00
2025-01-02 18:04:35 +08:00
if (targetAudience.Hp- finalDamage<0)
{
targetAudience.Hp = 0;
}
else
{
targetAudience.Hp -= finalDamage;
}
2024-12-27 22:58:44 +08:00
if (targetAudience.Hp<=0&&targetAudience.HaveDieTime==1)
2024-12-27 17:13:06 +08:00
{
2024-12-27 22:58:44 +08:00
2024-12-27 17:13:06 +08:00
UserObj.killNum++;
2024-12-27 22:58:44 +08:00
2024-12-27 17:13:06 +08:00
Debug.Log(UserObj.name+"<22><>ɱ<EFBFBD><C9B1><EFBFBD><EFBFBD>"+ UserObj.killNum);
}
2024-12-18 20:43:54 +08:00
targetAudience.HurtDirectin = direction;
2024-12-04 02:09:23 +08:00
}
2024-12-23 22:31:00 +08:00
/// <summary>
2024-12-25 11:22:39 +08:00
/// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>ѣ<EFBFBD><D1A3>Buff
2024-12-23 22:31:00 +08:00
/// </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)
{
return (Role targetRole) =>
{
float temp = UnityEngine.Random.Range(0f, 1f);
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-25 16:38:05 +08:00
GameObject go = Instantiate(Resources.Load<GameObject>("A_Fight/XuanYun"), targetRole.transform);
2024-12-25 17:47:37 +08:00
go.transform.position = new Vector2(go.transform.position.x, go.transform.position.y + 0.35f);
2024-12-25 16:38:05 +08:00
go.GetComponent<XuanYun>().DesSelf(duration);
2024-12-25 11:22:39 +08:00
Debug.LogWarning($"Ӧ<><D3A6>ѣ<EFBFBD><D1A3> {duration} <20><> {targetRole.name}.");
2024-12-23 22:31:00 +08:00
}
else
{
2024-12-25 11:22:39 +08:00
Debug.Log($"ѣ<><D1A3>buffδ<66><CEB4><EFBFBD><EFBFBD> on {targetRole.name}.");
2024-12-23 22:31:00 +08:00
}
};
}
2024-12-25 11:22:39 +08:00
/// <summary>
/// <20><><EFBFBD><EFBFBD>buff
/// </summary>
/// <param name="slowFactor"><3E><><EFBFBD>ٰٷֱ<D9B7></param>
/// <param name="duration">ʱ<><CAB1></param>
/// <returns></returns>
public Action<Role> CreateSlowDownBuff(float slowFactor, float duration)
{
return (Role targetRole) =>
{
Debug.LogError(this.name+"<22><><EFBFBD><EFBFBD>buff");
targetRole.SlowDown(slowFactor, duration);
};
}
2025-01-07 16:50:42 +08:00
/// <summary>
/// <20>ж<EFBFBD>buff
/// </summary>
/// <param name="poisonDuration"><3E><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1></param>
/// <param name="poisonInterval"><3E><><EFBFBD><EFBFBD></param>
/// <param name="poisonInterval"><3E>˺<EFBFBD></param>
/// <returns></returns>
2025-01-07 17:26:01 +08:00
public Action<Role> CreatePoisonBuff(float poisonDuration, float poisonInterval, float poisonDamage,Role AttackRole)
2025-01-07 16:50:42 +08:00
{
return (Role targetRole) =>
{
2025-01-07 17:26:01 +08:00
Debug.Log(this.name + "<22>ж<EFBFBD>buff");
targetRole.ApplyPoisonDamage(poisonDuration, poisonInterval,poisonDamage, AttackRole);
2025-01-07 16:50:42 +08:00
};
}
2024-12-04 02:09:23 +08:00
}