void DesktopController() { // Desktop controller flight.SimpleControl = SimpleControl; // lock mouse position to the center. if (this.gameObject.GetComponent <FlightOnWin>().isWin == false) { Screen.lockCursor = true; flight.AxisControl(new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"))); if (SimpleControl) { flight.DirectVelocity = false; flight.TurnControl(Input.GetAxis("Mouse X")); } else { flight.DirectVelocity = directVelBack; } flight.TurnControl(Input.GetAxis("Horizontal")); flight.SpeedUp(Input.GetAxis("Vertical")); if (Input.GetButton("Fire1")) { flight.WeaponControl.LaunchWeapon(); } if (Input.GetButtonDown("Fire2")) { flight.WeaponControl.SwitchWeapon(); } if (Input.GetKeyDown(KeyCode.C)) { if (View) { View.SwitchCameras(); } } if (Input.GetKeyDown(KeyCode.N)) { //Test Win... this.gameObject.GetComponent <FlightOnWin>().OnWin(); } } else { Screen.lockCursor = false; } }
bool shootTarget(Vector3 targetPos) { Vector3 dir = (targetPos - transform.position).normalized; dot = Vector3.Dot(dir, transform.forward); float distance = Vector3.Distance(targetPos, this.transform.position); if (distance <= DistanceAttack) { if (dot >= AttackDirection) { attacking = true; if (Random.Range(0, 100) > AttackRate) { flight.WeaponControl.LaunchWeapon(WeaponSelected); } if (distance < DistanceAttack / 3) { turnPosition(); } } else { WeaponSelected = Random.Range(0, flight.WeaponControl.WeaponLists.Length); return(false); } } else { flight.SpeedUp(); } return(true); }
void Update() { if (!flight || !Active) { return; } Screen.lockCursor = true; flight.AxisControl(new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"))); if (Input.GetKey(KeyCode.A)) { flight.TurnControl(-1); } if (Input.GetKey(KeyCode.D)) { flight.TurnControl(1); } if (Input.GetKey(KeyCode.W)) { flight.SpeedUp(); } if (Input.GetButton("Fire1")) { flight.WeaponControl.LaunchWeapon(); } if (Input.GetKeyDown(KeyCode.R)) { flight.WeaponControl.SwitchWeapon(); } }
void DesktopController() { // Desktop controller flight.SimpleControl = SimpleControl; // lock mouse position to the center. MouseLock.MouseLocked = true; flight.AxisControl(new Vector2(Input.GetAxis("Mouse X"), Input.GetAxis("Mouse Y"))); if (SimpleControl) { flight.DirectVelocity = false; flight.TurnControl(Input.GetAxis("Mouse X")); } else { flight.DirectVelocity = directVelBack; } flight.TurnControl(Input.GetAxis("Horizontal")); flight.SpeedUp(Input.GetAxis("Vertical")); if (Input.GetButton("Fire1")) { flight.WeaponControl.LaunchWeapon(); } if (Input.GetButtonDown("Fire2")) { flight.WeaponControl.SwitchWeapon(); } if (Input.GetKeyDown(KeyCode.C)) { if (View) { View.SwitchCameras(); } } }
bool shootTarget(Vector3 targetPos) { // Shooting ... // checking direction between Target and AI Vector3 dir = (targetPos - transform.position).normalized; dot = Vector3.Dot(dir, transform.forward); // checking distance between Target and AI float distance = Vector3.Distance(targetPos, this.transform.position); if (distance <= DistanceAttack) // is in Range ? // Ok in range { if (dot >= AttackDirection) // is in Direction ? // Ok Can Shoot them. { attacking = true; if (Random.Range(0, 100) <= AttackRate) // Make it delay and unstable shooting by Attack rate (if you set Attack Rate to 100 this AI will alway shooting like a brutal) { foreach (Chaingun gun in chains) { gun.Fire(gun.transform.position + gun.transform.forward); } //print(gameObject.name + " Shooting "); //flight.WeaponControl.LaunchWeapon (WeaponSelected);// FIRE A GUN!!! } if (distance < DistanceAttack / 3) // if too close the target , let's turning back a while. { turnPosition(); } } else { // cannot shoot. // random weapon in flight.WeaponControl.WeaponLists WeaponSelected = Random.Range(0, flight.WeaponControl.WeaponLists.Length); return(false); } } else { // cannot shoot. the target is too far!! let moving faster!! flight.SpeedUp(); } return(true); }