Commit 463aa24f authored by Tanner Grehawick's avatar Tanner Grehawick

Merge remote-tracking branch 'origin/master' into breakable

parents 32692b5c 1a6a7e32
{
"files.exclude":
{
"**/.DS_Store":true,
"**/.git":true,
"**/.gitignore":true,
"**/.gitmodules":true,
"**/*.booproj":true,
"**/*.pidb":true,
"**/*.suo":true,
"**/*.user":true,
"**/*.userprefs":true,
"**/*.unityproj":true,
"**/*.dll":true,
"**/*.exe":true,
"**/*.pdf":true,
"**/*.mid":true,
"**/*.midi":true,
"**/*.wav":true,
"**/*.gif":true,
"**/*.ico":true,
"**/*.jpg":true,
"**/*.jpeg":true,
"**/*.png":true,
"**/*.psd":true,
"**/*.tga":true,
"**/*.tif":true,
"**/*.tiff":true,
"**/*.3ds":true,
"**/*.3DS":true,
"**/*.fbx":true,
"**/*.FBX":true,
"**/*.lxo":true,
"**/*.LXO":true,
"**/*.ma":true,
"**/*.MA":true,
"**/*.obj":true,
"**/*.OBJ":true,
"**/*.asset":true,
"**/*.cubemap":true,
"**/*.flare":true,
"**/*.mat":true,
"**/*.meta":true,
"**/*.prefab":true,
"**/*.unity":true,
"build/":true,
"Build/":true,
"Library/":true,
"library/":true,
"obj/":true,
"Obj/":true,
"ProjectSettings/":true,
"temp/":true,
"Temp/":true
}
}
\ No newline at end of file
fileFormatVersion: 2
guid: a58ae0e00797d794297ccb4228d903bf
folderAsset: yes
timeCreated: 1487292663
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: fa60ffd6264804b43bc03430e8dd86b1
timeCreated: 1487292666
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 2057902e730664aacbc88367b9c3b892
guid: d31ebdd80916bea45bd33409fe585333
folderAsset: yes
timeCreated: 1486687237
timeCreated: 1486686817
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
assetBundleVariant:
\ No newline at end of file
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Sets dash velocity and smoothly decelerates to a minimum velocity
public class Dash : AbstractBehavior {
private float lastDash;
public float coolDown = 1f;
public float dashforce = 5;
public float holdTime = 0.4f;
public float minVelocity = 0.5f;
// Should be called every frame
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
// Sets dash velocity and smoothly decelerates to a minimum velocity
public class Dash : AbstractBehavior {
private float lastDash;
public float coolDown = 1f;
public float dashforce = 5;
public float holdTime = 0.4f;
public float minVelocity = 0.5f;
private bool _isDashing = false;
private Transform dashMeter;
// Call to check if currently dashing
public bool isDashing
{
get { return _isDashing; }
private set
{
_isDashing = value;
}
}
void Start() {
dashMeter = GameObject.FindGameObjectWithTag("DashMeter").transform;
}
// Should be called every frame
public void DashCheck() {
// Button pressed, not in cooldown, and not on wall
if (inputState.GetButtonValue(inputButtons[0]) && Time.time > lastDash && !collisionState.onWall) {
StartCoroutine(DoDash());
}
}
// Dash
UpdateUI();
}
void UpdateUI() {
float progress = 1 - ((lastDash - Time.time)/coolDown);
dashMeter.localScale = new Vector2(Mathf.Clamp01(progress), dashMeter.localScale.y);
}
// Dash
IEnumerator DoDash() {
// Cooldown
lastDash = Time.time + coolDown;
// Is dashing
isDashing = true;
// Set initial velocity
body.velocity = transform.right * dashforce;
// Disable gravity
......@@ -39,7 +63,6 @@ public class Dash : AbstractBehavior {
if(body.velocity.magnitude < minVelocity || collisionState.onWall) {
// Velocity is low enough or collision with wall
Debug.Log("Stopped");
break;
}
......@@ -51,5 +74,11 @@ public class Dash : AbstractBehavior {
// Restore gravity
body.gravityScale = initialGrav;
}
}
// Is not dashing
isDashing = false;
}
public void DashIgnoringCooldown() {
StartCoroutine(DoDash());
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class GameManager : SingletonBehaviour<GameManager>
{
private bool _isPaused;
//Manages game state. Pause, death, win, and changing levels.
public bool isPaused
{
get
{
return _isPaused;
}
set
{
_isPaused = value;
if (isPaused)
{
//set timescale back to normal
isPaused = false;
Debug.Log("Game is unpaused");
}
else
{
//set timescale to zero
isPaused = true;
Debug.Log("Game is paused");
}
}
}
public void Fail()
{
Debug.Log("You have died");
}
public void Win()
{
Debug.Log("You won!");
}
public void ChangeLevel()
{
Debug.Log("Changing level state");
}
}
fileFormatVersion: 2
guid: cad3061263b98c140a9a3a49d70204c9
timeCreated: 1486686808
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ToggleEnemy : MonoBehaviour {
Camera cam;
public List<Collider2D> enemies;
List<BaseEnemy> disabledEnemies;
// Use this for initialization
void Start () {
cam = Camera.main;
}
// Update is called once per frame
void Update () {
//get frustum of camera
Plane[] camPlanes = GeometryUtility.CalculateFrustumPlanes(cam);
for (int i = 0; i < enemies.Count; i++)
{
//check if enemy is in view of camera and disable if not
if (!GeometryUtility.TestPlanesAABB(camPlanes, enemies[i].bounds))
{
enemies[i].gameObject.GetComponent<BaseEnemy>().enabled = false;
enemies.Remove(enemies[i]);
}
}
}
}
......@@ -146,5 +146,9 @@ public class MapEditorEditor : Editor
// Toggle on field
MapEditor.On = GUILayout.Toggle(MapEditor.On, "ON");
// Initialize Borders
if(GUILayout.Button("Initialize Borders"))
Borders.initializeAll();
}
}
......@@ -37,6 +37,11 @@ public static class World
setupWithGOs();
}
public static void setup()
{
setup(50, 50 , 3);
}
private static void instantiateMap()
{
map = new GameObject[width][][];
......@@ -113,7 +118,7 @@ public static class World
{
if(x < 0 || y < 0 || z < 0 || x >= width || y >= height || z >= depth)
{
Debug.LogWarning("Pos out of bounds!");
//Debug.LogWarning("Pos out of bounds!");
return false;
}
return true;
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Birb : AbstractBehavior {
//Add the name of the animations to be played.
private string idleAnim = "";
private string walkAnim = "";
private string jumpAnim = "";
private string fallAnim = "";
private string wallAnim = "";
private string dashAnim = "";
private string hurtAnim = "";
public enum AnimState
{
Idle,
Walking,
Jumping,
Falling,
OnWall,
Dashing,
Hurt
//Add the necessary animation states.
}
AnimState state;
bool enemyHit;
void Start()
{
}
void Update()
{
ContinueState ();
}
public void Die()
{
animator.Play (hurtAnim);
GameManager.instance.Fail ();
}
//Determines if the animation state must change.
void SetOrKeepState(AnimState state)
{
if (this.state == state)
return;
EnterState (state);
}
//Plays the corresponding animation to each state.
void EnterState(AnimState state)
{
ExitState ();
switch (state)
{
case AnimState.Idle:
animator.Play (idleAnim);
break;
case AnimState.Walking:
animator.Play (walkAnim);
break;
case AnimState.Jumping:
animator.Play (jumpAnim);
break;
case AnimState.Falling:
animator.Play (fallAnim);
break;
case AnimState.OnWall:
animator.Play (wallAnim);
break;
case AnimState.Dashing:
animator.Play (dashAnim);
break;
}
this.state = state;
}
//Determines
void ContinueState()
{
switch (state)
{
case AnimState.Idle:
StateSwitch ();
break;
case AnimState.Walking:
if (!StateSwitch ())
EnterState (AnimState.Idle);
break;
case AnimState.Dashing:
if (body.gravityScale != 0)
StateSwitch ();
break;
case AnimState.Hurt:
if (!enemyHit) //Check if enemy hit.
StateSwitch ();
break;
case AnimState.OnWall:
if (!collisionState.onWall)
StateSwitch ();
break;
}
}
void ExitState()
{
}
bool StateSwitch()
{
if (inputState.GetButtonPressed (Buttons.A) && collisionState.onGround)
SetOrKeepState (AnimState.Jumping);
else if ((inputState.GetButtonPressed (Buttons.Right) || inputState.GetButtonPressed (Buttons.Left)) && collisionState.onGround)
SetOrKeepState (AnimState.Walking);
else if ((inputState.GetButtonPressed (Buttons.X)) && body.gravityScale == 0) //Add a way of knowing if the dash is off CD.
SetOrKeepState (AnimState.Dashing);
else if ((body.velocity.y < 0))
SetOrKeepState (AnimState.Falling);
else if (enemyHit)
SetOrKeepState (AnimState.Hurt);
else if (collisionState.onWall)
SetOrKeepState (AnimState.OnWall);
else
return false;
return true;
}
}
fileFormatVersion: 2
guid: de3aa9fc98a1afc4ea1040f7e728697b
timeCreated: 1486687809
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CameraFollow : SingletonBehaviour<CameraFollow>
{
Camera cameraObj;
public float smoothSpeed;
private float MaxHeight;
private float MaxWidth;
private float MinHeight;
private float MinWidth;
private float OZ;
// Use this for initialization
void Start ()
{
cameraObj = Camera.main;
float camHeight = cameraObj.orthographicSize * 2;
float camWidth = cameraObj.aspect * camHeight;
MaxHeight = World.Height - camHeight / 2;
MaxWidth = World.Width - camWidth / 2;
MinHeight = World.Height + camHeight / 2;
MinWidth = World.Width + camHeight / 2;
OZ = cameraObj.transform.position.z;
}
// Update is called once per frame
void Update ()
{
Vector3 targetPOS = Vector3.Lerp(cameraObj.transform.position, transform.position, smoothSpeed * Time.deltaTime);
/*
//camera dimensions and center
float camHeight = cameraObj.orthographicSize * 2;
float camWidth = cameraObj.aspect * camHeight;
if(targetPOS.y + camHeight > World.Height) //if camera is above bounds
{
targetPOS.y = (MaxHeight);
}
if(targetPOS.y - camHeight < World.Height) // if below bounds
{
targetPOS.y = (MinHeight);
}
if(targetPOS.x + camWidth > World.Width) //if right of bounds
{
targetPOS.x = (MaxWidth);
}
if(targetPOS.x - camWidth < World.Width) // if left of bounds
{
targetPOS.x = (MinWidth);
}*/
cameraObj.transform.position = new Vector3(targetPOS.x, targetPOS.y, OZ);
}
}
......@@ -67,7 +67,9 @@ public class InputState : MonoBehaviour {
public float GetButtonHoldTime(Buttons key){
if(buttonStates.ContainsKey(key)){
return buttonStates [key].holdTime;
}else{
}
else
{
return 0;
}
}
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class WallSliding : AbstractBehavior {
[SerializeField] private float speed;
[SerializeField] private float delay;
[SerializeField] private float wallJumpForce;
[SerializeField] private int leftButtonID;
[SerializeField] private int rightButtonID;
[SerializeField] private int jumpButtonID;
private float previousGravity;
private bool _isSliding;
private bool isEnding;
private bool isJumping;
public void Activate() {
ToggleScripts(false);
previousGravity = body.gravityScale;
body.velocity.Set(body.velocity.x, speed);
body.gravityScale = 0;
_isSliding = true;
isEnding = false;
isJumping = false;
StartCoroutine(CheckForEnd());
}
private IEnumerator CheckForEnd() {
while (_isSliding) {
if (ButtonCheck(leftButtonID) || ButtonCheck(rightButtonID)) {
if (!isEnding) StartCoroutine(EndWithDelay());
}
if (ButtonCheck(jumpButtonID)) {
if (!isJumping) JumpOffWall();
if (!isEnding) EndSliding();
}
yield return new WaitForFixedUpdate();
}
}
private bool ButtonCheck(int button) {
return inputState.GetButtonValue(inputButtons[button]);
}
private void JumpOffWall() {
isJumping = true;
body.AddForce(new Vector2((int)inputState.direction, 0) * wallJumpForce);
}
private IEnumerator EndWithDelay() {
isEnding = true;
yield return new WaitForSeconds(delay);
EndSliding();
}
private void EndSliding() {
body.gravityScale = previousGravity;
_isSliding = false;
isJumping = false;
ToggleScripts(true);
}
}
fileFormatVersion: 2
guid: 604ce289803c4154f97ae0b77cd158b7
timeCreated: 1486689234
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using UnityEngine;
using UnityEditor;