Compare commits
No commits in common. "27b2f1b025a05d9401b206c40b1e2dbef062bd96" and "ae43a9f4b947987bfd0120fbde24b1d3ef63b8f4" have entirely different histories.
27b2f1b025
...
ae43a9f4b9
@ -5,6 +5,7 @@ using System.Linq;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Debug = UnityEngine.Debug;
|
using Debug = UnityEngine.Debug;
|
||||||
|
using UnityEditor.Animations;
|
||||||
using DG.Tweening;
|
using DG.Tweening;
|
||||||
|
|
||||||
public class Attack : MonoBehaviour
|
public class Attack : MonoBehaviour
|
||||||
@ -41,7 +42,18 @@ public class Attack : MonoBehaviour
|
|||||||
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;
|
||||||
|
//public float AttackScope
|
||||||
|
//{
|
||||||
|
// [DebuggerStepThrough]
|
||||||
|
// get => attackScope;
|
||||||
|
// [DebuggerStepThrough]
|
||||||
|
// set
|
||||||
|
// {
|
||||||
|
// attackScope = value;
|
||||||
|
// GetComponent<CircleCollider2D>().radius = attackScope;
|
||||||
|
// //Debug.Log("攻击半径"+GetComponent<CircleCollider2D>().radius);
|
||||||
|
// }
|
||||||
|
//}
|
||||||
|
|
||||||
public async void Start()
|
public async void Start()
|
||||||
{
|
{
|
||||||
@ -115,10 +127,8 @@ public class Attack : MonoBehaviour
|
|||||||
timer = 0;
|
timer = 0;
|
||||||
flag = false;
|
flag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//Debug.Log(role.name+"攻击范围的图片大小"+attackRangeSprite.transform.localScale + "color" + attackRangeSprite.color+ "color.a" + attackRangeSprite.color.a + "是否显示"+ attackRangeSprite.enabled);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void GetAllColliderInAttackRange(Collider2D[] colliders)
|
public void GetAllColliderInAttackRange(Collider2D[] colliders)
|
||||||
@ -141,7 +151,12 @@ public class Attack : MonoBehaviour
|
|||||||
else if (bulletPrefab.GetComponent<Bullet>().myBulletType == BulletType.Spraying)
|
else if (bulletPrefab.GetComponent<Bullet>().myBulletType == BulletType.Spraying)
|
||||||
{
|
{
|
||||||
animator.SetInteger("State", 1);
|
animator.SetInteger("State", 1);
|
||||||
|
|
||||||
flag = true;
|
flag = true;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastAttackTime = Time.time; // 更新上次攻击时间
|
lastAttackTime = Time.time; // 更新上次攻击时间
|
||||||
@ -162,6 +177,45 @@ 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()
|
public void Pointattack()
|
||||||
{
|
{
|
||||||
@ -185,6 +239,7 @@ public class Attack : MonoBehaviour
|
|||||||
BulletGamobj.transform.position = BulletStartPos.position;
|
BulletGamobj.transform.position = BulletStartPos.position;
|
||||||
bulltes.Add(BulletGamobj);
|
bulltes.Add(BulletGamobj);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -339,6 +394,11 @@ public class Attack : MonoBehaviour
|
|||||||
|
|
||||||
// 更新矩形碰撞体的尺寸
|
// 更新矩形碰撞体的尺寸
|
||||||
attackColliderBox.size = boxSize;
|
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.OrSizeX = boxSize.x / characterClick.StartSizeX; // * 2f 因为 radius 是半径,图片的尺寸通常是直径
|
||||||
characterClick.OrSizeY = boxSize.y * 2 / characterClick.StartSizeY;
|
characterClick.OrSizeY = boxSize.y * 2 / characterClick.StartSizeY;
|
||||||
float offSetX = (characterClick.StartSizeX - characterClick.OrSizeX) / 2;
|
float offSetX = (characterClick.StartSizeX - characterClick.OrSizeX) / 2;
|
||||||
@ -349,6 +409,9 @@ public class Attack : MonoBehaviour
|
|||||||
attackRangeSprite.transform.position = new Vector2(attackRangeSprite.transform.position.x - offSetX, attackRangeSprite.transform.position.y);
|
attackRangeSprite.transform.position = new Vector2(attackRangeSprite.transform.position.x - offSetX, attackRangeSprite.transform.position.y);
|
||||||
//characterClick.OrSizeY = 1;
|
//characterClick.OrSizeY = 1;
|
||||||
Debug.Log("修改图片宽度");
|
Debug.Log("修改图片宽度");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user