攻击子弹范围
This commit is contained in:
parent
e71e2e820b
commit
b1554f23f7
@ -45,6 +45,7 @@ public class Attack : MonoBehaviour
|
|||||||
[Header("是否造成额外伤害")] public bool haveAddDamage = false;
|
[Header("是否造成额外伤害")] public bool haveAddDamage = false;
|
||||||
[Header("额外伤害类型")] public DamageType AdddamageType=DamageType.magicDamage;
|
[Header("额外伤害类型")] public DamageType AdddamageType=DamageType.magicDamage;
|
||||||
[Header("子弹爆炸范围")] public float BoomRange = 1;
|
[Header("子弹爆炸范围")] public float BoomRange = 1;
|
||||||
|
[Header("子弹放大倍数")] public float BulletAddSize = 0;
|
||||||
public bool isAttack = true;
|
public bool isAttack = true;
|
||||||
public bool flag = false;
|
public bool flag = false;
|
||||||
[HideInInspector] public float timer = 0;
|
[HideInInspector] public float timer = 0;
|
||||||
@ -188,6 +189,7 @@ public class Attack : MonoBehaviour
|
|||||||
BulletGamobj.GetComponent<Bullet>().attackObj = this;
|
BulletGamobj.GetComponent<Bullet>().attackObj = this;
|
||||||
BulletGamobj.GetComponent<Bullet>().bulletData.BulletSpeed *= (1 + roleBulletSpeedAdd);
|
BulletGamobj.GetComponent<Bullet>().bulletData.BulletSpeed *= (1 + roleBulletSpeedAdd);
|
||||||
BulletGamobj.GetComponent<Bullet>().Target = Target;
|
BulletGamobj.GetComponent<Bullet>().Target = Target;
|
||||||
|
BulletGamobj.transform.localScale=new Vector3(BulletGamobj.transform.localScale.x*(1+ BulletAddSize), BulletGamobj.transform.localScale.y * (1 + BulletAddSize), BulletGamobj.transform.localScale.z * (1 + BulletAddSize));//子弹放大
|
||||||
BulletGamobj.transform.up = direction;
|
BulletGamobj.transform.up = direction;
|
||||||
BulletGamobj.transform.position = BulletStartPos.position;
|
BulletGamobj.transform.position = BulletStartPos.position;
|
||||||
bulltes.Add(BulletGamobj);
|
bulltes.Add(BulletGamobj);
|
||||||
|
113
Role/mhd_Bullet.cs
Normal file
113
Role/mhd_Bullet.cs
Normal file
@ -0,0 +1,113 @@
|
|||||||
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Unity.VisualScripting;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UIElements;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public class mhd_Bullet : Bullet
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
private void Start()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void Update()
|
||||||
|
{
|
||||||
|
switch (this.bulletMoveType)
|
||||||
|
{
|
||||||
|
//更具子弹的移动方式来移动
|
||||||
|
case BulletMoveType.PeerToPeer:
|
||||||
|
if (IsMove)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
this.gameObject.transform.Translate(Vector3.up * Time.deltaTime * bulletData.BulletSpeed);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
timer += Time.deltaTime;
|
||||||
|
if (timer > BulletDeadTimer)
|
||||||
|
{
|
||||||
|
attackObj.bulltes.Remove(this.gameObject);
|
||||||
|
Debug.Log("对象已成功移除。当前列表数量:" + attackObj.bulltes.Count);
|
||||||
|
Destroy(this.gameObject);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
case BulletMoveType.PointToDirection:
|
||||||
|
break;
|
||||||
|
case BulletMoveType.Scope:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTriggerEnter2D(Collider2D collision)
|
||||||
|
{
|
||||||
|
Role Crole = collision.gameObject.GetComponent<Role>();
|
||||||
|
if (Crole)
|
||||||
|
{
|
||||||
|
if (Crole.camp != role.camp)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
foreach (var buff in role.storageBuff)
|
||||||
|
{
|
||||||
|
if (!Crole.PlayerBuff.Contains(buff))
|
||||||
|
{
|
||||||
|
Crole.PlayerBuff.Add(buff);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Crole.ApplyBuffs();
|
||||||
|
|
||||||
|
// Debug.Log(this.role.gameObject.name + "进行攻击计算");
|
||||||
|
int direction = 0;
|
||||||
|
if (collision.transform.position.x > transform.position.x) //子弹打到敌人左边,飘字显示到右边
|
||||||
|
{
|
||||||
|
direction = 1;
|
||||||
|
}
|
||||||
|
Crole.bloodLoss(new object[] { Crole, role.DamageCreate(Crole.GetComponent<Role>()), attackObj.damageTyp, role }, direction);
|
||||||
|
Crole.FlashRedEffect();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private void OnTriggerStay2D(Collider2D collision)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private void OnTriggerExit2D(Collider2D collision)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
11
Role/mhd_Bullet.cs.meta
Normal file
11
Role/mhd_Bullet.cs.meta
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
fileFormatVersion: 2
|
||||||
|
guid: dd49bd0505ac6954ea756500c434b98c
|
||||||
|
MonoImporter:
|
||||||
|
externalObjects: {}
|
||||||
|
serializedVersion: 2
|
||||||
|
defaultReferences: []
|
||||||
|
executionOrder: 0
|
||||||
|
icon: {instanceID: 0}
|
||||||
|
userData:
|
||||||
|
assetBundleName:
|
||||||
|
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user