private void Start() { shipRb = GetComponent <Rigidbody2D>(); shipLanding = FindObjectOfType <ShipLanding>(); satelliteController = FindObjectOfType <SatelliteController>(); gameManager = FindObjectOfType <GameManager>(); volumeManager = FindObjectOfType <VolumeManager>(); throttleUI.SetMaxValue(maxThrottle); remainingFuel = maxFuel; previousFuel = remainingFuel; }
// Start is called before the first frame update void Start() { light_sensors = new List <LightSensor>(4) { sensor_front_top, sensor_front_bot, sensor_back_top, sensor_back_bot }; calculated_solar_dir = new Vector3(); //pid = new PIDController(0.1f, 0.0001f, 0.01f); pid = new PIDController(0.1f, 0.015f, 0.001f); //pid = new PIDController(1f, 0, 0); satController = FindObjectOfType <SatelliteController>(); }
// This function will toggle the satellite of type sat to be created or destroyed in preview mode void Preview(GameObject sat) { if (current_sat == null) // We are creating a new Satellite { current_sat = Instantiate(sat, new Vector3(0, 0, 0), Quaternion.identity); current_sat_controller = current_sat.GetComponent <SatelliteController>(); UpdatePanel(); info_panel.SetActive(true); } else if (current_sat.GetComponent <SatelliteController>().sat_name == sat.GetComponent <SatelliteController>().sat_name) // We are destroying current Satellite { Destroy(current_sat); info_panel.SetActive(false); } else // We are creating a new Satellite and destroying the old one { Destroy(current_sat); current_sat = Instantiate(sat, new Vector3(0, 0, 0), Quaternion.identity); current_sat_controller = current_sat.GetComponent <SatelliteController>(); UpdatePanel(); } }
void OnCollisionEnter(Collision col) { if (col.gameObject.tag == "Satellite") { GameObject sat = col.collider.gameObject; SatelliteController SScript = (SatelliteController)sat.gameObject.GetComponent <SatelliteController> (); SScript.HandleCollision(transform); Destroy(particle); } else if (col.gameObject.tag == "EndPoint") { GameObject end = col.collider.gameObject; EndPointController EPScript = (EndPointController)end.gameObject.GetComponent <EndPointController> (); EPScript.HandleCollision(transform); Destroy(particle); } else if (col.gameObject.tag == "Particle") { Physics.IgnoreCollision(col.gameObject.GetComponent <Collider> (), GetComponent <Collider> ()); } else if (col.gameObject.tag == "Wall") { Destroy(particle); } else if (col.gameObject.tag == "Block") { GameObject ship = col.collider.gameObject; HumanShipController HScript = (HumanShipController)ship.gameObject.GetComponent <HumanShipController>(); HScript.HandleCollision(); Destroy(particle); } else if (col.gameObject.tag == "Asteroid") { Destroy(particle); } }
void Start() { shipController = GetComponent<SpaceshipController> (); satelliteController = GetComponent<SatelliteController> (); currentHealth = maximumHealth; shield = maxShield; // healthBarLength = Screen.width / 6; if (base.isLocalPlayer) { HUDCanvasManager.singleton.setHealthMaxValue (maximumHealth); HUDCanvasManager.singleton.updateHealth (currentHealth); HUDCanvasManager.singleton.updateShield((int)(shield / maxShield) * 100); HUDCanvasManager.singleton.setMaxCooldown(maxShield); HUDCanvasManager.singleton.setCooldown(shield); //deathAnimation.GetComponent<ParticleSystem>().Stop(); } if (NetworkClient.active) { EventWeaponHit += Pulse; } }
private void Update() { _moveAxis = _player.GetAxis2D("MoveX", "MoveY"); _hasGrabbableObjectInRange = ObjectGrabber.IsTouching; AnimatorDriver.Speed = Mathf.Abs(_horizontalVelocity) / MaxHorizontalVelocity; if (_horizontalVelocity < -0.1f) { AnimatorDriver.transform.localScale = new Vector3(1, 1, -1); } else if (_horizontalVelocity > 0.1f) { AnimatorDriver.transform.localScale = new Vector3(1, 1, 1); } if (_draggingObject != null) { if (_player.GetButtonUp("Grab") || Vector3.Distance(_draggingObject.transform.position, transform.position) > 3) { _draggingObject.Release(); _draggingObject = null; } return; } else { if (_hasGrabbableObjectInRange && _player.GetButton("Grab")) { foreach (Collider col in ObjectGrabber._touchingColliders) { //TODO: These should use inheritence so we only have to look for 1 type! SatelliteController satelliteController = col.GetComponent <SatelliteController>(); if (satelliteController != null) { satelliteController.Move(_moveAxis); _moveAxis = Vector2.zero; break; } MoverController moverController = col.GetComponent <MoverController>(); if (moverController != null) { moverController.Move(_moveAxis); _moveAxis = Vector2.zero; break; } Draggable draggableObj = col.GetComponent <Draggable>(); if (draggableObj != null && !draggableObj.IsBeingDragged) { _draggingObject = draggableObj; _draggingObject.Grab(_rigidbody); break; } } } } if (_player.GetButtonDown("Jump")) { if (CanJump) { _jumping = true; _jumpFrames = 3; _rigidbody.velocity = new Vector3(_rigidbody.velocity.x, JumpVelocity, _rigidbody.velocity.z); } else if (_isTouchingWall) { foreach (Collider col in WallHugger._touchingColliders) { Vector3 touchingPosition = col.ClosestPointOnBounds(transform.position); Vector3 normal = touchingPosition - transform.position; if (Mathf.Abs(normal.x) > Mathf.Abs(normal.y)) { _jumping = true; _jumpFrames = 3; _horizontalVelocity = -Mathf.Sign(normal.x) * WallJumpVelocity; _rigidbody.velocity = new Vector3(_horizontalVelocity, JumpVelocity, _rigidbody.velocity.z); break; } } } } if (_jumping && _player.GetButtonUp("Jump")) { _jumping = false; _jumpFrames = 0; _rigidbody.velocity = new Vector3(_rigidbody.velocity.x, Mathf.Min(_rigidbody.velocity.y, 0), _rigidbody.velocity.z); } }