public void Shoot() { if (!CanShoot()) { return; } _weapon.CurrentClipSize--; _nextTimetoFire = 0f; Vector3 targetDirection; bool result = Physics.Raycast(_cameraTransform.position, _cameraTransform.forward, out RaycastHit hit); targetDirection = result ? hit.point - _weapon.ShootPosition.position : _cameraTransform.forward; ProjectileStandard projectileClone = _weapon.RecycleProjectileWrapper.CreateOrRecoverObject(_weapon.ProjectilePrefab.gameObject); projectileClone.EnableRecyleRoutine(targetDirection, _weapon); _weapon.ShootAudio.PlayOneShot(_weapon.ShootAudio.clip); _weapon.MuzzleFlashEffect.Play(); if (_weapon.ProjectileEjectionEffect != null) { _weapon.ProjectileEjectionEffect.Play(); } OnWeaponFired?.Raise(_weapon); }
private void SendSpawnBullet(ProjectileStandard otherPlayerWeapon) { var protocol = new Protocol(); var buffer = protocol.Serialize((byte)PacketId.SpawnBulletEvent, _myPlayerId); var packet = default(Packet); packet.Create(buffer); _peer.Send(channelID, ref packet); }
public override void Tick() { base.Tick(); //Do projectile for static tower if (TowerType == ETower.StaticCannon) { ProjectileStandard projectile = (ProjectileStandard)Instantiate(_standardProjectile, _spawn.transform.position, _spawn.transform.rotation); projectile.Type = ETower.StaticCannon; projectile.OnSpawnMove(4); } }
void OnShoot() { // Apply the parameters based on projectile charge ProjectileStandard proj = GetComponent <ProjectileStandard>(); if (proj) { proj.damage = damage.GetValueFromRatio(m_ProjectileBase.initialCharge); proj.radius = radius.GetValueFromRatio(m_ProjectileBase.initialCharge); proj.speed = speed.GetValueFromRatio(m_ProjectileBase.initialCharge); proj.gravityDownAcceleration = gravityDownAcceleration.GetValueFromRatio(m_ProjectileBase.initialCharge); } }
private void OnTriggerStay(Collider other) { if (!_isDelaying) { switch (TowerType) { case ETower.StandardCannon: { Vector3 correctTarget = new Vector3(FollowClosestPlayer().transform.position.x, _standardTop.transform.position.y, FollowClosestPlayer().transform.position.z); _standardTop.transform.LookAt(correctTarget); ProjectileStandard sProjectile = (ProjectileStandard)Instantiate(_standardProjectile, _spawn.transform.position, _spawn.transform.rotation); sProjectile.Type = ETower.StandardCannon; sProjectile.OnSpawnMove(1); _isDelaying = true; StartCoroutine(WaitSeconds(1)); break; } case ETower.Reverse: { Vector3 correctTarget = new Vector3(FollowClosestPlayer().transform.position.x, _reverseTop.transform.position.y, FollowClosestPlayer().transform.position.z); _reverseTop.transform.LookAt(correctTarget); ProjectileReverse rProjectile = (ProjectileReverse)Instantiate(_reverseProjectile, _spawn.transform.position, _spawn.transform.rotation); rProjectile.Type = ETower.Reverse; rProjectile.OnSpawnMove(0); _isDelaying = true; StartCoroutine(WaitSeconds(1f)); break; } default: { break; } } } }
public LifeTimeProjectile(ProjectileStandard projectileStandard, float range) { ProjectileStandard = projectileStandard; ReamingLifeTime = range; }
public void AddItemToDestruction(ProjectileStandard projectileStandard) { _projectiles.Add(new LifeTimeProjectile(projectileStandard, projectileStandard.Range)); }