Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added touch controls #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
318 changes: 318 additions & 0 deletions Assembly-CSharp.csproj

Large diffs are not rendered by default.

Binary file modified Assets/Done/Done_Prefabs/Done_Player.prefab
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified Assets/Done/Done_Scenes/Done_Main.unity
Binary file not shown.
17 changes: 10 additions & 7 deletions Assets/Done/Done_Scripts/Done_EvasiveManeuver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ public class Done_EvasiveManeuver : MonoBehaviour
private float currentSpeed;
private float targetManeuver;

private Rigidbody rigidBody;

void Start ()
{
currentSpeed = rigidbody.velocity.z;
rigidBody = GetComponent<Rigidbody> ();
currentSpeed = rigidBody.velocity.z;
StartCoroutine(Evade());
}

Expand All @@ -34,15 +37,15 @@ IEnumerator Evade ()

void FixedUpdate ()
{
float newManeuver = Mathf.MoveTowards (rigidbody.velocity.x, targetManeuver, smoothing * Time.deltaTime);
rigidbody.velocity = new Vector3 (newManeuver, 0.0f, currentSpeed);
rigidbody.position = new Vector3
float newManeuver = Mathf.MoveTowards (rigidBody.velocity.x, targetManeuver, smoothing * Time.deltaTime);
rigidBody.velocity = new Vector3 (newManeuver, 0.0f, currentSpeed);
rigidBody.position = new Vector3
(
Mathf.Clamp(rigidbody.position.x, boundary.xMin, boundary.xMax),
Mathf.Clamp(rigidBody.position.x, boundary.xMin, boundary.xMax),
0.0f,
Mathf.Clamp(rigidbody.position.z, boundary.zMin, boundary.zMax)
Mathf.Clamp(rigidBody.position.z, boundary.zMin, boundary.zMax)
);

rigidbody.rotation = Quaternion.Euler (0, 0, rigidbody.velocity.x * -tilt);
rigidBody.rotation = Quaternion.Euler (0, 0, rigidBody.velocity.x * -tilt);
}
}
5 changes: 4 additions & 1 deletion Assets/Done/Done_Scripts/Done_Mover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ public class Done_Mover : MonoBehaviour
{
public float speed;

private Rigidbody rigidBody;

void Start ()
{
rigidbody.velocity = transform.forward * speed;
rigidBody = GetComponent<Rigidbody> ();
rigidBody.velocity = transform.forward * speed;
}
}
22 changes: 15 additions & 7 deletions Assets/Done/Done_Scripts/Done_PlayerController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,22 @@ public class Done_PlayerController : MonoBehaviour
public float fireRate;

private float nextFire;

private Rigidbody rigidBody;
private AudioSource audioSource;

void Start()
{
rigidBody = GetComponent<Rigidbody> ();
audioSource = GetComponent<AudioSource> ();
}

void Update ()
{
if (Input.GetButton("Fire1") && Time.time > nextFire)
{
nextFire = Time.time + fireRate;
Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
audio.Play ();
audioSource.Play ();
}
}

Expand All @@ -35,15 +43,15 @@ void FixedUpdate ()
float moveVertical = Input.GetAxis ("Vertical");

Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
rigidbody.velocity = movement * speed;
rigidBody.velocity = movement * speed;

rigidbody.position = new Vector3
rigidBody.position = new Vector3
(
Mathf.Clamp (rigidbody.position.x, boundary.xMin, boundary.xMax),
Mathf.Clamp (rigidBody.position.x, boundary.xMin, boundary.xMax),
0.0f,
Mathf.Clamp (rigidbody.position.z, boundary.zMin, boundary.zMax)
Mathf.Clamp (rigidBody.position.z, boundary.zMin, boundary.zMax)
);

rigidbody.rotation = Quaternion.Euler (0.0f, 0.0f, rigidbody.velocity.x * -tilt);
rigidBody.rotation = Quaternion.Euler (0.0f, 0.0f, rigidBody.velocity.x * -tilt);
}
}
7 changes: 5 additions & 2 deletions Assets/Done/Done_Scripts/Done_RandomRotator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@
public class Done_RandomRotator : MonoBehaviour
{
public float tumble;


private Rigidbody rigidBody;

void Start ()
{
rigidbody.angularVelocity = Random.insideUnitSphere * tumble;
rigidBody = GetComponent<Rigidbody> ();
rigidBody.angularVelocity = Random.insideUnitSphere * tumble;
}
}
5 changes: 4 additions & 1 deletion Assets/Done/Done_Scripts/Done_WeaponController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ public class Done_WeaponController : MonoBehaviour
public float fireRate;
public float delay;

private AudioSource audioSource;

void Start ()
{
audioSource = GetComponent<AudioSource> ();
InvokeRepeating ("Fire", delay, fireRate);
}

void Fire ()
{
Instantiate(shot, shotSpawn.position, shotSpawn.rotation);
audio.Play();
audioSource.Play();
}
}
66 changes: 53 additions & 13 deletions Assets/Models/vehicle_enemyShip.FBX.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

66 changes: 53 additions & 13 deletions Assets/Models/vehicle_playerShip.FBX.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/TouchControls.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions Assets/TouchControls/Scripts.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading