public IEnumerator Reload(NpcCtrl npc) { //AI의 Reload 상태 값 변경과 애니메이션 실행 npc.IsReload = true; npc.AniCtrl.ReloadAni(); _audio.volume = GameManager.INSTANCE.volume.sfx * 0.7f; _audio.PlayOneShot(_sfx[1]); CurBullet = mag; yield return(new WaitForSeconds(3f)); //재장전 상태 종료 npc.IsReload = false; }
public void Fire(NpcCtrl npc) { if (Time.time >= fireTime) { if (CurBullet > 0) { //사격 애니메이션 실행 npc.AniCtrl.FireAni(); CurBullet--; //탄 감소 fireTime = Time.time + fireRate + Random.Range(0.1f, 0.3f); _audio.volume = GameManager.INSTANCE.volume.sfx; _audio.PlayOneShot(_sfx[0]); muzzlePar.Play(); //적 타격 데미지 RaycastHit hit; int layerMask = 1 << 8; layerMask = ~layerMask; if (Physics.Raycast(firePos.position, firePos.forward, out hit, Mathf.Infinity, layerMask)) { Debug.DrawLine(firePos.position, hit.point, Color.red); float dmg = Random.Range(minDmg, maxDmg); if (hit.transform.GetComponent <HitDmg>()) { if (!hit.transform.GetComponent <HitDmg>().IsHeadDmg) { hit.transform.GetComponent <HitDmg>().HitDamage(dmg); } if (hit.transform.GetComponent <HitDmg>().IsHeadDmg) { hit.transform.GetComponent <HitDmg>().HeadDamage(dmg); } } } } } }
public override void ReceivePacket(Packet packet) { //Npc控制不需要在服务器进行转发给所有的客户端 if (packet == null) { return; } NpcCtrl response = new NpcCtrl(packet.m_data); //站台索引 UInt16 stationIndex = response.m_stationIndex; //0上行,1下行 byte upOrDownFlag = response.m_upOrDownFlag; //0上车,1下车 byte statusFlag = response.m_statusFlag; UnityEngine.Debug.Log("接收到NpcCtrl消息."); //该消息控制屏蔽门状态,因为屏蔽门状态决定了Npc行为 StationModule module = (StationModule)SingletonMgr.ModuleMgr.GetModule(StringMgr.StationModuleName); PingBiMenMgr mgr = (PingBiMenMgr)module.GetDeviceMgr(stationIndex, DeviceType.PingBiMen); if (upOrDownFlag == 0) { //上行 mgr.ShangXingPingBiMenIsOpen = true; if (statusFlag == 0) { //上车 Debug.Log("Npc上行上车..."); for (int i = 0; i < mgr.ShangXingPingBiMenList.Count; ++i) { ((PingBiMenDevice)mgr.ShangXingPingBiMenList[i]).CanUp = true; } } else if (statusFlag == 1) { //下车 Debug.Log("Npc上行下车..."); for (int i = 0; i < mgr.ShangXingPingBiMenList.Count; ++i) { ((PingBiMenDevice)mgr.ShangXingPingBiMenList[i]).CanDown = true; } } } else if (upOrDownFlag == 1) { //下行 mgr.XiaXingPingBiMenIsOpen = true; if (statusFlag == 0) { //上车 Debug.Log("Npc下行上车..."); for (int i = 0; i < mgr.XiaXingPingBiMenList.Count; ++i) { ((PingBiMenDevice)mgr.XiaXingPingBiMenList[i]).CanUp = true; } } else if (statusFlag == 1) { //下车 Debug.Log("Npc下行下车..."); for (int i = 0; i < mgr.XiaXingPingBiMenList.Count; ++i) { ((PingBiMenDevice)mgr.XiaXingPingBiMenList[i]).CanDown = true; } } } }