Commit e61bda3f authored by Tanner Grehawick's avatar Tanner Grehawick

Merge branch 'master' of git.gmu.edu:gadig/Birb

parents bb345224 1e755e8d
fileFormatVersion: 2
guid: 5e257b3931afd45bf902bc96e4c29208
timeCreated: 1487900567
<<<<<<< HEAD
guid: 79d075457339b354e831e24223780806
folderAsset: yes
timeCreated: 1487896426
=======
guid: f5015e51666ab3b4e9a750c868d6703b
folderAsset: yes
timeCreated: 1487785551
>>>>>>> origin/master
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
......@@ -22,8 +22,10 @@ public class ToggleEnemy : MonoBehaviour {
//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]);
// enemies[i].gameObject.GetComponent<BaseEnemy>().enabled = false;
// enemies.Remove(enemies[i]);
}
}
}
......
fileFormatVersion: 2
guid: 11ecc39894ce94f60a0a952e704c611f
timeCreated: 1487896949
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -3,13 +3,24 @@ using System.Collections.Generic;
using UnityEngine;
public class Walk : AbstractBehavior {
public int speed;
public float speed;
private float airSpeed;
public float airAcceleration;
public float friction;
public float wallClingTime; //time you will 'stick' to the wall after pressing the opposite direction
private float xScale;
public float realSpeed;
private int rightInt = 0;
private int leftInt = 0;
private float rightTime = 0;
private float leftTime = 0;
// Use this for initialization
void Start() {
xScale = body.transform.localScale.x;
}
// Update is called once per frame
......@@ -17,8 +28,11 @@ public class Walk : AbstractBehavior {
Buttons left = inputButtons[0];
Buttons right = inputButtons[1];
int rightInt = 0;
int leftInt = 0;
rightInt = 0;
leftInt = 0;
rightTime = inputState.GetButtonHoldTime(right);
leftTime = inputState.GetButtonHoldTime(left);
if (inputState.GetButtonValue(right))
rightInt = 1;
......@@ -30,15 +44,40 @@ public class Walk : AbstractBehavior {
else
leftInt = 0;
if (collisionState.onGround)
if (collisionState.onGround) //movement on ground
{
body.velocity = new Vector2(speed * (rightInt + leftInt), body.velocity.y);
} else
realSpeed = body.velocity.x;
if (inputState.GetButtonValue(right) || inputState.GetButtonValue(left))
{
realSpeed = Mathf.Clamp(realSpeed + speed * (rightInt + leftInt), -speed, speed);
}
else
{
if (realSpeed != 0)
{
realSpeed += (-1) * Mathf.Sign(realSpeed) * friction;
if (Mathf.Abs(realSpeed) < friction)
realSpeed = 0;
}
}
body.velocity = new Vector2(realSpeed, body.velocity.y);
} else if (!collisionState.onWall)
{
airSpeed = body.velocity.x;
if (inputState.GetButtonValue(right) || inputState.GetButtonValue(left))
{
airSpeed = Mathf.Clamp(airSpeed + airAcceleration * (rightInt + leftInt), -speed, speed);
if(Mathf.Abs(airSpeed) <= speed)
airSpeed = Mathf.Clamp(airSpeed + airAcceleration * (rightInt + leftInt), -speed, speed);
else
{
if (airSpeed != 0)
{
airSpeed += (-1) * Mathf.Sign(airSpeed) * airAcceleration;
if (Mathf.Abs(airSpeed) < airAcceleration)
airSpeed = 0;
}
}
}
else
{
......@@ -49,6 +88,45 @@ public class Walk : AbstractBehavior {
}
}
body.velocity = new Vector2(airSpeed, body.velocity.y);
} else //handles on the wall
{
airSpeed = body.velocity.x;
//only sets a change if the button has been held for a set time
if (rightTime >= wallClingTime)
{
airSpeed = Mathf.Clamp(airSpeed + airAcceleration * (rightInt), -speed, speed);
}
if (leftTime >= wallClingTime)
{
airSpeed = Mathf.Clamp(airSpeed + airAcceleration * (leftInt), -speed, speed);
}
//same as if not on wall and not pressing the buttons
if (!inputState.GetButtonValue(right) && !inputState.GetButtonValue(left))
{
if (airSpeed != 0)
{
airSpeed += (-1) * Mathf.Sign(airSpeed) * airAcceleration;
if (Mathf.Abs(airSpeed) < airAcceleration)
airSpeed = 0;
}
}
body.velocity = new Vector2(airSpeed, body.velocity.y);
}
//change localScale depending on direction
if (inputState.GetButtonValue (right) && inputState.GetButtonValue (left))
{
} else if (inputState.GetButtonValue (right))
{
inputState.direction = Directions.Right;
body.transform.localScale = new Vector3 (xScale, body.transform.localScale.y, body.transform.localScale.z);
} else if (inputState.GetButtonValue (left))
{
inputState.direction = Directions.Left;
body.transform.localScale = new Vector3 (-xScale, body.transform.localScale.y, body.transform.localScale.z);
}
}
}
Birb @ 1a6a7e32
Subproject commit 1a6a7e32dc77552677da1f8b3dd483d3ad2fac55
<<<<<<< HEAD
m_EditorVersion: 5.5.0f3
=======
m_EditorVersion: 5.3.5f1
m_StandardAssetsVersion: 0
>>>>>>> origin/master
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment