private void Awake() { // Randomize delay before firing _cooldownTimer = UnityEngine.Random.Range(2.5f, 1.0f); _playerShip = FindObjectOfType <PlayerShipBehavior>(); _parentCenter = GenericFunctions.GetClosestCircle(transform.position); }
private void Awake() { _eventHandler = FindObjectOfType <GameEventHandler>(); _playerObject = GameObject.FindWithTag("Player"); _genericFunctions = FindObjectOfType <GenericFunctions>(); _rb = GetComponent <Rigidbody2D>(); _parentBubbleCenter = GenericFunctions.GetClosestCircle(transform.position); }
private void Start() { Vector3 position = transform.position; _closestCenter = GenericFunctions.GetClosestCircle(position); _closestEnemy = GenericFunctions.FindClosestEnemy(position); _rb = GetComponent <Rigidbody2D>(); }
private void Update() { Vector3 shipPosition = transform.position; Vector3 newShipLocation = GenericFunctions.GetClosestCircle(shipPosition); shipIsWithinEngagementRange = Vector3.Distance(shipLocation, shipPosition) < 13.5; // Only update shipLocation if it has changed if (newShipLocation != previousShipLocation) { previousShipLocation = shipLocation; shipLocation = newShipLocation; _architect.GenerateWorld(shipLocation); _generateMap.UpdateMap(shipLocation); } // Rotate Vector3 mousePos = _cam.ScreenToWorldPoint(Input.mousePosition); Vector3 perpendicular = Vector3.Cross(shipPosition - mousePos, Vector3.forward); transform.rotation = Quaternion.LookRotation(Vector3.forward, perpendicular); // Move Vector3 impulse = new Vector3(Input.GetAxis("Horizontal") * movementForce, Input.GetAxis("Vertical") * movementForce, 0); _rb.AddForce(impulse, ForceMode2D.Impulse); if (Vector3.Distance(shipLocation, shipPosition) > 12f) { // Add force towards the center on edges Vector3 direction = shipLocation - shipPosition; _rb.AddForce(direction * (movementForce / 15.5f), ForceMode2D.Impulse); } }
// Start is called before the first frame update void Awake() { _rb = gameObject.GetComponent <Rigidbody2D>(); _parentCenter = GenericFunctions.GetClosestCircle(transform.position); }
// Start is called before the first frame update void Awake() { _playerShip = FindObjectOfType <PlayerShipBehavior>(); _parentCenter = GenericFunctions.GetClosestCircle(transform.position); }
private void Awake() { _closestCenter = GenericFunctions.GetClosestCircle(transform.position); }