예제 #1
0
    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());
        }
    }
예제 #2
0
    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());
        }
    }
예제 #3
0
 void Awake()
 {
     _shiftable = GetComponent<Shiftable>();
     foreach (var ps in ShiftParticleSystems)
     {
         ps.Stop();
     }
 }
예제 #4
0
    private void Awake()
    {
        _shiftable = GetComponent<Shiftable>();
        _rotateSpeed = Random.insideUnitSphere * RotateSpeed;
        _destructor = GetComponent<SelfDestructor>();
        _lifeTimeCooldown = Random.Range(MinLifetime, MaxLifetime);

        _fadeCooldown = FadeTime;
        _collectibleTracker = GetComponent<CollectibleTracker>();
    }
예제 #5
0
 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);
     }
 }
예제 #6
0
    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;
    }
예제 #7
0
 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;
 }
예제 #8
0
    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;
    }
예제 #9
0
    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);
    }
예제 #10
0
 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]);
         }
     }
 }
예제 #11
0
 public void SpawnVehicle(Vehicle vehiclePrefab, Shiftable spawner)
 {
     SpawnVehicle(vehiclePrefab, spawner.UniversePosition, spawner.transform.rotation);
 }
예제 #12
0
파일: MapPin.cs 프로젝트: talford2/SpaceX
 private void Awake()
 {
     _shiftable = GetComponent<Shiftable>();
     _state = MapPinState.Active;
 }
예제 #13
0
 private void _shiftable_OnShift(Shiftable sender, Vector3 delta)
 {
     _lastPos -= delta;
 }
예제 #14
0
파일: Beam.cs 프로젝트: talford2/SpaceX
 private void Shift(Shiftable sender, Vector3 delta)
 {
     if (IsLive)
         UpdateLineRenderer();
 }
예제 #15
0
파일: Vehicle.cs 프로젝트: talford2/SpaceX
    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");
    }
예제 #16
0
 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;
 }
예제 #17
0
파일: Laser.cs 프로젝트: talford2/SpaceX
    private void Awake()
    {
        _shiftable = GetComponent<Shiftable>();
        _shiftable.OnShift += Shift;
        if (Tracer != null)
        {
            Tracer.useWorldSpace = true;
        }

        _mask = ~LayerMask.GetMask("Distant", "Universe Background", "Player", "Environment");
    }
예제 #18
0
 private void Awake()
 {
     _shiftable = GetComponent<Shiftable>();
     _shiftable.OnShift += Switch;
 }
예제 #19
0
파일: FlakBomb.cs 프로젝트: talford2/SpaceX
 private void Awake()
 {
     _shiftable = GetComponent<Shiftable>();
     _mask = ~LayerMask.GetMask("Distant", "Universe Background", "Environment");
     _detectableMask = LayerMask.GetMask("Detectable");
 }
예제 #20
0
파일: Beam.cs 프로젝트: talford2/SpaceX
 private void Awake()
 {
     _shiftable = GetComponent<Shiftable>();
     _shiftable.OnShift += Shift;
     _lineRenderer = GetComponent<LineRenderer>();
     _length = MissileLength;
     _hitMask = ~LayerMask.GetMask("Distant", "Universe Background", "Environment");
 }
예제 #21
0
파일: Universe.cs 프로젝트: talford2/SpaceX
 private void Shiftable_OnCellIndexChange(Shiftable sender, CellIndex delta)
 {
     Shift(delta);
 }
예제 #22
0
파일: Universe.cs 프로젝트: talford2/SpaceX
 public void WarpTo(Shiftable spawner)
 {
     WarpTo(spawner.UniversePosition);
 }
예제 #23
0
 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>();
 }
예제 #24
0
파일: Laser.cs 프로젝트: talford2/SpaceX
 private void Shift(Shiftable sender, Vector3 delta)
 {
     if (IsLive)
     {
         _shootFrom -= delta;
         _hitPosition -= delta;
         UpdateLineRenderer();
     }
 }
예제 #25
0
 private void Awake()
 {
     _shiftable = GetComponent<Shiftable>();
     SetFree(false);
 }