IEnumerator Reload(GunSetting gs) { yield return(new WaitForSeconds(3.0f)); gs.clipcounter = 0; gs.startReload = false; //сообщение о перезарядке }
public void Init(float firingRate, NetData User) { this.firingInterval = new FixedNumber(1 / firingRate); lastTime = FixedNumber.Zero; gunSetting = DataManager.Instance.gunManager.gun; this.user = User; timer = FixedNumber.Zero; }
void ShootRealisation(GunSetting gs) { if (gs.clipcounter >= gs.clip && gs.canReload || gs.aiming && aimingTransform == null) { return; } // --- 2 BSP REALISATION --- if (gs.twoBsp) { if (bsp == gs.secondBsp) { bsp = null; } if (bsp == null) { bsp = gs.firstBsp; } else { bsp = gs.secondBsp; } } else { bsp = gs.firstBsp; } // --- END 2 BSP R-N --- shootInterval = gs.interval; //Shoot(gs.shell, bsp); /// --- SHOT --- Transform bul = (Transform)Instantiate(gs.shell, bsp.position, bsp.rotation); bul.name = thisName; BulletsParent bp = bul.gameObject.GetComponent <BulletsParent>(); bp.Shellsetting(gs.shellSpeed, gs.shellDamage); if (bp.isAiming()) { bp.GetTarget(aimingTransform.gameObject); } gs.clipcounter++; shootinterTimer = 0f; if (!gs.startReload && gs.canReload && gs.clipcounter >= gs.clip) { StartCoroutine(Reload(gs)); gs.startReload = true; } // --- THIS IS SECOND REALISATION OF SHOOTING --- /* if(shootinterTimer == 0f) * { * if(bsp == null) bsp = bulletSpawnPoint; * else bsp = bulletSpawnPointTwo; * * Shoot(bullet, bsp); * } * * shootinterTimer += Time.deltaTime; * * if(shootInterval < shootinterTimer) * { * if(bsp == bulletSpawnPointTwo) * { * bsp = null; * } * shootinterTimer = 0f; * }*/ }