Merge branch 'main' of http://shu.sheziwanglo.cn:3000/shurongsen/UnityCommon
This commit is contained in:
commit
2ce74d4a65
@ -50,6 +50,7 @@ public class Attack : MonoBehaviour
|
|||||||
CircleCollider2D circleCollider2D = GetComponent<CircleCollider2D>();
|
CircleCollider2D circleCollider2D = GetComponent<CircleCollider2D>();
|
||||||
|
|
||||||
|
|
||||||
|
attackCooldown = transform.parent.GetComponent<enemy>().AttackCD;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ public class Bullet : MonoBehaviour
|
|||||||
direction = 1;
|
direction = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
Crole.bloodLoss(new object[] { Crole, role.Attack + bulletData.attack, attackObj.damageTyp, role },direction);
|
Crole.bloodLoss(new object[] { Crole, role.DamageCreate(), attackObj.damageTyp, role },direction);
|
||||||
attackObj.bulltes.Remove(this.gameObject);
|
attackObj.bulltes.Remove(this.gameObject);
|
||||||
|
|
||||||
if (myBulletType!=BulletType.Spraying)
|
if (myBulletType!=BulletType.Spraying)
|
||||||
@ -202,7 +202,7 @@ public class Bullet : MonoBehaviour
|
|||||||
if (Time.time - lastDamageTime > 1f) // 每秒扣一次血
|
if (Time.time - lastDamageTime > 1f) // 每秒扣一次血
|
||||||
{
|
{
|
||||||
|
|
||||||
Crole.bloodLoss(new object[] { Crole, role.Attack + bulletData.attack, attackObj.damageTyp, role });
|
Crole.bloodLoss(new object[] { Crole, role.DamageCreate(), attackObj.damageTyp, role });
|
||||||
lastDamageTime = Time.time;
|
lastDamageTime = Time.time;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
66
Role/Role.cs
66
Role/Role.cs
@ -35,7 +35,7 @@ public enum Camp
|
|||||||
[ExecuteInEditMode]
|
[ExecuteInEditMode]
|
||||||
public class Role : Fun
|
public class Role : Fun
|
||||||
{
|
{
|
||||||
[Header("Id")] public int id;
|
[Header("Id")] public string id;
|
||||||
[Header("阵营")] public Camp camp ;
|
[Header("阵营")] public Camp camp ;
|
||||||
[Header("血量")] public float hp = 100f;//血量
|
[Header("血量")] public float hp = 100f;//血量
|
||||||
private float maxHp;
|
private float maxHp;
|
||||||
@ -48,7 +48,17 @@ public class Role : Fun
|
|||||||
[Header("自己的画布")]public Canvas _Canvas;
|
[Header("自己的画布")]public Canvas _Canvas;
|
||||||
[Header("自己的图片")] public SpriteRenderer spriteRenderers; // 存储所有的SpriteRenderer组件
|
[Header("自己的图片")] public SpriteRenderer spriteRenderers; // 存储所有的SpriteRenderer组件
|
||||||
[Header("被打的方向")] public int HurtDirectin;
|
[Header("被打的方向")] public int HurtDirectin;
|
||||||
|
public string Quality;//品质
|
||||||
|
public string Elements;//属性
|
||||||
|
public string Info;//详情
|
||||||
|
public string SkillId;//技能
|
||||||
|
public string AttackType;//攻击类型
|
||||||
|
public string AttackActionType;//攻击作用类型
|
||||||
|
|
||||||
|
public float AttackRange { get; set; }//攻击范围
|
||||||
|
public float AttackCD;//攻击CD
|
||||||
|
public float CritRate;//暴击率
|
||||||
|
public float CriticalHitRateBonus;//暴击加成
|
||||||
|
|
||||||
public float Hp
|
public float Hp
|
||||||
{
|
{
|
||||||
@ -76,7 +86,7 @@ public class Role : Fun
|
|||||||
GameObject go = GameObject.Instantiate(HpTextPrefab, _Canvas.transform);
|
GameObject go = GameObject.Instantiate(HpTextPrefab, _Canvas.transform);
|
||||||
go.GetComponent<SnowHpControl>().direction = HurtDirectin;
|
go.GetComponent<SnowHpControl>().direction = HurtDirectin;
|
||||||
go.GetComponent<SnowHpControl>().CreateText();
|
go.GetComponent<SnowHpControl>().CreateText();
|
||||||
go.GetComponent<Text>().text = (temp - hp).ToString(); // ÏÔʾÉ˺¦Öµ
|
go.GetComponent<Text>().text = (temp - hp).ToString("F0"); // 显示伤害值
|
||||||
FlashRedEffect(); // 血量减少时的红色闪烁效果
|
FlashRedEffect(); // 血量减少时的红色闪烁效果
|
||||||
|
|
||||||
|
|
||||||
@ -98,6 +108,8 @@ public class Role : Fun
|
|||||||
set => gold = value;
|
set => gold = value;
|
||||||
}
|
}
|
||||||
[Header("攻击力")] private float attack = 10f;
|
[Header("攻击力")] private float attack = 10f;
|
||||||
|
[Header("攻击力上限")] public float MaxAttack = 10f;
|
||||||
|
[Header("攻击力下限")] public float MinAttack = 10f;
|
||||||
public float Attack
|
public float Attack
|
||||||
{
|
{
|
||||||
get => attack;
|
get => attack;
|
||||||
@ -154,7 +166,7 @@ public class Role : Fun
|
|||||||
public virtual async void Start()
|
public virtual async void Start()
|
||||||
{
|
{
|
||||||
maxHp = hp;
|
maxHp = hp;
|
||||||
|
SetSelfInfo();
|
||||||
|
|
||||||
if (Application.isPlaying)
|
if (Application.isPlaying)
|
||||||
{
|
{
|
||||||
@ -415,4 +427,52 @@ public class Role : Fun
|
|||||||
{
|
{
|
||||||
Debug.Log("父类的升级逻辑,空的,请在子类重写");
|
Debug.Log("父类的升级逻辑,空的,请在子类重写");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void SetSelfInfo()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (camp==Camp.Player)
|
||||||
|
{
|
||||||
|
Debug.Log("攻击力赋值==============================" + MengyaoInfo.Instance.m_Mengyao.Count);
|
||||||
|
foreach (Character character in MengyaoInfo.Instance.m_Mengyao)
|
||||||
|
{
|
||||||
|
if (id ==character.Id)
|
||||||
|
{
|
||||||
|
|
||||||
|
MinAttack = int.Parse(character.MinAttack);
|
||||||
|
MaxAttack = int.Parse(character.MaxAttack);
|
||||||
|
AttackCD = float.Parse(character.AttackCD);
|
||||||
|
CritRate = float.Parse(character.CritRate);
|
||||||
|
Quality=character.Quality;//品质
|
||||||
|
Elements=character.Elements;//属性
|
||||||
|
Info=character.Info;//详情
|
||||||
|
SkillId=character.SkillId;//技能
|
||||||
|
AttackType=character.AttackType;//攻击类型
|
||||||
|
AttackActionType=character.AttackActionType;//攻击作用类型
|
||||||
|
CriticalHitRateBonus = float.Parse(character.CriticalHitRateBonus);
|
||||||
|
Debug.Log("攻击力赋值++++++++++++++++++++++++++++++");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public float DamageCreate()//伤害生成
|
||||||
|
{
|
||||||
|
// 生成普通伤害
|
||||||
|
float num = UnityEngine.Random.Range(MinAttack, MaxAttack);
|
||||||
|
|
||||||
|
// 判断是否暴击
|
||||||
|
float critChance = UnityEngine.Random.Range(0f, 1f); // 生成一个0到1之间的随机数
|
||||||
|
if (critChance < CritRate) // 如果暴击发生
|
||||||
|
{
|
||||||
|
// 计算暴击伤害(普通伤害乘以暴击加成)
|
||||||
|
num *= (1 + CriticalHitRateBonus);
|
||||||
|
Debug.Log("暴击发生!伤害增加:" + num);
|
||||||
|
}
|
||||||
|
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user