void Update() { if (!isUpdate) { return; } if (m_breakableControls == null) { m_breakableControls = DragonInputController.Instance; } velocity = (mechDragon.position - previousPos).magnitude; previousPos = mechDragon.position; if (DragonValues.Instance.FuelAmount <= 0.0f) { AudioManager.instance.PlayAudioAt(mechDragon.position, "LowFuel", mechDragon); gameObject.AddComponent <Rigidbody>(); isUpdate = false; } if (GameStarted) { if (/*Input.GetButtonDown("Fire1")*/ m_breakableControls.BurpFire()) { //TO DO: Fine tune velocityn vaikutus projectile speediin GameObject fb = Instantiate(fireball, jaw.position, Quaternion.identity) as GameObject; fb.GetComponent <Fireball>().Shoot(mechDragon.forward, projectileSpeed * 10 * velocity / 2); AudioManager.instance.PlayAudioAt(mechDragon.position + new Vector3(0, 0, 23), "FireBreath"); fireAnimV = 1.0f; } //TODO drop oil if (/*Input.GetButtonDown("Fire2")*/ m_breakableControls.DropFuel()) { GameObject fb = Instantiate(oilDrop, oilDropPos.position, Quaternion.identity) as GameObject; fb.GetComponent <Oil>().Shoot(Vector3.down, projectileSpeed); AudioManager.instance.PlayAudioAt(mechDragon.position + new Vector3(0, -2.6f, -8.5f), "OilDrop"); } fireAnimV -= Time.deltaTime * 1.5f; fireAnimV = Mathf.Clamp01(fireAnimV); anim.SetFloat("Shoot", fireAnimV); pitch = -m_breakableControls.GetPitch(); //-Input.GetAxis("Pitch"); yaw = m_breakableControls.GetYaw(); //Input.GetAxis("Yaw"); roll = -m_breakableControls.GetRoll(); //Input.GetAxis("Roll"); float minValue = 0.1f; SetAnimFloat("Pitch+", pitch, minValue); SetAnimFloat("Pitch-", pitch, -minValue); SetAnimFloat("Yaw+", yaw, minValue); SetAnimFloat("Yaw-", yaw, -minValue); SetAnimFloat("Roll+", roll, minValue); SetAnimFloat("Roll-", roll, -minValue); anim.SetFloat("Idle", 1.0f); //thrust = Mathf.Clamp(Input.GetAxis("Gas"),0.1f, 1f); //legacy thrust mechDragon.Rotate(mechDragon.right * pitch, Space.World); //climb up or down ("elevator") mechDragon.Rotate(mechDragon.up * yaw, Space.World); //idly barrel roll ("ailerons") mechDragon.Rotate(mechDragon.forward * roll, Space.World); //steer left/right ("rudder") //turn based on the roll ("banking) //mechDragon.Rotate(new Vector3(0, -Vector3.Dot(Vector3.up, mechDragon.right), 0)); //muista muokata fuel consumptionia thrustin/kaasun mukaan if (/*Input.GetAxis("Gas")*/ m_breakableControls.GetGasSpeed() > 0.01f && thrust < MaxSpeed) { thrust = thrust + Time.deltaTime * acceleration; } else if (thrust > minSpeed) { thrust = thrust - Time.deltaTime * acceleration / 2; } else { thrust = minSpeed; } mechDragon.Translate(mechDragon.forward * thrust, Space.World); } else if (Input.GetButton("BreathFire")) { StartGame(); audioManager.PlayAudioAt(mechDragon.position, "GameStart"); } if (Input.GetKeyDown(KeyCode.R) || Input.GetButtonDown("ResetCamera")) { InputTracking.Recenter(); } }