@@ -177,6 +177,127 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!1 &509501010
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 4
m_Component:
- 224: {fileID: 509501011}
- 222: {fileID: 509501014}
- 114: {fileID: 509501013}
- 114: {fileID: 509501012}
m_Layer: 5
m_Name: Button
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &509501011
RectTransform:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 509501010}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children: []
m_Father: {fileID: 1245018455}
m_RootOrder: 1
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 172.1, y: 110.2}
m_SizeDelta: {x: 248.9, y: 60.7}
m_Pivot: {x: 0, y: 0}
--- !u!114 &509501012
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 509501010}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 1392445389, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Navigation:
m_Mode: 3
m_SelectOnUp: {fileID: 0}
m_SelectOnDown: {fileID: 0}
m_SelectOnLeft: {fileID: 0}
m_SelectOnRight: {fileID: 0}
m_Transition: 1
m_Colors:
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
m_HighlightedColor: {r: 0.1586206, g: 1, b: 0, a: 1}
m_PressedColor: {r: 1, g: 0.88965523, b: 0, a: 1}
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
m_ColorMultiplier: 1
m_FadeDuration: 0.1
m_SpriteState:
m_HighlightedSprite: {fileID: 0}
m_PressedSprite: {fileID: 0}
m_DisabledSprite: {fileID: 0}
m_AnimationTriggers:
m_NormalTrigger: Normal
m_HighlightedTrigger: Highlighted
m_PressedTrigger: Pressed
m_DisabledTrigger: Disabled
m_Interactable: 1
m_TargetGraphic: {fileID: 509501013}
m_OnClick:
m_PersistentCalls:
m_Calls:
- m_Target: {fileID: 1245018456}
m_MethodName: PlayPressed
m_Mode: 1
m_Arguments:
m_ObjectArgument: {fileID: 0}
m_ObjectArgumentAssemblyTypeName: UnityEngine.Object, UnityEngine
m_IntArgument: 0
m_FloatArgument: 0
m_StringArgument:
m_BoolArgument: 0
m_CallState: 2
m_TypeName: UnityEngine.UI.Button+ButtonClickedEvent, UnityEngine.UI, Version=1.0.0.0,
Culture=neutral, PublicKeyToken=null
--- !u!114 &509501013
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 509501010}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: -765806418, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 21300000, guid: b968da918da2a47198f9856eaa59b937, type: 3}
m_Type: 0
m_PreserveAspect: 1
m_FillCenter: 1
m_FillMethod: 4
m_FillAmount: 1
m_FillClockwise: 1
m_FillOrigin: 0
--- !u!222 &509501014
CanvasRenderer:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 509501010}
--- !u!1 &663997529
GameObject:
m_ObjectHideFlags: 0
@@ -188,7 +309,7 @@ GameObject:
- 222: {fileID: 663997532}
- 114: {fileID: 663997531}
m_Layer: 5
m_Name: Panel
m_Name: MenuBG
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@@ -224,15 +345,15 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 0.392}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_Sprite: {fileID: 10907, guid: 0000000000000000f000000000000000, type: 0}
m_Type: 1
m_Sprite: {fileID: 21300000, guid: f6fba4a73882c4558818c308582c236d, type: 3}
m_Type: 0
m_PreserveAspect: 0
m_FillCenter: 1
m_FillMethod: 4
@@ -318,6 +439,7 @@ GameObject:
- 223: {fileID: 1245018454}
- 114: {fileID: 1245018453}
- 114: {fileID: 1245018452}
- 114: {fileID: 1245018456}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
@@ -352,10 +474,10 @@ MonoBehaviour:
m_Script: {fileID: 1980459831, guid: f5f67c52d1564df4a8936ccd202a3bd8, type: 3}
m_Name:
m_EditorClassIdentifier:
m_UiScaleMode: 0
m_UiScaleMode: 1
m_ReferencePixelsPerUnit: 100
m_ScaleFactor: 1
m_ReferenceResolution: {x: 800, y: 600}
m_ReferenceResolution: {x: 1024, y: 576}
m_ScreenMatchMode: 0
m_MatchWidthOrHeight: 0
m_PhysicalUnit: 3
@@ -393,10 +515,22 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_Children:
- {fileID: 663997530}
- {fileID: 509501011}
m_Father: {fileID: 0}
m_RootOrder: 1
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
--- !u!114 &1245018456
MonoBehaviour:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1245018451}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: faa4384c08a254caf9fd4e77368e4b61, type: 3}
m_Name:
m_EditorClassIdentifier:

