2024-12-09 11:19:14 +08:00
|
|
|
using System;
|
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using cfg.BlacksmithData;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class Bullet : MonoBehaviour
|
|
|
|
{
|
|
|
|
[SerializeField] private SpriteRenderer _sprite;
|
|
|
|
public int Attack => attack;
|
|
|
|
private int attack = 0;
|
|
|
|
private int num = 1;
|
|
|
|
public float Speed => speed;
|
|
|
|
private float speed=0;
|
|
|
|
public float NextTime;
|
|
|
|
private float time=0;
|
|
|
|
public bool Start => start;
|
|
|
|
private bool start=false;
|
|
|
|
|
2024-12-11 23:46:58 +08:00
|
|
|
public void SetAttack(SkillState itemData, int a,float sp= 1,int nu=1)
|
2024-12-09 11:19:14 +08:00
|
|
|
{
|
2024-12-11 23:46:58 +08:00
|
|
|
var skillData=JsonTab.Instance.tables.SkillStructure.Get(itemData.data.Skillbody);
|
|
|
|
BDebug.LogError(skillData.Skillbodyicon);
|
|
|
|
_sprite.sprite = AssetBundleManager.ins.Sprite(skillData.Skillbodyicon, AtlasType.ButtleIcon);
|
2024-12-09 11:19:14 +08:00
|
|
|
attack = a;
|
|
|
|
speed = sp;
|
|
|
|
num = nu;
|
|
|
|
time = BattleManager.ins.NowTime + 10;
|
|
|
|
start = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
private void OnTriggerEnter2D(Collider2D other)
|
|
|
|
{
|
|
|
|
var mouster=other.GetComponent<Mouster>();
|
|
|
|
if (!start|| mouster == null) return;
|
|
|
|
mouster.SetInjured(Attack);
|
|
|
|
num -= 1;
|
|
|
|
if (num<=0)
|
|
|
|
{
|
|
|
|
start = false;
|
|
|
|
BattleManager.ins.RemoveBullets(this);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void BulletUpdate()
|
|
|
|
{
|
|
|
|
if (!start)
|
|
|
|
{
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (time<BattleManager.ins.NowTime)
|
|
|
|
{
|
|
|
|
start = false;
|
|
|
|
BattleManager.ins.RemoveBullets(this);
|
|
|
|
}
|
|
|
|
transform.Translate(transform.up*Speed* Time.deltaTime,Space.World);
|
|
|
|
}
|
|
|
|
}
|