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
Project Files commit in prototype stage
- Loading branch information
Showing
148 changed files
with
2,211 additions
and
0 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.
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,137 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class Anim2D : MonoBehaviour { | ||
|
||
// calculation variables | ||
private Vector3 tempVector; | ||
private Vector3 tempVector2; | ||
private int i; | ||
|
||
// animation variables (variables used for processing aniamtion) | ||
|
||
public float sheetRows = 5; // Total columns in sprite sheet | ||
public float sheetColumns = 4; // Total Rows in sprite sheet | ||
|
||
public float FrameRate = 11f; // how many frames to play per second | ||
|
||
private float frameNum = 1; // the current frame being played, | ||
private string currentAnim; // the ID of the current animation being played | ||
private float currentStart = 0; //Dynamic variable that tells the animation system what the first frame of the current animation is | ||
private float currentEnd = 0; | ||
private bool loopCheck; //Does this animation loop? | ||
private float AnimTime = 0f; // time to pass before playing next animation | ||
private Vector2 sheetPos; // the X, Y position of the frame | ||
private Vector2 sheetOffset; // the offset value of the X, Y coordinate for the texture | ||
|
||
|
||
//This Class allows us to create a bunch of data and store it in this specific container | ||
[System.Serializable] | ||
public class AnimClass | ||
{ | ||
public string Name; | ||
public bool looping; | ||
public int anim_Min; | ||
public int anim_Max; | ||
} | ||
|
||
public AnimClass[] Animz; | ||
|
||
|
||
|
||
|
||
// Use this for initialization | ||
void Start () { | ||
|
||
//Telling this controller that Idle is the default animation so that it doesn't throw an error | ||
currentAnim = "Idle"; | ||
} | ||
|
||
|
||
void Update () { | ||
|
||
HandleAnimation(); | ||
KeyCommands(); | ||
|
||
} | ||
|
||
void HandleAnimation () // handles all animation | ||
{ | ||
|
||
FindAnimation(currentAnim); | ||
ProcessAnimation(); | ||
|
||
} | ||
|
||
//Here we decide | ||
void FindAnimation (string currentAnim) | ||
{ | ||
|
||
for (var i = 0; i < Animz.Length; i++){ | ||
if ( Animz[i].Name == currentAnim){ | ||
|
||
loopCheck = Animz[i].looping; | ||
currentStart = Animz[i].anim_Min; | ||
currentEnd = Animz[i].anim_Max; | ||
|
||
i = Animz.Length; | ||
} | ||
} | ||
} | ||
|
||
//These are dummy key input sensors. You should have a seperate player controller (or AI controller) that declares "currentAnim" to this script | ||
void KeyCommands(){ | ||
if (Input.GetKeyDown(KeyCode.UpArrow)){ | ||
currentAnim = "Idle"; | ||
} | ||
if (Input.GetKeyDown(KeyCode.RightArrow)){ | ||
currentAnim = "Kill"; | ||
} | ||
} | ||
|
||
|
||
void ProcessAnimation () | ||
{ | ||
|
||
// AnimTime -= Time.deltaTime; subtract the number | ||
// of seconds passed since the last frame, if the game | ||
// is running at 30 frames per second the variable will | ||
// subtract by 0.033 of a second (1/30) | ||
|
||
AnimTime -= Time.deltaTime; | ||
|
||
if (AnimTime <= 0) | ||
{ | ||
frameNum += 1; | ||
// one play animations (play from start to finish) | ||
|
||
frameNum = Mathf.Clamp(frameNum,currentStart,currentEnd+1); | ||
|
||
if ( loopCheck == true){ | ||
if (frameNum > currentEnd){ | ||
frameNum = currentStart; | ||
} | ||
} | ||
|
||
// if the FrameRate is 11, 1/11 is one eleventh of a second, that is the time we are waiting before we | ||
//play the next frame. | ||
|
||
AnimTime += (1/FrameRate); | ||
} | ||
|
||
sheetPos.y = 0; | ||
|
||
// find the number of frames down the animation is and set the y coordinate accordingly | ||
for (i=(int)frameNum; i > 5; i-=5) | ||
{ | ||
sheetPos.y += 1; | ||
} | ||
|
||
sheetPos.x = i - 1; // find the X coordinate of the frame to play | ||
sheetOffset = new Vector2(1 - (sheetPos.x/sheetRows),1 -(sheetPos.y/sheetColumns)); // find the X and Y coordinate of the frame to display | ||
|
||
renderer.material.SetTextureOffset ("_MainTex", sheetOffset); // offset the texture to display the correct frame | ||
} | ||
|
||
} | ||
|
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,148 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
[RequireComponent(typeof(BoxCollider))] | ||
public class EnemyPhysics : MonoBehaviour { | ||
|
||
public LayerMask collisionMask; | ||
|
||
private BoxCollider colliderX; | ||
private Vector3 s; | ||
private Vector3 c; | ||
public float EnemySpeed; | ||
public float gravity; | ||
private bool offScreen = false; | ||
private string lastHit; | ||
private float skin = .005f; | ||
private float dirX; | ||
private float dirY; | ||
private float direction = -1; | ||
private Vector3 movement; | ||
|
||
[HideInInspector] | ||
public bool grounded; | ||
[HideInInspector] | ||
public bool movementStopped; | ||
|
||
Ray rayV; | ||
Ray rayD; | ||
Ray rayH; | ||
RaycastHit hit; | ||
|
||
void Start(){ | ||
colliderX = GetComponent<BoxCollider>(); | ||
s = colliderX.size; | ||
c = colliderX.center; | ||
|
||
} | ||
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); | ||
if (offScreen){ | ||
transform.Translate (new Vector2 (moveAmt.x, deltaY), Space.World); | ||
} | ||
else{ | ||
transform.Translate(finalTransform, Space.World); | ||
} | ||
|
||
} | ||
|
||
|
||
void OnTriggerEnter(Collider other) { | ||
lastHit = other.tag; | ||
if (lastHit =="Backboard"){Debug.Log (lastHit);} | ||
} | ||
|
||
|
||
void Update () { | ||
|
||
if (lastHit == "Backboard"){ | ||
Invoke ("SelfDestruct", 3); | ||
offScreen= true; | ||
} | ||
else if (movementStopped && !offScreen) { | ||
direction *= -1; | ||
} | ||
else{} | ||
|
||
float amtToMove = EnemySpeed * Time.deltaTime * direction; | ||
|
||
movement.x = amtToMove; | ||
movement.y -= gravity * Time.deltaTime; | ||
|
||
|
||
move (movement); | ||
|
||
if (this.transform.position.y < -6){ | ||
SelfDestruct(); | ||
} | ||
} | ||
|
||
void SelfDestruct(){ | ||
DestroyObject (this.gameObject); | ||
} | ||
} |
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,14 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class EntryPortal : MonoBehaviour { | ||
public float rotateSpeed = -3; | ||
private Vector3 rotateZ; | ||
|
||
void Update () { | ||
|
||
rotateZ.z = rotateSpeed; | ||
transform.Rotate(rotateZ, Space.World); | ||
} | ||
|
||
} |
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,56 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class GameCamera : MonoBehaviour { | ||
|
||
private Transform target; | ||
private float maxX = 0f; | ||
private int buttonWidth = 400; | ||
private int buttonHeight = 100; | ||
private bool buttonShown=false; | ||
public int currentLevel = 0; | ||
public int nextLevel = 0; | ||
public OutPortal exit; | ||
public GUIStyle gStyle; | ||
|
||
|
||
public void setTarget(Transform t) { | ||
target = t; | ||
} | ||
|
||
void OnGUI() { | ||
if (!exit.hitP){ | ||
if(!target){ | ||
Invoke ("showButton", 1.55f); | ||
} | ||
if (buttonShown && !target){ | ||
if (GUI.Button (new Rect(Screen.width /2 - buttonWidth/2, Screen.height /2 - buttonHeight/2, buttonWidth, buttonHeight), "YOU HAVE DIED", gStyle)) { | ||
Application.LoadLevel (currentLevel); | ||
} | ||
} | ||
else{ | ||
buttonShown=false; | ||
} | ||
} | ||
else{ | ||
if (GUI.Button (new Rect(Screen.width /2 - buttonWidth/2, Screen.height /2 - buttonHeight/2, buttonWidth, buttonHeight), "LEVEL COMPLETE", gStyle)) { | ||
Application.LoadLevel (nextLevel); | ||
} | ||
|
||
} | ||
} | ||
|
||
void showButton(){ | ||
buttonShown=true; | ||
} | ||
|
||
void LateUpdate() { | ||
if (target) { | ||
float x = target.position.x; | ||
if (x > maxX) { | ||
transform.position = new Vector3(x,transform.position.y,transform.position.z); | ||
maxX = x; | ||
} | ||
} | ||
} | ||
} |
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,28 @@ | ||
using UnityEngine; | ||
using System.Collections; | ||
|
||
public class GameManager : MonoBehaviour { | ||
|
||
public GameObject player; | ||
public GameObject portal; | ||
private GameCamera cam; | ||
|
||
// Use this for initialization | ||
void Start () { | ||
cam = GetComponent<GameCamera>(); | ||
SpawnStart (); | ||
|
||
} | ||
|
||
|
||
private void SpawnStart () { | ||
Instantiate (portal, portal.transform.position, portal.transform.rotation); | ||
Invoke ("SpawnPlayer", 1.5f); | ||
|
||
} | ||
|
||
private void SpawnPlayer () { | ||
GameObject merp = (Instantiate (player, player.transform.position,player.transform.rotation) as GameObject); | ||
cam.setTarget (merp.transform); | ||
} | ||
} |
Oops, something went wrong.