void Update() { if (!MainClass.isGameRunning) { return; } Rigidbody2D shipRB = ship.GetComponent <Rigidbody2D>(); float velocity = (int)(shipRB.velocity.magnitude * 100.0f); velocityText.text = "" + velocity; ShipControll shipControll = ship.GetComponent <ShipControll>(); LaserGun laserGun = ship.GetComponent <LaserGun>(); setLight(MainEnginesLight, shipControll.engineOn); setLight(ControlEnginesLight, shipControll.controlEnginesOn); setLight(LaserLight, laserGun.isShoting); }
void Update() { if (focused) { if (ShipControll.getRef().SelectedShip != null) { camFocus = ShipControll.getRef().SelectedShip.transform.position; } } if (Input.GetKey(KeyCode.W)) { translateCam(Vector3.forward); } else if (Input.GetKey(KeyCode.S)) { translateCam(Vector3.back); } if (Input.GetKey(KeyCode.A)) { translateCam(Vector3.left); } else if (Input.GetKey(KeyCode.D)) { translateCam(Vector3.right); } if (Input.GetKey(KeyCode.Q)) { translateCam(Vector3.down); } else if (Input.GetKey(KeyCode.E)) { translateCam(Vector3.up); } if (Input.GetAxis("Mouse ScrollWheel") > 0) { zoomCam(-camZoomRate); } else if (Input.GetAxis("Mouse ScrollWheel") < 0) { zoomCam(camZoomRate); } this.transform.parent.parent.position = camFocus; if (Input.GetMouseButton(1)) { if (axes == RotationAxes.MouseXAndY) { this.transform.parent.Rotate(Input.GetAxis("Mouse Y") * -sensitivityY * Time.deltaTime, 0, 0); this.transform.parent.parent.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX * Time.deltaTime, 0); } else if (axes == RotationAxes.MouseX) { this.transform.parent.parent.Rotate(0, Input.GetAxis("Mouse X") * sensitivityX * Time.deltaTime, 0); } else { this.transform.parent.Rotate(Input.GetAxis("Mouse Y") * sensitivityY * Time.deltaTime, 0, 0); } Screen.lockCursor = true; } else if (Input.GetMouseButtonUp(1)) { Screen.lockCursor = false; } }
// Use this for initialization void Start() { reference = this; }