void Start() { cannon = GetComponent <CannonController>(); motor = GetComponent <ShipMotor>(); ship = GetComponent <Ship>(); ship.OnDead += OnDead; }
void Start() { motor = GetComponent <ShipMotor>(); motor.OnStartBoost += OnStartBoost; initialTrailColor = thrusterTrail.startColor; }
private void ChaseTarget(ShipStateController controller) { ShipMotor shipMotor = controller.GetMotor(); Rigidbody ship = controller.GetRigidbody(); Rigidbody target = controller.GetTarget(); if (target == null) { return; } Steer(shipMotor, ship, target); AdjustThrottle(); Vector3 toTarget = target.position - ship.position; float angle = Vector3.Angle(ship.transform.forward, toTarget); Vector3 velocityDifference = ship.velocity - target.velocity; //Check throttle //Check angle from player //Check velocity differences //Adjust throttle //steer based on stats/throttle }
private void Start() { motor = GetComponent<ShipMotor>(); cannon = GetComponent<CannonController>(); lockCursor(); }
private void Start() { motor = GetComponent <ShipMotor>(); cannon = GetComponent <CannonController>(); lockCursor(); }
void Start() { motor = GetComponent<ShipMotor>(); motor.OnStartBoost += OnStartBoost; initialTrailColor = thrusterTrail.startColor; }
void Awake() { motor = GetComponent <ShipMotor>(); //* motor.MaxSpeed = motor.baseMaxSpeed; //bullets = new List<PlayerBullet>(); if (!gameCamera && GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>()) { gameCamera = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera>(); } if (!collider && GetComponent <CircleCollider2D>()) { collider = GetComponent <CircleCollider2D>(); } if (!bmManager && GetComponent <BulletModifierManager>()) { bmManager = GetComponent <BulletModifierManager>(); } if (!safeZoneOnRespawn && GetComponent <SafeZoneOnRespawn>()) { safeZoneOnRespawn = GetComponent <SafeZoneOnRespawn>(); } initalPosition = transform.position; }
void Start() { cannon = GetComponent<CannonController>(); motor = GetComponent<ShipMotor>(); ship = GetComponent<Ship>(); ship.OnDead += OnDead; }
void Update() { transform.position += direction.ToVector3() * Speed * Time.deltaTime; Ray ray = new Ray(transform.position, (transform.rotation * Vector3.up)); Debug.DrawRay(ray.origin, ray.direction, Color.red); RaycastHit2D[] hits = Physics2D.RaycastAll(ray.origin.ToVector2(), ray.direction.ToVector2(), 0.0f); foreach (RaycastHit2D hit in hits) { if (hit.collider.gameObject == this.gameObject) { continue; } Ship ship = hit.collider.gameObject.GetComponent <Ship>(); if (ship != null && ship.Team != Team) { ShipMotor motor = hit.collider.gameObject.GetComponent <ShipMotor>(); if (motor.Destroyed) { break; } motor.Damage(Team, Damage); if (!Piercing) { Destroy(this.gameObject); } } } }
protected override void Interact(ShipMotor shipMotor) { foreach (var asteroid in GameObject.FindObjectsOfType <Asteroid>()) { asteroid.StopForXTime(slow); } Destroy(gameObject); }
// Use this for initialization void Start() { ship_input = ship_settings.UseAi ? new AIInput() as IShipInput : new ControllerInput(); ship_motor = new ShipMotor(ship_input, transform, ship_settings); }
void OnTriggerEnter2D(Collider2D other) { ShipMotor shipMotor = other.gameObject.GetComponent <ShipMotor>(); if (shipMotor != null) { Interact(shipMotor); } }
void Start() { motor = GetComponent <ShipMotor>(); cam = Camera.main; if (cam == null) { Debug.Log("No Camera Found"); } }
void Start() { health = maxHealth; motor = GetComponent <ShipMotor>(); if (OnHealthChange != null) { OnHealthChange(health, 0); } }
void Start() { motor = ship.GetComponent <ShipMotor>(); canvas = GetComponent <Canvas>(); rectTransform = GetComponent <RectTransform>(); ship.OnHealthChange += OnHealthChange; ship.OnScoreChange += OnScoreChange; motor.OnBoostChange += OnBoostChange; SetScoreVisible(ship.GetScore()); }
void Start() { if (soundSystem == null) { this.enabled = false; return; } cannon = GetComponent<CannonController>(); motor = GetComponent<ShipMotor>(); ship = GetComponent<Ship>(); Bind(); shootSoundPriority = soundSystem.MinPriority(); boostSoundPriority = soundSystem.MaxPriority(); }
void Start() { if (soundSystem == null) { this.enabled = false; return; } cannon = GetComponent <CannonController>(); motor = GetComponent <ShipMotor>(); ship = GetComponent <Ship>(); Bind(); shootSoundPriority = soundSystem.MinPriority(); boostSoundPriority = soundSystem.MaxPriority(); }
void OnTriggerEnter2D(Collider2D hitInfo) { Debug.Log(hitInfo.name); if (armed) { ShipMotor ship = hitInfo.GetComponent <ShipMotor>(); if (ship != null) { ship.TakeDamage(damage); Instantiate(smokePrefab, transform.position, transform.rotation); Destroy(gameObject); } else { Instantiate(smokePrefab, transform.position, transform.rotation); Destroy(gameObject); } } }
void Start() { camera = GetComponent <Camera>(); curRollDamping = rollDamping; motor = ship.GetComponent <ShipMotor>(); motor.OnStartManeuver += OnStartManeuver; motor.OnStopManeuver += OnStopManeuver; motor.OnStartBoost += OnStartBoost; motor.OnStopBoost += OnStopBoost; ship.OnRespawn += OnRespawn; ship.OnHealthChange += OnHealthChange; normalFov = camera.fieldOfView; boostFov = normalFov * boostFovFactor; fovTarget = normalFov; shakeTimer = shakeTime; }
void Start() { camera = GetComponent<Camera>(); curRollDamping = rollDamping; motor = ship.GetComponent<ShipMotor>(); motor.OnStartManeuver += OnStartManeuver; motor.OnStopManeuver += OnStopManeuver; motor.OnStartBoost += OnStartBoost; motor.OnStopBoost += OnStopBoost; ship.OnRespawn += OnRespawn; ship.OnHealthChange += OnHealthChange; normalFov = camera.fieldOfView; boostFov = normalFov * boostFovFactor; fovTarget = normalFov; shakeTimer = shakeTime; }
void Start() { motor = GetComponent<ShipMotor>(); initialRotation = new Vector3(270.0f, 0.0f, 0.0f); }
void Awake() { shipMotor = GetComponent<ShipMotor>(); tiltJoystick = GetComponent<TiltJoystick>(); }
void Awake() { shipMotor = GetComponent <ShipMotor>(); tiltJoystick = GetComponent <TiltJoystick>(); }
void Start() { motor = ship.GetComponent<ShipMotor>(); canvas = GetComponent<Canvas>(); rectTransform = GetComponent<RectTransform>(); ship.OnHealthChange += OnHealthChange; ship.OnScoreChange += OnScoreChange; motor.OnBoostChange += OnBoostChange; SetScoreVisible(ship.GetScore()); }
void Start() { motor = GetComponent <ShipMotor>(); initialRotation = new Vector3(270.0f, 0.0f, 0.0f); }
void Update() { //Calculate Total Engine Force (Break down into engines later) float _xMov = Input.GetAxisRaw("Horizontal"); float _zMov = Input.GetAxisRaw("Vertical"); Vector2 _movVerticle = transform.up * _zMov; Vector2 _velocity = (_movVerticle).normalized * speed; // Debug.Log("Velocity : [" + _velocity[0] + ", " + _velocity[1] + "]"); //Apply movment motor.Move(_velocity); motor.Rot(-turnForce * _xMov); // gameObject.GetComponent<Rigidbody2D>().AddTorque(1.0f*Time.deltaTime); if (Input.GetButtonDown("Fire1")) { ShootMissile(); } if (Input.GetButtonDown("Fire2")) { StartCoroutine(ShootMachineGun()); } void ShootMissile() { if (whichBay) { whichBay = false; GameObject _missile = Instantiate(missilePrefab, firePointRight.position, firePointRight.rotation); _missile.GetComponent <Rigidbody2D>().velocity = gameObject.GetComponent <Rigidbody2D>().velocity; _missile.GetComponent <Rigidbody2D>().angularVelocity = gameObject.GetComponent <Rigidbody2D>().angularVelocity; _missile.GetComponent <Rigidbody2D>().AddForce(transform.right * MissileForce); } else { whichBay = true; GameObject _missile = Instantiate(missilePrefab, firePointLeft.position, firePointLeft.rotation); _missile.GetComponent <Rigidbody2D>().velocity = gameObject.GetComponent <Rigidbody2D>().velocity; _missile.GetComponent <Rigidbody2D>().angularVelocity = gameObject.GetComponent <Rigidbody2D>().angularVelocity; _missile.GetComponent <Rigidbody2D>().AddForce(-1.0f * transform.right * MissileForce); } } IEnumerator ShootMachineGun() { RaycastHit2D hitInfoL = Physics2D.Raycast(machinegunLeft.position + machinegunLeft.up, machinegunLeft.up); RaycastHit2D hitInfoR = Physics2D.Raycast(machinegunRight.position + machinegunRight.up, machinegunRight.up); if (hitInfoL) { ShipMotor ship = hitInfoL.transform.GetComponent <ShipMotor>(); if (ship != null) { ship.TakeDamage(damage); Instantiate(impactEffect, hitInfoL.point, Quaternion.identity); lineRendererL.SetPosition(0, machinegunLeft.position); lineRendererL.SetPosition(1, hitInfoL.point); } } else { lineRendererL.SetPosition(0, machinegunLeft.position); lineRendererL.SetPosition(1, machinegunLeft.position + machinegunLeft.up * 100); } if (hitInfoR) { ShipMotor ship = hitInfoR.transform.GetComponent <ShipMotor>(); if (ship != null) { ship.TakeDamage(damage); Instantiate(impactEffect, hitInfoR.point, Quaternion.identity); lineRendererR.SetPosition(0, machinegunRight.position); lineRendererR.SetPosition(1, hitInfoR.point); } } else { lineRendererR.SetPosition(0, machinegunRight.position); lineRendererR.SetPosition(1, machinegunRight.position + machinegunRight.up * 100); } lineRendererL.enabled = true; lineRendererR.enabled = true; yield return(0); lineRendererL.enabled = false; lineRendererR.enabled = false; } }
void Start() { colliders = player.GetComponents <Collider>(); motor = GetComponent <ShipMotor>(); ship = GetComponent <Ship>(); }
protected abstract void Interact(ShipMotor shipMotor);
void Update() { // If you want to disable input while you are using menues... no thanks // if (EventSystem.current.IsPointerOverGameObject()) // return; //Calculate Total Engine Force (Break down into engines later) float _xMov = Input.GetAxisRaw("Horizontal"); float _zMov = Input.GetAxisRaw("Vertical"); Vector2 _movVerticle = transform.up * _zMov; Vector2 _velocity = (_movVerticle).normalized * speed; // Debug.Log("Velocity : [" + _velocity[0] + ", " + _velocity[1] + "]"); //Apply movment motor.Move(_velocity); motor.Rot(-turnForce * _xMov); // gameObject.GetComponent<Rigidbody2D>().AddTorque(1.0f*Time.deltaTime); if (Input.GetMouseButtonDown(0)) { ShootMissile(); Vector3 mousePos = GetWorldPositionOnPlane(Input.mousePosition, 0f); Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y); RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero); // Debug.Log("MousePosition" + Input.mousePosition); // Debug.Log("MousePositionWorldPoint" + mousePos); if (hit.collider != null) { Debug.Log("We Hit" + hit.collider.name + " " + hit.point); } RemoveFocus(); } if (Input.GetMouseButtonDown(1)) { StartCoroutine(ShootMachineGun()); Vector3 mousePos = GetWorldPositionOnPlane(Input.mousePosition, 0f); Vector2 mousePos2D = new Vector2(mousePos.x, mousePos.y); RaycastHit2D hit = Physics2D.Raycast(mousePos2D, Vector2.zero); // Debug.Log("MousePosition" + Input.mousePosition); // Debug.Log("MousePositionWorldPoint" + mousePos); if (hit.collider != null) { Interactable interactable = hit.collider.GetComponent <Interactable>(); if (interactable != null) { SetFocus(interactable); } } } // if(Input.GetButtonDown("Fire1")) // { // ShootMissile(); // } // if(Input.GetButtonDown("Fire2")) // { // StartCoroutine(ShootMachineGun()); // } void ShootMissile() { if (whichBay) { whichBay = false; GameObject _missile = Instantiate(missilePrefab, firePointRight.position, firePointRight.rotation); _missile.GetComponent <Rigidbody2D>().velocity = gameObject.GetComponent <Rigidbody2D>().velocity; _missile.GetComponent <Rigidbody2D>().angularVelocity = gameObject.GetComponent <Rigidbody2D>().angularVelocity; _missile.GetComponent <Rigidbody2D>().AddForce(transform.right * 20f); } else { whichBay = true; GameObject _missile = Instantiate(missilePrefab, firePointLeft.position, firePointLeft.rotation); _missile.GetComponent <Rigidbody2D>().velocity = gameObject.GetComponent <Rigidbody2D>().velocity; _missile.GetComponent <Rigidbody2D>().angularVelocity = gameObject.GetComponent <Rigidbody2D>().angularVelocity; _missile.GetComponent <Rigidbody2D>().AddForce(-1.0f * transform.right * 20f); } } IEnumerator ShootMachineGun() { RaycastHit2D hitInfoL = Physics2D.Raycast(machinegunLeft.position + machinegunLeft.up, machinegunLeft.up); RaycastHit2D hitInfoR = Physics2D.Raycast(machinegunRight.position + machinegunRight.up, machinegunRight.up); if (hitInfoL) { ShipMotor ship = hitInfoL.transform.GetComponent <ShipMotor>(); if (ship != null) { ship.TakeDamage(damage); Instantiate(impactEffect, hitInfoL.point, Quaternion.identity); lineRendererL.SetPosition(0, machinegunLeft.position); lineRendererL.SetPosition(1, hitInfoL.point); } } else { lineRendererL.SetPosition(0, machinegunLeft.position); lineRendererL.SetPosition(1, machinegunLeft.position + machinegunLeft.up * 100); } if (hitInfoR) { ShipMotor ship = hitInfoR.transform.GetComponent <ShipMotor>(); if (ship != null) { ship.TakeDamage(damage); Instantiate(impactEffect, hitInfoR.point, Quaternion.identity); lineRendererR.SetPosition(0, machinegunRight.position); lineRendererR.SetPosition(1, hitInfoR.point); } } else { lineRendererR.SetPosition(0, machinegunRight.position); lineRendererR.SetPosition(1, machinegunRight.position + machinegunRight.up * 100); } lineRendererL.enabled = true; lineRendererR.enabled = true; yield return(0); lineRendererL.enabled = false; lineRendererR.enabled = false; } }
protected override void Interact(ShipMotor shipMotor) { shipMotor.UpdateLife(healAmount); Destroy(gameObject); }
void Start() { motor = gameObject.GetComponent<ShipMotor>(); }
public ShipController(ShipMotor shipMotorInstance) { _shipMotorInstance = shipMotorInstance; }
public override void Update() { UpdateLight(); motor = getChunk().getVoxelObject().component.GetComponent <ShipMotor>(); }
void Start() { colliders = player.GetComponents<Collider>(); motor = GetComponent<ShipMotor>(); ship = GetComponent<Ship>(); }
private void Steer(ShipMotor shipMotor, Rigidbody ship, Rigidbody target) { Vector3 toTarget = target.position - ship.position; Vector3 targetAngle = Quaternion.LookRotation(toTarget).eulerAngles; Vector3 shipAngles = ship.rotation.eulerAngles; //Yaw (Left/Right) float shipXAngle = shipAngles.x; float targetXAngle = targetAngle.x; if (shipXAngle > targetXAngle) { shipXAngle -= 360; } float clockwise = targetXAngle - shipXAngle; shipXAngle = shipAngles.x; if (targetXAngle > shipXAngle) { targetXAngle -= 360; } float counterClockwise = shipXAngle - targetXAngle; bool useClockwise = (clockwise <= counterClockwise); if (useClockwise) { shipMotor.Pitch(-1f * Time.fixedDeltaTime); } else { shipMotor.Pitch(1f * Time.fixedDeltaTime); } //Pitch (Up/Down) float shipYAngle = shipAngles.y; float targetYAngle = targetAngle.y; if (shipYAngle > targetYAngle) { shipYAngle -= 360; } clockwise = targetYAngle - shipYAngle; shipYAngle = shipAngles.y; if (targetYAngle > shipYAngle) { targetYAngle -= 360; } counterClockwise = shipYAngle - targetYAngle; useClockwise = (clockwise <= counterClockwise); if (useClockwise) { shipMotor.Yaw(-1f * Time.fixedDeltaTime); } else { shipMotor.Yaw(1f * Time.fixedDeltaTime); } }
void Start() { motor = GetComponent <ShipMotor>(); }