DESKTOP-DDTRVOR\asus 36fa2e1e12 修改声音
2024-12-26 11:39:49 +08:00

102 lines
2.8 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using cfg.BlacksmithData;
using UnityEngine;
using Random = UnityEngine.Random;
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 int Cri => criti;
private int criti;
public float NextTime;
private float time=0;
public bool Start => start;
private bool start=false;
public void SetAttack(SkillState itemData, int a,float sp= 1,int nu=1,int criticalStrike =0)
{
var skillData=JsonTab.Instance.tables.SkillStructure.Get(itemData.data.Skillbody);
_sprite.sprite = AssetBundleManager.ins.Sprite(skillData.Skillbodyicon, AtlasType.ButtleIcon);
switch (skillData.Skillbodyicon)
{
case "jian1":
SoundSystem.ins.Attack1Audio();
break;
case "jian2":
SoundSystem.ins.Attack1Audio();
break;
case "jian3":
SoundSystem.ins.Attack1Audio();
break;
case "jian4":
SoundSystem.ins.Attack1Audio();
break;
case "shitou":
SoundSystem.ins.Attack1Audio();
break;
case "changbing1":
break;
case "changbing2":
break;
case "changbing3":
break;
case "changbing4":
break;
case "huoqiu":
break;
case "gongshi":
break;
case "feibiao1":
break;
case "feibiao2":
break;
case "feibiao3":
break;
case "feibiao4":
break;
}
attack = a;
speed = sp;
num = nu;
time = BattleManager.ins.NowTime + 10;
start = true;
criti = criticalStrike;
}
private void OnTriggerEnter2D(Collider2D other)
{
var mouster=other.GetComponent<Mouster>();
if (!start|| mouster == null) return;
var r = criti>Random.Range(0, 100);
var a = r ? Attack : Attack * 1.5;
mouster.SetInjured((int) a);
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);
}
}