A bit of code cleanup.

This commit is contained in:
Kaj Forney 2021-10-31 13:43:04 -06:00
parent 9e198b844e
commit 8a7fe3ee8f
Signed by: kforney
GPG key ID: 3AB4E2E04CEF656F
12 changed files with 16 additions and 93 deletions

View file

@ -1,6 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
public class CoinCollect : MonoBehaviour
{

View file

@ -1,6 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
public class GroundCheck : MonoBehaviour
{

View file

@ -1,6 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
using UnityEngine.SceneManagement;
public class MainMenu : MonoBehaviour

View file

@ -1,6 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
public class Movement2D : MonoBehaviour
{

View file

@ -1,6 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
public class PlatformManager : MonoBehaviour
{

View file

@ -1,6 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine;
using UnityEngine.UI;
public class ScoreCounter : MonoBehaviour

View file

@ -1,7 +1,4 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SocialPlatforms.Impl;
using UnityEngine.UI;
public class endingScore : MonoBehaviour
@ -11,10 +8,4 @@ public class endingScore : MonoBehaviour
{
GetComponent<Text>().text = "score: " + ScoreCounter.scoreAmount.ToString();
}
// Update is called once per frame
void Update()
{
}
}

View file

@ -1,23 +1,8 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class goal : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
private void OnCollisionEnter2D(Collision2D other)
{
if (other.collider.tag == "Player")

View file

@ -1,8 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.SceneManagement;
using Random = UnityEngine.Random;
@ -76,13 +72,11 @@ public class tetromino : MonoBehaviour
//I want to run this for each piece of the tetromino.
foreach (Transform child in transform)
{
if (validateFall(child))
{
if (checkFallCollision(child))
{
wouldCollide = true;
break;
}
}
}
if (wouldCollide == false)
@ -98,12 +92,14 @@ public class tetromino : MonoBehaviour
}
}
private bool validateFall(Transform pieceToCheck) //returns true if the next step collides with something
private bool checkFallCollision(Transform pieceToCheck) //returns true if the next step collides with something
{
//Cast a ray to the next position of the tetromino.
//NOTE: disabled "Queries Start in Colliders" in Project Settings>Physics 2D (thank you again, Tavi).
RaycastHit2D collision = Physics2D.Raycast(pieceToCheck.position, Vector2.down, 1.0f);
// Debug.DrawRay(pieceToCheck.position,Vector3.down,Color.red,1000.0f);
//Only go further if the ray collided with something, and if that something is not another
//piece of the same tetromino.
if (collision.collider != null && collision.collider.transform.parent != pieceToCheck.parent)
{
Debug.Log("Collided with object: " + collision.collider.name);

View file

@ -1,6 +1,3 @@
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Random = UnityEngine.Random;
@ -24,16 +21,6 @@ public class tetrominoSpawnManager : MonoBehaviour
spawnTetromino();
}
// Update is called once per frame
void Update()
{
//DEBUG: Spawn a new tetromino on click.
// if (Input.GetMouseButtonDown(0))
// {
// spawnTetromino();
// }
}
public void spawnTetromino()
{
nextTetromino = Random.Range(1, 7);

View file

@ -1,5 +1,3 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
@ -7,12 +5,6 @@ public class tetrominoUserControl : MonoBehaviour
{
public GameObject activeTetromino;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
@ -45,15 +37,13 @@ public class tetrominoUserControl : MonoBehaviour
if (Input.GetButtonDown("tetrisRotateLeft") && activeTetromino != null)
{
rotateWithChecks(90);
// activeTetromino.gameObject.transform.Rotate(0,0,90,Space.World);
checkRotateCollisions(90);
GetComponent<AudioSource>().Play();
}
if (Input.GetButtonDown("tetrisRotateRight") && activeTetromino != null)
{
rotateWithChecks(90);
// activeTetromino.gameObject.transform.Rotate(0,0,-90,Space.World);
checkRotateCollisions(90);
GetComponent<AudioSource>().Play();
}
@ -97,7 +87,7 @@ public class tetrominoUserControl : MonoBehaviour
}
}
public void rotateWithChecks(int degrees)
public void checkRotateCollisions(int degrees)
{
bool wouldCollide = false;
Collider2D[] results = new Collider2D[10];

View file

@ -1,22 +1,8 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class titleButtonsControl : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
}
public void startButtonClick()
{
GetComponent<AudioSource>().Play();