-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
unknown-user
committed
Apr 12, 2014
1 parent
2e2cc12
commit 92ace74
Showing
27 changed files
with
93 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class AsteroidDetector : MonoBehaviour | ||
{ | ||
void OnTriggerEnter2D (Collider2D other) | ||
{ | ||
other.gameObject.renderer.enabled = true; | ||
} | ||
|
||
void OnTriggerExit2D (Collider2D other) | ||
{ | ||
other.gameObject.renderer.enabled = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#pragma strict | ||
|
||
var cameraTarget : GameObject; // Inspector> Assign the Camera Target NON è il target della camera ma la posizione che vuole raggiungere la camera | ||
|
||
var smoothTime : float = 0.5; | ||
var cameraFollowX : boolean = true; // Inspector> if is checked -> The Camera will follow X position of cameraTarget | ||
var cameraFollowY : boolean = true; // Inspector> if is checked -> The Camera will follow Y position of cameraTarget | ||
var cameraFollowHeight : boolean = false; // if true the Camera Y Position = cameraHeight | ||
var cameraHeight : float = 10; // cameraHeight | ||
var velocity : Vector2; | ||
private var thisTransform : Transform; | ||
|
||
function Start () | ||
{ | ||
thisTransform = transform; | ||
} | ||
|
||
function Update () | ||
{ | ||
|
||
if (cameraFollowX) // if cameraFollowX = true = Inspector is checked | ||
{ | ||
thisTransform.position.x = Mathf.SmoothDamp (thisTransform.position.x, cameraTarget.transform.position.x, velocity.x, smoothTime); | ||
} | ||
|
||
if (cameraFollowY) // if cameraFollowY = true = Inspector is checked | ||
{ | ||
thisTransform.position.y = Mathf.SmoothDamp (thisTransform.position.y, cameraTarget.transform.position.y, velocity.y, smoothTime); | ||
} | ||
|
||
if (!cameraFollowY && cameraFollowHeight) // if cameraFollowY = false = Inspector is unchecked AND cameraFollowHeight = true = Inspector is checked | ||
{ | ||
camera.transform.position.y = cameraHeight; // The Camera Y position = cameraHeight | ||
} | ||
|
||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,48 @@ | ||
using UnityEngine; | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class SpaceShipController : MonoBehaviour | ||
{ | ||
|
||
private Vector3 moveDirection; | ||
public float moveSpeed = 2; | ||
public float turnSpeed; | ||
public float moveSpeed = 0; | ||
public float turnSpeed = 0; | ||
private Vector3 moveToward; | ||
|
||
// Use this for initialization | ||
void Start () | ||
{ | ||
moveDirection = Vector3.right; | ||
} | ||
|
||
// Update is called once per frame | ||
void Update () | ||
{ | ||
// 1 | ||
Vector3 currentPosition = transform.position; | ||
|
||
// 2 | ||
if (Input.GetButton ("Fire1")) { | ||
// 3 | ||
Vector3 moveToward = Camera.main.ScreenToWorldPoint (Input.mousePosition); | ||
// 4 | ||
moveDirection = moveToward - currentPosition; | ||
moveDirection.z = 0; | ||
moveDirection.Normalize (); | ||
|
||
Vector3 target = moveDirection * moveSpeed + currentPosition; | ||
transform.position = Vector3.Lerp (currentPosition, target, Time.deltaTime); | ||
|
||
float targetAngle = Mathf.Atan2 (moveDirection.y, moveDirection.x) * Mathf.Rad2Deg; | ||
transform.rotation = | ||
Quaternion.Slerp (transform.rotation, | ||
Quaternion.Euler (0, 0, targetAngle), | ||
turnSpeed * Time.deltaTime); | ||
moveToward = Camera.main.ScreenToWorldPoint (Input.mousePosition); | ||
moveToward.z = 0; | ||
CircleCollider2D circle = transform.GetComponent<CircleCollider2D> (); | ||
if ((moveToward - currentPosition).sqrMagnitude > circle.radius / 15) { | ||
moveSpeed = 5; | ||
turnSpeed = 5; | ||
// 4 | ||
currentPosition.z = 0; | ||
moveDirection = moveToward - currentPosition; | ||
moveDirection.z = 0; | ||
moveDirection.Normalize (); | ||
|
||
|
||
float targetAngle = Mathf.Atan2 (moveDirection.y, moveDirection.x) * Mathf.Rad2Deg; | ||
transform.rotation = | ||
Quaternion.Slerp (transform.rotation, | ||
Quaternion.Euler (0, 0, targetAngle), | ||
turnSpeed * Time.deltaTime); | ||
collider2D.rigidbody2D.AddForce (moveDirection * moveSpeed); | ||
} | ||
} | ||
|
||
} | ||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Library/ScriptAssemblies/Assembly-UnityScript-Editor.dll.mdb
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Library/ScriptAssemblies/Assembly-UnityScript-firstpass.dll
Binary file not shown.
Binary file modified
BIN
+0 Bytes
(100%)
Library/ScriptAssemblies/Assembly-UnityScript-firstpass.dll.mdb
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.