Large diffs are not rendered by default.

This file was deleted.

@@ -2,129 +2,64 @@
using System.Collections;
using System.Collections.Generic;

//TODO: FIX RIGHT EDGE DETECTION
public class GrandmaGhostMove : Movement {
public class GrandmaGhostMove : MonoBehaviour {

private Queue<KeyCode> path;
private int nSides;
private int currPI;
public bool isGhost;
//private int[] leftEdges;
private int[] rightEdges;
[HideInInspector]
public Queue<KeyCode> path;

[HideInInspector]
public RectTransform rect;

[HideInInspector]
public Vector2 position;

void Start () {
path = new Queue<KeyCode>();
rightEdges = new int[nSides + 1];
calcRightEdges();
rect = GetComponent<RectTransform>();
position = rect.anchoredPosition;
}

void Update () {
currPI = transform.parent.GetSiblingIndex();
nSides = LevelManager.instance.numSides;
public void ResetGhost(Vector2 position) {
rect.anchoredPosition = position;
this.position = position;
}

public bool UpdateGhostPosition (bool canMoveUp, bool canMoveDown, bool canMoveRight, bool canMoveLeft) {
bool didMove = false;

//Moves with key presses
if (isGhost)
{
if (Input.GetKeyDown(KeyCode.W))
{
if (currPI >= nSides)
{
transform.SetParent(transform.parent.parent.GetChild(currPI - nSides));
}
}
if (Input.GetKeyDown(KeyCode.A))
{
if ((currPI > 0) && (currPI % nSides != 0))
{
transform.SetParent(transform.parent.parent.GetChild(currPI - 1));
}
}
if (Input.GetKeyDown(KeyCode.S))
{
if (currPI <= (nSides*nSides - nSides))
{
transform.SetParent(transform.parent.parent.GetChild(currPI + nSides));
}
}
if (Input.GetKeyDown(KeyCode.D))
{
if ((currPI < (nSides*nSides - 1)) && !onRightEdges(currPI))
{
transform.SetParent(transform.parent.parent.GetChild(currPI + 1));
}
}
} else
if (canMoveUp && Input.GetKeyDown(KeyCode.W) && position.y < 0f)
{
if (Input.GetKeyDown(KeyCode.W))
{
path.Enqueue(KeyCode.W);

}
if (Input.GetKeyDown(KeyCode.A))
{

path.Enqueue(KeyCode.A);

}
if (Input.GetKeyDown(KeyCode.S))
{

path.Enqueue(KeyCode.S);
}
if (Input.GetKeyDown(KeyCode.D))
{

path.Enqueue(KeyCode.D);

}
path.Enqueue(KeyCode.W);
rect.anchoredPosition = position;
position += Vector2.up*50f;
didMove = true;
}

}

public override void Move()
{
//Debug.Log("GRANNY GOTTA MOVE");
if (path.Count > 0)
if (canMoveLeft && Input.GetKeyDown(KeyCode.A) && position.x > 0f)
{
KeyCode key = path.Dequeue();
if (key == KeyCode.W)
{
transform.SetParent(transform.parent.parent.GetChild(currPI - nSides));
}
else if (key == KeyCode.A)
{
transform.SetParent(transform.parent.parent.GetChild(currPI - 1));
}
else if (key == KeyCode.S)
{
transform.SetParent(transform.parent.parent.GetChild(currPI + nSides));
}
else if (key == KeyCode.D)
{
transform.SetParent(transform.parent.parent.GetChild(currPI + 1));
}
path.Enqueue(KeyCode.A);
rect.anchoredPosition = position;
position += Vector2.left*50f;
didMove = true;
}
}

private void calcRightEdges()
{
//Debug.Log("calcing right edges");
for (int i = 0; i <= nSides; i++)
if (canMoveDown && Input.GetKeyDown(KeyCode.S) && position.y > -50f*(LevelManager.instance.numSides-1))
{
rightEdges[i] = (i * nSides) - 1;
path.Enqueue(KeyCode.S);
rect.anchoredPosition = position;
position += Vector2.down*50f;
didMove = true;
}
}

public bool onRightEdges(int index)
{
//Debug.Log("checking right edges");
bool toReturn = false;
foreach (int x in rightEdges) {
toReturn = (index == x);
if (canMoveRight && Input.GetKeyDown(KeyCode.D) && position.x < 50f*(LevelManager.instance.numSides-1))
{
path.Enqueue(KeyCode.D);
rect.anchoredPosition = position;
position += Vector2.right*50f;
didMove = true;
}

return toReturn;
return didMove;
}

void Update() {
rect.anchoredPosition = Vector2.MoveTowards(rect.anchoredPosition, position, Time.deltaTime*400f);
}
}
@@ -0,0 +1,68 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GrandmaMove : MonoBehaviour {

[HideInInspector]
public RectTransform rect;

[HideInInspector]
public Queue<KeyCode> path;

[HideInInspector]
public Vector2 position;

void Start() {
rect = GetComponent<RectTransform>();
}

public void ResetGranny(Vector2 position) {
StopAllCoroutines();
rect.anchoredPosition = position;
this.position = position;
path.Clear();
}

public int Move() {
if (path.Count > 0) {
KeyCode nextMovement = path.Dequeue();
switch(nextMovement) {

case KeyCode.W:
position += Vector2.up*50f;
StartCoroutine(MoveAnim(position));
break;
case KeyCode.A:
position += Vector2.left*50f;
StartCoroutine(MoveAnim(position));
break;
case KeyCode.S:
position += Vector2.down*50f;
StartCoroutine(MoveAnim(position));
break;
case KeyCode.D:
position += Vector2.right*50f;
StartCoroutine(MoveAnim(position));
break;
default:
return int.Parse(nextMovement.ToString().Substring(nextMovement.ToString().Length - 1));
break;

}
}
return -1;
}

protected IEnumerator MoveAnim(Vector2 newPosition) {
float timer = 0f;

while(timer < 1f) {
timer += Time.deltaTime*10f;
rect.anchoredPosition = Vector2.Lerp(rect.anchoredPosition, newPosition, timer);
yield return new WaitForEndOfFrame();
}
rect.anchoredPosition = newPosition;
yield return null;
}
}

This file was deleted.

@@ -3,120 +3,286 @@
using UnityEngine.SceneManagement;
using System.Collections.Generic;
using UnityEngine.UI;
using System;

public class LevelManager : MonoBehaviour {

public static LevelManager instance;

//How many sides does the level have?
/// <summary>
/// How many sides does the level have?
/// </summary>
public int numSides = 5;

public Movement[] monsters;
public Movement granny;
/// <summary>
/// The max number of moves the player can make
/// </summary>
public int maxMoves = 10;
private int movesLeft;
public Text moveCounter;

/// <summary>
/// Automatically finds all entities that move
/// </summary>
private Movement[] entities;
private Vector2[] startingPositions;
private GrandmaGhostMove ghost;
private GrandmaMove granny;

//Timer stuff
public float timer;
private float timerValue;
private bool grannyMovedLast;

//Signifies end location for level
public Movement endSquare;
//Holds all traps
public Trap[] traps;
public RectTransform spawnPoint, winPoint;

//Contains all the obstacles in the scene that no one can walk on
public RectTransform[] obstacles;

//Which traps are you allowed on this level?
public GameObject[] availableTraps;

//stores trap ghosts
public GameObject[] trapGhosts;

//How many of each trap are you allowed on this level?
public int[] trapCount;

//Maps each available trap to the number available for that trap
private Dictionary<Trap, int> traps;

//Holds all the traps that have been spawned
private List<GameObject> spawnedTraps, spawnedTrapGhosts;

//reference to the inventory parent
public RectTransform inventory;

//Holds the cat
public RectTransform kitty;
private bool kittyCollected;

//State machine manager
public enum GameState {Planning, Executing, Win, Dead};
private GameState state;

//Keeping track of UI levels
public GameObject actionLayer;
public GameObject trapLayer;
public GameObject ghostLayer;
//Reference to the world parent
public RectTransform world;

//Signifies active, win, and lose states
private bool executing;
private bool won;
private bool dead;
//Reference to the game state text object
public Text gameStateText;

#region MonoBehavior Functions
//Creates instance of level manager, sets timer
void Start () {
instance = this;
timerValue = timer;
entities = FindObjectsOfType<Movement>();
ghost = FindObjectOfType<GrandmaGhostMove>();
granny = FindObjectOfType<GrandmaMove>();

traps = new Dictionary<Trap, int>();
for(int i = 0; i < trapCount.Length; i++) {
traps.Add(availableTraps[i].GetComponent<Trap>(), trapCount[i]);
inventory.GetChild(i).GetChild(0).GetComponent<Text>().text = traps[availableTraps[i].GetComponent<Trap>()].ToString();
}

spawnedTraps = new List<GameObject>();
spawnedTrapGhosts = new List<GameObject>();

startingPositions = new Vector2[entities.Length];
for(int i = 0; i < entities.Length; i++) {
startingPositions[i] = entities[i].GetComponent<RectTransform>().anchoredPosition;
}

movesLeft = maxMoves;
moveCounter.text = movesLeft.ToString();
}

void Update () {

//Hitting space activates the level; No more movements can be input.
if(Input.GetKeyDown(KeyCode.Space)) {
populateTrapArray();
executing = true;
switch(state) {

case GameState.Planning:
HandlePlanning();
break;
case GameState.Executing:
HandleExecuting();
break;
case GameState.Win:
HandleWin();
break;
case GameState.Dead:
HandleDead();
break;

}

//Hitting R resets the scene. TODO: FIX THIS WHEN MENUS ARE SET
if (Input.GetKeyDown(KeyCode.R))
{
SceneManager.LoadScene(0);
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}

//if u ded
if (dead)
{
executing = false;
}
}
#endregion



//if the level is active...
if (executing) {
if(timerValue < 0) {
timerValue = timer;
foreach (Movement m in monsters) {
if (m.active)
{
m.Move();
}
#region Game State Machine
private void HandlePlanning() {
bool canMoveUp = true, canMoveDown = true, canMoveLeft = true, canMoveRight = true;
for(int i = 0; i < obstacles.Length; i++) {
if(ghost.position + Vector2.up*50f == obstacles[i].anchoredPosition) canMoveUp = false;
if(ghost.position + Vector2.down*50f == obstacles[i].anchoredPosition) canMoveDown = false;
if(ghost.position + Vector2.left*50f == obstacles[i].anchoredPosition) canMoveLeft = false;
if(ghost.position + Vector2.right*50f == obstacles[i].anchoredPosition) canMoveRight = false;
}

//Updates the ghost's position only in the planning stage
if(movesLeft > 0 && ghost.UpdateGhostPosition(canMoveUp, canMoveDown, canMoveRight, canMoveLeft)) {
movesLeft--;
moveCounter.text = movesLeft.ToString();
}

//Places traps
for(int i = 0; i < availableTraps.Length; i++) {
if(Input.GetKeyDown((KeyCode)Enum.Parse(typeof(KeyCode), "Alpha" + (i+1))) && traps[availableTraps[i].GetComponent<Trap>()] > 0) {
ghost.path.Enqueue((KeyCode)Enum.Parse(typeof(KeyCode), "Alpha" + (i+1)));
traps[availableTraps[i].GetComponent<Trap>()]--;
inventory.GetChild(i).GetChild(0).GetComponent<Text>().text = traps[availableTraps[i].GetComponent<Trap>()].ToString();
GameObject temp = (GameObject)GameObject.Instantiate(trapGhosts[i], world);
temp.GetComponent<RectTransform>().anchoredPosition = ghost.position;
temp.transform.localScale = Vector3.one;
temp.transform.SetSiblingIndex(ghost.transform.GetSiblingIndex() - 1);
spawnedTrapGhosts.Add(temp);
}
}

//Changes the state to the executing stage
if(Input.GetKeyDown(KeyCode.Space)) {
GoGrannyGo();
}

}

private void HandleExecuting() {
if(timerValue < 0) {
timerValue = timer;
if(grannyMovedLast) {
foreach (Movement m in entities) {
if (m.active) {
bool canMoveUp = true, canMoveDown = true, canMoveLeft = true, canMoveRight = true;
for(int i = 0; i < obstacles.Length; i++) {
if(m.position + Vector2.up*50f == obstacles[i].anchoredPosition) canMoveUp = false;
if(m.position + Vector2.down*50f == obstacles[i].anchoredPosition) canMoveDown = false;
if(m.position + Vector2.left*50f == obstacles[i].anchoredPosition) canMoveLeft = false;
if(m.position + Vector2.right*50f == obstacles[i].anchoredPosition) canMoveRight = false;
}

m.Move(canMoveUp, canMoveDown, canMoveRight, canMoveLeft);
}
}
granny.Move();
} else {
timerValue -= Time.deltaTime;
int spawn = granny.Move();
if(spawn != -1) {
GameObject temp = (GameObject)GameObject.Instantiate(availableTraps[spawn-1], world);
temp.GetComponent<RectTransform>().anchoredPosition = granny.position;
temp.transform.localScale = Vector3.one;
temp.transform.SetSiblingIndex(granny.transform.GetSiblingIndex() - 1);
spawnedTraps.Add(temp);
}
}
HandleCollision();
grannyMovedLast = !grannyMovedLast;
} else {
timerValue -= Time.deltaTime;
}
HandleCollision();
}

//if win state is achieved...
if (won)
{
executing = false;
}
private void HandleDead() {
if(Input.GetKeyDown(KeyCode.Space)) {
ResetGranny();
}
}

//TODO: MAKE THIS NOT SUCK ASS
void HandleCollision() {
//Check for gma collisions w monsters
for (int i = 0; i < monsters.Length; i++)
{
if (granny.transform.parent.Equals(monsters[i].transform.parent))
{
dead = true;
granny.GetComponent<Image>().enabled = false;
}
}
private void HandleWin() {

//Check for monster collision w traps. ACCOUNT FOR LAYERS
for (int i = 0; i < monsters.Length; i++)
{
for (int j = 0; j < traps.Length; j++)
{
if (monsters[i].transform.GetSiblingIndex() == traps[j].transform.GetSiblingIndex())
{
monsters[i].active = false;
}
}
}
}
#endregion

//Check if gma is at end square
/*if (granny.transform.GetSiblingIndex() == endSquare.transform.GetSiblingIndex())
{
won = true;
}*/

#region Helper Functions
void HandleCollision() {
foreach (Movement m in entities) {
if(m.active) {
if(m.position == granny.position) {
KillGranny();
}
for(int i = 0; i < spawnedTraps.Count; i++) {
spawnedTraps[i].GetComponent<Trap>().Spring(m);
}
}
}
if(granny.position == winPoint.anchoredPosition && kittyCollected) {
WinGranny();
} else if(granny.position == kitty.anchoredPosition) {
kittyCollected = true;
kitty.GetComponent<CanvasGroup>().alpha = 0f;
} else if(granny.path.Count == 0) {
ResetGranny();
}
}

public void populateTrapArray()
{
//aaaaaa
}
void KillGranny() {
state = GameState.Dead;
gameStateText.text = state.ToString();
}

void ResetGranny() {
state = GameState.Planning;
granny.ResetGranny(spawnPoint.anchoredPosition);
ghost.ResetGhost(spawnPoint.anchoredPosition);
gameStateText.text = state.ToString();

for(int i = 0; i < entities.Length; i++) {
entities[i].Reset(startingPositions[i]);
}

movesLeft = maxMoves;
moveCounter.text = movesLeft.ToString();
kitty.GetComponent<CanvasGroup>().alpha = 1f;

for(int i = 0; i < spawnedTraps.Count; i++) {
Destroy(spawnedTraps[i]);
}
spawnedTraps.Clear();

for(int i = 0; i < spawnedTrapGhosts.Count; i++) {
Destroy(spawnedTrapGhosts[i]);
}
spawnedTrapGhosts.Clear();

for(int i = 0; i < trapCount.Length; i++) {
traps[availableTraps[i].GetComponent<Trap>()] = trapCount[i];
//Sets the available number of traps
inventory.GetChild(i).GetChild(0).GetComponent<Text>().text = traps[availableTraps[i].GetComponent<Trap>()].ToString();
}
}

void GoGrannyGo() {
state = GameState.Executing;
granny.path = ghost.path;
gameStateText.text = state.ToString();
}

void WinGranny() {
state = GameState.Win;
gameStateText.text = state.ToString();
}

public float MoveLerpValue() {
return timerValue/timer;
}

#endregion
}
@@ -0,0 +1,14 @@
using UnityEngine;
using System.Collections;
using UnityEngine.SceneManagement;

public class MainMenuManager : MonoBehaviour {

public void PlayPressed() {
SceneManager.LoadScene(2);
}

public void CreditsPressed() {
SceneManager.LoadScene("Credits");
}
}

This file was deleted.

@@ -4,8 +4,38 @@
//Parent for different types of object movement
public class Movement : MonoBehaviour {

[HideInInspector]
public bool active = true;

public virtual void Move() { }
[HideInInspector]
public Trap trap;

[HideInInspector]
public RectTransform rect;

[HideInInspector]
public Vector2 position;

protected virtual void Start() {
rect = GetComponent<RectTransform>();
}

public virtual void Move(bool canMoveUp, bool canMoveDown, bool canMoveRight, bool canMoveLeft) {
if(trap != null) trap.HandleTrap(this);
}

public virtual void Reset(Vector2 resetPosition) { }

protected IEnumerator MoveAnim(Vector2 newPosition) {
float timer = 0f;

while(timer < 1f) {
timer += Time.deltaTime*10f;
rect.anchoredPosition = Vector2.Lerp(rect.anchoredPosition, newPosition, timer);
yield return new WaitForEndOfFrame();
}
rect.anchoredPosition = newPosition;
yield return null;
}

}
@@ -0,0 +1,109 @@
using UnityEngine;
using System.Collections;

public class SingleDirectionMovement : Movement {

//Sets if object is moving up/down or left/right
public bool upDown;

//distance - how many moves are made before reversing directions
public int distance;

private int distanceTraveled = 0;
private bool movingPositive = true;
private int numSides;

protected override void Start ()
{
base.Start ();
numSides = LevelManager.instance.numSides;
if(distance < 0) {
movingPositive = false;
} else {
movingPositive = true;
}
this.position = rect.anchoredPosition;
}

public override void Reset (Vector2 resetPosition)
{
base.Reset (resetPosition);
distanceTraveled = 0;
if(distance < 0) {
movingPositive = false;
} else {
movingPositive = true;
}
rect.anchoredPosition = resetPosition;
this.position = resetPosition;
}


public override void Move (bool canMoveUp, bool canMoveDown, bool canMoveRight, bool canMoveLeft)
{
base.Move (canMoveUp, canMoveDown, canMoveRight, canMoveLeft);
if(trap != null && trap.interruptMovement) return;

if(upDown) {
if(movingPositive) {
if(distanceTraveled < Mathf.Abs(distance)) {
if (canMoveUp && rect.anchoredPosition.y < -50f) {
position += Vector2.up*50f;
StartCoroutine(MoveAnim(position));
distanceTraveled++;
} else {
movingPositive = !movingPositive;
distanceTraveled = 0;
}
} else if(distanceTraveled == Mathf.Abs(distance)) {
movingPositive = false;
distanceTraveled = 0;
}
} else {
if(distanceTraveled < Mathf.Abs(distance)) {
if (canMoveDown && rect.anchoredPosition.y > -50*numSides) {
position -= Vector2.up*50f;
StartCoroutine(MoveAnim(position));
distanceTraveled++;
} else {
movingPositive = !movingPositive;
distanceTraveled = 0;
}
} else if(distanceTraveled == Mathf.Abs(distance)) {
movingPositive = true;
distanceTraveled = 0;
}
}
} else {
if(movingPositive) {
if(distanceTraveled < Mathf.Abs(distance)) {
if (canMoveRight && rect.anchoredPosition.x < 50f*(numSides-1)) {
position += Vector2.right*50f;
StartCoroutine(MoveAnim(position));
distanceTraveled++;
} else {
movingPositive = !movingPositive;
distanceTraveled = 0;
}
} else if(distanceTraveled == Mathf.Abs(distance)) {
movingPositive = false;
distanceTraveled = 0;
}
} else {
if(distanceTraveled < Mathf.Abs(distance)) {
if (canMoveLeft && rect.anchoredPosition.x > 0) {
position -= Vector2.right*50f;
StartCoroutine(MoveAnim(position));
distanceTraveled++;
} else {
movingPositive = !movingPositive;
distanceTraveled = 0;
}
} else if(distanceTraveled == Mathf.Abs(distance)) {
movingPositive = true;
distanceTraveled = 0;
}
}
}
}
}

This file was deleted.

@@ -5,21 +5,22 @@
//TODO: refactor to handle types,
public class Trap : MonoBehaviour {

public bool active;
//Assign type, handle action when called on accordingly
public enum TYPE { Sticky, Pushy, Switchy};

//Makes trap visible if active
public void turnOnIfApplicable() {
if (active)
{
GetComponent<SpriteRenderer>().enabled = true;
}
public bool active, interruptMovement;

protected RectTransform rect;

protected void Start() {
rect = GetComponent<RectTransform>();
}

//springs active traps
public void spring()
{
//TODO: handle each type of trap
}
/// <summary>
/// Override this function to handle HOW the trap is 'sprung'
/// </summary>
/// <param name="target">Target.</param>
public virtual void Spring(Movement target) { }

/// <summary>
/// Override this to make the target move a specific way
/// </summary>
public virtual void HandleTrap(Movement target) { }
}
@@ -0,0 +1,18 @@
using UnityEngine;
using System.Collections;

public class Trap_DentureCream : Trap {

public override void Spring (Movement target)
{
if(target == null || rect == null) return;
base.Spring (target);
if(target.position == rect.anchoredPosition) {
target.trap = this;
}
}

public override void HandleTrap (Movement target) {
base.HandleTrap (target);
}
}
Deleted file not rendered
Deleted file not rendered

This file was deleted.

Deleted file not rendered

This file was deleted.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Deleted file not rendered

This file was deleted.

Deleted file not rendered

This file was deleted.

Deleted file not rendered
Deleted file not rendered

This file was deleted.

Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Deleted file not rendered
Deleted file not rendered
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
BIN +39.6 KB Assets/shittybg.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -6,4 +6,10 @@ EditorBuildSettings:
serializedVersion: 2
m_Scenes:
- enabled: 1
path: Assets/Scenes/demo.unity
path: Assets/Scenes/Menus/Main Menu.unity
- enabled: 1
path: Assets/Scenes/Menus/Level Select.unity
- enabled: 1
path: Assets/Scenes/demos and testing/OH DANG SON.unity
- enabled: 1
path: Assets/Scenes/Menus/Credits.unity
@@ -74,7 +74,6 @@ PlayerSettings:
ignoreAlphaClear: 0
xboxOneResolution: 0
xboxOneMonoLoggingLevel: 0
xboxOneLoggingLevel: 1
ps3SplashScreen: {fileID: 0}
videoMemoryForVertexBuffers: 0
psp2PowerMode: 0
@@ -285,7 +284,6 @@ PlayerSettings:
ps4PatchPkgPath:
ps4PatchLatestPkgPath:
ps4PatchChangeinfoPath:
ps4PatchDayOne: 0
ps4attribUserManagement: 0
ps4attribMoveSupport: 0
ps4attrib3DSupport: 0
@@ -375,7 +373,6 @@ PlayerSettings:
tizenSigningProfileName:
tizenGPSPermissions: 0
tizenMicrophonePermissions: 0
tizenMinOSVersion: 0
n3dsUseExtSaveData: 0
n3dsCompressStaticMem: 1
n3dsExtSaveDataNumber: 0x12345
@@ -414,8 +411,12 @@ PlayerSettings:
intPropertyNames:
- Standalone::ScriptingBackend
- WebPlayer::ScriptingBackend
- iOS::Architecture
- iOS::ScriptingBackend
Standalone::ScriptingBackend: 0
WebPlayer::ScriptingBackend: 0
iOS::Architecture: 2
iOS::ScriptingBackend: 1
boolPropertyNames:
- Android::VR::enable
- Metro::VR::enable
@@ -1,2 +1,2 @@
m_EditorVersion: 5.4.1f1
m_EditorVersion: 5.4.0f3
m_StandardAssetsVersion: 0