<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class BombBox : MonoBehaviour
{
    public GameObject cannonBall;
    public static bool cannonBallExists;
    List<GameObject> currentCannonballs = new List<GameObject>();

    private void Update()
    {
        if (GameObject.Find("Cannonball") != null)
        {
            cannonBallExists = true;
        }
        else
        {
            cannonBallExists = false;
        }
    }

    public void DestroyCannonBalls()
    {
        for (int i = 0; i < GameObject.FindGameObjectsWithTag("ActionObject").Length; i++)
        {
            if (GameObject.FindGameObjectsWithTag("ActionObject")[i].name == "Cannonball")
            {
                if (!GameObject.FindGameObjectsWithTag("ActionObject")[i].gameObject.GetComponent<CannonBall>().active)
                {
                    currentCannonballs.Add(GameObject.FindGameObjectsWithTag("ActionObject")[i]);
                }
            }
        }
        for (int i = 0; i < currentCannonballs.Count; i++)
        {
            GameObject CB = currentCannonballs[i];
            currentCannonballs.Remove(CB);
            Object.Destroy(CB);
        }
    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerActions : MonoBehaviour {

    //components
    SkinnedMeshRenderer smr;

    //action vars
    public static GameObject slotA;
    public static GameObject slotB;
    PlayerMovementCC pm;
    public static bool dead;
    public static Vector3 lastSpawnPos;

    //the slots will be replaced with bone objects later
    public static GameObject slotAObj = null;
    public static GameObject slotBObj = null;
    public static GameObject targetObject;
    public List<GameObject> targetObjectList = new List<GameObject>();
    //ones slots are replaced with bones, these will not need to exist. or perhaps be swapped with slotA/B tracktransforms scripts because they will probable need them afterwords.
    TrackTransforms slotBTransTracker;
    TrackTransforms slotATransTracker;

    void Start ()
    {
        slotA = GameObject.Find("SlotA");
        slotB = GameObject.Find("SlotB");
        slotATransTracker = slotA.GetComponent<TrackTransforms>();
        slotBTransTracker = slotB.GetComponent<TrackTransforms>();
        pm = PersistentManager.Instance.Player.GetComponent<PlayerMovementCC>();
        smr = GetComponentInChildren<SkinnedMeshRenderer>();
    }
	
	void Update ()
    {
        //GENERAL VARIABLE UPDATES
        VarUpdate();
        //ACTION INPUTS
        ActionInput();
    }

    //VARIABLE MANAGEMENT FUNCTIONS
    void VarUpdate()
    {
        //MOVEMENT VARS_____________________________________________________________________________________________________________________________
        //ACTION VARS_____________________________________________________________________________________________________________________________
        //determine target keyitem through distance of surrounding keyitems
        float dist = 3.0f;
        for (int i = 0; i < targetObjectList.Count; i++)
        {
            if (targetObjectList[i] != false)
            {
                float d = Vector3.Distance(targetObjectList[i].transform.position, gameObject.transform.position);
                if (d < dist)
                {
                    dist = d;
                    targetObject = targetObjectList[i];
                }
            }
            else
            {
                targetObjectList.Remove(targetObjectList[i]);
            }
        }
        if (targetObjectList.Count == 0)
        {
            targetObject = null;
        }
        //reset things
        targetObjectList.RemoveAll(GameObject => GameObject == null);
    }
    //ACTION INPUT FUNCTIONS
    void ActionInput()
    {
        if (slotBObj != null && !PlayerMovementCC.grounded)
        {
            if (!slotBObj.GetComponentInChildren<KeyItem>().drop && PlayerMovementCC.footRayDist > 1)
            {
                slotBObj.GetComponentInChildren<KeyItem>().Drop();
            }
        }
        if (slotAObj != null && !PlayerMovementCC.grounded && PlayerMovementCC.footRayDist > 1)
        {
            if (!slotAObj.GetComponentInChildren<KeyItem>().drop)
            {
                slotAObj.GetComponentInChildren<KeyItem>().Drop();
            }
        }
        if (Input.GetButtonDown("Action1"))
        {
            //pickup/drop/swap keyitem from slotB
            if (targetObject != null && !PlayerMovementCC.crouched)
            {
                if (targetObject.name == "BombBox")
                {
                    if (slotBObj == null)
                    {
                        if (targetObject.GetComponentInChildren<KeyItem>().BSwap)
                        {
                            if (BombBox.cannonBallExists)
                            {
                                targetObject.GetComponent<BombBox>().DestroyCannonBalls();
                            }
                            GameObject CB = (GameObject)Instantiate(targetObject.GetComponentInParent<BombBox>().cannonBall, targetObject.transform.position, Quaternion.Euler(0,0,0));
                            CB.name = "Cannonball";
                            CB.GetComponentInChildren<KeyItem>().Pickup(slotB, slotBObj);
                            if (targetObjectList.Contains(targetObject))
                            {
                                targetObjectList.Remove(targetObject);
                            }
                        }
                        return;
                    }
                }
                else
                {
                    if (slotBObj == null)
                    {
                        if (targetObject.GetComponentInChildren<KeyItem>().BSwap)
                        {
                            targetObject.GetComponentInChildren<KeyItem>().Pickup(slotB, slotBObj);
                            if (targetObjectList.Contains(targetObject))
                            {
                                targetObjectList.Remove(targetObject);
                            }
                        }
                        return;
                    }
                    if (slotBObj != null)
                    {
                        if (slotBObj.GetComponentInChildren<KeyItem>().BSwap)
                        {
                            targetObject.GetComponentInChildren<KeyItem>().Pickup(slotB, slotBObj);
                            if (targetObjectList.Contains(targetObject))
                            {
                                targetObjectList.Remove(targetObject);
                            }
                            return;
                        }
                    }
                }
            }
            else if (slotBObj != null)
            {
                if (slotBObj.GetComponentInChildren<KeyItem>().drop)
                {
                    slotBObj.GetComponentInChildren<KeyItem>().Drop();
                }
            }
        }
        if (Input.GetButtonDown("Action2"))
        {
            if (!PlayerMovementCC.crouched)
            {
                if (slotBObj != null)
                {
                    if (slotAObj != null)
                    {
                        if (slotBObj.GetComponentInChildren<KeyItem>().ABSwap && slotAObj.GetComponentInChildren<KeyItem>().ABSwap)
                        {
                            slotBObj.GetComponentInChildren<KeyItem>().Swap(slotA);
                            slotAObj.GetComponentInChildren<KeyItem>().Swap(slotB);
                            AssignNewSlotObjects(slotBObj, slotAObj, false);
                            if (PlayerMovementCC.footRay.direction.y != 1)
                            {
                                PlayerMovementCC.swapKeyItemSpeedDamp = true;
                            }
                            HUDManager.swap = true;
                        }
                        return;
                    }
                    else
                    {
                        if (slotBObj.GetComponentInChildren<KeyItem>().ABSwap)
                        {
                            slotBObj.GetComponentInChildren<KeyItem>().Swap(slotA);
                            AssignNewSlotObjects(slotBObj, null, false);
                            HUDManager.swap = true;
                        }
                        return;
                    }                    
                }
                if (slotAObj != null)
                {
                    if (slotAObj.GetComponentInChildren<KeyItem>().ABSwap)
                    {
                        slotAObj.GetComponentInChildren<KeyItem>().Swap(slotB);
                        AssignNewSlotObjects(null, slotAObj, false);
                        HUDManager.swap = true;
                    }
                    return;
                }
            }
        }
        if (Input.GetButtonDown("Action3"))
        {
            if (!PlayerMovementCC.crouched)
            {
                if (slotBObj != null)
                {
                    if (slotAObj != null)
                    {
                        if (slotAObj.name == "Cannon" && slotBObj.name == "Cannonball" && !slotAObj.GetComponent<CannonLauncher>().loaded && slotBObj.GetComponentInChildren<KeyItem>().crouch && slotAObj.GetComponentInChildren<KeyItem>().crouch)
                        {
                            slotBObj.GetComponentInChildren<MeshRenderer>().enabled = false;
                            PlayerMovementCC.crouched = true;
                        }
                        if (slotAObj.GetComponentInChildren<KeyItem>().crouch && slotBObj.GetComponentInChildren<KeyItem>().crouch)
                        {
                            PlayerMovementCC.crouched = true;
                        }
                    }
                    else
                    {
                        if (slotBObj.GetComponentInChildren<KeyItem>().crouch)
                        {
                            PlayerMovementCC.crouched = true;
                        }
                    }
                }
                if (slotAObj != null && slotBObj == null)
                {
                    if (slotAObj.GetComponentInChildren<KeyItem>().crouch)
                    {
                        PlayerMovementCC.crouched = true;
                    }
                }
                if (slotAObj == null && slotBObj == null)
                {
                    PlayerMovementCC.crouched = true;
                }
            }
        }
        if (Input.GetButtonUp("Action3"))
        {
            if (slotAObj != null && slotBObj != null)
            {
                if (slotAObj.name == "Cannon")
                {
                    if (!slotAObj.GetComponent<CannonLauncher>().loaded && slotBObj.name == "Cannonball" && PlayerMovementCC.crouched && PlayerMovementCC.grounded)
                    {
                        Destroy(slotBObj);
                        slotAObj.GetComponent<CannonLauncher>().loaded = true;
                    }
                }
            }
            if (PlayerMovementCC.crouched && PlayerMovementCC.grounded)
            {
                PlayerMovementCC.crouched = false;
            }
        }
        if (Input.GetButtonDown("Action4"))
        {
            if (slotAObj != null)
            {
                if (slotAObj.GetComponentInChildren<KeyItem>().drop)
                {
                    slotAObj.GetComponent<KeyItemUse>().Use();
                }
            }
        }
        //vvv for propeller vvv
        if (Input.GetButtonUp("Action4"))
        {
            if (slotAObj != null)
            {
                if (slotAObj.GetComponentInChildren<KeyItem>().drop && PlayerMovementCC.gravity != -4f)
                {
                    PlayerMovementCC.gravity = -4f;
                }
            }
        }
    }
    public void AssignNewSlotObjects(GameObject newA, GameObject newB, bool invertAssignmentOrder)
    {
        GameObject a = newA;
        GameObject b = newB;
        if (invertAssignmentOrder)
        {
            slotBObj = b;
            slotAObj = a;
        }
        else
        {
            slotAObj = a;
            slotBObj = b;
        }

    }
    IEnumerator respawnCoroutine(Vector3 Pos)
    {
        PlayerMovementCC.walkSpeed = 0f;
        PlayerMovementCC.velocity = Vector3.zero;
        smr.enabled = false;
        yield return new WaitForSeconds(0.6f);
        transform.position = Pos;
        dead = false;
        PlayerMovementCC.walkSpeed = 2.5f;
        for (int i = 0; i < 5; i++)
        {
            yield return new WaitForSeconds(0.1f);
            if (smr.enabled)
            {
                smr.enabled = false;
            }
            else
            {
                smr.enabled = true;
            }
        }
    }
    public void Die(Vector3 respawnPos)
    {
        lastSpawnPos = respawnPos;
        dead = true;
        if (slotAObj != null)
        {
            slotAObj.GetComponentInChildren<KeyItem>().Drop();
        }
        if (slotBObj != null)
        {
            slotBObj.GetComponentInChildren<KeyItem>().Drop();
        }
        if (slotBObj == null && slotAObj == null)
        {
            StartCoroutine(respawnCoroutine(respawnPos));
        }
    }

    private void OnTriggerExit(Collider other)
    {
        if (other.gameObject.tag == "ActionObject" && other.gameObject.transform.parent.gameObject.layer == 13)
        {
            if (targetObjectList.Contains(other.gameObject.transform.parent.gameObject))
            {
                targetObjectList.Remove(other.gameObject.transform.parent.gameObject);
            }
        }
        if (other.gameObject.layer == 18)
        {
            PersistentManager.Instance.CurrentAreaID = "";
        }
    }
    private void OnTriggerStay(Collider other)
    {
        if (other.gameObject.name == "Cannonball")
        {
            print("Its dayuh");
        }
        if (other.gameObject.tag == "ActionObject" && other.gameObject.transform.parent.gameObject.layer == 13)
        {
            if (!targetObjectList.Contains(other.gameObject.transform.parent.gameObject))
            {
                targetObjectList.Add(other.gameObject.transform.parent.gameObject);
            }
        }
        if (other.gameObject.layer == 17 && PersistentManager.Instance.CurrentPuzzleID != other.gameObject.name)
        {
            PersistentManager.Instance.CurrentPuzzleID = other.gameObject.name;
        }
        if (other.gameObject.layer == 18 && PersistentManager.Instance.CurrentAreaID != other.gameObject.name)
        {
            PersistentManager.Instance.CurrentAreaID = other.gameObject.name;
        }
    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;


[ExecuteInEditMode]
public class FloorButton : MonoBehaviour {

    int buttonIDNumber;
    Animator anim;
    public GameObject reticleBone;
    public bool pressed;

    //maybe temporary??
    public bool playerblocked;

    private void Awake()
    {
        anim = transform.parent.GetComponent<Animator>();
    }

    void Update()
    {
        pressed = anim.GetBool("Pressed");
        if (anim == null)
        {
            anim = transform.parent.GetComponent<Animator>();
        }
        string[] nameArray = transform.parent.name.Split('_');
        int i = 0;
        foreach (var item in nameArray)
        {
            int.TryParse(nameArray[i], out buttonIDNumber);
            i++;
        }
        if (nameArray.Length != 2)
        {
            print(gameObject.name + " NOT NAMED CORRECTLY");
        }
        if (GameObject.Find("ButtonReceiver_" + buttonIDNumber) != null)
        {
            if (GameObject.Find("ButtonReceiver_" + buttonIDNumber).GetComponent<ButtonReceiver>().idle && anim.GetBool("Pressed"))
            {
                anim.SetBool("Pressed", false);
            }
        }
        else if (anim.GetBool("Pressed"))
        {
            anim.SetBool("Pressed", false);
        }
    }

    private void OnDrawGizmos()
    {
        switch (buttonIDNumber)
        {
            case 1:
                Gizmos.color = Color.green;
                break;
            case 2:
                Gizmos.color = Color.red;
                break;
            case 3:
                Gizmos.color = Color.blue;
                break;
            default:
                Gizmos.color = Color.black;
                break;
        }
    }

    //send a bool toggle to all receivers
    void SendSignal()
    {
        GameObject[] recs = GameObject.FindGameObjectsWithTag("Receiver");
        for (int i = 0; i < recs.Length; i++)
        {
            if (recs[i].name == "ButtonReceiver_" + buttonIDNumber && recs[i].GetComponent<ButtonReceiver>().powered)
            {
                recs[i].GetComponent<ButtonReceiver>().Move();
            }
        }
        //if (GameObject.Find("ButtonReceiver_" + buttonIDNumber) != null)
        //{
        //    if (GameObject.Find("ButtonReceiver_" + buttonIDNumber).GetComponent<ButtonReceiver>().powered)
        //    {
        //        GameObject.Find("ButtonReceiver_" + buttonIDNumber).GetComponent<ButtonReceiver>().Move();
        //    }
        //}
    }

    private void OnTriggerEnter(Collider other)
    {
        if (PlayerActions.slotAObj != null && PlayerMovementCC.crouched && !playerblocked)
        {
            if (PlayerActions.slotAObj.name == "Hammer" && !anim.GetBool("Pressed"))
            {
                anim.SetBool("Pressed", true);
                SendSignal();
            }
        }
        if (other.name == "Player")
        {
            playerblocked = true;
        }
    }
    private void OnTriggerStay(Collider other)
    {
        if (other.name == "Player")
        {
            playerblocked = true;
        }
    }
    private void OnTriggerExit(Collider other)
    {
        if (other.name == "Player")
        {
            playerblocked = false;
        }
    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class HUDManager : MonoBehaviour {

    Transform actionList;
    static public bool swap;
    float oldSwapTo = 360;
    static public float swapTo = 180;
    public GameObject swapPanel;
    Dictionary<string, Sprite> itemSprites = new Dictionary<string, Sprite>();
    public Sprite hammerSprite;
    public Sprite cannonSprite;
    public Sprite propellerSprite;
    public Sprite cannonballSprite;
    public Sprite diamondSprite;
    public Sprite nullSprite;
    GameObject slotAPanel;
    GameObject slotBPanel;
    public GameObject pickupButton;
    public GameObject swapButton;
    public GameObject dropButton;
    public GameObject pickupKey;
    public GameObject swapKey;
    public GameObject dropKey;

    void Start()
    {
        actionList = transform.GetChild(0).transform.GetChild(1);
        for (int i = 0; i < FindObjectsOfType<Image>().Length; i++)
        {
            FindObjectsOfType<Image>()[i].color = PersistentManager.Instance.HUDColor;
        }
        itemSprites.Add("Hammer", hammerSprite);
        itemSprites.Add("Cannon", cannonSprite);
        itemSprites.Add("Propeller", propellerSprite);
        itemSprites.Add("Cannonball", cannonballSprite);
        itemSprites.Add("Dramond", diamondSprite);
        slotAPanel = GameObject.Find("Item2");
        slotBPanel = GameObject.Find("Item1");
    }

    void Update ()
    {
        // action panel management
        if (Input.GetButtonDown("Action1"))
        {
            if (GameObject.Find("PickupKey(Clone)"))
            {
                Destroy(actionList.transform.Find("PickupKey(Clone)").gameObject);
            }
        }
        ManageDropIcon(dropKey);
        ManagePickupIcon(pickupKey);
        ManageSwapIcon(swapKey);

        //swap animation
        slotAPanel.transform.localRotation = Quaternion.Euler(-swapPanel.transform.localRotation.eulerAngles);
        slotBPanel.transform.localRotation = Quaternion.Euler(-swapPanel.transform.localRotation.eulerAngles);

        if (!Input.GetButton("Action2"))
        {
            ManageItemIcons();
        }

        if (swapTo == 180)
        {
            slotAPanel = GameObject.Find("Item2");
            slotBPanel = GameObject.Find("Item1");
        }
        if (swapTo == 360)
        {
            slotAPanel = GameObject.Find("Item1");
            slotBPanel = GameObject.Find("Item2");
        }

        if (swap)
        {
            if (swapTo == 180)
            {
                swapTo = 360;
                swap = false;
                return;
            }
            if (swapTo == 360)
            {
                swapTo = 180;
                swap = false;
                return;
            }
        }

        if (swapPanel.transform.localRotation.z != swapTo)
        {
            float t = Time.deltaTime * Mathf.Pow(0.6f, -2);
            swapPanel.transform.localRotation = Quaternion.Lerp(swapPanel.transform.localRotation, Quaternion.Euler(0, 0, swapTo), t);
        }

        if (PlayerActions.slotBObj != null)
        {
            if (PlayerActions.slotAObj != null)
            {
                if (PlayerActions.slotAObj.GetComponentInChildren<KeyItem>().ABSwap && PlayerActions.slotBObj.GetComponentInChildren<KeyItem>().ABSwap)
                {
                    swapPanel.GetComponent<Image>().enabled = true;
                }
                else
                {
                    swapPanel.GetComponent<Image>().enabled = false;
                }
            }
            else
            {
                if (PlayerActions.slotBObj.GetComponentInChildren<KeyItem>().ABSwap)
                {
                    swapPanel.GetComponent<Image>().enabled = true;
                }
                else
                {
                    swapPanel.GetComponent<Image>().enabled = false;
                }
            }
        }
        else if (PlayerActions.slotAObj != null)
        {
            if (PlayerActions.slotAObj.GetComponentInChildren<KeyItem>().ABSwap)
            {
                swapPanel.GetComponent<Image>().enabled = true;
            }
            else
            {
                swapPanel.GetComponent<Image>().enabled = false;
            }
        }

    }

    void ManagePickupIcon(GameObject key/*, GameObject Button , bool controlMode*/)
    {
        if (GameObject.Find("PickupKey(Clone)") == null)
        {
            if (PlayerActions.targetObject != null && PlayerActions.slotBObj == null)
            {
                if (PlayerActions.targetObject.GetComponentInChildren<KeyItem>().BSwap)
                {
                    GameObject o = Instantiate(key, actionList.gameObject.transform.position, transform.rotation, actionList);
                    o.GetComponent<Image>().color = PersistentManager.Instance.HUDColor;
                    o.transform.GetChild(0).gameObject.GetComponent<Image>().color = PersistentManager.Instance.HUDColor;
                }
            }
        }
        else
        {
            if (PlayerActions.slotBObj != null)
            {
                Destroy(actionList.gameObject.transform.Find("PickupKey(Clone)").gameObject);
            }
            if (PlayerActions.targetObject == null)
            {
                Destroy(actionList.gameObject.transform.Find("PickupKey(Clone)").gameObject);
            }
            else if (!PlayerActions.targetObject.GetComponentInChildren<KeyItem>().BSwap)
            {
                Destroy(actionList.gameObject.transform.Find("PickupKey(Clone)").gameObject);
            }
        }
    }
    void ManageDropIcon(GameObject key/*, GameObject Button , bool controlMode*/)
    {
        if (GameObject.Find("DropKey(Clone)") == null)
        {
            if (PlayerActions.slotBObj != null && PlayerActions.slotBObj.GetComponentInChildren<KeyItem>().drop && PlayerActions.targetObject == null)
            {
                GameObject o = Instantiate(key, actionList.gameObject.transform.position, transform.rotation, actionList);
                o.GetComponent<Image>().color = PersistentManager.Instance.HUDColor;
                o.transform.GetChild(0).gameObject.GetComponent<Image>().color = PersistentManager.Instance.HUDColor;
            }
        }
        else
        {
            if (PlayerActions.slotBObj == null || !PlayerActions.slotBObj.GetComponentInChildren<KeyItem>().drop || PlayerActions.targetObject != null)
            {
                Destroy(actionList.gameObject.transform.Find("DropKey(Clone)").gameObject);
            }
        }
    }
    void ManageSwapIcon(GameObject key/*, GameObject Button , bool controlMode*/)
    {
        if (GameObject.Find("SwapKey(Clone)") == null)
        {
            if (PlayerActions.slotBObj != null && PlayerActions.slotBObj.GetComponentInChildren<KeyItem>().drop && PlayerActions.targetObject != null)
            {
                if (PlayerActions.targetObject.GetComponentInChildren<KeyItem>().BSwap)
                {
                    GameObject o = Instantiate(key, actionList.gameObject.transform.position, transform.rotation, actionList);
                    o.GetComponent<Image>().color = PersistentManager.Instance.HUDColor;
                    o.transform.GetChild(0).gameObject.GetComponent<Image>().color = PersistentManager.Instance.HUDColor;
                }
            }
        }
        else
        {
            if (PlayerActions.slotBObj == null || !PlayerActions.slotBObj.GetComponentInChildren<KeyItem>().drop || PlayerActions.targetObject == null)
            {
                Destroy(actionList.gameObject.transform.Find("SwapKey(Clone)").gameObject);
            }
        }
    }
    void ManageItemIcons()
    {
        if (PlayerActions.slotAObj != null)
        {
            slotAPanel.GetComponentInChildren<Image>().enabled = true;
            switch (PlayerActions.slotAObj.name)
            {
                case "Hammer":
                    slotAPanel.GetComponentInChildren<Image>().sprite = hammerSprite;
                    break;
                case "Cannon":
                    slotAPanel.GetComponentInChildren<Image>().sprite = cannonSprite;
                    break;
                case "Propeller":
                    slotAPanel.GetComponentInChildren<Image>().sprite = propellerSprite;
                    break;
                case "Cannonball":
                    slotAPanel.GetComponentInChildren<Image>().sprite = cannonballSprite;
                    break;
                case "Diamond":
                    slotAPanel.GetComponentInChildren<Image>().sprite = diamondSprite;
                    break;
            }
        }
        else
        {
            slotAPanel.GetComponentInChildren<Image>().sprite = nullSprite;
            slotAPanel.GetComponentInChildren<Image>().enabled = false;
        }
        if (PlayerActions.slotBObj != null)
        {
            slotBPanel.GetComponentInChildren<Image>().enabled = true;
            switch (PlayerActions.slotBObj.name)
            {
                case "Hammer":
                    slotBPanel.GetComponentInChildren<Image>().sprite = hammerSprite;
                    break;
                case "Cannon":
                    slotBPanel.GetComponentInChildren<Image>().sprite = cannonSprite;
                    break;
                case "Propeller":
                    slotBPanel.GetComponentInChildren<Image>().sprite = propellerSprite;
                    break;
                case "Cannonball":
                    slotBPanel.GetComponentInChildren<Image>().sprite = cannonballSprite;
                    break;
                case "Diamond":
                    slotBPanel.GetComponentInChildren<Image>().sprite = diamondSprite;
                    break;
            }
        }
        else
        {
            slotBPanel.GetComponentInChildren<Image>().sprite = nullSprite;
            slotBPanel.GetComponentInChildren<Image>().enabled = false;
        }
    }
    void CleanUpInvalidControllerIcons(/*bool controlMode*/)
    {

    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;

public class DeathZone : MonoBehaviour {
    public Vector3 playerRespawnPoint;
    public Vector3 hammerRespawnPoint;
    public Vector3 propellerRespawnPoint;
    public Vector3 cannonRespawnPoint;

    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.name == "Player")
        {
            other.GetComponent<PlayerActions>().Die(playerRespawnPoint);
        }
        if (other.gameObject.name == "Hammer")
        {
            other.GetComponentInChildren<KeyItem>().Die(hammerRespawnPoint);
        }
        if (other.gameObject.name == "Propeller")
        {
            other.GetComponentInChildren<KeyItem>().Die(propellerRespawnPoint);
        }
        if (other.gameObject.name == "Cannon")
        {
            other.GetComponentInChildren<KeyItem>().Die(cannonRespawnPoint);
        }
    }

    private void OnDrawGizmos()
    {
        Gizmos.color = Color.cyan;
        Gizmos.DrawWireSphere(playerRespawnPoint, 0.25f);
        Gizmos.color = Color.red;
        Gizmos.DrawWireSphere(hammerRespawnPoint, 0.25f);
        Gizmos.color = Color.green;
        Gizmos.DrawWireSphere(propellerRespawnPoint, 0.25f);
        Gizmos.color = Color.blue;
        Gizmos.DrawWireSphere(cannonRespawnPoint, 0.25f);
    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ScreenShot : MonoBehaviour {

	void Update ()
    {
        if (Input.GetButtonDown("Action1"))
        {
            ScreenCapture.CaptureScreenshot("C:/Users/troak/Desktop/SC.png");
        }
    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ButtonReceiver : MonoBehaviour {

    public string puzzleZoneID;
    public Vector3 initPos;
    public Vector3 dirFactor;
    float h;
    public int steps = 1;
    public int totalSteps;
    public int step;
    public bool reverse;
    public bool isChild;
    public bool idle;
    public bool powered;
    public int buttonIDNumber = -1;
    BoxCollider trigger;
    Rigidbody rb;
    float moveSpeed;

    private void Awake()
    {
        if (transform.parent.GetComponent<ButtonReceiver>() != null)
        {
            initPos = transform.localPosition;
        }
        else
        {
            initPos = transform.localPosition;
        }
        trigger = gameObject.GetComponent<BoxCollider>();
        rb = gameObject.GetComponent<Rigidbody>();
        h = trigger.size.y;
    }
    private void Start()
    {
        if (transform.parent.GetComponent<ButtonReceiver>() != null)
        {
            initPos = transform.localPosition;
        }
        else
        {
            initPos = transform.localPosition;
        }
        trigger = gameObject.GetComponent<BoxCollider>();
        rb = gameObject.GetComponent<Rigidbody>();
        h = trigger.size.y;
        puzzleZoneID = transform.parent.name;
    }

    private void Update()
    {
        if (trigger == null)
        {
            trigger = gameObject.GetComponent<BoxCollider>();
            h = trigger.size.y;
        }
        if (rb == null)
        {
            rb = gameObject.GetComponent<Rigidbody>();
        }
        string[] nameArray = transform.name.Split('_');
        int i = 0;
        foreach (var item in nameArray)
        {
            int.TryParse(nameArray[i], out buttonIDNumber);
            i++;
        }
        if (nameArray.Length != 2)
        {
            print(gameObject.name + " NOT NAMED CORRECTLY");
        }

        else
        {
            isChild = true;
        }
        if (transform.position == initPos - (step * dirFactor))
        {
            idle = true;
        }
        else
        {
            idle = false;
        }
        if (puzzleZoneID != null && PersistentManager.Instance.CurrentPuzzleID != null)
        {
            if (puzzleZoneID == PersistentManager.Instance.CurrentPuzzleID)
            {
                powered = true;
            }
        }
        else
        {
            powered = false;
        }
    }

    private void FixedUpdate()
    {
    //    if (transform.parent.GetComponent<ButtonReceiver>() == null)
    //    {
    //        isChild = false;
    //        if (transform.childCount > 0)
    //        {
    //            if (transform.GetChild(0).GetComponent<ButtonReceiver>().totalSteps == 0)
    //            {
    //                totalSteps = steps + transform.GetChild(0).GetComponent<ButtonReceiver>().steps;
    //            }
    //            else
    //            {
    //                totalSteps = steps + transform.GetChild(0).GetComponent<ButtonReceiver>().totalSteps;
    //            }
    //            Vector3 d = (transform.position) - (initPos - (step * dirFactor));
    //            float t = Time.deltaTime * Mathf.Pow(d.magnitude, -2);
    //            Vector3 moveTo = Vector3.Lerp(transform.position, initPos - (step * dirFactor), t); 
    //            rb.MovePosition(moveTo);
    //        }
    //        else
    //        {
                Vector3 d = (transform.position) - (initPos - (step * dirFactor));
                float t = Time.deltaTime * Mathf.Pow(d.magnitude, -0.5f);
                Vector3 moveTo = Vector3.Lerp(transform.position, initPos - (step * dirFactor), t);
                rb.MovePosition(moveTo);
        //        }
        //    }
    }

    private void OnDrawGizmos()
    {
        switch (buttonIDNumber)
        {
            case 1:
                Gizmos.color = Color.green;
                break;
            case 2:
                Gizmos.color = Color.red;
                break;
            case 3:
                Gizmos.color = Color.blue;
                break;
            default:
                Gizmos.color = Color.black;
                break;
        }
        if (trigger != null)
        {
            Gizmos.DrawWireCube(trigger.gameObject.transform.position + trigger.center, trigger.size);
        }
    }

    public void Move()
    {
        int stepCount;
        if (totalSteps == 0)
        {
            stepCount = steps;
        }
        else
        {
            stepCount = totalSteps;
        }

        //float stepDist = h / stepCount;

        if (step == stepCount && !reverse)
        {
            reverse = true;
        }
        if (step == 0 && reverse)
        {
            reverse = false;
        }
        if (reverse)
        {
            step--;
            idle = false;
        }
        else
        {
            step++;
            idle = false;
        }
    }

    //private void OnTriggerStay(Collider other)
    //{
    //    if (other.transform.parent != null && puzzleZoneID != "")
    //    {
    //        if (other.transform.parent.GetComponentInChildren<FloorButton>() != null)
    //        {
    //            if (other.transform.parent.GetComponentInChildren<FloorButton>().buttonIDNumber == buttonIDNumber && puzzleZoneID == PersistentManager.Instance.CurrentPuzzleID)
    //            {
    //                powered = true;
    //            }
    //        }
    //    }
    //}
    //private void OnTriggerExit(Collider other)
    //{
    //    if (other.transform.parent != null)
    //    {
    //        if (other.transform.parent.GetComponentInChildren<FloorButton>() != null)
    //        {
    //            if (other.transform.parent.GetComponentInChildren<FloorButton>().buttonIDNumber == buttonIDNumber && powered)
    //            {
    //                powered = false;
    //            }
    //        }
    //    }
    //}
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class KeyItemUse : MonoBehaviour {
    KeyItem ki;
    Animator anim;
    public bool active;


    private void Start()
    {
        ki = gameObject.GetComponentInChildren<KeyItem>();
        anim = gameObject.GetComponent<Animator>();
    }

    private void Update()
    {
        if (PlayerActions.slotAObj != null)
        {
            if (PlayerActions.slotAObj.name != "Propeller")
            {
                if (PlayerMovementCC.gravity != -12)
                {
                    PlayerMovementCC.gravity = -12;
                }
                if (name == "Propeller")
                {
                    active = false;
                }
            }
            else
            {
                if (!PlayerMovementCC.grounded && PlayerMovementCC.gravity == -12)
                {
                    if (PlayerMovementCC.impact.y != 0)
                    {
                        PlayerMovementCC.gravity = -2;
                    }
                    else
                    {
                        PlayerMovementCC.gravity = -4;
                    }
                }
            }
            if (PlayerActions.slotAObj.name != "Cannon")
            {
                if (active)
                {
                    active = false;
                }
            }
            else
            {
                if (active)
                {
                    GetComponentInChildren<KeyItem>().ABSwap = false;
                    Cannon();
                }
            }
        }
        else
        {
            active = false;
            if (PlayerMovementCC.gravity != -12)
            {
                PlayerMovementCC.gravity = -12;
            }
        }

        //ANIMATIONS
        if (gameObject.name == "Propeller")
        {
            PropellerAnims();
        }
        if (gameObject.name == "Cannon")
        {
            CannonAnims();
        }
    }

    public void Use()
    {
        if (name == "Propeller")
        {
            Propeller();
        }
        if (name == "Cannon" && GetComponent<CannonLauncher>().loaded)
        {
            active = true;
        }
    }
    private void Propeller()
    {
        if (PlayerActions.slotAObj.name == "Propeller" && PlayerMovementCC.grounded)
        {
            active = true;
            PlayerMovementCC.velocityY = 0;
            for (float i = 0; i < 01f; i += 0.01f)
            {
                float f = 0;
                if (i < 2.9f)
                {
                    if (i - (i * 0.0001f) < 0)
                    {
                        f = 0;
                    }
                    else
                    {
                        f = i - (i * 0.0001f);
                    }
                }
                else
                {
                    f = i;
                }
                PersistentManager.Instance.Player.GetComponent<PlayerMovementCC>().AddImpact(Vector3.up, f);
                if (!PlayerMovementCC.grounded)
                {
                    PlayerMovementCC.gravity = -2;
                }
            }
        }
    }
    private void PropellerAnims()
    {
        anim.SetBool("InSlotA", PlayerActions.slotAObj == gameObject ? true : false);
        bool flying;
        if (anim.GetBool("InSlotA"))
        {
            flying = active ? true : false;
            flying = !PlayerMovementCC.grounded && PlayerMovementCC.footRayDist > 1.4f ? true : false;
        }
        else
        {
            flying = false;
        }

        
        anim.SetBool("Flying", flying);
    }
    private void Cannon()
    {
        PlayerMovementCC.walkSpeed = 0;
        if (Input.GetButtonUp("Action4"))
        {
            GetComponent<CannonLauncher>().Launch();
            active = false;
        }
    }
    private void CannonAnims()
    {
        anim.SetBool("InSlotA", PlayerActions.slotAObj == gameObject ? true : false);
        anim.SetBool("Loaded", GetComponent<CannonLauncher>().loaded == true ? true : false);
        if (PlayerActions.slotAObj != null)
        {
            if (PlayerActions.slotAObj.name == "Cannon")
            {
                if (CharAnim.anim.GetCurrentAnimatorStateInfo(0).fullPathHash == Animator.StringToHash("Base Layer.Crouched") || CharAnim.anim.GetCurrentAnimatorStateInfo(0).fullPathHash == Animator.StringToHash("Base Layer.Holding|Crouched"))
                {
                    anim.SetBool("Crouched", true);
                }
                else
                {
                    anim.SetBool("Crouched", false);
                }
            }
        }
        else
        {
            anim.SetBool("Crouched", false);
        }


        GameObject armitureBase = gameObject.transform.GetChild(0).gameObject;
        if (PlayerActions.slotAObj == gameObject && active && !PlayerMovementCC.crouched)
        {
            
            Vector3 target = new Vector3(GetComponentInChildren<ReticleController>().gameObject.transform.position.x, armitureBase.transform.position.y, GetComponentInChildren<ReticleController>().gameObject.transform.position.z);
            Debug.DrawLine(armitureBase.transform.position, target, Color.red);
            armitureBase.transform.LookAt(target);
        }
        if (PlayerActions.slotAObj == gameObject && !active && armitureBase.transform.localEulerAngles != Vector3.zero)
        {
            armitureBase.transform.localRotation = Quaternion.Slerp(armitureBase.transform.localRotation, Quaternion.Euler(Vector3.zero), Time.deltaTime * 2f);
            //armitureBase.transform.localEulerAngles = Vector3.Lerp(armitureBase.transform.localEulerAngles, Vector3.zero, Time.deltaTime * 2f);
        }
    }
    private void Hammer()
    {
    }


    ////CANNON STUFF vvvvvvvvvvv
    ////populate line renderer with appropriate settings
    //private void RenderArc(LineRenderer lr, int res, float angle, float velocity, float g)
    //{
    //    lr.SetVertexCount(res + 1);
    //    lr.SetPositions(CalculateArcArray(res, angle, velocity, g));
    //}
    ////creat an array of Vector3 positions for rc
    //private Vector3[] CalculateArcArray(int res, float angle, float velocity, float g)
    //{
    //    float radianAngle = Mathf.Deg2Rad * angle;
    //    Vector3[] arcArray = new Vector3[res + 1];
    //    float maxDistance = (velocity * velocity * Mathf.Sin(2 * radianAngle)) / g;

    //    for (int i = 0; i <= res; i++)
    //    {
    //        float t = (float)i / (float)res;
    //        arcArray[i] = CalculateArcPoint(t, maxDistance, radianAngle, velocity, g);
    //    }
    //    return arcArray;
    //}
    ////calculate height and distance of each vertex
    //private Vector3 CalculateArcPoint(float t, float maxDistance, float radianAngle, float velocity, float g)
    //{
    //    float x = t * maxDistance;
    //    float y = x * Mathf.Tan(radianAngle) - ((g * x * x) / (2 * velocity * velocity * Mathf.Cos(radianAngle) * Mathf.Cos(radianAngle)));
    //    return new Vector3(x, y, 0);
    //}
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Puzzle : MonoBehaviour
{
    List<GameObject> areas = new List<GameObject>();

    private void Start()
    {
        Transform[] ts = gameObject.GetComponentsInChildren<Transform>();
        foreach (Transform t in ts)
        {
            if (t.gameObject.layer == 18)
            {
                areas.Add(t.gameObject);
            }
        }
    }

    private void Update()
    {
        if (PersistentManager.Instance.CurrentPuzzleID == gameObject.name)
        {
            if (gameObject.name == "Puzzle2")
            {
                if (PersistentManager.Instance.CurrentAreaID == areas[0].name)
                {
                    areas[0].GetComponentInChildren<DeathZone>().gameObject.GetComponent<BoxCollider>().enabled = true;
                    areas[1].GetComponentInChildren<DeathZone>().gameObject.GetComponent<BoxCollider>().enabled = false;
                }
                if (PersistentManager.Instance.CurrentAreaID == areas[1].name)
                {
                    areas[0].GetComponentInChildren<DeathZone>().gameObject.GetComponent<BoxCollider>().enabled = false;
                    areas[1].GetComponentInChildren<DeathZone>().gameObject.GetComponent<BoxCollider>().enabled = true;
                }
            }
            if (gameObject.name == "Puzzle1")
            {
                areas[0].GetComponentInChildren<DeathZone>().gameObject.GetComponent<BoxCollider>().enabled = true;
            }
            if (gameObject.name == "Center")
            {
                areas[0].GetComponentInChildren<DeathZone>().gameObject.GetComponent<BoxCollider>().enabled = true;
            }
        }
        else
        {
            foreach (GameObject g in areas)
            {
                g.GetComponentInChildren<DeathZone>().gameObject.GetComponent<BoxCollider>().enabled = false;
            }
        }
    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CannonBall : MonoBehaviour
{
    public LayerMask mask;
    public GameObject particle1;
    public GameObject particle2;
    ParticleSystem ps;
    MeshRenderer mr;

    public bool isAmmo = true;
    public bool active;

    private void Start()
    {
        mr = GetComponentInChildren<MeshRenderer>();
        ps = GetComponentInChildren<ParticleSystem>();
        var emission = ps.emission;
        emission.enabled = false;

        if (isAmmo)
        {
            mr.enabled = false;
        }
        if (!mr.enabled)
        {
            StartCoroutine(Enable());
        }
    }

    IEnumerator Enable()
    {
        yield return new WaitForSeconds(0.08f);
        mr.enabled = true;
    }

    private void Update()
    {
        if (!mr.enabled && !isAmmo)
        {
            mr.enabled = true;
        }
        if (Vector3.Magnitude(transform.position - PersistentManager.Instance.Player.transform.position) > 30)
        {
            Object.Destroy(gameObject);
        }
        var emission = ps.emission;
        if (active && emission.enabled == false)
        {
            emission.enabled = true;
        }
        if (!active && emission.enabled == true)
        {
            emission.enabled = false;
        }
    }

    private void OnCollisionEnter(Collision collision)
    {
        if (active)
        {
            Instantiate(particle1, gameObject.transform.position, gameObject.transform.rotation);
            Instantiate(particle2, gameObject.transform.position, gameObject.transform.rotation);
            Object.Destroy(gameObject);
        }
    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExecuteInEditMode]
public class ParabolaTesting : MonoBehaviour
{
    LineRenderer lr;
    public float velocity;
    public float angle;
    public int resolution = 20;

    float g;
    float radianAngle;

    private void Awake()
    {
        lr = GetComponentInChildren<LineRenderer>();
        g = Mathf.Abs(Physics.gravity.y);
    }

    private void Update()
    {
        RenderArc(lr, resolution, angle, velocity, g);
    }

    //populate line renderer with appropriate settings
    private void RenderArc(LineRenderer lr, int res, float angle, float velocity, float g)
    {
        lr.positionCount = res + 1;
        lr.SetPositions(CalculateArcArray(res, angle, velocity, g));
    }
    //creat an array of Vector3 positions for rc
    private Vector3[] CalculateArcArray(int res, float angle, float velocity, float g)
    {
        float radianAngle = Mathf.Deg2Rad * angle;
        Vector3[] arcArray = new Vector3[res + 1];
        float maxDistance = (velocity * velocity * Mathf.Sin(2 * radianAngle)) / g;

        for (int i = 0; i <= res; i++)
        {
            float t = (float)i / (float)res;
            arcArray[i] = CalculateArcPoint(t, maxDistance, radianAngle, velocity, g);
        }
        return arcArray;
    }
    //calculate height and distance of each vertex
    private Vector3 CalculateArcPoint(float t, float maxDistance, float radianAngle, float velocity, float g)
    {
        float x = t * maxDistance;
        float y = x * Mathf.Tan(radianAngle) - ((g * x * x) / (2 * velocity * velocity * Mathf.Cos(radianAngle) * Mathf.Cos(radianAngle)));
        return new Vector3(x, y, 0);
    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ReticleController : MonoBehaviour
{
    public float testf;

    public LayerMask mask;
    public Vector3 position;
    public Vector3 _ref;
    Animator promptAnim;
    SpriteRenderer promptSR;
    Vector3 defPosition;
    public bool isColl;
    SpriteRenderer sr;
    KeyItemUse keu;
    [Range(-10, 10)]
    public float heightModifier = 8310003f;
    float height;

    private void Start()
    {
        sr = GetComponent<SpriteRenderer>();
        keu = transform.parent.transform.parent.GetComponent<KeyItemUse>();
        if (transform.parent.transform.parent.name == "Hammer")
        {
            promptAnim = GetComponentInChildren<Animator>();
            promptSR = promptAnim.GetComponent<SpriteRenderer>();
        }
    }

    private void Update()
    {
        if (PlayerActions.slotAObj != null)
        {
            if (transform.parent.transform.parent.name == PlayerActions.slotAObj.name)
            {
                if (PlayerActions.slotAObj.name == "Cannon")
                {
                    height = (PersistentManager.Instance.Player.GetComponent<CharacterController>().height + (PersistentManager.Instance.Player.GetComponent<CharacterController>().skinWidth * 0.55f) + CannonLauncher.h + heightModifier);
                    transform.position = RayCastDown();
                    if (keu.active && !PlayerMovementCC.crouched && isColl)
                    {
                        sr.color = Color.white;
                    }
                    else
                    {
                        sr.color = new Color(1, 1, 1, 0);
                    }
                    defPosition = Vector3.Scale(PersistentManager.Instance.Player.transform.forward, new Vector3(1, 0, 1)) + new Vector3(0, height, 0);

                    if (sr.transform.rotation.eulerAngles != new Vector3(90, 0, 0))
                    {
                        sr.transform.rotation = Quaternion.Euler(90, 0, 0);
                    }

                    if (keu.active)
                    {
                        Vector3 input = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));
                        Quaternion r = Quaternion.AngleAxis(CamManager.targetA, Vector3.up);
                        Vector3 r2 = r * input;
                        Vector2 inputDir = new Vector2(r2.normalized.x, r2.normalized.z);
                        if (Mathf.Abs(position.x + inputDir.x / 20f) < 5f && Mathf.Abs(position.z + inputDir.y / 20f) < 5f)
                        {
                            position += new Vector3(inputDir.x, 0, inputDir.y) / 15f;
                        }
                    }
                    else if (position != defPosition)
                    {
                        position = defPosition;
                    }
                }
                if (PlayerActions.slotAObj.name == "Hammer")
                {
                    promptAnim.gameObject.transform.LookAt(Camera.main.transform.position, Vector3.up);
                    height = (PersistentManager.Instance.Player.GetComponent<CharacterController>().height + (PersistentManager.Instance.Player.GetComponent<CharacterController>().skinWidth * 0.55f) + transform.parent.GetComponent<KeyItem>().BMeasurements.y);
                    if (!PlayerMovementCC.crouched && isColl)
                    {
                        if (transform.parent.GetComponent<KeyItem>().crouch)
                        {
                            if (sr.color == new Color(1, 1, 1, 0))
                            {
                                StartCoroutine(CrouchPause());
                            }
                            else
                            {
                                sr.color = Color.white;
                            }
                        }
                        else
                        {
                            sr.color = Color.red;
                        }
                    }
                    else
                    {
                        sr.color = new Color(1, 1, 1, 0);
                        promptAnim.SetBool("Prompt", false);
                        promptSR.enabled = false;
                    }
                    if (!PlayerMovementCC.crouched)
                    {
                        defPosition = Vector3.Scale(PersistentManager.Instance.Player.transform.forward, new Vector3(1.95f, 0, 1.95f)) + new Vector3(0, height, 0);
                    }

                    Vector3 origin = Vector3.Scale((PersistentManager.Instance.Player.transform.position + defPosition), new Vector3(1, 0, 1)) + (Vector3.up * height);
                    RaycastHit hit;
                    if (Physics.SphereCast(origin, 0.46f, Vector3.down, out hit, height - testf, mask, QueryTriggerInteraction.Collide))
                    {
                        GameObject obj = hit.collider.gameObject;
                        if (obj.GetComponent<FloorButton>())
                        {
                            float t = Time.deltaTime * Mathf.Pow(0.6f, -2);
                            transform.position = Vector3.SmoothDamp(transform.position, obj.GetComponent<FloorButton>().reticleBone.transform.position, ref _ref, t);
                            if (!obj.GetComponent<FloorButton>().pressed && !PlayerMovementCC.crouched && transform.parent.GetComponent<KeyItem>().crouch && !Input.GetButton("Action3"))
                            {
                                print(obj.transform.position.y);
                                print(PersistentManager.Instance.Player.transform.position.y);
                                if (obj.GetComponent<FloorButton>().reticleBone.transform.position.y > PersistentManager.Instance.Player.transform.position.y)
                                {
                                    promptAnim.SetBool("Prompt", true);
                                    promptSR.enabled = true;
                                }
                                else
                                {
                                    promptAnim.SetBool("Prompt", false);
                                    promptSR.enabled = false;
                                }
                            }
                            else
                            {
                                promptAnim.SetBool("Prompt", false);
                                promptSR.enabled = false;
                            }
                        }
                        else
                        {
                            float t = Time.deltaTime * Mathf.Pow(0.6f, -2);
                            transform.position = Vector3.SmoothDamp(transform.position, RayCastDown(), ref _ref, t);
                            position = defPosition;
                            promptAnim.SetBool("Prompt", false);
                            promptSR.enabled = false;
                        }
                    }
                    else
                    {
                        float t = Time.deltaTime * Mathf.Pow(0.6f, -2);
                        transform.position = Vector3.SmoothDamp(transform.position, RayCastDown(), ref _ref, t);
                        position = defPosition;
                        promptAnim.SetBool("Prompt", false);
                        promptSR.enabled = false;
                    }
                }
            }
            else
            {
                sr.color = new Color(1, 1, 1, 0);
            }
        }
        else
        {
            sr.color = new Color(1, 1, 1, 0);
        }
    }

    IEnumerator CrouchPause()
    {
        print("!!");
        yield return new WaitForSeconds(0.3f);
        sr.color = Color.white;
    }

    Vector3 RayCastDown()
    {
        RaycastHit hit;
        Vector3 origin = Vector3.Scale((transform.parent.position + position), new Vector3(1, 0, 1)) + (Vector3.up * height);
        Vector3 newpos;
        Debug.DrawLine(origin, new Vector3(origin.x, -height, origin.z), Color.red);
        if (Physics.Raycast(origin, Vector3.down, out hit, height * 2, mask, QueryTriggerInteraction.Collide))
        {
            isColl = true;
            newpos = hit.point + new Vector3(0, 0.1f, 0);
        }
        else
        {
            isColl = false;
            newpos = new Vector3(origin.x, transform.position.y, origin.z);
        }
        return newpos;
    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExecuteInEditMode]
public class TrackTransforms : MonoBehaviour {

    //POS
    public GameObject posObj;
    public bool trackPosBool;
    public Vector3 posOffset;
    public float trackPosSpeed;
    Vector3 trackPosRef;
    public bool trackXPos;
    public bool trackYPos;
    public bool trackZPos;
    //TRACK DIRECTION POS
    public bool trackForwardPosBool;
    //ROT
    public GameObject rotObj;
    public bool trackRotBool;
    public float trackRotSpeed;
    float trackRotRef;
    public bool trackXRot;
    public bool trackYRot;
    public bool trackZRot;
    public Vector3 rotOffset;

    void Update()
    {
        //POS
        if (trackPosBool)
        {
            TrackPos(trackXPos ,trackYPos ,trackZPos , posOffset);
        }
        //TRACK DIRECTION POS
        if (trackForwardPosBool)
        {
            TrackForwardPos();
        }
        //ROT
        if (trackRotBool)
        {
            TrackRot(trackXRot, trackYRot, trackZRot, rotOffset);
        }
    }

    void TrackPos(bool X, bool Y, bool Z, Vector3 offset)
    {
        //float x = X.GetHashCode();
        //float y = Y.GetHashCode();
        //float z = Z.GetHashCode();
      
        if (posObj != null)
        {
            Vector3 finalPos;
            finalPos = posObj.transform.TransformPoint(offset);
            transform.position = Vector3.SmoothDamp(transform.position, finalPos, ref trackPosRef, trackPosSpeed);
        }
    }

    void TrackRot(bool X, bool Y, bool Z, Vector3 offset)
    {
        float x = X.GetHashCode();
        float y = Y.GetHashCode();
        float z = Z.GetHashCode();

        //Vector3 selections = new Vector3(x, y, z);

        if (rotObj != null)
        {
            Vector3 finalRot;
            finalRot = rotObj.transform.rotation.eulerAngles;
            if (y == 1)
            {
                transform.eulerAngles = Vector3.up * Mathf.SmoothDampAngle(transform.eulerAngles.y, finalRot.y, ref trackRotRef, trackRotSpeed);
                transform.eulerAngles += offset;
            }
        }
        
    }

    void TrackForwardPos()
    {
        transform.position = rotObj.transform.position + rotObj.transform.forward + posOffset;
    }

    private void OnDrawGizmos()
    {
        if (posObj.tag == "ActionObject")
        {
            Gizmos.DrawIcon(transform.position, "sv_icon_dot8_pix16_gizmo");
        }
        else
        {
            Gizmos.DrawIcon(transform.position, "sv_icon_dot2_pix16_gizmo");
        }
    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SlotB : MonoBehaviour {

    public GameObject obj;

	void Update ()
    {
        var lookPos = new Ray (obj.transform.position, PlayerMovement.avgFootNormal).GetPoint(1);
        //var rotation = Quaternion.LookRotation(lookPos);
        transform.rotation = Quaternion.LookRotation(lookPos);
    }

    private void OnDrawGizmos()
    {
        Gizmos.DrawIcon(transform.position, "sv_icon_dot1_pix16_gizmo");
    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CharAnim : MonoBehaviour {
    static public Animator anim;
    CharacterController cc;

    private void Start()
    {
        anim = GetComponent<Animator>();
        cc = GetComponent<CharacterController>();
    }

    private void Update()
    {
        anim.SetBool("Crouched", PlayerMovementCC.crouched);
        anim.SetBool("Moving", PlayerMovementCC.moving);
        anim.SetFloat("CCVelocity", PlayerMovementCC.inputDir.magnitude * PlayerMovementCC.walkSpeed);

        if (PlayerActions.slotBObj != null)
        {
            anim.SetBool("Holding", true);
        }
        else
        {
            anim.SetBool("Holding", false);
        }
        anim.SetFloat("YVelocity", PersistentManager.Instance.Player.GetComponent<CharacterController>().velocity.y);
        anim.SetFloat("FootRayDist", PlayerMovementCC.footRayDist);
        anim.SetBool("Grounded", PlayerMovementCC.grounded);
        anim.SetBool("Space", Input.GetButtonDown("Action4"));
        if (PlayerActions.slotAObj != null)
        {
            if (PlayerActions.slotAObj.name == "Propeller")
            {
                anim.SetBool("Propeller", true);
            }
            else
            {
                anim.SetBool("Propeller", false);
            }
        }
    }
}
<file_sep>﻿using UnityEngine;

public struct Parabola
{
    public readonly Vector3 start;
    public readonly Vector3 end;
    public readonly float height;

    public static float DisplacementY(Parabola p)
    {
        float dY;
        dY = p.end.y - p.start.y;
        return dY;
    }
    public static Vector3 DisplacementXZ(Parabola p)
    {
        Vector3 dXZ;
        dXZ = new Vector3(p.end.x - p.start.x, 0, p.end.z - p.start.z);
        return dXZ;
    }
    public static float Time(Parabola p)
    {
        float t;
        t = (Mathf.Sqrt(-2 * p.height / Physics.gravity.y) + Mathf.Sqrt(2 * (Parabola.DisplacementY(p) - p.height) / Physics.gravity.y));
        return t;
    }
    public static Vector3 VelocityY(Parabola p)
    {
        Vector3 vY = Vector3.up * Mathf.Sqrt(-2 * Physics.gravity.y * p.height);
        return vY;
    }
}<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovement : MonoBehaviour {

    //componenets
    public Rigidbody rb;
    public Collider coll;
    private Transform InputAxis;

    //movement vars
    public Vector3 v;
    public Quaternion q = new Quaternion();
    public double footNormalDot;
    public float moveSpeed;
    public float jumpForce;
    public bool j;
    public bool grounded;
    public bool jumping;
    public bool disabled = false;
    public bool isColiding = false;
    private Vector3 avgCollNormal = Vector3.zero;

    //raycasting vars
    public static Vector3 orientation = Vector3.forward;
    public static Ray facingRay;
    public static Ray footRay;
    public static List<Ray> heelRays = new List<Ray>(8);
    public LayerMask footRayLayerMask;
    private Ray inputAxisRay;
    private Vector3 footRayHit = Vector3.zero;
    public static Vector3 avgFootNormal = Vector3.zero;

    //Collider vars
    public List<Collision> collisions = new List<Collision>();
    public int normCount;

    void Start()
    {
        rb = GetComponent<Rigidbody>();
        coll = GetComponent<Collider>();
        facingRay = new Ray(transform.position, Vector3.back);
        InputAxis = GameObject.Find("InputAxis").GetComponent<Transform>();
    }

    private void Update()
    {
        //GENERAL VARIABLE UPDATES
        VarUpdate();
        //MOVEMENT INPUT
        //RAYCASTING
        FootRay();
        RadialRays();
    }

    void FixedUpdate()
    {
        //MOVEMENT INPUT
        MovementInput(v);
        //DEBUG
        //VARIABLE RESET
    }

    //VARIABLE MANAGEMENT FUNCTIONS
    void VarUpdate()
    {
        //MOVEMENT VARS_____________________________________________________________________________________________________________________________
        //movement vector
        v = new Vector3(
            (Input.GetAxis("Horizontal")) * (moveSpeed * (2 - Mathf.Abs(InputAxis.up.x * 0.5f))),
            -(((5 * Mathf.Abs(InputAxis.right.z)) - Mathf.Abs(InputAxis.up.x * 0.5f))) + -((5 * Mathf.Abs(InputAxis.up.y * InputAxis.right.x) - Mathf.Abs((InputAxis.up.z * Mathf.RoundToInt(InputAxis.up.y)) * 0.5f))),
            ((Input.GetAxis("Vertical")) * (moveSpeed - 0.5f)) * (moveSpeed * (2 - Mathf.Abs(InputAxis.up.z * 0.5f))));

        //climbing slopes makes you move slower
        if (footNormalDot != -1)
        {
            v = new Vector3(v.x * 0.8f, v.y, v.z * 0.8f);
        }

        //quanternion velocity rotation
        q.SetLookRotation(avgFootNormal, Vector3.up);
        InputAxis.rotation = q;
        inputAxisRay = new Ray(InputAxis.position, InputAxis.up);

        //calculate average collision normal and determine if grounded
        for (int i = 0; i < collisions.Count; i++)
        {
            foreach (ContactPoint contact in collisions[i].contacts)
            {
                avgCollNormal += contact.normal;
                normCount += 1;
            }
        }
        avgCollNormal = avgCollNormal / normCount;
        if (!grounded)
        {
            if (collisions.Count > 0)
            {
                isColiding = true;
            }
            if (collisions.Count == 0)
            {
                isColiding = false;
            }
        }
        //reset things
        collisions.Clear();
        footNormalDot = (System.Math.Round(Vector3.Dot(Vector3.down, avgFootNormal), 2));
        normCount = 0;
        avgCollNormal = Vector3.zero;
    }
    //MOVEMENT INPUT FUNCTIONS
    void MovementInput(Vector3 v)
    {
        if (!jumping)
        {
            if (grounded)
            {
                rb.velocity = new Vector3(v.x, v.y, v.z);
            }
            else
            {
                rb.velocity = new Vector3(v.x, rb.velocity.y, v.z);
            }
        }
        else
        {
            if (!isColiding)
            {
                if (rb.velocity.y > 0)
                {
                    rb.velocity = new Vector3(Input.GetAxis("Horizontal") * (moveSpeed), rb.velocity.y, Input.GetAxis("Vertical") * (moveSpeed));
                }
                else
                {
                    rb.velocity = new Vector3(Input.GetAxis("Horizontal") * (moveSpeed * 1.5f), rb.velocity.y, Input.GetAxis("Vertical") * (moveSpeed * 1.5f));
                }
            }
        }
    }
    //plans are to implement jump as a contextual action input
    void JumpInput()
    {
        if (j)
        {
            jumping = true;
            rb.velocity = new Vector3(rb.velocity.x, jumpForce, rb.velocity.z);
            j = false;
        }
    }
    //RAYCAST FUNCTIONS
    void FootRay()
    {
        Quaternion q = Quaternion.AngleAxis(90, Vector3.up);
        if ((Input.GetAxisRaw("Vertical") != 0) || (Input.GetAxisRaw("Horizontal") != 0))
        {
            orientation = new Vector3(-Input.GetAxisRaw("Vertical"), 0, Mathf.RoundToInt(Input.GetAxisRaw("Horizontal")));
        }
        Vector3 d = orientation * 2;
        facingRay.origin = transform.position;
        facingRay.direction = q * d;
        footRay.origin = transform.position;
        footRay.direction = Vector3.down * 2;

        RaycastHit hit;

        if (Physics.Raycast(footRay, out hit, 1f, footRayLayerMask, QueryTriggerInteraction.Ignore))
        {
            if (jumping && rb.velocity.y < 0.01f)
            {
                jumping = false;
            }
            if (!jumping)
            {
                isColiding = true;
                if (rb.useGravity)
                {
                    rb.velocity = new Vector3(v.x, rb.velocity.y, v.z);
                    grounded = true;
                    rb.useGravity = false;
                }
                footRayHit = hit.point;
                if (rb.position.y <= hit.point.y - footRay.direction.y)
                {
                    rb.MovePosition(new Vector3(rb.position.x, hit.point.y - footRay.direction.y, rb.position.z));
                }

            }
        }
        if (!Physics.Raycast(footRay, out hit, 1.1f, footRayLayerMask, QueryTriggerInteraction.Ignore) || jumping)
        {
            grounded = false;
            rb.useGravity = true;
        }
    }
    void RadialRays()
    {
        for (int i = 0; i < heelRays.Capacity; i++)
        {
            Ray heelRay = new Ray(FindPoint(footRay.origin, gameObject.GetComponent<CapsuleCollider>().radius, i), Vector3.down);
            heelRays.Add(heelRay);
        }

        List<Vector3> norms = new List<Vector3>();
        Vector3 avgNormal = Vector3.zero;

        foreach (Ray item in heelRays)
        {
            RaycastHit hit;
            if (Physics.Raycast(item, out hit, 1, footRayLayerMask, QueryTriggerInteraction.Ignore))
            {
                norms.Add(hit.normal);
            }
        }

        foreach (Vector3 item in norms)
        {
            avgNormal += item;
        }

        avgNormal = (avgNormal / norms.Count);
        avgFootNormal = avgNormal;
        heelRays.Clear();
    }
    Vector3 FindPoint(Vector3 c, float r, int i)
    {
        return c + Quaternion.AngleAxis(45.0f * i, Vector3.forward) * (Vector3.right * r);
    }
    //COLLISION FUNCTIONS
    private void OnCollisionEnter(Collision collision)
    {
    }
    private void OnCollisionExit(Collision collision)
    {
    }
    private void OnCollisionStay(Collision collision)
    {
        if (!collisions.Contains(collision))
        {
            collisions.Add(collision);
        }
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.tag == ("Disable") && !disabled)
        {
            disabled = true;
        }
    }
    private void OnTriggerExit(Collider other)
    {
        if (other.gameObject.tag == ("Disable") && disabled)
        {
            disabled = false;
        }
    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovementCC : MonoBehaviour
{

    static public float walkSpeed = 2.5f;
    static public float gravity = -12;
    public float controllerHeight = 2;
    public float turningSpeed = 0.5f;
    public float mass = 3.0f;
    static public Vector3 impact = Vector3.zero;
    public LayerMask footSphereLayerMask;

    public static bool moving;
    Vector3 initPos;
    public static bool grounded;
    public static bool balancing;
    public static bool crouched = false;
    [HideInInspector] public static Vector2 inputDir;
    float turningVelocityRef;
    static public Vector3 velocity;
    [HideInInspector] static public bool swapKeyItemSpeedDamp;
    static public float velocityY;
    [HideInInspector] static public Ray footRay;
    [HideInInspector] static public float footRayDist;
    [HideInInspector] public static CharacterController controller;

    void Start()
    {
        controller = GetComponent<CharacterController>();
        controller.height = controllerHeight;
        controller.enableOverlapRecovery = true;
        controller.detectCollisions = true;
    }

    void Update()
    {
        //input
        Vector3 input = Vector3.zero;
        inputDir = Vector2.zero;
        if (!crouched)
        {
            input = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical"));

            Quaternion r = Quaternion.AngleAxis(CamManager.targetA, Vector3.up);
            Vector3 r2 = r * input;

            //Vector3 correctedVertical = input.y * Camera.main.transform.forward;
            //Vector3 correctedHorizontal = input.x * Camera.main.transform.right;
            //Vector3 combinedInput = correctedHorizontal + correctedVertical;

            inputDir = new Vector2(r2.normalized.x, r2.normalized.z);
        }

        CrouchCheck();
        GroundedInput(inputDir);
    }
    private void FixedUpdate()
    {
        impact = Vector3.Lerp(impact, Vector3.zero, 5*Time.deltaTime);
        footRayDist = FootDist();
        GroundSphere();
        BackCheck();
        if (GroundRays() == 0 && grounded)
        {
            grounded = false;
        }
        if (impact.magnitude > 0.2f)
        {
            controller.Move((impact + velocity/2) * Time.deltaTime);
        }
        else
        {
            Move(velocity);
        }
        if (initPos != transform.position)
        {
            moving = true;
        }
        else
        {
            moving = false;
        }
        initPos = transform.position;
    }

    //GIZMOS
    private void OnDrawGizmos()
    {
    }

    //ACTIONS
    void CrouchCheck()
    {
        if (!grounded && crouched)
        {
            crouched = false;
        }
    }

    //RAYCAST FUNCTIONS
    void GroundSphere()
    {
        Ray ray = new Ray(transform.position + controller.center - (Vector3.up * controller.height / 4), -transform.up);
        RaycastHit[] hits = new RaycastHit[5];
        hits = Physics.SphereCastAll(ray, controller.radius, controller.skinWidth * 5.5f, footSphereLayerMask, QueryTriggerInteraction.Ignore);

        if (hits.Length > 0)
        {
            grounded = true;
        }
    }
    int GroundRays()
    {
        int i = 0;
        i += GroundRay(controller.radius, 0) + GroundRay(-controller.radius, 0) + GroundRay(0, controller.radius) + GroundRay(0, -controller.radius);
        return i;
    }
    int GroundRay(float Xoffset, float Zoffset)
    {
        Vector3 origin = transform.position + controller.center + new Vector3(0 + Xoffset, -0.25f, 0 + Zoffset);
        Debug.DrawRay(origin, -Vector3.up, Color.red);
        if (Physics.Raycast(new Ray(origin, -transform.up), 1, footSphereLayerMask, QueryTriggerInteraction.Ignore))
        {
            return 1;
        }
        else return 0;
    }
    float FootDist()
    {
        RaycastHit hit = new RaycastHit();
        Vector3 origin = transform.position + controller.center + new Vector3(0, -0.25f, 0);
        Debug.DrawRay(origin, -Vector3.up, Color.red);
        if (Physics.Raycast(new Ray(origin, -transform.up), out hit, 100, footSphereLayerMask, QueryTriggerInteraction.Ignore))
        {
            double h = (double)hit.distance;
            float f = (float)System.Math.Round(h, 2);
            return f;
        }
        else return 100;
    }

    //ROTATION FUNCTIONS
    Vector3 ApplySlopeRotation(Vector3 velocity, float Dist)
    {
        if (grounded)
        {
            Ray Ray = new Ray(transform.position + controller.center - (Vector3.up * controller.height / 4), -transform.up);
            RaycastHit Hit;
            if (Physics.Raycast(Ray, out Hit, Dist, footSphereLayerMask, QueryTriggerInteraction.Ignore))
            {
                footRay = new Ray(Hit.point, Hit.normal);
                balancing = false;
            }
            else
            {
                balancing = true;
            }
        }

        Vector3 rotatedVector = Quaternion.FromToRotation(transform.up, footRay.direction) * velocity;
        return rotatedVector;
    }

    //MOVE FUNCTIONS
    void GroundedInput(Vector2 inputDir)
    {
        if (!crouched)
        {
            if (inputDir != Vector2.zero && walkSpeed != 0)
            {
                float targetRotation = Mathf.Atan2(inputDir.x, inputDir.y) * Mathf.Rad2Deg;
                transform.eulerAngles = Vector3.up * Mathf.SmoothDampAngle(transform.eulerAngles.y, targetRotation, ref turningVelocityRef, turningSpeed);
            }

            if (!grounded)
            {
                velocityY += Time.deltaTime * gravity;
            }
            else
            {
                if (gravity != -12)
                {
                    if (PlayerActions.slotAObj.name == "Propeller")
                    {
                        PlayerActions.slotAObj.GetComponent<KeyItemUse>().active = false;
                    }
                    impact = Vector3.zero;
                    gravity = -12;
                }
                velocityY = 0;
            }
        }

        float speed = 0f;
        if (PlayerActions.slotBObj != null && PlayerActions.slotAObj == null)
        {
            if (PlayerActions.slotBObj.GetComponentInChildren<KeyItem>().drop)
            {
                speed = walkSpeed * inputDir.magnitude;
            }
        }
        if (PlayerActions.slotAObj != null && PlayerActions.slotBObj == null)
        {
            if (PlayerActions.slotAObj.GetComponentInChildren<KeyItem>().drop)
            {
                speed = walkSpeed * inputDir.magnitude;
            }
        }
        if (PlayerActions.slotBObj != null && PlayerActions.slotAObj != null)
        {
            if (PlayerActions.slotAObj.GetComponentInChildren<KeyItem>().drop && PlayerActions.slotBObj.GetComponentInChildren<KeyItem>().drop)
            {
                speed = walkSpeed * inputDir.magnitude;
            }
        }
        if (PlayerActions.slotAObj == null && PlayerActions.slotBObj == null)
        {
            speed = walkSpeed * inputDir.magnitude;
        }
        if (swapKeyItemSpeedDamp)
        {
            speed = 0;
            swapKeyItemSpeedDamp = false;
        }

        Vector3 v = transform.forward * speed + Vector3.up * velocityY;
        if (grounded)
        {
            velocity = ApplySlopeRotation(v, controller.radius + 0.5f);
        }
        else
        {
            velocity = v;
        }
    }
    void Move(Vector3 v)
    {
        controller.Move(v * Time.deltaTime);
    }

    //FORCE FUNCTIONS
    public void AddImpact(Vector3 dir, float force)
    {
        impact += dir.normalized * force / mass;
    }
    void BackCheck()
    {
        Vector3 n = Vector3.zero;
        Vector3 p1 = transform.position + controller.center + new Vector3(0, controller.height / 2 - controller.radius * 1.5f, 0);
        Vector3 p2 = transform.position + controller.center - new Vector3(0, controller.height / 2 - controller.radius * 1.5f, 0);
        RaycastHit[] hits = Physics.CapsuleCastAll(p1, p2, controller.radius, -transform.forward, 0.02f, footSphereLayerMask);
        foreach (RaycastHit item in hits)
        {
            if (item.rigidbody != null)
            {
                if (item.rigidbody.velocity.magnitude != 0)
                {
                    n += item.normal;
                    AddImpact(n, 2f);
                }
            }
        }
    }

    //USE EXISTING FOOTSPHERE TO DETECT GROUNDED ITL BE EASY, THEN ONLY APPLY THE Y FORCE WHEN NOT GROUNDED SO ROTATING WONT GET FUCKED UP WHEN YOU ARE STADNIG STILL.

}<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

[ExecuteInEditMode]
public class DropShadow : MonoBehaviour {

    public LayerMask layerMask;
    public float yRayOffset;
    public float yShadowOffset;

	void Start ()
    {
		
	}

	void FixedUpdate ()
    {

        if (transform.parent.tag == "ActionObject")
        {
            if (!transform.parent.gameObject.GetComponentsInChildren<KeyItem>()[0].inSlot || transform.parent.gameObject == PlayerActions.slotAObj)
            {
                GetComponent<Renderer>().material.SetColor("_Color", new Color(1, 1, 1, 0f));
            }
            else
            {
                Ray ray = new Ray(transform.parent.position - (yRayOffset * Vector3.up), Vector3.down);
                RaycastHit hit;
                if (Physics.Raycast(ray.origin, ray.direction, out hit, 50f, layerMask, QueryTriggerInteraction.Ignore))
                {
                    float newYShadowOffset = yShadowOffset;
                    if (gameObject.transform.parent.GetComponent<Rigidbody>() != null)
                    {
                        newYShadowOffset = yShadowOffset - Mathf.Abs(gameObject.transform.parent.GetComponent<Rigidbody>().velocity.y / 75);
                    }
                    if (gameObject.transform.parent.GetComponent<PlayerMovementCC>() != null)
                    {
                        newYShadowOffset = yShadowOffset - Mathf.Abs(PlayerMovementCC.velocity.y / 75);
                    }
                    transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
                    transform.position = transform.parent.position + (hit.distance + newYShadowOffset) * Vector3.down;
                    GetComponent<Renderer>().material.SetColor("_Color", new Color(1, 1, 1, 0.2f - hit.distance / 15f));
                }
                else
                {
                    transform.rotation = Quaternion.Euler(Vector3.zero);
                    transform.position = transform.parent.position + (yShadowOffset * Vector3.up);
                    GetComponent<Renderer>().material.SetColor("_Color", new Color(1, 1, 1, 0f));
                }
            }
        }
        else
        {
            Ray ray = new Ray(transform.parent.position - (yRayOffset * Vector3.up), Vector3.down);
            RaycastHit hit;
            if (Physics.Raycast(ray.origin, ray.direction, out hit, 50f, layerMask, QueryTriggerInteraction.Ignore))
            {
                float newYShadowOffset = yShadowOffset;
                if (gameObject.transform.parent.GetComponent<Rigidbody>() != null)
                {
                    newYShadowOffset = yShadowOffset - Mathf.Abs(gameObject.transform.parent.GetComponent<Rigidbody>().velocity.y / 75);
                }
                if (gameObject.transform.parent.GetComponent<PlayerMovementCC>() != null)
                {
                    newYShadowOffset = yShadowOffset - Mathf.Abs(PlayerMovementCC.velocity.y / 75);
                }
                transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);
                transform.position = transform.parent.position + (hit.distance + newYShadowOffset) * Vector3.down;
                GetComponent<Renderer>().material.SetColor("_Color", new Color(1, 1, 1, 0.2f - hit.distance / 15f));
            }
            else
            {
                transform.rotation = Quaternion.Euler(Vector3.zero);
                if (!PlayerMovementCC.grounded)
                {
                    GetComponent<Renderer>().material.SetColor("_Color", new Color(1, 1, 1, 0f));
                }
            }
        }
	}
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEngine;

public class CamManager : MonoBehaviour {

    public GameObject gimble;
    public GameObject target;
    private Camera cam;
    private Vector3 orientation;
    private Vector3 _ref;
    private float _ref2;
    float a;
    float curA;
    [HideInInspector] public static float targetA;
    List<float> angles = new List<float>();
    int angleIndex;
    private bool axisIsDown = false;
    //LERP STUFF
    Vector3 startPos;

    void Start ()
    {
        //45,90,135,180,225,270,315,0

        angles.Add(0f);
        angles.Add(45f);
        angles.Add(90f);
        angles.Add(135f);
        angles.Add(180f);
        angles.Add(225f);
        angles.Add(270f);
        angles.Add(315f);

        angleIndex = PersistentManager.Instance.SceneAngles[SceneManager.GetActiveScene().buildIndex];

        cam = Camera.main;
        startPos = gimble.transform.position;
        transform.position = new Vector3(target.transform.position.x, target.transform.position.y, target.transform.position.z);
    }
	
	void Update ()
    {
        if (!PlayerActions.dead)
        {
            if (PlayerActions.slotAObj != null)
            {
                if (PlayerActions.slotAObj.name == "Cannon" && PlayerActions.slotAObj.GetComponent<KeyItemUse>().active)
                {
                    if (PlayerActions.slotAObj.GetComponentInChildren<ReticleController>().isColl)
                    {
                        transform.position = Vector3.SmoothDamp(transform.position, (target.transform.position + (PlayerActions.slotAObj.GetComponentInChildren<ReticleController>().gameObject.transform.position - target.transform.position) / 2), ref _ref, 0.5f);
                    }
                    else
                    {
                        Vector3 reticlePos = Vector3.Scale(PlayerActions.slotAObj.GetComponentInChildren<ReticleController>().gameObject.transform.position, new Vector3(1, 0, 1));
                        transform.position = Vector3.SmoothDamp(transform.position, (target.transform.position + (reticlePos - target.transform.position) / 2), ref _ref, 0.5f);
                    }
                }
                else
                {
                    float speed = PlayerMovementCC.walkSpeed != 0 ? PlayerMovementCC.inputDir.normalized.magnitude : 0;
                    transform.position = Vector3.SmoothDamp(transform.position, (target.transform.position + target.transform.forward + (target.transform.forward * speed)), ref _ref, 0.5f);
                }
            }
            else
            {
                float speed = PlayerMovementCC.walkSpeed != 0 ? PlayerMovementCC.inputDir.normalized.magnitude : 0;
                transform.position = Vector3.SmoothDamp(transform.position, (target.transform.position + target.transform.forward + (target.transform.forward * speed)), ref _ref, 0.33f);
            }
        }
        else
        {
            transform.position = Vector3.SmoothDamp(transform.position, PlayerActions.lastSpawnPos, ref _ref, 0.5f);
        }

        //Camera Rotation
        curA = transform.rotation.eulerAngles.y;

        if (Mathf.Round(Input.GetAxisRaw("CamRot")) != 0)
        {
            if (axisIsDown == false)
            {
                if (Mathf.Round(Input.GetAxisRaw("CamRot")) == -1f)
                {
                    if (angleIndex == angles.Count - 1)
                    {
                        angleIndex = 0;
                    }
                    else
                    {
                        angleIndex += 1;
                    }
                    currentLerpTime = 0;
                }
                if (Mathf.Round(Input.GetAxisRaw("CamRot")) == 1f)
                {
                    if (angleIndex == 0)
                    {
                        angleIndex = angles.Count - 1;
                    }
                    else
                    {
                        angleIndex -= 1;
                    }
                    currentLerpTime = 0;
                }
                axisIsDown = true;
            }
        }
        if (Mathf.Round(Input.GetAxisRaw("CamRot")) == 0)
        {
            axisIsDown = false;
        } 
        targetA = angles[angleIndex];

        if (transform.rotation.eulerAngles.y != angles[angleIndex])
        {
            transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, angles[angleIndex], 0), Time.deltaTime*6) /*Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, angles[angleIndex], 0), Time.deltaTime)*/;
        }
    }

    float lerpTime = 1f;
    float currentLerpTime;

    float moveDistance = 10f;

    
    //Vector3 endPos;

    //protected void Start()
    //{
    //    startPos = transform.position;
    //    endPos = transform.position + transform.up * moveDistance;
    //}

    //protected void Update()
    //{
    //    //reset when we press spacebar
    //    if (Input.GetKeyDown(KeyCode.Space))
    //    {
    //        currentLerpTime = 0f;
    //    }

    //    //increment timer once per frame
    //    currentLerpTime += Time.deltaTime;
    //    if (currentLerpTime > lerpTime)
    //    {
    //        currentLerpTime = lerpTime;
    //    }

    //    //lerp!
    //    float perc = currentLerpTime / lerpTime;
    //    transform.position = Vector3.Lerp(startPos, endPos, perc);
    //}
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class SlotAPivot : MonoBehaviour {

	void Update ()
    {
        var lookPos = PersistentManager.Instance.Player.transform.forward;
        lookPos.y = 0;
        var rotation = Quaternion.LookRotation(lookPos);
        transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime * 10f);
    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CannonLauncher : MonoBehaviour {

    //BASICS (formatted for 2D, it's easy to translate to 3D just sub x for x and z):
    //
    // CONSTANT ACCELETARION IN STRAIGHT LINE:
    // d = displacement, u = initial velocity, v = final velocity, a = acceleration, t = time
    // 1): s = ((u+v)/2)t
    // 2): v = u + at
    // 3): s = ut + (a(t^2))/2
    // 4): s = vt - (a(t^2))/2
    // 5): v^2 = u^2 + 2as
    //
    // ARC CALCULATION DOES NOT HIT MOVING TARGETS
    //                     . h    .
    //             .         |            .
    //        .              |                  . p
    //     .                 |                    |
    //   .                   |                    |
    // a------------------------------------------'
    //
    // p = target point, a = starting point, g = -18m/s^2 downwards, h = height of arc, 
    //
    // split the action into the three parts of the arc, represented as straight line equations.
    //
    // UP: displacement = h, acceleration = g (cos your counteracting gravity), final velocity = 0
    // DOWN: displacement = Py - h, acceleration = g becuase of gravity, initial velocity = 0
    // DISTANCE: displacement = Px, acceleration = 0 (air resistance would dampen acceleration, but is ignored), time = up(t) down(t)

    public Transform start;
    public Transform target;
    public GameObject ball;
    public GameObject armitureBase;
    public Vector3 anglepoint;
    public bool loaded;

    float disY;
    static public float h = 4;
    public float gravity = Physics.gravity.y;

    public bool debugPath;

    private void Start()
    {
        armitureBase = gameObject.transform.GetChild(0).gameObject;
    }

    private void FixedUpdate()
    {
        if (debugPath)
        {
            DrawPath();
        }
    }

    private void OnDrawGizmos()
    {
        Gizmos.DrawIcon(anglepoint, "sv_icon_dot8_pix16_gizmo");
    }

    public void Launch()
    {
        PlayerMovementCC.walkSpeed = 2.5f;
        GameObject inst = Instantiate(ball, start.position, Quaternion.Euler(Vector3.zero));
        inst.name = "Cannonball";
        CannonBall cb = inst.GetComponent<CannonBall>();
        Rigidbody rb = inst.GetComponent<Rigidbody>();
        cb.active = true;
        rb.useGravity = true;
        if (!PlayerMovementCC.crouched)
        {
            rb.velocity = CalculateLaunchData().initialVelocity;
            rb.AddTorque(armitureBase.transform.right, ForceMode.Impulse);
        }
        else
        {
            rb.velocity = PersistentManager.Instance.Player.transform.forward * 10;
            rb.AddTorque(armitureBase.transform.right, ForceMode.Impulse);
        }
        loaded = false;
    }

    LaunchData CalculateLaunchData()
    {
        float displacementY = target.position.y - start.position.y;
        if (displacementY > h)
        {
            displacementY = h;
        }
        Vector3 displacementXZ = new Vector3(target.position.x - start.position.x, 0, target.position.z - start.position.z);
        float time = (Mathf.Sqrt(-2 * h / gravity) + Mathf.Sqrt(2 * (displacementY - h) / gravity));
        Vector3 velocityY = Vector3.up * Mathf.Sqrt(-2 * gravity * h);
        Vector3 velocityXZ = displacementXZ / time;

        return new LaunchData (velocityXZ + velocityY * -Mathf.Sign(gravity), time);
    }

    void DrawPath()
    {
        LaunchData launchData = CalculateLaunchData();
        Vector3 previousDrawPoint = start.position;

        int resolution = 30;
        for (int i = 1; i <= resolution; i++)
        {
            float simulationTime = i / (float)resolution * launchData.timeToTarget;
            Vector3 displacement = launchData.initialVelocity * simulationTime + (gravity * Vector3.up) * simulationTime * simulationTime / 2f;
            Vector3 drawPoint = start.position + displacement;
            Debug.DrawLine(previousDrawPoint, drawPoint, Color.green);
            previousDrawPoint = drawPoint;
            if (i == 4)
            {
                anglepoint = drawPoint;
            }
        }
    }

    struct LaunchData
    {
        public readonly Vector3 initialVelocity;
        public readonly float timeToTarget;

        public LaunchData(Vector3 initialVelocity, float timeToTarget)
        {
            this.initialVelocity = initialVelocity;
            this.timeToTarget = timeToTarget;
        }
    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine.SceneManagement;
using UnityEngine;

public class PersistentManager : MonoBehaviour {

    public static PersistentManager Instance { get; private set; }

    public string CurrentPuzzleID;
    public string CurrentAreaID;
    public bool Axis3IsDown;
    public Color HUDColor;
    public GameObject Player;
    public GameObject HUD;
    public List<int> SceneAngles = new List<int>();

    private void Awake()
    {
        Application.targetFrameRate = 30;
        QualitySettings.vSyncCount = 0;

        for (int i = 0; i < SceneManager.sceneCountInBuildSettings; i++)
        {
            if (i == 0)
            {
                SceneAngles.Add(4);
            }  
        }
        if (Instance == null)
        {
            Instance = this;
            DontDestroyOnLoad(gameObject);
        }
        else
        {
            Destroy(gameObject);
        }
        Player = GameObject.Find("Player");
        HUD = GameObject.Find("ScreenSpaceCanvas");
    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class KeyItem : MonoBehaviour
{
    public Vector3 v;

    //Action bools
    public bool BSwap;
    public bool ASwap;
    public bool ABSwap;
    public bool drop;
    //bool fall;
    public bool crouch;
    //Properties
    public bool inSlot;
    public Mesh AMesh;
    public Mesh BMesh;
    public Mesh idleMesh;
    public Vector3 AMeasurements;
    public Vector3 BMeasurements;
    public Vector3 slotBOffset;
    public Vector3 slotBMeshOffset;
    public Vector3 slotBRot;
    public Vector3 slotAOffset;
    public Vector3 slotARot;
    Quaternion Arot;
    Quaternion Brot;
    Vector3 Apos;
    Vector3 Bpos;
    public GameObject currentSlot;
    //Components
    Rigidbody rb;
    BoxCollider bc;
    MeshCollider mc;
    PlayerActions pa;
    MeshRenderer mr;
    SkinnedMeshRenderer smr;
    //ect
    public LayerMask layerMask;

    private void Start()
    {
        rb = transform.parent.GetComponent<Rigidbody>();
        bc = GetComponent<BoxCollider>();
        mc = transform.parent.GetComponent<MeshCollider>();
        pa = PersistentManager.Instance.Player.GetComponent<PlayerActions>();
        if (transform.parent.GetComponentInChildren<SkinnedMeshRenderer>())
        {
            smr = transform.parent.GetComponentInChildren<SkinnedMeshRenderer>();
        }
        else if (transform.parent.GetComponentInChildren<MeshRenderer>())
        {
            mr = transform.parent.GetComponentInChildren<MeshRenderer>();
        }
        AMeasurements = AMesh.bounds.size;
        BMeasurements = BMesh.bounds.size;
    }
    private void Update()
    {
        if (gameObject.transform.parent.name != "BombBox")
        {
            UpdateTransforms();
            if (currentSlot != null)
            {
                crouch = CrouchCheck();
                if (currentSlot.name == "SlotB")
                {
                    if (PlayerActions.targetObject != null)
                    {
                        BSwap = BSwapCheck(PlayerActions.targetObject);
                    }
                    drop = DropCheck();
                    if (transform.parent.name != "Cannonball")
                    {
                        ABSwap = ABSwapCheck(gameObject, PlayerActions.slotA, slotAOffset, slotARot, AMeasurements);
                    }
                }
                if (currentSlot.name == "SlotA")
                {
                    drop = DropCheck();
                    if (transform.parent.name != "Cannonball")
                    {
                        if (transform.parent.name == "Hammer")
                        {
                            ABSwap = ABSwapCheck(gameObject, PlayerActions.slotB, new Vector3(0,0,-0.25f), slotBRot, BMeasurements * 1.75f);
                        }
                        else
                        {
                            ABSwap = ABSwapCheck(gameObject, PlayerActions.slotB, slotBOffset, slotBRot, BMeasurements);
                        }
                    }
                }
            }
            else
            {
                BSwap = BSwapCheck(null);
            }
            InSlot();
        }
        else
        {
            if (PlayerActions.slotBObj == null)
            {
                BSwap = BSwapCheck(null);
            }
            else
            {
                BSwap = false;
            }
        }
        UIEffect();
    }

    void UpdateTransforms()
    {
        Arot = Quaternion.Euler(PlayerActions.slotA.transform.rotation.eulerAngles + slotARot);
        Brot = Quaternion.Euler(PlayerActions.slotB.transform.rotation.eulerAngles + slotBRot);
        Apos = PlayerActions.slotA.transform.position + (transform.parent.transform.forward * slotAOffset.x + transform.parent.transform.up * slotAOffset.y + transform.parent.transform.right * slotAOffset.z);
        Bpos = PlayerActions.slotB.transform.position + (transform.parent.transform.forward * slotBOffset.x + transform.parent.transform.up * slotBOffset.y + transform.parent.transform.right * slotBOffset.z);
    }
    bool boxCast(GameObject keyItem, GameObject slot, Vector3 offset, Vector3 angleOffset, Vector3 measurements)
    {
        if (keyItem != null)
        {
            GameObject player = PersistentManager.Instance.Player;
            Quaternion r = Quaternion.Euler(slot.transform.rotation.eulerAngles + angleOffset);
            Vector3 o = slot.transform.right * offset.x/100 + slot.transform.up * offset.y/100 + slot.transform.forward * offset.z/100;
            Vector3 c = new Vector3(slot.transform.position.x, slot.transform.position.y + measurements.y / 2, slot.transform.position.z) + player.transform.forward / 5 + o;
            Debug.DrawRay(c, Vector3.Scale(Vector3.Scale(measurements / 2.25f, new Vector3(1, 1, 1)), slot.transform.forward));
            Debug.DrawRay(c, Vector3.Scale(Vector3.Scale(measurements / 2.25f, new Vector3(1, 1, 1)), -slot.transform.forward));
            Debug.DrawRay(c, Vector3.Scale(Vector3.Scale(measurements / 2.25f, new Vector3(1, 1, 1)), slot.transform.up));
            Debug.DrawRay(c, Vector3.Scale(Vector3.Scale(measurements / 2.25f, new Vector3(1, 1, 1)), -slot.transform.up));
            Debug.DrawRay(c, Vector3.Scale(Vector3.Scale(measurements / 2.25f, new Vector3(1, 1, 1)), slot.transform.right));
            Debug.DrawRay(c, Vector3.Scale(Vector3.Scale(measurements / 2.25f, new Vector3(1, 1, 1)), -slot.transform.right));
            if (!PlayerMovementCC.grounded)
            {
                return Physics.CheckBox(c - new Vector3(0, 0.5f, 0), Vector3.Scale(measurements / 2.25f,  new Vector3(1, 1, 1)), r, layerMask, QueryTriggerInteraction.Ignore);
            }
            else return Physics.CheckBox(c, Vector3.Scale(measurements / 2.25f, new Vector3(1, 1, 1)), r, layerMask, QueryTriggerInteraction.Ignore);            
        }
        else
        {
            return true;
        }
    }

    bool BSwapCheck(GameObject target)
    {
        if (gameObject.transform.parent.name == "BombBox")
        {
            if (PlayerActions.slotBObj != null)
            {
                return false;
            }
            else
            {
                if (target != null)
                {
                    if (!boxCast(gameObject, currentSlot, slotBOffset, slotBRot, BMeasurements) && !boxCast(target.GetComponentInChildren<KeyItem>().gameObject, currentSlot, target.GetComponentInChildren<KeyItem>().slotBOffset, target.GetComponentInChildren<KeyItem>().slotBRot, target.GetComponentInChildren<KeyItem>().BMeasurements))
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
                else
                {
                    if (!boxCast(gameObject, PlayerActions.slotB, slotBOffset, slotBRot, BMeasurements))
                    {
                        return true;
                    }
                    else
                    {
                        return false;
                    }
                }
            }
        }
        else
        {
            if (target != null)
            {
                if (!boxCast(gameObject, currentSlot, slotBOffset, slotBRot, BMeasurements) && !boxCast(target.GetComponentInChildren<KeyItem>().gameObject, currentSlot, target.GetComponentInChildren<KeyItem>().slotBOffset, target.GetComponentInChildren<KeyItem>().slotBRot, target.GetComponentInChildren<KeyItem>().BMeasurements))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                if (!boxCast(gameObject, PlayerActions.slotB, slotBOffset, slotBRot, BMeasurements))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
    }
    bool ASwapCheck(GameObject target)
    {
        if (!boxCast(gameObject, currentSlot, slotAOffset, slotARot, AMeasurements) && !boxCast(target, currentSlot, target.GetComponent<KeyItem>().slotAOffset, target.GetComponent<KeyItem>().slotARot, AMeasurements))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    bool ABSwapCheck(GameObject target, GameObject targetSlot, Vector3 offset, Vector3 angleOffset, Vector3 measurements)
    {
        if (!boxCast(target, targetSlot, offset, angleOffset, measurements))
        {
            return true;
        }
        else
        {
            return false;
        }
    }
    bool DropCheck()
    {
        if (currentSlot.name == "SlotB")
        {
            if (gameObject.transform.parent.name == "Hammer")
            {
                if (!boxCast(gameObject, currentSlot, slotBOffset + new Vector3(0, -100f,0), slotBRot, BMeasurements))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            else
            {
                if (!boxCast(gameObject, currentSlot, slotBOffset, slotBRot, BMeasurements))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
        }
        if (currentSlot.name == "SlotA")
        {
            if (!boxCast(gameObject, currentSlot, slotAOffset, slotARot, AMeasurements))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        return false;
    }
    bool CrouchCheck()
    {
        if (PlayerMovementCC.grounded && !PlayerMovementCC.balancing)
        {
            if (currentSlot.name == "SlotA")
            {
                if (!boxCast(gameObject, PlayerActions.slotB, new Vector3(0, -43, 55), new Vector3(0, 90, 0), new Vector2(BMeasurements.y, BMeasurements.x * 2f)))
                {
                    return true;
                }
                else
                {
                    return false;
                }
            }
            if (currentSlot.name == "SlotB")
            {
                return drop;
            }
        }
        return false;
    }

    public void Pickup(GameObject slot, GameObject replace)
    {
        currentSlot = slot;
        if (replace == null)
        {
            inSlot = true;
            PlayerActions.slotBObj = gameObject.transform.parent.gameObject;
            InSlot();
        }
        else
        {
            inSlot = true;
            InSlot();
            replace.GetComponentInChildren<KeyItem>().Drop();
            PlayerActions.slotBObj = gameObject.transform.parent.gameObject;
        }
    }
    public void Swap(GameObject swapToSlot)
    {
        currentSlot = swapToSlot;
    }
    public void Drop()
    {
        if (currentSlot.name == "SlotA")
        {
            PlayerActions.slotAObj = null;
        }
        else
        {
            PlayerActions.slotBObj = null;
        }
        inSlot = false;
        rb.velocity = Vector3.zero;
        rb.AddForce(PersistentManager.Instance.Player.transform.up / 2, ForceMode.Impulse);
    }
    public void InSlot()
    {
        if (gameObject != null && rb != null)
        {
            if (inSlot)
            {
                bc.center = new Vector3(0, 0, 0);
                if (rb.gameObject.layer != 14)
                {
                    rb.gameObject.layer = 14;
                    rb.useGravity = false;
                    rb.freezeRotation = true;
                }
                if (currentSlot.name == "SlotB")
                {
                    transform.parent.rotation = Brot;
                    transform.parent.position = Bpos;
                    mc.sharedMesh = BMesh;
                    gameObject.transform.parent.GetChild(0).position =
                        currentSlot.transform.GetChild(0).transform.position +
                        (currentSlot.transform.GetChild(0).transform.right * slotBMeshOffset.x +
                        currentSlot.transform.GetChild(0).transform.up * slotBMeshOffset.y +
                        currentSlot.transform.GetChild(0).transform.forward * slotBMeshOffset.z);
                    //will be replaced by animation VvVv
                    bc.size = BMesh.bounds.size;
                }
                else
                {
                    transform.parent.rotation = Arot;
                    transform.parent.position = Apos;
                    mc.sharedMesh = AMesh;
                    gameObject.transform.parent.GetChild(0).position = currentSlot.transform.GetChild(0).transform.position;
                    //will be replaced by animation VvVv
                    bc.size = AMesh.bounds.size;
                }
            }
            else
            {
                Vector3 notInSlotBoundsSize = idleMesh.bounds.size * 2f;
                for (int i = 0; i < 3; i++)
                {
                    if (notInSlotBoundsSize[i] < 1)
                    {
                        notInSlotBoundsSize[i] = 1;
                    }
                }
                if (rb.gameObject.layer != 13)
                {
                    rb.gameObject.layer = 13;
                    rb.freezeRotation = false;
                    rb.useGravity = true;
                }
                if (mc.sharedMesh != idleMesh || bc.size != notInSlotBoundsSize)
                {
                    //will be replaced by animation VvVv
                    bc.size = notInSlotBoundsSize;
                    mc.sharedMesh = idleMesh;
                }
                if (currentSlot != null)
                {
                    transform.parent.transform.position = gameObject.transform.parent.GetChild(0).transform.position;
                    gameObject.transform.parent.GetChild(0).transform.localPosition = Vector3.zero;
                    currentSlot = null;
                }
            }
        }
    }
    IEnumerator respawnCoroutine(Vector3 Pos)
    {
        rb.velocity = Vector3.zero;
        if (mr != null)
        {
            mr.enabled = false;
        }
        else
        {
            smr.enabled = false;
        }
        yield return new WaitForSeconds(0.6f);
        transform.parent.position = Pos;
        for (int i = 0; i < 5; i++)
        {
            yield return new WaitForSeconds(0.1f);
            if (mr != null)
            {
                if (mr.enabled)
                {
                    mr.enabled = false;
                }
                else
                {
                    mr.enabled = true;
                }
            }
            else
            {
                if (smr.enabled)
                {
                    smr.enabled = false;
                }
                else
                {
                    smr.enabled = true;
                }
            }
        }
    }
    public void Die(Vector3 respawnPoint)
    {
        if (!inSlot)
        {
            if (transform.parent.name == "Cannon")
            {
                if (GetComponentInParent<CannonLauncher>().loaded)
                {
                    StartCoroutine(respawnCoroutine(respawnPoint));
                    GetComponentInParent<CannonLauncher>().loaded = false;
                }
                else
                {
                    StartCoroutine(respawnCoroutine(respawnPoint));
                }
            }
            else
            {
                StartCoroutine(respawnCoroutine(respawnPoint));
            }
        }
    }
    void UIEffect()
    {
        //if (PlayerActions.targetObject == gameObject.transform.parent.gameObject && BSwap || ASwap)
        //{
        //    if (GetComponentInParent<Renderer>().material.GetFloat("_Offset_Z") == 0)
        //    {
        //        GetComponentInParent<Renderer>().material.SetFloat("_Offset_Z", -0.005f);
        //    }
        //}
        //else
        //{
        //    if (GetComponentInParent<Renderer>().material.GetFloat("_Offset_Z") != 0)
        //    {
        //        GetComponentInParent<Renderer>().material.SetFloat("_Offset_Z", 0);
        //    }
        //}
    }

    private void OnTriggerEnter(Collider other)
    {
        if (other.gameObject.layer == 12 && gameObject.transform.parent.name != "BombBox")
        {
            if (!inSlot && rb.velocity.y >= 0 && transform.parent.gameObject.name != "Cannonball")
            {
                rb.AddForce(new Vector3(
                    other.gameObject.GetComponent<CharacterController>().velocity.x * 0.8f,
                    other.gameObject.GetComponent<CharacterController>().velocity.y * 0.4f,
                    other.gameObject.GetComponent<CharacterController>().velocity.z * 0.8f), ForceMode.VelocityChange);
            }
        }
    }
}
<file_sep>﻿using UnityEngine;
using UnityEditor;

[CustomEditor(typeof(TrackTransforms))]
public class TrackTransformsEditor : Editor
{
    public override void OnInspectorGUI()
    {
        base.OnInspectorGUI();

        //COULD NOT FIGURE OUT HOW TO USE TOGGLE BUTTONS???
        /*TrackTransforms myTrackTransforms = (TrackTransforms)target;

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Tracking Target");
        myTrackTransforms.obj = (GameObject)EditorGUILayout.ObjectField(myTrackTransforms.obj, typeof(GameObject), true);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Track Position");
        trackPosition = EditorGUI.Toggle(new Rect(0, 5, position.width, 20), )
        EditorGUILayout.EndHorizontal();

        //EditorGUI.BeginDisabledGroup(myTrackTransforms.trackPosBool);
        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Transform Offset");
        myTrackTransforms.posOffset = EditorGUILayout.Vector3Field(GUIContent.none, myTrackTransforms.posOffset);
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Transofrm Factor");
        myTrackTransforms.posFactor = EditorGUILayout.Vector3Field(GUIContent.none, myTrackTransforms.posFactor);
        EditorGUILayout.EndHorizontal();
        //EditorGUI.EndDisabledGroup();

        EditorGUILayout.BeginHorizontal();
        GUILayout.Label("Track Y Rotation");
        myTrackTransforms.trackPosBool = EditorGUILayout.Toggle(false);
        EditorGUILayout.EndHorizontal();*/
    }
}
<file_sep>﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Barricade : MonoBehaviour
{
    BoxCollider bc;
    Animator anim;
    SkinnedMeshRenderer mr;
    bool blink;

    IEnumerator coroutine()
    {
        yield return new WaitForSeconds(0.4f);
        for (int i = 0; i < 5; i ++)
        {
            yield return new WaitForSeconds(0.1f);
            if (mr.enabled)
            {
                mr.enabled = false;
            }
            else
            {
                mr.enabled = true;
            }
        }
        Destroy(gameObject);
    }

    private void Start()
    {
        bc = GetComponent<BoxCollider>();
        anim = GetComponent<Animator>();
        mr = GetComponentInChildren<SkinnedMeshRenderer>();
    }

    private void Update()
    {
        if (blink)
        {
            StartCoroutine(coroutine());
            blink = false;
        }
    }

    void Break()
    {
        bc.enabled = false;
        anim.SetBool("Broken", true);
        blink = true;
    }

    private void OnCollisionEnter(Collision collision)
    {
        if (collision.gameObject.name == "Cannonball")
        {
            if (collision.gameObject.GetComponent<CannonBall>().active)
            {
                Break();
            }
        }
    }
}
