public void Update() { if (Input.GetKey(KeyCode.Space)) { PlayShootdownAnim((Vector2)transform.position + (Random.insideUnitCircle * Range)); } // Update lines and draw them. for (int i = 0; i < lines.Count; i++) { Color c = Color.Lerp(Start, End, times[i] / LineTime); CameraLines.DrawLine(lines[i].Key, lines[i].Value, c); times[i] += Time.deltaTime; if (times[i] >= LineTime) { lines.RemoveAt(i); times.RemoveAt(i); i--; } } Collider.radius = Range; float x = (Range / 3f); Field.transform.localScale = new Vector3(x, x, 1f); }
public void Update() { ClampValues(); if (isClient && Player.Local != null) { // If we are active client... if (Ship.Unit.Faction == Player.Local.Faction) { // If we control/own this ship... if (Ship.Unit.IsSelected) { // If currently selected by user... // Then draw a cross at the target position. // EDIT: Was too distacting, and line has the same purpose. // TargetCross.DrawAt(TargetPos); // And a line from the ship to the cross. CameraLines.DrawLine(transform.position, TargetPos, Color.green); } } } if (!isServer) { return; } // All server only. // If the ship part(s) is/are destroyed, then the engine stops! if (IsPhysicallyBroken()) { if (Active) { Deactivate(); } } // If active... if (!Active) { return; } // If not in deadzone (reached target)... float dst = GetDistanceToTarget(); if (IsInDeadzone(dst)) { ShipLocomotion.CurrentTurn = 0; ShipLocomotion.CurrentThrottle = 0; return; } // Adjust throttle based on distance to target. ShipLocomotion.CurrentThrottle = GetThrottle(dst); // Adjust turn speed based on angle to target. ShipLocomotion.CurrentTurn = GetTurn(GetCurrentAngle(), GetAngleToTarget()); AngleToTarget = GetAngleToTarget(); CurrentAngle = GetCurrentAngle(); }
public void OnDestroy() { Instance = null; }
public void Awake() { Instance = this; }