You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
75 lines
1.9 KiB
75 lines
1.9 KiB
using System.Collections.Generic;
|
|
using System.Numerics;
|
|
using UnityEngine;
|
|
|
|
public class IVBullet : MonoBehaviour
|
|
{
|
|
[SerializeField] BoxCollider col;
|
|
[SerializeField] ParticleSystem ptcBullet;
|
|
|
|
BattleMgr battleMgr;
|
|
BigInteger biDmg;
|
|
float fCrtDam;
|
|
float Shake;
|
|
int Vibrato;
|
|
int iCrtRate;
|
|
int idNumber;
|
|
int useFrom;
|
|
|
|
HashSet<string> targetFilter;
|
|
HashSet<IBattleEntity> damaged = new();
|
|
|
|
private void FixedUpdate()
|
|
{
|
|
bool isHit = false;
|
|
battleMgr.LoopAllBattleEntities((battleEntity) =>
|
|
{
|
|
if(damaged.Contains(battleEntity))
|
|
return true;
|
|
|
|
var entity = battleEntity as Entity;
|
|
if (targetFilter.Contains(entity.tag) && col.bounds.Contains(entity.Position))
|
|
{
|
|
battleEntity.GetDamage(biDmg, fCrtDam, iCrtRate, idNumber);
|
|
damaged.Add(battleEntity);
|
|
ptcPlay();
|
|
}
|
|
|
|
return true;
|
|
});
|
|
|
|
if(isHit)
|
|
{
|
|
IVCameraController.SShakeCamera(0.2f, Shake, Vibrato);
|
|
}
|
|
}
|
|
|
|
private void ptcPlay()
|
|
{
|
|
if(ptcBullet != null)
|
|
ptcBullet.Play();
|
|
}
|
|
|
|
public void SetStatus(BattleMgr mgr, BigInteger bidmg, float fcrtdam, int icrtrate, int idnumber, float fshake, int ivibrato, int useFrom = 0)
|
|
{
|
|
battleMgr = mgr;
|
|
biDmg = bidmg;
|
|
fCrtDam = fcrtdam;
|
|
iCrtRate = icrtrate;
|
|
idNumber = idnumber;
|
|
Shake = fshake;
|
|
Vibrato = ivibrato;
|
|
|
|
if(targetFilter is null || this.useFrom != useFrom)
|
|
{
|
|
this.useFrom = useFrom;
|
|
|
|
if(useFrom == 0)
|
|
targetFilter = new HashSet<string>() { GameProperty.Instance.EnemyTag };
|
|
else
|
|
targetFilter = new HashSet<string>() { GameProperty.Instance.PlayerTag };
|
|
}
|
|
|
|
damaged.Clear();
|
|
}
|
|
}
|