xiugbug
This commit is contained in:
parent
cfcbd6c168
commit
b41d02098c
@ -5,7 +5,6 @@ using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using UnityEngine;
|
||||
using Debug = UnityEngine.Debug;
|
||||
using UnityEditor.Animations;
|
||||
using DG.Tweening;
|
||||
|
||||
public class Attack : MonoBehaviour
|
||||
@ -42,18 +41,7 @@ public class Attack : MonoBehaviour
|
||||
public bool isAttack = true;
|
||||
public bool flag = false;
|
||||
[HideInInspector] public float timer = 0;
|
||||
//public float AttackScope
|
||||
//{
|
||||
// [DebuggerStepThrough]
|
||||
// get => attackScope;
|
||||
// [DebuggerStepThrough]
|
||||
// set
|
||||
// {
|
||||
// attackScope = value;
|
||||
// GetComponent<CircleCollider2D>().radius = attackScope;
|
||||
// //Debug.Log("攻击半径"+GetComponent<CircleCollider2D>().radius);
|
||||
// }
|
||||
//}
|
||||
|
||||
|
||||
public async void Start()
|
||||
{
|
||||
@ -127,8 +115,10 @@ public class Attack : MonoBehaviour
|
||||
timer = 0;
|
||||
flag = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//Debug.Log(role.name+"攻击范围的图片大小"+attackRangeSprite.transform.localScale + "color" + attackRangeSprite.color+ "color.a" + attackRangeSprite.color.a + "是否显示"+ attackRangeSprite.enabled);
|
||||
|
||||
}
|
||||
|
||||
public void GetAllColliderInAttackRange(Collider2D[] colliders)
|
||||
@ -151,12 +141,7 @@ public class Attack : MonoBehaviour
|
||||
else if (bulletPrefab.GetComponent<Bullet>().myBulletType == BulletType.Spraying)
|
||||
{
|
||||
animator.SetInteger("State", 1);
|
||||
|
||||
flag = true;
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
lastAttackTime = Time.time; // 更新上次攻击时间
|
||||
@ -177,45 +162,6 @@ public class Attack : MonoBehaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
/*public void attack(Role targetRole)
|
||||
{
|
||||
|
||||
if (bulletPrefab == null)
|
||||
{
|
||||
Debug.LogError("子弹预制体为空");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Vector2 direction = (targetRole.transform.position - transform.position).normalized;
|
||||
|
||||
if (bulletPrefab.GetComponent<Bullet>().myBulletType == BulletType.Spraying)
|
||||
{
|
||||
GameObject BulletGamobj = GameObject.Instantiate(bulletPrefab, this.transform.root);
|
||||
BulletGamobj.GetComponent<Bullet>().role = role;
|
||||
BulletGamobj.GetComponent<Bullet>().attackObj = this;
|
||||
// BulletGamobj.transform.up = direction;
|
||||
BulletGamobj.transform.position =new Vector2(transform.position.x+0.15f, transform.position.y+0.2f);
|
||||
bulltes.Add(BulletGamobj);
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < bulletData.BulletScattering; i++)
|
||||
{
|
||||
// 改变子弹方向,根据角色自身的攻击范围来计算
|
||||
GameObject BulletGamobj = GameObject.Instantiate(bulletPrefab, this.transform.root);
|
||||
BulletGamobj.GetComponent<Bullet>().role = role;
|
||||
BulletGamobj.GetComponent<Bullet>().attackObj = this;
|
||||
BulletGamobj.transform.up = direction;
|
||||
BulletGamobj.transform.position = transform.position;
|
||||
bulltes.Add(BulletGamobj);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
public void Pointattack()
|
||||
{
|
||||
@ -239,7 +185,6 @@ public class Attack : MonoBehaviour
|
||||
BulletGamobj.transform.position = BulletStartPos.position;
|
||||
bulltes.Add(BulletGamobj);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -394,11 +339,6 @@ public class Attack : MonoBehaviour
|
||||
|
||||
// 更新矩形碰撞体的尺寸
|
||||
attackColliderBox.size = boxSize;
|
||||
|
||||
|
||||
|
||||
//float originalWidth = attackRangeSprite.bounds.size.x;
|
||||
//attackRangeSprite.transform.localScale = new Vector3(boxSize.x*1.4f/4, boxSize.y, 1f);
|
||||
characterClick.OrSizeX = boxSize.x / characterClick.StartSizeX; // * 2f 因为 radius 是半径,图片的尺寸通常是直径
|
||||
characterClick.OrSizeY = boxSize.y * 2 / characterClick.StartSizeY;
|
||||
float offSetX = (characterClick.StartSizeX - characterClick.OrSizeX) / 2;
|
||||
@ -409,9 +349,6 @@ public class Attack : MonoBehaviour
|
||||
attackRangeSprite.transform.position = new Vector2(attackRangeSprite.transform.position.x - offSetX, attackRangeSprite.transform.position.y);
|
||||
//characterClick.OrSizeY = 1;
|
||||
Debug.Log("修改图片宽度");
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user