UnityCommon/Role/Role.cs

505 lines
14 KiB
C#
Raw Normal View History

2024-12-04 05:50:39 +08:00
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
2024-12-05 16:25:46 +08:00
using System.Drawing;
2024-12-04 05:50:39 +08:00
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;
2024-12-05 16:25:46 +08:00
using UnityEngine.UIElements;
2024-12-04 05:50:39 +08:00
using Debug = UnityEngine.Debug;
2024-12-05 16:25:46 +08:00
using Image = UnityEngine.UI.Image;
2024-12-16 17:48:50 +08:00
using DG.Tweening;
using UnityEngine.SocialPlatforms;
2024-12-05 16:25:46 +08:00
public enum Camp
{/// <summary>
/// <20><><EFBFBD><EFBFBD>
/// </summary>
Player,
/// <summary>
/// <20><><EFBFBD><EFBFBD>
/// </summary>
Enemy,
/// <summary>
/// <20><><EFBFBD><EFBFBD>
/// </summary>
Neutral
}
2024-12-04 05:50:39 +08:00
/// <summary>
/// <20><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>,<2C><><EFBFBD>Ҵ<EFBFBD><D2B4><EFBFBD><EFBFBD>¼<EFBFBD>
/// </summary>
[ExecuteInEditMode]
public class Role : Fun
{
2024-12-23 16:57:40 +08:00
[Header("Id")] public string id;
2024-12-24 09:36:18 +08:00
[Header("<22><><EFBFBD><EFBFBD>")] public string Name;
2024-12-05 16:25:46 +08:00
[Header("<22><>Ӫ")] public Camp camp ;
2024-12-04 05:50:39 +08:00
[Header("Ѫ<><D1AA>")] public float hp = 100f;//Ѫ<><D1AA>
2024-12-24 14:11:28 +08:00
//[Header("<22><><EFBFBD><EFBFBD>")] public List<Skill> Myskill;//<2F><><EFBFBD><EFBFBD>
2024-12-24 12:04:18 +08:00
2024-12-14 21:15:33 +08:00
private float maxHp;
[Header(("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>"))] public int dieIndex=-1;
2024-12-18 16:55:00 +08:00
[Header("hp<68><70><EFBFBD><EFBFBD>ֱ<EFBFBD>ӿ<EFBFBD>")] public Image Hpfiil;
[Header("hp<68><70><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")] public Image HpfiilYello;
2024-12-14 21:15:33 +08:00
[Header("<22><>Ѫ<EFBFBD><D1AA><EFBFBD><EFBFBD>")] public GameObject HpTextPrefab;
2024-12-18 16:55:00 +08:00
2024-12-14 21:15:33 +08:00
[Header("<22>Լ<EFBFBD><D4BC>Ļ<EFBFBD><C4BB><EFBFBD>")]public Canvas _Canvas;
2024-12-16 17:48:50 +08:00
[Header("<22>Լ<EFBFBD><D4BC><EFBFBD>ͼƬ")] public SpriteRenderer spriteRenderers; // <20><EFBFBD><E6B4A2><EFBFBD>е<EFBFBD>SpriteRenderer<65><72><EFBFBD><EFBFBD>
2024-12-18 20:43:54 +08:00
[Header("<22><><EFBFBD><EFBFBD><EFBFBD>ķ<EFBFBD><C4B7><EFBFBD>")] public int HurtDirectin;
2024-12-23 16:57:40 +08:00
public string Quality;//Ʒ<><C6B7>
public string Elements;//<2F><><EFBFBD><EFBFBD>
public string Info;//<2F><><EFBFBD><EFBFBD>
public string SkillId;//<2F><><EFBFBD><EFBFBD>
public string AttackType;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public string AttackActionType;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public float AttackRange { get; set; }//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Χ
public float AttackCD;//<2F><><EFBFBD><EFBFBD>CD
public float CritRate;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public float CriticalHitRateBonus;//<2F><><EFBFBD><EFBFBD><EFBFBD>ӳ<EFBFBD>
2024-12-16 17:48:50 +08:00
2024-12-04 05:50:39 +08:00
public float Hp
{
get => hp;
set
{
2024-12-14 21:15:33 +08:00
float temp = hp;
2024-12-04 05:50:39 +08:00
hp = value;
2024-12-14 21:15:33 +08:00
2024-12-18 16:55:00 +08:00
// <20><><EFBFBD><EFBFBD>Ѫ<EFBFBD><D1AA><EFBFBD><EFBFBD>ʾ
if (Hpfiil != null)
2024-12-14 21:15:33 +08:00
{
Hpfiil.fillAmount = hp / maxHp;
2024-12-18 16:55:00 +08:00
// ʹ<><CAB9> DOTween <20><><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ѫ<EFBFBD><D1AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
DOTween.To(() => HpfiilYello.fillAmount, x => HpfiilYello.fillAmount = x, hp / maxHp, 0.8f) // 0.5f Ϊ<><CEAA><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1>
.SetEase(Ease.InOutQuad); // ʹ<>û<EFBFBD><C3BB><EFBFBD>Ч<EFBFBD><D0A7><EFBFBD><EFBFBD>ʹѪ<CAB9><D1AA><EFBFBD><EFBFBD><E4BBAF><EFBFBD><EFBFBD>ƽ<EFBFBD><C6BD>
2024-12-14 21:15:33 +08:00
}
2024-12-18 16:55:00 +08:00
// <20><><EFBFBD><EFBFBD>Ѫ<EFBFBD><D1AA><EFBFBD>ı<EFBFBD>Ч<EFBFBD><D0A7>
if (HpTextPrefab != null && hp < maxHp)
2024-12-14 21:15:33 +08:00
{
2024-12-19 19:01:39 +08:00
hit();
2024-12-24 10:58:35 +08:00
Navigation.StopPathDoTween(0.2f); // ֹͣ<CDA3>κν<CEBA><CEBD><EFBFBD><EFBFBD>е<EFBFBD> DoTween <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>0.2sΪʾ<EFBFBD><EFBFBD>ֵ
2024-12-14 21:15:33 +08:00
GameObject go = GameObject.Instantiate(HpTextPrefab, _Canvas.transform);
2024-12-18 20:43:54 +08:00
go.GetComponent<SnowHpControl>().direction = HurtDirectin;
go.GetComponent<SnowHpControl>().CreateText();
2024-12-23 16:57:40 +08:00
go.GetComponent<Text>().text = (temp - hp).ToString("F0"); // <20><>ʾ<EFBFBD>˺<EFBFBD>ֵ
2024-12-14 21:15:33 +08:00
}
2024-12-18 16:55:00 +08:00
// <20>жϽ<D0B6>ɫ<EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
2024-12-04 05:50:39 +08:00
if (hp <= 0)
{
2024-12-18 16:55:00 +08:00
die(); // ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-12-04 05:50:39 +08:00
}
2024-12-18 16:55:00 +08:00
2024-12-04 05:50:39 +08:00
}
}
2024-12-05 16:25:46 +08:00
[Header("<22><><EFBFBD><EFBFBD>")] public float gold = 10f;
public float Gold
{
[DebuggerStepThrough]
get => gold;
[DebuggerStepThrough]
set => gold = value;
}
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")] private float attack = 10f;
2024-12-23 16:57:40 +08:00
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")] public float MaxAttack = 10f;
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")] public float MinAttack = 10f;
2024-12-05 16:25:46 +08:00
public float Attack
{
get => attack;
set => attack = value;
}
[Header("<22>ȼ<EFBFBD>")] private int level = 1;
public int Level
{
[DebuggerStepThrough] get => level;
[DebuggerStepThrough] set => level = value;
}
2024-12-04 05:50:39 +08:00
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")] public int physicalArmor = 10;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
[Header("ħ<><C4A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")] public int magicArmor = 5;//ħ<><C4A7><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-12-23 22:31:00 +08:00
2024-12-04 05:50:39 +08:00
[Header("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")] public SimplePathfindingDoTween Navigation;
[System.Serializable ]
public class AnimationList//<2F><><EFBFBD><EFBFBD>list
{
//[Header("<22><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD>ѭ<EFBFBD><D1AD>")] public bool isloop = false;
[Header("<22><><EFBFBD><EFBFBD>ͼƬ")] public List<Sprite> value; // <20>ֵ<EFBFBD><D6B5><EFBFBD>ֵ
[Header("<22><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>֡<EFBFBD><D6A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>(<28><><EFBFBD><EFBFBD>)")] public int CharacterAnimationFrameInterval = 50;
}
[Header("<22><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>")] public List<AnimationList> AnimationTree = new List<AnimationList>();
[Header("<22><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")] public int animationHighlight = 0;
[Header("<22><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>")] public SpriteRenderer spriteRenderer;
[Header("<22><>ɫImageλ<65><CEBB>")] public Image image;
public delegate void AnimationItem(int AnimationItem);
public event AnimationItem OnAnimationStart;
public event AnimationItem OnAnimationIng;
public event AnimationItem OnAnimationEnd;
[Header("<22><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>")] public bool isAnimationPlay = false;//<2F><><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
2024-12-05 16:25:46 +08:00
[Header("<22><>ײ<EFBFBD><D7B2>")]public CircleCollider2D mycollider;
2024-12-14 21:15:33 +08:00
[Header("<22><><EFBFBD><EFBFBD><EFBFBD>ű<EFBFBD>")] public Attack attackClass;
[Header("<22><>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD>ͼƬ<CDBC><C6AC><EFBFBD><EFBFBD>")] public int CurrentIndex;
2024-12-19 19:01:39 +08:00
public int hitIndex = 2;//<2F>ܻ<EFBFBD><DCBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public int normalIndex = 0;//<2F>ƶ<EFBFBD><C6B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
public bool isHit=false;//
2024-12-14 21:15:33 +08:00
2024-12-23 22:31:00 +08:00
public List<BUff> buffList = new List<BUff>();
/// <summary>
/// <20><><EFBFBD><EFBFBD>buff
/// </summary>
public List<Action<Role>> storageBuff = new List<Action<Role>>();
/// <summary>
/// ʹ<><CAB9>buff
/// </summary>
public List<Action<Role>> PlayerBuff=new List<Action<Role>>();
2024-12-14 21:15:33 +08:00
public virtual async void Start()
2024-12-04 05:50:39 +08:00
{
2024-12-14 21:15:33 +08:00
maxHp = hp;
2024-12-23 16:57:40 +08:00
SetSelfInfo();
2024-12-14 21:15:33 +08:00
2024-12-04 05:50:39 +08:00
if (Application.isPlaying)
{
2024-12-05 16:25:46 +08:00
if (attackClass)
{
attackClass.role = this;
}
2024-12-04 05:50:39 +08:00
UpdateBuff();
}
2024-12-05 16:25:46 +08:00
tag = Enum.GetName(typeof(Camp), camp);
2024-12-04 05:50:39 +08:00
updateAnimation();
2024-12-23 22:31:00 +08:00
2024-12-24 10:30:02 +08:00
//AddBuff(storageBuff,this.CreateDecelerationBuff(10f,1f));
2024-12-23 22:31:00 +08:00
}
/// <summary>
/// <20><><EFBFBD><EFBFBD>Buff
/// </summary>
/// <param name="buffAction"></param>
public void AddBuff(List<Action<Role>> buffs, Action<Role> buffAction)
{
buffs.Add(buffAction);
2024-12-24 10:30:02 +08:00
Debug.LogError(this.name + "<22><><EFBFBD><EFBFBD>buff<66><66>"+ buffs);
2024-12-23 22:31:00 +08:00
}
/// <summary>
/// ִ<><D6B4><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD>ǰ Buff
/// </summary>
public void ApplyBuffs()
{
foreach (var buff in PlayerBuff)
{
2024-12-24 16:43:25 +08:00
Debug.LogError(this.name + "<22><><EFBFBD><EFBFBD>ִ<EFBFBD><D6B4>buff<66>ж<EFBFBD>");
2024-12-24 10:30:02 +08:00
buff.Invoke(this); // <20><><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>ΪĿ<CEAA><EFBFBD><EAB4AB>
2024-12-23 22:31:00 +08:00
}
// <20><><EFBFBD><EFBFBD> Buff <20>б<EFBFBD><D0B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Buff <20><>һ<EFBFBD><D2BB><EFBFBD>Ե<EFBFBD>
2024-12-25 11:22:39 +08:00
PlayerBuff.Clear();
2024-12-04 05:50:39 +08:00
}
2024-12-23 22:31:00 +08:00
2024-12-04 05:50:39 +08:00
/// <summary>
/// <20><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
public async void updateAnimation()
{
while (true)
{
2024-12-04 06:08:11 +08:00
if (AnimationTree.Count == 0)
{
isAnimationPlay = false;
return;
}
isAnimationPlay = true;
if (animationHighlight >= AnimationTree.Count)
2024-12-04 05:50:39 +08:00
{
animationHighlight = AnimationTree.Count - 1;
}
2024-12-19 19:01:39 +08:00
else if (animationHighlight < 0)
{
2024-12-04 05:50:39 +08:00
animationHighlight = 0;
}
List<Sprite> LightSprite = AnimationTree[animationHighlight].value;
2024-12-19 19:01:39 +08:00
if (LightSprite == null)
2024-12-04 05:50:39 +08:00
{
2024-12-04 06:08:11 +08:00
isAnimationPlay = false;
2024-12-04 05:50:39 +08:00
return;
};
OnAnimationStart?.Invoke(animationHighlight);
2024-12-14 21:15:33 +08:00
var lsanimationHighlight = animationHighlight;
2024-12-04 05:50:39 +08:00
foreach (Sprite sprite in LightSprite)
{
2024-12-14 21:15:33 +08:00
if (lsanimationHighlight == animationHighlight)
2024-12-04 05:50:39 +08:00
{
2024-12-14 21:15:33 +08:00
if (image != null)
{
image.sprite = sprite;
}
else if (spriteRenderer != null)
{
spriteRenderer.sprite = sprite;
}
if (animationHighlight >= 0 && animationHighlight < AnimationTree.Count)
{
OnAnimationIng?.Invoke(animationHighlight);
await Task.Delay(AnimationTree[animationHighlight].CharacterAnimationFrameInterval);
}
2024-12-04 05:50:39 +08:00
}
2024-12-14 21:15:33 +08:00
else
2024-12-04 05:50:39 +08:00
{
2024-12-14 21:15:33 +08:00
break;
2024-12-04 05:50:39 +08:00
}
}
2024-12-14 21:15:33 +08:00
OnAnimationEnd?.Invoke(lsanimationHighlight);
if (lsanimationHighlight == dieIndex)
{
2024-12-14 23:20:36 +08:00
2024-12-19 19:01:39 +08:00
SpawnPool.intance.ReturnEnemyToPool(this.gameObject); // <20><><EFBFBD>յ<EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD>˵<EFBFBD><CBB5><EFBFBD><EFBFBD><EFBFBD>
ResetAllStatus();
}
if (lsanimationHighlight == hitIndex)
{
animationHighlight = normalIndex;
2024-12-14 21:15:33 +08:00
}
2024-12-04 05:50:39 +08:00
}
}
2024-12-05 16:25:46 +08:00
2024-12-19 19:01:39 +08:00
2024-12-04 05:50:39 +08:00
/// <summary>
/// <20><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>
/// </summary>
2024-12-19 19:01:39 +08:00
public virtual void die()
2024-12-04 05:50:39 +08:00
{
if (Application.isPlaying)
{
2024-12-14 21:15:33 +08:00
animationHighlight = dieIndex;
Navigation.PauseAnimation();
Debug.Log("die");
2024-12-04 05:50:39 +08:00
}
}
2024-12-19 19:01:39 +08:00
/// <summary>
/// <20><>ɫ<EFBFBD>ܵ<EFBFBD><DCB5><EFBFBD><EFBFBD><EFBFBD>
/// </summary>
public virtual void hit()
{
if (Application.isPlaying)
{
animationHighlight = hitIndex;
}
}
2024-12-20 21:41:40 +08:00
/// <summary>
/// <20><>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>
/// </summary>
public void SlowDown(float num)
{
Navigation.speedFactor *= num;
}
2024-12-04 05:50:39 +08:00
/// <summary>
/// <20><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>buff
/// </summary>
async void UpdateBuff()//<2F><>λbuff<66><66><EFBFBD><EFBFBD>
{
while (true)
{
List<BUff> deleteArr = new List<BUff>();
foreach (BUff buffItem in buffList)
{
if (buffItem.executionInterval <= 0)
{
buffItem.executionInterval = buffItem.executionInterval_max;
buffItem.Funaction.Invoke(buffItem.value);
}
buffItem.executionInterval -= 0.1f;
buffItem.timeLeft -= 0.1f;
if (buffItem.timeLeft <= 0)
{
deleteArr.Add(buffItem);
}
}
foreach (BUff item in deleteArr)
{
buffList.Remove(item);
}
await Task.Delay(100);//buff<66><66><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Сʱ<D0A1><CAB1>0.1<EFBFBD><EFBFBD>ִ<EFBFBD><EFBFBD>һ<EFBFBD><EFBFBD>
}
}
2024-12-14 21:15:33 +08:00
/// <summary>
/// <20><><EFBFBD>ý<EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>״̬
/// </summary>
public void ResetAllStatus()
{
// <20><><EFBFBD><EFBFBD>Ѫ<EFBFBD><D1AA>
Hp = 100f;
// <20><><EFBFBD>ù<EFBFBD><C3B9><EFBFBD><EFBFBD><EFBFBD>
Attack = 10f;
// <20><><EFBFBD>û<EFBFBD><C3BB><EFBFBD>
physicalArmor = 10;
magicArmor = 5;
// <20><><EFBFBD>õȼ<C3B5>
Level = 1;
// <20><><EFBFBD>ý<EFBFBD><C3BD><EFBFBD>
Gold = 10f;
// <20><><EFBFBD><EFBFBD> Buff <20>б<EFBFBD>
buffList.Clear();
// <20><><EFBFBD><EFBFBD><EFBFBD>е<EFBFBD><D0B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9>ǰ<EFBFBD>ĵ<EFBFBD><C4B5><EFBFBD><EFBFBD><EFBFBD>Ϊ
if (Navigation != null)
{
//Navigation.Stop(); // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> Stop <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֹͣ<CDA3><D6B9><EFBFBD><EFBFBD>
}
// <20><><EFBFBD>ý<EFBFBD>ɫ<EFBFBD><C9AB><EFBFBD><EFBFBD>
animationHighlight = 0;
isAnimationPlay = false;
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><EFBFBD><E5A3A8><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (mycollider != null)
{
mycollider.enabled = true; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ײ<EFBFBD><D7B2>
}
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>õ<EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
}
2024-12-16 17:48:50 +08:00
2024-12-24 14:56:21 +08:00
public void FlashRedEffect(int color = 0, float time = 0.2f)//0<><30>1 <20><EFBFBD><ECA1A2>
2024-12-16 17:48:50 +08:00
{
2024-12-24 14:56:21 +08:00
// <20><><EFBFBD><EFBFBD>spriteRenderer<65><72><EFBFBD><EFBFBD>
if (spriteRenderer != null)
{
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>Sequence<63><65>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˳<EFBFBD><CBB3>ִ<EFBFBD><D6B4>
Sequence sequence = DOTween.Sequence();
// <20><>ɫ<EFBFBD>
if (color == 0)
2024-12-16 17:48:50 +08:00
{
2024-12-24 14:56:21 +08:00
// <20><>Ϊ<EFBFBD><CEAA>ɫ<EFBFBD><C9AB><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ɫ
sequence.Append(spriteRenderer.DOColor(UnityEngine.Color.red, 0.2f))
.Append(spriteRenderer.DOColor(UnityEngine.Color.white, time));
}
else if (color == 1)
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
UnityEngine.Color frostBlueWithAlpha = new UnityEngine.Color(0.2f, 0.5f, 1f); ; // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ɫ
// <20><>Ϊ<EFBFBD><CEAA>ɫ<EFBFBD><C9AB><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>ɫ
sequence.Append(spriteRenderer.DOColor(frostBlueWithAlpha, 0.2f))
.Append(spriteRenderer.DOColor(UnityEngine.Color.white, time));
2024-12-16 17:48:50 +08:00
}
2024-12-24 14:56:21 +08:00
// <20><>ʼִ<CABC><D6B4>Sequence
sequence.Play();
}
2024-12-16 17:48:50 +08:00
}
2024-12-24 14:56:21 +08:00
2024-12-16 17:48:50 +08:00
public void StopDoTween(float stopTime)
{
// <20><>ͣ<EFBFBD><CDA3>ǰ<EFBFBD>Ķ<EFBFBD><C4B6><EFBFBD>
transform.DOPause();
// <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӳ٣<D3B3><D9A3><EFBFBD>ֱʱ<D6B1>
DOTween.To(() => 0f, x => { }, 0f, stopTime).OnKill(() =>
{
// <20><><EFBFBD>ӳٽ<D3B3><D9BD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ָ<EFBFBD><D6B8><EFBFBD><EFBFBD><EFBFBD>
transform.DOPlay();
});
}
// <20><><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD>
public virtual void Upgrade()
{
Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>߼<EFBFBD><DFBC><EFBFBD><EFBFBD>յģ<D5B5><C4A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д");
}
2024-12-23 16:57:40 +08:00
public void SetSelfInfo()
{
if (camp==Camp.Player)
{
2024-12-24 17:40:22 +08:00
// Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ==============================" + MengyaoInfo.Instance.m_Mengyao.Count);
2024-12-23 16:57:40 +08:00
foreach (Character character in MengyaoInfo.Instance.m_Mengyao)
{
if (id ==character.Id)
{
2024-12-24 09:36:18 +08:00
Name = character.Name;
2024-12-23 16:57:40 +08:00
MinAttack = int.Parse(character.MinAttack);
MaxAttack = int.Parse(character.MaxAttack);
AttackCD = float.Parse(character.AttackCD);
CritRate = float.Parse(character.CritRate);
Quality=character.Quality;//Ʒ<><C6B7>
Elements=character.Elements;//<2F><><EFBFBD><EFBFBD>
Info=character.Info;//<2F><><EFBFBD><EFBFBD>
SkillId=character.SkillId;//<2F><><EFBFBD><EFBFBD>
AttackType=character.AttackType;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
AttackActionType=character.AttackActionType;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
CriticalHitRateBonus = float.Parse(character.CriticalHitRateBonus);
2024-12-24 17:40:22 +08:00
//Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ++++++++++++++++++++++++++++++");
2024-12-23 16:57:40 +08:00
}
}
}
}
public float DamageCreate()//<2F>˺<EFBFBD><CBBA><EFBFBD><EFBFBD><EFBFBD>
{
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD>˺<EFBFBD>
float num = UnityEngine.Random.Range(MinAttack, MaxAttack);
// <20>ж<EFBFBD><D0B6>Ƿ񱩻<C7B7>
float critChance = UnityEngine.Random.Range(0f, 1f); // <20><><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>0<EFBFBD><30><31><D6AE><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
if (critChance < CritRate) // <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
// <20><><EFBFBD><EFBFBD><E3B1A9><EFBFBD>˺<EFBFBD><CBBA><EFBFBD><EFBFBD><EFBFBD>ͨ<EFBFBD>˺<EFBFBD><CBBA><EFBFBD><EFBFBD>Ա<EFBFBD><D4B1><EFBFBD><EFBFBD>ӳɣ<D3B3>
num *= (1 + CriticalHitRateBonus);
2024-12-24 17:40:22 +08:00
//Debug.Log("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>˺<EFBFBD><CBBA><EFBFBD><EFBFBD>ӣ<EFBFBD>" + num);
2024-12-23 16:57:40 +08:00
}
return num;
}
2024-12-24 12:04:18 +08:00
2024-12-25 11:22:39 +08:00
public virtual void SlowDown(float slowFactor, float duration)
2024-12-24 12:04:18 +08:00
{
2024-12-25 11:22:39 +08:00
}
2024-12-24 12:04:18 +08:00
2024-12-04 05:50:39 +08:00
}