private IEnumerator Shoot() { if (!frozen && isTracking) { GameObject spawnedBullet = Instantiate(bullet) as GameObject; spawnedBullet.transform.position = shootBox.transform.position; Rigidbody bulletBody = spawnedBullet.GetComponent <Rigidbody>(); spawnedBullet.GetComponent <DimondProjectile>().parent = this.gameObject; position2 = player.transform.position; predictedPosition = (position2 - position1) * predicitonAdjusmentIncrease; float totalChange = Mathf.Abs(predictedPosition.x) + Mathf.Abs(predictedPosition.y) + Mathf.Abs(predictedPosition.z); totalChange = Mathf.Clamp(totalChange, 0f, 15f); predictedPosition *= totalChange / positionPredictionValue; minimalDistanceToAffectSpeed = Vector3.Distance(bulletBody.transform.position, player.transform.position) < 10f ? 2f : 1f; //scales the speed so up close it is still fast and far away it is about the same speed spawnedBullet.transform.LookAt(player.transform.position + (predictedPosition / minimalDistanceToAffectSpeed)); //if player is close, adjust look more (* 2), if its far adjust look less (* 1) bulletBody.velocity = (spawnedBullet.transform.forward * bulletSpeed * (Vector3.Distance(bulletBody.transform.position, player.transform.position) / distancePredictionValue) * minimalDistanceToAffectSpeed); //it just works Shiftable projectileTimeZone = bullet.GetComponent <Shiftable>(); projectileTimeZone.timeZone = GetComponent <Shiftable>().timeZone; spawnedBullet.GetComponent <DimondProjectile>().particleHolder = particleHolder; yield return(new WaitForSeconds(durationBetweenShotsInSeconds)); StartCoroutine(Shoot()); } else { yield return(new WaitForSeconds(durationBetweenShotsInSeconds)); StartCoroutine(Shoot()); } }
private IEnumerator Shoot() { if (!frozen && isTracking) { d20Audio.PlayD20Sound(1); for (int i = 0; i < shootBoxes.Length; i++) { GameObject bullet = Instantiate(projectile); bullet.transform.position = shootBoxes[i].transform.position; Rigidbody rbody = bullet.GetComponent <Rigidbody>(); bullet.transform.LookAt(player.transform); rbody.velocity = shootBoxes[i].transform.forward.normalized * bulletSpeed; D20Projectile projectileScript = bullet.GetComponent <D20Projectile>(); projectileScript.parent = gameObject; Shiftable projectileTimeZone = bullet.GetComponent <Shiftable>(); projectileTimeZone.timeZone = GetComponent <Shiftable>().timeZone; } yield return(new WaitForSeconds(durationBetweenShotsInSeconds)); StartCoroutine(Shoot()); } else { yield return(new WaitForSeconds(durationBetweenShotsInSeconds)); StartCoroutine(Shoot()); } }
void Awake() { _shiftable = GetComponent<Shiftable>(); foreach (var ps in ShiftParticleSystems) { ps.Stop(); } }
private void Awake() { _shiftable = GetComponent<Shiftable>(); _rotateSpeed = Random.insideUnitSphere * RotateSpeed; _destructor = GetComponent<SelfDestructor>(); _lifeTimeCooldown = Random.Range(MinLifetime, MaxLifetime); _fadeCooldown = FadeTime; _collectibleTracker = GetComponent<CollectibleTracker>(); }
private void Switch(Shiftable sender, Vector3 delta) { foreach (var onComponent in SwitchOn) { onComponent.enabled = PlayerController.Current.InPlayerActiveCells(_shiftable.UniverseCellIndex); } foreach (var offComponent in SwitchOff) { offComponent.enabled = !PlayerController.Current.InPlayerActiveCells(_shiftable.UniverseCellIndex); } }
void Awake() { _naturalScale = transform.localScale.x; _finalDestination = Universe.Current.GetUniversePosition(transform.position); _warpPos = transform.position - (transform.forward * Distance); _cooldown = Timeout; _shiftable = GetComponent<Shiftable>(); //_rigidBody = GetComponent<Rigidbody>(); //_rigidBody.isKinematic = true; }
private bool InRange(Shiftable sender) { _universeCellIndex = Universe.Current.ViewPort.Shiftable.UniverseCellIndex; var dX = sender.UniverseCellIndex.X - _universeCellIndex.X; if (dX >= -_cellRadius && dX <= _cellRadius) { var dY = sender.UniverseCellIndex.Y - _universeCellIndex.Y; if (dY >= -_cellRadius && dY <= _cellRadius) { var dZ = sender.UniverseCellIndex.Z - _universeCellIndex.Z; if (dZ >= -_cellRadius && dZ <= _cellRadius) { return true; } } } return false; }
public virtual void Awake() { if (UniverseEvents == null) { UniverseEvents = new List<UniverseEvent>(); } Shiftable = GetComponent<Shiftable>(); Shiftable.OnShift += Shiftable_OnShift; _triggerRadiusSquared = TriggerRadius*TriggerRadius; _trackerRadiusSquared = TrackerRadius*TrackerRadius; UniverseEvents.Add(this); _cellRadius = Mathf.CeilToInt(TriggerRadius/Universe.Current.CellSize); _universeCellIndex = Universe.Current.ViewPort.Shiftable.UniverseCellIndex; }
void Awake() { _shiftable = GetComponent<Shiftable>(); if (_shiftable != null) { _shiftable.OnShift += _shiftable_OnShift; } // Creating prefab var particlePrefab = new GameObject(); particlePrefab.transform.SetParent(transform); particlePrefab.transform.position = transform.position; var lineRender = particlePrefab.AddComponent<LineRenderer>(); lineRender.useWorldSpace = false; particlePrefab.hideFlags = HideFlags.HideInHierarchy; // Create particle instances _particles = new List<LineDustParticle>(); for (int i = 0; i < ParticleCount; i++) { var newParticle = Instantiate(particlePrefab); newParticle.transform.position = transform.position + Random.insideUnitSphere * Radius; newParticle.transform.forward = Velocity.normalized; newParticle.transform.SetParent(transform); var lineRenderer = newParticle.GetComponent<LineRenderer>(); var linePositions = new List<Vector3>(); linePositions.Add(Vector3.zero); linePositions.Add(Velocity * ParticleLength); lineRenderer.SetPositions(linePositions.ToArray()); lineRenderer.material = ParticleMaterial; lineRenderer.SetWidth(ParticleWidth, ParticleWidth); newParticle.hideFlags = HideFlags.None; _particles.Add(new LineDustParticle { IsActive = true, Object = newParticle, LineRenderer = lineRenderer }); } Destroy(lineRender); }
private void Shift(Shiftable sender, Vector3 delta) { if (_lastPositions != null) { for (var i = 0; i < _lastPositions.Count; i++) { _lastPositions[i] -= delta; _lineRenderer.SetPosition(i, _lastPositions[i]); } } }
public void SpawnVehicle(Vehicle vehiclePrefab, Shiftable spawner) { SpawnVehicle(vehiclePrefab, spawner.UniversePosition, spawner.transform.rotation); }
private void Awake() { _shiftable = GetComponent<Shiftable>(); _state = MapPinState.Active; }
private void _shiftable_OnShift(Shiftable sender, Vector3 delta) { _lastPos -= delta; }
private void Shift(Shiftable sender, Vector3 delta) { if (IsLive) UpdateLineRenderer(); }
private void Awake() { _shiftable = GetComponent<Shiftable>(); foreach (var shootPoint in PrimaryShootPoints) { if (PrimaryWeaponPrefab != null) shootPoint.Initialize(PrimaryWeaponPrefab.MuzzlePrefab); } foreach (var shootPoint in SecondaryShootPoints) { if (SecondaryWeaponPrefab != null) shootPoint.Initialize(SecondaryWeaponPrefab.MuzzlePrefab); } _velocityReference = new VelocityReference(_velocity); _killable = GetComponent<Killable>(); _killable.OnDamage += VehicleDamage; _killable.OnDie += VehicleDie; _allowBoost = true; _targetRotation = transform.rotation; _environmentMask = LayerMask.GetMask("Environment"); }
private void Shiftable_OnShift(Shiftable sender, Vector3 delta) { var thisEvent = sender.GetComponent<UniverseEvent>(); var enable = false; if (!thisEvent.HasBeenTriggered) { enable = InRange(sender); } thisEvent.enabled = enable; }
private void Awake() { _shiftable = GetComponent<Shiftable>(); _shiftable.OnShift += Shift; if (Tracer != null) { Tracer.useWorldSpace = true; } _mask = ~LayerMask.GetMask("Distant", "Universe Background", "Player", "Environment"); }
private void Awake() { _shiftable = GetComponent<Shiftable>(); _shiftable.OnShift += Switch; }
private void Awake() { _shiftable = GetComponent<Shiftable>(); _mask = ~LayerMask.GetMask("Distant", "Universe Background", "Environment"); _detectableMask = LayerMask.GetMask("Detectable"); }
private void Awake() { _shiftable = GetComponent<Shiftable>(); _shiftable.OnShift += Shift; _lineRenderer = GetComponent<LineRenderer>(); _length = MissileLength; _hitMask = ~LayerMask.GetMask("Distant", "Universe Background", "Environment"); }
private void Shiftable_OnCellIndexChange(Shiftable sender, CellIndex delta) { Shift(delta); }
public void WarpTo(Shiftable spawner) { WarpTo(spawner.UniversePosition); }
private void Awake() { _screenCentre = new Vector3(0.5f * Screen.width, 0.5f * Screen.height); var boundaryPadding = 20f; _screenBounds = new Rect(boundaryPadding, boundaryPadding, Screen.width - 2f * boundaryPadding, Screen.height - 2f * boundaryPadding); _shiftable = GetComponent<Shiftable>(); }
private void Shift(Shiftable sender, Vector3 delta) { if (IsLive) { _shootFrom -= delta; _hitPosition -= delta; UpdateLineRenderer(); } }
private void Awake() { _shiftable = GetComponent<Shiftable>(); SetFree(false); }