Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Nearing final state build
- Loading branch information
Showing
110 changed files
with
625 additions
and
123 deletions.
There are no files selected for viewing
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 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 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 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 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 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 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.
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,135 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
[RequireComponent(typeof(BoxCollider))] | ||
public class CatScript : MonoBehaviour { | ||
|
||
|
||
public LayerMask collisionMask; | ||
private BoxCollider colliderX; | ||
private Vector3 s; | ||
private Vector3 c; | ||
public float EnemySpeed; | ||
public float gravity; | ||
private float skin = .005f; | ||
private float dirX; | ||
private float dirY; | ||
private float direction = 1; | ||
private Vector3 movement; | ||
private Vector3 originalSize; | ||
private Vector3 originalCenter; | ||
private float colliderScaleX; | ||
|
||
[HideInInspector] | ||
public bool grounded; | ||
[HideInInspector] | ||
public bool movementStopped; | ||
|
||
Ray rayV; | ||
Ray rayD; | ||
Ray rayH; | ||
RaycastHit hit; | ||
|
||
void Start(){ | ||
//audio.Play (); | ||
colliderX = GetComponent<BoxCollider>(); | ||
s = colliderX.size; | ||
c = colliderX.center; | ||
colliderScaleX = transform.localScale.x; | ||
SetCollider (s, c); | ||
} | ||
|
||
public void move(Vector2 moveAmt) { | ||
|
||
float deltaY = moveAmt.y *Time.deltaTime; | ||
float deltaX = moveAmt.x; | ||
Vector2 p = transform.position; | ||
|
||
grounded= false; | ||
for (int i = 0; i <3; i++) { | ||
dirY = Mathf.Sign (deltaY); | ||
float x = (p.x + c.x - s.x/2) + s.x/2 * i; | ||
float y = p.y + c.y +s.y/2 * dirY; | ||
|
||
rayV = new Ray(new Vector2(x,y), new Vector2(0,dirY)); | ||
Debug.DrawRay (rayV.origin, rayV.direction); | ||
if (Physics.Raycast (rayV,out hit, Mathf.Abs (deltaY) + skin, collisionMask)) { | ||
|
||
float dst = Vector3.Distance (rayV.origin, hit.point); | ||
|
||
|
||
if (dst > skin) { | ||
deltaY = -dst - skin * dirY; | ||
} | ||
else{ | ||
deltaY = 0; | ||
} | ||
grounded = true; | ||
break; | ||
|
||
} | ||
} | ||
|
||
movementStopped = false; | ||
for (int i = 0; i <3; i++) { | ||
dirX = Mathf.Sign (deltaX); | ||
float x = p.x + c.x + s.x/2 * dirX; | ||
float y = (p.y + c.y - s.y/2) + s.y/2 * i; | ||
|
||
rayH = new Ray(new Vector2(x,y), new Vector2(dirX,0)); | ||
Debug.DrawRay (rayH.origin, rayH.direction); | ||
if (Physics.Raycast (rayH,out hit, Mathf.Abs (deltaX) + skin, collisionMask)) { | ||
|
||
float dst = Vector3.Distance (rayH.origin, hit.point); | ||
|
||
|
||
if (dst > skin) { | ||
deltaX = dst * dirX - skin * dirX; | ||
} | ||
else{ | ||
//deltaX = 0; | ||
} | ||
movementStopped = true; | ||
break; | ||
|
||
} | ||
} | ||
if (!grounded && !movementStopped) { | ||
Vector3 playerDir = new Vector3(deltaX,deltaY); | ||
Vector3 o = new Vector3((p.x + c.x + s.x/2 * dirX),(p.y + c.y +s.y/2 * dirY)); | ||
Debug.DrawRay (o, playerDir.normalized); | ||
rayD = new Ray(o, playerDir.normalized); | ||
if(Physics.Raycast (rayD,Mathf.Sqrt (deltaX*deltaX + deltaY*deltaY),collisionMask)){ | ||
grounded = true; | ||
deltaY = 0; | ||
} | ||
} | ||
|
||
Vector2 finalTransform = new Vector2 (deltaX,deltaY); | ||
transform.Translate(finalTransform, Space.World); | ||
//movement = new Vector3(finalTransform.x, finalTransform.y, 0); | ||
} | ||
|
||
|
||
void Update () { | ||
move (movement); | ||
if (transform.position.x > 11){SelfDestruct ();} | ||
float amtToMove = EnemySpeed * Time.deltaTime * direction; | ||
|
||
movement.x = amtToMove; | ||
movement.y -= gravity * Time.deltaTime; | ||
|
||
} | ||
|
||
void SelfDestruct(){ | ||
DestroyObject (this.gameObject); | ||
} | ||
|
||
public void SetCollider(Vector3 size, Vector3 center){ | ||
colliderX.size = size; | ||
colliderX.center= center; | ||
|
||
s = size * colliderScaleX; | ||
c = center * colliderScaleX; | ||
} | ||
} |
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,19 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class ClickThroughMenu : MonoBehaviour { | ||
public Texture backgroundTexture; | ||
public int nextScene; | ||
// Use this for initialization | ||
void Start () { | ||
|
||
} | ||
void OnGUI(){ | ||
GUI.DrawTexture (new Rect(0,0,Screen.width,Screen.height), backgroundTexture); | ||
} | ||
void Update () { | ||
if(Input.GetMouseButtonDown(0)){ | ||
Application.LoadLevel (nextScene); | ||
} | ||
} | ||
} |
Oops, something went wrong.