diff --git a/AndroidTut.cs b/AndroidTut.cs new file mode 100644 index 0000000..e7dae0f --- /dev/null +++ b/AndroidTut.cs @@ -0,0 +1,18 @@ +using UnityEngine; +using System.Collections; + +public class AndroidTut : MonoBehaviour { + public string AndroidText; + // Use this for initialization + void Start () { + if (SystemInfo.deviceType == DeviceType.Handheld) + { + GetComponent().text = AndroidText; + } + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/AnimSwitch.cs b/AnimSwitch.cs new file mode 100644 index 0000000..329b60f --- /dev/null +++ b/AnimSwitch.cs @@ -0,0 +1,56 @@ +using UnityEngine; +using System.Collections; + +public class AnimSwitch : MonoBehaviour { + + public GameObject LeftEye; + public GameObject RightEye; + public Animator animator; + public float EyeRad; + public float AnimOffsX, AnimOffsY; + private Vector3 DefaultL, DefaultR; + public Rigidbody2D rig; + public Collider2D col; + private float TimeFrame; + + // Use this for initialization + void Start() + { + animator = GetComponent(); + //rig = GetComponent(); + //col = GetComponent(); + DefaultL = LeftEye.transform.localPosition; + DefaultR = RightEye.transform.localPosition; + } + + // Update is called once per frame + void Update () + { + animator.SetFloat("Speed", rig.velocity.magnitude); + animator.SetBool("OnGround", col.IsTouchingLayers(1)); + if (Input.anyKey) + { + animator.SetFloat("IdleTime", 0); + TimeFrame = Time.timeSinceLevelLoad; + } + else + { + animator.SetFloat("IdleTime", Time.timeSinceLevelLoad - TimeFrame); + } + Vector3 _MousePoint = + Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 0)); + //use animation set values to indicate how far the eyes may wander + Vector3 AnimOffs = new Vector3(AnimOffsX, AnimOffsY, 0); + //convert mouse pos to localpos + Vector3 LEP = transform.InverseTransformPoint(_MousePoint); + Vector3 REP = transform.InverseTransformPoint(_MousePoint); + //reduce mouse pos to a small number, then set eye pos to that number. + if (LEP.magnitude > EyeRad) + LEP = LEP.normalized * EyeRad; + if (REP.magnitude > EyeRad) + REP = REP.normalized * EyeRad; + LeftEye.transform.localPosition = LEP + DefaultL + AnimOffs; + RightEye.transform.localPosition = REP + DefaultR + AnimOffs; + + } +} diff --git a/AttMoveCheck.cs b/AttMoveCheck.cs new file mode 100644 index 0000000..134063e --- /dev/null +++ b/AttMoveCheck.cs @@ -0,0 +1,30 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class AttMoveCheck : MonoBehaviour { + public AttractorBalance[] AB; + public Vector3 PrevPos; + public Quaternion zero = new Quaternion(0, 0, 0, 0); + private AudioSource AS; + // Use this for initialization + void Start () { + AB = FindObjectsOfType(); + AS = GetComponent(); + } + + // Update is called once per frame + void Update() + { + if (Input.GetButtonDown("Slow Time") && AS.pitch > 0.11f) + AS.pitch *= 0.1f; + if (Input.GetButtonUp("Slow Time") && AS.pitch < 0.11f) + AS.pitch *= 10f; + if (transform.position != PrevPos) + { + PrevPos = transform.position; + foreach (AttractorBalance A in AB) + A.ChangeMags(); + } + } +} diff --git a/Attractor.cs b/Attractor.cs new file mode 100644 index 0000000..5042d95 --- /dev/null +++ b/Attractor.cs @@ -0,0 +1,15 @@ +using UnityEngine; +using System.Collections; + +public class Attractor : MonoBehaviour { + + // Use this for initialization + void Start () { + + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/AttractorBalance.cs b/AttractorBalance.cs new file mode 100644 index 0000000..8552cff --- /dev/null +++ b/AttractorBalance.cs @@ -0,0 +1,54 @@ +using UnityEngine; +using System.Collections; + +public class AttractorBalance : MonoBehaviour { + + public bool Gset = true; + public Vector2 MagnetizePos; + private Rigidbody2D CharRig; + // Use this for initialization + void Start () + { + CharRig = GetComponent(); + } + + // Update is called once per frame + void FixedUpdate () + { + if (!Gset) + { + CharRig.AddForce(((MagnetizePos - CharRig.position)/4) , ForceMode2D.Impulse); + CharRig.velocity *= 0.925f; + } + } + + public void ChangeMags() + { + GameObject[] GO = + GameObject.FindGameObjectsWithTag("Attractor_tag"); + + MagnetizePos = Vector2.zero; + + if (GO.Length > 0) + { + int j = 0; + foreach (GameObject i in GO) + { + i.transform.rotation = Quaternion.identity; + j++; + MagnetizePos += new Vector2(i.transform.position.x, i.transform.position.y); + } + MagnetizePos /= j; + if (Gset) + { + CharRig.gravityScale = 0; + Gset = false; + } + } + else if (!Gset) + { + CharRig.gravityScale = 1; + Gset = true; + } + } +} diff --git a/ButtonHoldObject.cs b/ButtonHoldObject.cs new file mode 100644 index 0000000..ebb063d --- /dev/null +++ b/ButtonHoldObject.cs @@ -0,0 +1,48 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ButtonHoldObject : MonoBehaviour { + public GameObject LeverObject; + public Sprite UnPressed; + public Sprite Pressed; + public bool RequiresPressable; + private SpriteRenderer SR; + public int ObjectsInside; + private void Start() + { + SR = GetComponent(); + } + void OnTriggerEnter2D(Collider2D other) + { + if (RequiresPressable) + { + if(other.tag == "CanPress") + ObjectsInside++; + } + else + ObjectsInside++; + if (ObjectsInside > 0) + { + SR.sprite = Pressed; + LeverObject.SetActive(false); + } + } + void OnTriggerExit2D(Collider2D other) + { + + if (RequiresPressable) + { + if (other.tag == "CanPress") + ObjectsInside--; + } + else + ObjectsInside--; + if (ObjectsInside <= 0) + { + SR.sprite = UnPressed; + LeverObject.SetActive(true); + } + + } +} diff --git a/Checkpoint.cs b/Checkpoint.cs new file mode 100644 index 0000000..960c42b --- /dev/null +++ b/Checkpoint.cs @@ -0,0 +1,24 @@ +using UnityEngine; +using System.Collections; + +public class Checkpoint : MonoBehaviour { + + // Use this for initialization + void Start () { + + } + + // Update is called once per frame + void Update () + { + + } + void OnTriggerEnter2D(Collider2D collision) + { + Debug.Log(collision.gameObject.tag); + if (collision.gameObject.tag == "Contravert") + { + collision.gameObject.GetComponent().StartPos = collision.gameObject.transform.position; + } + } +} diff --git a/ConSpr_Code.cs b/ConSpr_Code.cs new file mode 100644 index 0000000..be10b1e --- /dev/null +++ b/ConSpr_Code.cs @@ -0,0 +1,16 @@ +using UnityEngine; +using System.Collections; + +public class ConSpr_Code : MonoBehaviour { + private GameObject Contravert; + + void Start () + { + Contravert = GameObject.FindGameObjectWithTag("Contravert"); + } + // Update is called once per frame + void Update () + { + transform.position = Contravert.transform.position; + } +} diff --git a/Fan.cs b/Fan.cs new file mode 100644 index 0000000..3ca1224 --- /dev/null +++ b/Fan.cs @@ -0,0 +1,17 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Fan : MonoBehaviour { + + // Use this for initialization + void Start () { + + } + + // Update is called once per frame + void Update () + { + transform.Rotate(Vector3.up, Time.deltaTime * 360); + } +} diff --git a/FollowChar.cs b/FollowChar.cs new file mode 100644 index 0000000..999134b --- /dev/null +++ b/FollowChar.cs @@ -0,0 +1,39 @@ +using UnityEngine; +using System.Collections; + +public class FollowChar : MonoBehaviour { + + //this class is really shit, if I intend to use the chase cam I should redo the whole thing. + + private GameObject Conv; + private Vector3 Target; + public float MincX, MincY, MaxcX, MaxcY, MinX, MinY, MaxX, MaxY; + // Use this for initialization + void Start () + { + Conv = GameObject.FindGameObjectWithTag("Contravert"); + } + + // Update is called once per frame + void Update () + { + if (Conv.transform.position.x > MincX && Conv.transform.position.y > MincY && Conv.transform.position.x < MaxcX && Conv.transform.position.y < MaxcY) + { + Target.z = -10; + if (Conv.transform.position.x < MinX) + Target.x = MinX; + else if (Conv.transform.position.x > MaxX) + Target.x = MaxX; + else + Target.x = Conv.transform.position.x; + + if (Conv.transform.position.y < MinY) + Target.y = MinY; + else if (Conv.transform.position.y > MaxY) + Target.y = MaxY; + else + Target.y = Conv.transform.position.y; + transform.position = Vector3.MoveTowards(transform.position, Target, 1); + } + } +} diff --git a/GenAtt.cs b/GenAtt.cs new file mode 100644 index 0000000..8a1274e --- /dev/null +++ b/GenAtt.cs @@ -0,0 +1,370 @@ +using UnityEngine; +using System.Collections; +using UnityEngine.SceneManagement; + +public class GenAtt : MonoBehaviour { + [HideInInspector] + public AudioSource ConSound; //Sound the magnets make when created + public Vector3 StartPos; //position player stars at when dying + public Transform Att, Att2, Att3; //attractor positions + public LayerMask MLcast; //objects the mouse can click on + [HideInInspector] + public ContactFilter2D OverlapCast; // + [HideInInspector] + public AttractorBalance[] BalanceNodes; + [HideInInspector] + public GameObject ClingToObj; + [HideInInspector] + public Rigidbody2D ThisObj; + public GameObject[] Hazards; + private GameObject[] ResHazards; + private DeviceType DT; + private GameObject[] Atts = + new GameObject[3]; + private int[] CurrentAtt = + { 0,1,2}; + private Vector2 pos2D; + bool Tick = false; + bool DeathTick = false; + bool CanSloMo = true; + public bool ResetLevel; + + + void OnTriggerEnter2D(Collider2D collision) + { + if (collision.tag == "NoSloMo") + { + Time.timeScale = 0.75f; + CanSloMo = false; + } + } + void OnTriggerExit2D(Collider2D collision) + { + if (collision.tag == "NoSloMo") + { + Time.timeScale = 1f; + CanSloMo = true; + } + } + void Start() + { + OverlapCast.layerMask = MLcast; + DT = + SystemInfo.deviceType; + StartPos = transform.position; + ThisObj = GetComponent(); + + ResHazards = new GameObject[Hazards.Length]; + for (int i = 0; i < Hazards.Length; i++) + { + ResHazards[i] = GameObject.Instantiate(Hazards[i]); + } + foreach (GameObject RH in ResHazards) + { + RH.SetActive(false); + } + } + + void OnCollisionEnter2D(Collision2D other) + { + if (other.gameObject.tag == "KillPlayer") + Die(); + if (other.gameObject.tag == "Checkpoint") + StartPos = transform.position; + } + + public void RemPort() + { + foreach (GameObject A in Atts) + { + Destroy(A); + } + Tick = true; + } + + void Die() + { + if (ResetLevel) + SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); + else + { + foreach (GameObject A in Atts) + { + Destroy(A); + } + Tick = true; + DeathTick = true; + transform.position = StartPos; + ThisObj.velocity = Vector2.zero; + ThisObj.angularVelocity = 0; + foreach (GameObject H in Hazards) + { + GameObject.Destroy(H); + } + for (int i = 0; i < ResHazards.Length; i++) + { + Hazards[i] = GameObject.Instantiate(ResHazards[i]); + Hazards[i].SetActive(true); + } + } + } + + // Update is called once per frame + void Update () + { + if (Input.GetButtonDown("Slow Time") && CanSloMo) + { + Time.timeScale = 0.2f; + } + if (Input.GetButtonUp("Slow Time") && CanSloMo) + Time.timeScale = 1; + pos2D = + new Vector2 (transform.position.x, transform.position.y); + + if (DT == DeviceType.Desktop || DT == DeviceType.Unknown) + { + + if (Tick) + { + BalanceNodes = FindObjectsOfType(typeof(AttractorBalance)) as AttractorBalance[]; + foreach (AttractorBalance AB in BalanceNodes) + { + AB.ChangeMags(); + } + Tick = false; + if (DeathTick) + GetComponent().velocity = Vector2.zero; + DeathTick = false; + } + if (Input.GetButtonDown("Magnet 1") || Input.GetButtonDown("Magnet 2") || Input.GetButtonDown("Magnet 3")) + { + Vector3 _MousePoint = + Camera.main.ScreenToWorldPoint(new Vector3 (Input.mousePosition.x, Input.mousePosition.y, 10)); + Vector2 MousePoint = //2D mousepoint in relation to the player + new Vector2 (_MousePoint.x, _MousePoint.y); + MousePoint = MousePoint - pos2D; + MousePoint = MousePoint.normalized; + Collider2D RC = Physics2D.OverlapPoint(_MousePoint, MLcast); + if (RC != null && RC.gameObject.tag == "Placeable") + { + ClingToObj = RC.gameObject; + if (Input.GetButtonDown("Magnet 1")) + CreateATT(0, _MousePoint); + if (Input.GetButtonDown("Magnet 2")) + CreateATT(1, _MousePoint); + if (Input.GetButtonDown("Magnet 3")) + CreateATT(2, _MousePoint); + + } + else + { + Collider2D RCircle = Physics2D.OverlapCircle(_MousePoint, 1, MLcast); + if (RCircle != null && RCircle.gameObject.tag == "Placeable") + { + Vector2 NearestPoint = Vector2.zero; + float NearestDist = 10; + for (int i = -1; i <= 1; i++) + { + for (int j = -1; j <= 1; j++) + { + RaycastHit2D RCH = + Physics2D.Linecast(_MousePoint, _MousePoint +new Vector3(i, j), MLcast); + Debug.DrawLine(_MousePoint, _MousePoint + new Vector3(i, j)); + Debug.Log("CircleHit " + RCH.collider); + if (RCH.collider != null && RCH.collider.gameObject.tag == "Placeable" && RCH.distance < NearestDist) + { + ClingToObj = RCH.collider.gameObject; + NearestDist = RCH.distance; + NearestPoint = RCH.point; + } + } + } + + + if (NearestPoint != Vector2.zero) + { + if (Input.GetButtonDown("Magnet 1")) + CreateATT(0, NearestPoint); + if (Input.GetButtonDown("Magnet 2")) + CreateATT(1, NearestPoint); + if (Input.GetButtonDown("Magnet 3")) + CreateATT(2, NearestPoint); + + } + + + } + + else + { + RaycastHit2D RCH = + Physics2D.Raycast(pos2D, MousePoint, 1000f, MLcast); + + + if (RCH.collider != null && RCH.collider.gameObject.tag == "Placeable") + { + ClingToObj = RCH.collider.gameObject; + if (Input.GetButtonDown("Magnet 1")) + CreateATT(0, RCH.point); + if (Input.GetButtonDown("Magnet 2")) + CreateATT(1, RCH.point); + if (Input.GetButtonDown("Magnet 3")) + CreateATT(2, RCH.point); + + + } + } + } + + //Other OnClick effects... + } + if(Input.GetButtonDown("Remove Magnets")) + { + foreach(GameObject A in Atts) + { + Destroy(A); + } + Tick = true; + } + //Other PC specific code + } + + else + { + if (Tick) + { + BalanceNodes = FindObjectsOfType(typeof(AttractorBalance)) as AttractorBalance[]; + foreach (AttractorBalance AB in BalanceNodes) + { + AB.ChangeMags(); + } + Tick = false; + Tick = false; + if (DeathTick) + GetComponent().velocity = Vector2.zero; + DeathTick = false; + + } + if (Input.touchCount > 0) + { + foreach (Touch Tap in Input.touches) + { + if (Tap.phase == TouchPhase.Ended) + { + Vector3 _MousePoint = + Camera.main.ScreenToWorldPoint(new Vector3(Tap.position.x, Tap.position.y, 0)); + Vector2 MousePoint = + new Vector2(_MousePoint.x, _MousePoint.y); + + Collider2D RC = Physics2D.OverlapPoint(MousePoint, 1 << 9); + if (RC != null && RC.gameObject.tag == "Attractor_tag") + { + Destroy(RC.gameObject); + Tick = true; + } + else if (RC != null && RC.gameObject.tag == "RemPort") + { + foreach (GameObject A in Atts) + { + Destroy(A); + } + Tick = true; + } + else + { + MousePoint = MousePoint - pos2D; + MousePoint = MousePoint.normalized; + RaycastHit2D RCH = + Physics2D.Raycast(pos2D, MousePoint, 50f, MLcast); + + Collider2D RCX = Physics2D.OverlapPoint(MousePoint, MLcast); + if (RCX != null && RCX.gameObject.tag == "Placeable") + { + if (Atts[0] == null) + CreateATT(0, RCH.point); + else if (Atts[1] == null) + CreateATT(1, RCH.point); + else if (Atts[2] == null) + CreateATT(2, RCH.point); + else + CreateATT(CurrentAtt[0], RCH.point); + } + + else if (RCH.collider != null) + { + //Play *Shock* animation + if (RCH.collider.gameObject.tag == "Placeable") + { + if (Atts[0] == null) + CreateATT(0, RCH.point); + else if (Atts[1] == null) + CreateATT(1, RCH.point); + else if (Atts[2] == null) + CreateATT(2, RCH.point); + else + CreateATT(CurrentAtt[0], RCH.point); + } + } + } + } + } + } + } + } + + void CreateATT(int ThisATT, Vector2 Location) + { + + for (int i = 0; i < CurrentAtt.Length -1; i ++) + { + if (CurrentAtt[i] == ThisATT) + { + CurrentAtt[i] = CurrentAtt[i + 1]; + CurrentAtt[i + 1] = ThisATT; + } + } + if (Atts[ThisATT] != null) + { + Atts[ThisATT].transform.position = + new Vector3(Location.x, Location.y, 0); + Atts[ThisATT].transform.SetParent(ClingToObj.transform); + ConSound = Atts[ThisATT].GetComponent(); + + } + else + { + if (DT == DeviceType.Desktop) + { + if (ThisATT == 0) + Atts[ThisATT] = + (Instantiate(Att, new Vector3(Location.x, Location.y, 0), new Quaternion()) as Transform).gameObject; + if (ThisATT == 1) + Atts[ThisATT] = + (Instantiate(Att2, new Vector3(Location.x, Location.y, 0), new Quaternion()) as Transform).gameObject; + if (ThisATT == 2) + Atts[ThisATT] = + (Instantiate(Att3, new Vector3(Location.x, Location.y, 0), new Quaternion()) as Transform).gameObject; + ConSound = Atts[ThisATT].GetComponent(); + } + else + { + Atts[ThisATT] = + (Instantiate(Att, new Vector3(Location.x, Location.y, 0), new Quaternion()) as Transform).gameObject; + ConSound = Atts[ThisATT].GetComponent(); + } + Atts[ThisATT].transform.SetParent(ClingToObj.transform); + Atts[ThisATT].transform.rotation =Quaternion.identity; + } + BalanceNodes = FindObjectsOfType(typeof(AttractorBalance)) as AttractorBalance[]; + foreach (AttractorBalance AB in BalanceNodes) + { + AB.ChangeMags(); + } + ConSound.volume = 0.3f; + if (Time.timeScale == 0.2f) + ConSound.pitch = 0.07f + Random.value * 0.03f; + else + ConSound.pitch = 0.7f + Random.value * 0.3f; + ConSound.Play(); + } +} diff --git a/LoadIfLevelCompleted.cs b/LoadIfLevelCompleted.cs new file mode 100644 index 0000000..3a1dfdc --- /dev/null +++ b/LoadIfLevelCompleted.cs @@ -0,0 +1,26 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; + +public class LoadIfLevelCompleted : MonoBehaviour { + public GameObject[] ObjectsToHide; + public int ReqLvl; + // Use this for initialization + void Start () + { + if (PlayerPrefs.GetInt(ReqLvl.ToString()) > 0) + { + foreach(GameObject GO in ObjectsToHide) + { + GO.SetActive(true); + } + } + else + foreach (GameObject GO in ObjectsToHide) + { + GO.SetActive(false); + } + } + +} diff --git a/MagnetImage.cs b/MagnetImage.cs new file mode 100644 index 0000000..0dd8bfe --- /dev/null +++ b/MagnetImage.cs @@ -0,0 +1,26 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class MagnetImage : MonoBehaviour { + public Sprite[] Sprites; + public float FadeTime; + + private float NextSprite; + // Use this for initialization + void Start () + { + + } + + // Update is called once per frame + void Update () + { + if (NextSprite > 0) + NextSprite -= Time.deltaTime; + else + { + + } + } +} diff --git a/OpenSettings.cs b/OpenSettings.cs new file mode 100644 index 0000000..bebe124 --- /dev/null +++ b/OpenSettings.cs @@ -0,0 +1,12 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class OpenSettings : MonoBehaviour { + public GameObject SettingsObject; + + public void OnClick () + { + SettingsObject.SetActive(!SettingsObject.activeSelf); + } +} diff --git a/Paralax.cs b/Paralax.cs new file mode 100644 index 0000000..dea740c --- /dev/null +++ b/Paralax.cs @@ -0,0 +1,28 @@ +using UnityEngine; +using System.Collections; + +public class Paralax : MonoBehaviour { + private GameObject MC; + private Vector3 InitialPosition; + public float Layer; //Largest at back + public float LVLW, LVLH; + public bool InvX, InvY; //Set to -1 to invert, otherwise set to 1 + // Use this for initialization + void Start () + { + MC = GameObject.FindGameObjectWithTag("MainCamera"); + InitialPosition = transform.localPosition; + } + + // Update is called once per frame + void Update () + { + float XM = MC.transform.position.x; + float YM = MC.transform.position.y; + if (InvX) + XM = LVLW - XM; + if (InvY) + YM = LVLH - YM; + transform.localPosition = new Vector3((XM / LVLW)*((Layer*2f)-(Layer * 0.1f)), (YM / LVLH)*((Layer*0.2f) - (Layer*0.1f)), 1) + InitialPosition; + } +} diff --git a/Patrol.cs b/Patrol.cs new file mode 100644 index 0000000..5418856 --- /dev/null +++ b/Patrol.cs @@ -0,0 +1,32 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class Patrol : MonoBehaviour { + public Vector2 StartPos; + public Vector2 EndPos; + public float speed; + private Vector2 TargetPos; + // Use this for initialization + void Start () + { + TargetPos = StartPos; + } + + // Update is called once per frame + void Update () + { + if (Vector2.Distance(transform.position,TargetPos) < speed*Time.deltaTime) + { + transform.position = TargetPos; + if (TargetPos == EndPos) + TargetPos = StartPos; + else + TargetPos = EndPos; + } + else + { + transform.position = Vector2.MoveTowards(transform.position, TargetPos, speed*Time.deltaTime); + } + } +} diff --git a/PauseGame.cs b/PauseGame.cs new file mode 100644 index 0000000..0acd1e7 --- /dev/null +++ b/PauseGame.cs @@ -0,0 +1,203 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; +using UnityEngine.SceneManagement; +using UnityEngine.EventSystems; + +//I don't even know what's going on in here anymore, there's so, so much shit on this page. + +public class PauseGame : MonoBehaviour +{ + public bool IsPaused = false; //is the game paused? + public bool IsOptions = false; //is the options menu opened? + public AudioSource Audible; //music source + public GameObject BGcamera; //background camera + public GameObject BGimage; //image that is substituted for the background camera. Should I disable the background objects as well? maybe... + public GameObject PauseMenu; //Pause menu GUI + public GameObject OptionsMenu; //Options menu GUI + [HideInInspector] + public CanvasGroup PauseAlpha; //Changing the .alpha changes the pause menu alpha + [HideInInspector] + public GameObject Player; //Guess what this is? + public float CtimeScale = 1; //Current timescale, converted tickrate. + [HideInInspector] + public AudioListener Audacity; + [HideInInspector] + public int TextureQuality = 0; //overall game quality + [HideInInspector] + public float MusicVol = 1; + [HideInInspector] + public float MasterVol = 1; + [HideInInspector] + public float Tickrate = 60; + [HideInInspector] + public bool PrettyBackgrounds = false; + public Slider TexSlid; + public Slider TickSlid; + public Slider MusSlid; + public Slider MasSlid; + public Toggle BGTog; + + void Start () + { + Player = GameObject.FindGameObjectWithTag("Player"); + PauseAlpha = GetComponentInChildren(); + PauseMenu.SetActive(false); + OptionsMenu.SetActive(false); + if (PlayerPrefs.GetInt("FirstPlay",0) != 1) + { + int QualityLvl = QualitySettings.GetQualityLevel(); + TextureQuality = QualityLvl; + Tickrate = 250 * (QualityLvl + 1); + MusicVol = 50; + MasterVol = 50; + if (QualityLvl > 1) + { + PrettyBackgrounds = true; + PlayerPrefs.SetInt("PrettyBackgrounds", 1); + } + PlayerPrefs.SetFloat("Tickrate", Tickrate); + PlayerPrefs.SetInt("TextureQuality", QualityLvl); + PlayerPrefs.SetFloat("MusicVol", MusicVol); + PlayerPrefs.SetFloat("MasterVol", MasterVol); + PlayerPrefs.SetInt("FirstPlay", 1); + } + else + { + Tickrate = PlayerPrefs.GetFloat("Tickrate",60); + TextureQuality = PlayerPrefs.GetInt("TextureQuality",1); + MusicVol = PlayerPrefs.GetFloat("MusicVol",50); + MasterVol = PlayerPrefs.GetFloat("MasterVol",50); + int PBG = PlayerPrefs.GetInt("PrettyBackgrounds", 0); + if (PBG == 1) + PrettyBackgrounds = true; + else + PrettyBackgrounds = false; + } + } + public void AdjustTQ(float TQ) + { + TextureQuality = (int)TQ; + } + public void AdjustMusV(float MV) + { + MusicVol = MV; + } + public void AdjustMasV(float TQ) + { + MusicVol = TQ; + } + public void AdjustPB(bool PB) + { + PrettyBackgrounds = PB; + } + public void AdjustTick(float tick) + { + Tickrate = tick; + } + void Update () + { + if (PauseMenu.activeSelf && PauseAlpha.alpha < 1) + { + PauseAlpha.alpha += 0.1f; + } + + if (Input.GetButtonDown("Pause")) + { + if (IsPaused) + Continue(); + else + OpenPause(); + } + if (Input.GetButtonDown("Slow Time") && CtimeScale == 1) + { + CtimeScale = 0.2f; + } + else if (Input.GetButtonUp("Slow Time") && CtimeScale == 0.2f) + { + CtimeScale = 1f; + } + + } + public void OpenPause() + { + //open Pause Menu + PauseMenu.SetActive(true); + IsPaused = true; + if (Player != null) + Player.SetActive(false); + + } + public void Continue() + { + //close Pause Menu + PauseMenu.SetActive(false); + IsPaused = false; + PauseAlpha.alpha = 0; + if (Player != null) + Player.SetActive(true); + } + public void Restart() + { + IsPaused = false; + Time.timeScale = 1; + SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex); + Player.SetActive(true); + + } + public void Map() + { + IsPaused = false; + Time.timeScale = 1; + SceneManager.LoadScene("Level select"); + Player.SetActive(true); + + } + public void OpenOptions() + { + //Opens Options Menu + IsOptions = true; + PauseMenu.SetActive(false); + OptionsMenu.SetActive(true); + TexSlid.value = TextureQuality; + TickSlid.value = Tickrate; + MusSlid.value = MusicVol; + MasSlid.value = MasterVol; + BGTog.isOn = PrettyBackgrounds; +} + public void CloseOptions() + { + IsOptions = false; + PauseMenu.SetActive(true); + OptionsMenu.SetActive(false); + } + public void Apply() + { + + QualitySettings.SetQualityLevel(TextureQuality); + AudioListener.volume = MasterVol / 100; + Audible.volume = MusicVol / 100; + if (PrettyBackgrounds) + { + if (BGcamera != null) + BGcamera.SetActive(true); + BGimage.SetActive(false); + PlayerPrefs.SetInt("PrettyBackgrounds", 1); + } + else + { + if (BGcamera != null) + BGcamera.SetActive(false); + BGimage.SetActive(true); + PlayerPrefs.SetInt("PrettyBackgrounds", 0); + } + Time.fixedDeltaTime = 1/Tickrate; + Debug.Log(Tickrate); + CloseOptions(); + PlayerPrefs.SetFloat("Tickrate", Tickrate); + PlayerPrefs.SetInt("TextureQuality", TextureQuality); + PlayerPrefs.SetFloat("MusicVol", MusicVol); + PlayerPrefs.SetFloat("MasterVol", MasterVol); + } +} diff --git a/RemoveMags.cs b/RemoveMags.cs new file mode 100644 index 0000000..a919f1f --- /dev/null +++ b/RemoveMags.cs @@ -0,0 +1,14 @@ +using UnityEngine; +using System.Collections; + +public class RemoveMags : MonoBehaviour { + + // Use this for initialization + void Start () + { + if (SystemInfo.deviceType == DeviceType.Desktop) + { + GameObject.Destroy(gameObject); + } + } +} diff --git a/ResetObjects.cs b/ResetObjects.cs new file mode 100644 index 0000000..13c234b --- /dev/null +++ b/ResetObjects.cs @@ -0,0 +1,31 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ResetObjects : MonoBehaviour { + public GameObject[] ToReset; + private Vector3[] transformations; + private float[] Rotations; + // Use this for initialization + void Start () + { + transformations = new Vector3[ToReset.Length]; + for (int i = 0; i < ToReset.Length;i++) + { + transformations[i] = ToReset[i].transform.position; + Rotations[i] = ToReset[i].GetComponent().rotation; + } + } + + // Update is called once per frame + public void OnDeath () + { + for (int i = 0; i < ToReset.Length; i++) + { + ToReset[i].GetComponent().MovePosition(transformations[i]); + ToReset[i].GetComponent().MoveRotation(Rotations[i]); + ToReset[i].GetComponent().velocity = Vector3.zero; + ToReset[i].GetComponent().angularVelocity = 0; + } + } +} diff --git a/ResumeGame.cs b/ResumeGame.cs new file mode 100644 index 0000000..666b219 --- /dev/null +++ b/ResumeGame.cs @@ -0,0 +1,16 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ResumeGame : MonoBehaviour { + + // Use this for initialization + void Start () { + + } + + // Update is called once per frame + void Update () { + + } +} diff --git a/SettingsButton.cs b/SettingsButton.cs new file mode 100644 index 0000000..6392c2e --- /dev/null +++ b/SettingsButton.cs @@ -0,0 +1,136 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.UI; +using UnityEngine.SceneManagement; +using UnityEngine.EventSystems; + +//I don't even know what's going on in here anymore, there's so, so much shit on this page. + +public class SettingsButton : MonoBehaviour +{ + public bool IsPaused = false; //is the game paused? + public bool IsOptions = false; //is the options menu opened? + public AudioSource Audible; //music source + public GameObject OptionsMenu; //Options menu GUI + public GameObject Menu; + [HideInInspector] + public GameObject Player; //Guess what this is? + public float CtimeScale = 1; //Current timescale, converted tickrate. + [HideInInspector] + public int TextureQuality = 0; //overall game quality + [HideInInspector] + public float MusicVol = 1; + [HideInInspector] + public float MasterVol = 1; + [HideInInspector] + public float Tickrate = 60; + [HideInInspector] + public bool PrettyBackgrounds = false; + public Slider TexSlid; + public Slider TickSlid; + public Slider MusSlid; + public Slider MasSlid; + public Toggle BGTog; + + void Start () + { + Player = GameObject.FindGameObjectWithTag("Player"); + OptionsMenu.SetActive(false); + if (PlayerPrefs.GetInt("FirstPlay",0) != 1) + { + int QualityLvl = QualitySettings.GetQualityLevel(); + TextureQuality = QualityLvl; + Tickrate = 250 * (QualityLvl + 1); + MusicVol = 50; + MasterVol = 50; + if (QualityLvl > 1) + { + PrettyBackgrounds = true; + PlayerPrefs.SetInt("PrettyBackgrounds", 1); + } + PlayerPrefs.SetFloat("Tickrate", Tickrate); + PlayerPrefs.SetInt("TextureQuality", QualityLvl); + PlayerPrefs.SetFloat("MusicVol", MusicVol); + PlayerPrefs.SetFloat("MasterVol", MasterVol); + PlayerPrefs.SetInt("FirstPlay", 1); + } + else + { + Tickrate = PlayerPrefs.GetFloat("Tickrate",60); + TextureQuality = PlayerPrefs.GetInt("TextureQuality",1); + MusicVol = PlayerPrefs.GetFloat("MusicVol",50); + MasterVol = PlayerPrefs.GetFloat("MasterVol",50); + int PBG = PlayerPrefs.GetInt("PrettyBackgrounds", 0); + if (PBG == 1) + PrettyBackgrounds = true; + else + PrettyBackgrounds = false; + } + } + + public void AdjustTQ(float TQ) + { + TextureQuality = (int)TQ; + } + public void AdjustMusV(float MV) + { + MusicVol = MV; + } + public void AdjustMasV(float TQ) + { + MusicVol = TQ; + } + public void AdjustPB(bool PB) + { + PrettyBackgrounds = PB; + } + public void AdjustTick(float tick) + { + Tickrate = tick; + } + public void OpenOptions() + { + //Opens Options Menu + IsOptions = true; + OptionsMenu.SetActive(true); + TexSlid.value = TextureQuality; + TickSlid.value = Tickrate; + MusSlid.value = MusicVol; + MasSlid.value = MasterVol; + BGTog.isOn = PrettyBackgrounds; + Menu.SetActive(false); +} + public void CloseOptions() + { + IsOptions = false; + OptionsMenu.SetActive(false); + Menu.SetActive(true); + } + public void Apply() + { + QualitySettings.SetQualityLevel(TextureQuality); + AudioListener.volume = MasterVol / 100; + Audible.volume = MusicVol / 100; + if (PrettyBackgrounds) + { + PlayerPrefs.SetInt("PrettyBackgrounds", 1); + } + else + { + PlayerPrefs.SetInt("PrettyBackgrounds", 0); + } + Time.fixedDeltaTime = 1/Tickrate; + Debug.Log(Tickrate); + + PlayerPrefs.SetFloat("Tickrate", Tickrate); + PlayerPrefs.SetInt("TextureQuality", TextureQuality); + PlayerPrefs.SetFloat("MusicVol", MusicVol); + PlayerPrefs.SetFloat("MasterVol", MasterVol); + CloseOptions(); + } + public void SwitchToLevel(int i) + { + SceneManager.LoadScene(i); + } +} diff --git a/ShouldSplat.cs b/ShouldSplat.cs new file mode 100644 index 0000000..4d5914d --- /dev/null +++ b/ShouldSplat.cs @@ -0,0 +1,29 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class ShouldSplat : MonoBehaviour { + float PrevVel; + Rigidbody2D SquishyRigid; + AudioSource SoundSource; + + // Use this for initialization + void Start () + { + SquishyRigid = GetComponent(); + SoundSource = GetComponent(); + PrevVel = Mathf.NegativeInfinity; + } + + // Update is called once per frame + void Update () + { + if (SquishyRigid.velocity.magnitude - PrevVel < -5f) + { + SoundSource.volume = -(SquishyRigid.velocity.magnitude - PrevVel +5) * 0.1f; + SoundSource.Play(); + } + PrevVel = SquishyRigid.velocity.magnitude; + + } +} diff --git a/SpinningThings.cs b/SpinningThings.cs new file mode 100644 index 0000000..c428c3c --- /dev/null +++ b/SpinningThings.cs @@ -0,0 +1,33 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class SpinningThings : MonoBehaviour { + public bool ShouldSpin; + public float PushLength; + public float MoveSpeed; + + private float MovedAmount; + private Vector3 StartPos; + // Use this for initialization + void Start () + { + StartPos = transform.localPosition; + } + + // Update is called once per frame + void Update () + { + if (ShouldSpin) transform.Rotate(Vector3.forward,360*Time.deltaTime); + if (MoveSpeed > 0) + { + transform.position += transform.up * Time.deltaTime * MoveSpeed; + MovedAmount += MoveSpeed * Time.deltaTime; + if (MovedAmount > PushLength) + { + MovedAmount -= PushLength; + transform.position -= PushLength * transform.up; + } + } + } +} diff --git a/SwitchStage.cs b/SwitchStage.cs new file mode 100644 index 0000000..d2e8f2c --- /dev/null +++ b/SwitchStage.cs @@ -0,0 +1,54 @@ +using UnityEngine; +using System.Collections; +using UnityEngine.SceneManagement; + +public class SwitchStage : MonoBehaviour { + public int ThisLvl; + private int CurrentLevel; + private int CurrentLevels; + private int LVLreq; + public bool SwitchCond; + public int levelRequirement; + public + // Use this for initialization + void Start() + { + CurrentLevel = SceneManager.GetActiveScene().buildIndex; + for (int i = 0; i <= GameObject.FindObjectsOfType().Length + 1; i ++) + { + LVLreq += PlayerPrefs.GetInt(i.ToString()); + } + } + void OnTriggerEnter2D(Collider2D Col2d) + { + if (SwitchCond && Col2d.gameObject.tag == "Contravert") + { + PlayerPrefs.SetInt(CurrentLevel.ToString(), 1); + SceneManager.LoadScene("Level select"); + + } + Debug.Log(Col2d); + } + void OnMouseDown() + { + Debug.Log(LVLreq); + if (!SwitchCond && LVLreq >= levelRequirement) + SceneManager.LoadScene(ThisLvl +1); + } + void Update() + { + if (!SwitchCond) + { + if (LVLreq < levelRequirement) + GetComponent().color = Color.clear; + else if (PlayerPrefs.GetInt(ThisLvl.ToString()) == 0) + GetComponent().color = Color.white; + else + GetComponent().color = Color.blue; + } + else + { + transform.Rotate(Vector3.forward, -360 * Time.deltaTime); + } + } +} diff --git a/TickrateAffiliate.cs b/TickrateAffiliate.cs new file mode 100644 index 0000000..c536c9f --- /dev/null +++ b/TickrateAffiliate.cs @@ -0,0 +1,23 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class TickrateAffiliate : MonoBehaviour { + public Rigidbody2D Target; + // Use this for initialization + void Start () + { + } + + // Update is called once per frame + void Update () + { + transform.position += (Vector3)Target.velocity * Time.deltaTime; + transform.Rotate(Vector3.forward, Target.angularVelocity * Time.deltaTime); + } + void FixedUpdate() + { + transform.position = Target.position; + transform.rotation = Target.transform.rotation; + } +} diff --git a/dieOnCol.cs b/dieOnCol.cs new file mode 100644 index 0000000..79b5ca9 --- /dev/null +++ b/dieOnCol.cs @@ -0,0 +1,27 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class dieOnCol : MonoBehaviour { + public bool ShouldRes; + Vector3 StartPos; + void Start() + { + StartPos = transform.position; + } + void OnCollisionEnter2D(Collision2D other) + { + + if (other.gameObject.tag == "KillPlayer") + { + if (!ShouldRes) + GameObject.Destroy(gameObject); + else + { + transform.position = StartPos; + GetComponent().velocity = Vector2.zero; + GetComponent().angularVelocity = 0; + } + } + } +} diff --git a/stretchSkew.cs b/stretchSkew.cs new file mode 100644 index 0000000..e5ebb91 --- /dev/null +++ b/stretchSkew.cs @@ -0,0 +1,36 @@ +using UnityEngine; +using System.Collections; + +public class stretchSkew : MonoBehaviour { + + public Rigidbody2D RGB; + public Transform TRN; + private float RotateOffset = 0; + private float ROS; + // Use this for initialization + void Start () + { + } + + // Update is called once per frame + void Update () + { + transform.position = TRN.position; + TRN.localPosition = Vector3.zero; + float angle = Mathf.Atan2(RGB.velocity.y, RGB.velocity.x) * Mathf.Rad2Deg; + Vector3 Rot = transform.rotation.eulerAngles; + Rot.z = angle; + transform.rotation = Quaternion.Euler(Rot); + + ROS = Mathf.DeltaAngle(RotateOffset, -angle); + TRN.Rotate(0, 0, ROS,Space.Self); + RotateOffset += ROS; + + + + if (RGB.velocity.magnitude < 10f) + transform.localScale = new Vector3(1, 1f - 0.5f * (RGB.velocity.magnitude) / 10, 1); + else + transform.localScale = new Vector3(1, 0.5f, 1); + } +}