Code cleanup!
This commit is contained in:
parent
03bdc2f92f
commit
15e5bb8c04
10 changed files with 70 additions and 19 deletions
|
@ -12,7 +12,7 @@ public class GroundCheck : MonoBehaviour
|
||||||
}
|
}
|
||||||
private void OnCollisionEnter2D(Collision2D collision)
|
private void OnCollisionEnter2D(Collision2D collision)
|
||||||
{
|
{
|
||||||
if (collision.collider.tag == "Ground" || collision.collider.tag == "Platform" || collision.collider.tag == "Tetromino")
|
if (collision.collider.CompareTag("Ground") || collision.collider.CompareTag("Platform") || collision.collider.CompareTag("Tetromino"))
|
||||||
{
|
{
|
||||||
Debug.Log("Now standing on "+ collision.collider.name);
|
Debug.Log("Now standing on "+ collision.collider.name);
|
||||||
Player.GetComponent<Movement2D>().isGrounded = true;
|
Player.GetComponent<Movement2D>().isGrounded = true;
|
||||||
|
@ -21,7 +21,7 @@ public class GroundCheck : MonoBehaviour
|
||||||
|
|
||||||
private void OnCollisionExit2D(Collision2D collision)
|
private void OnCollisionExit2D(Collision2D collision)
|
||||||
{
|
{
|
||||||
if (collision.collider.tag == "Ground" || collision.collider.tag == "Platform" || collision.collider.tag == "Tetromino")
|
if (collision.collider.CompareTag("Ground") || collision.collider.CompareTag("Platform") || collision.collider.CompareTag("Tetromino"))
|
||||||
{
|
{
|
||||||
if (GetComponent<BoxCollider2D>().IsTouchingLayers(solidLayer) == false)
|
if (GetComponent<BoxCollider2D>().IsTouchingLayers(solidLayer) == false)
|
||||||
{
|
{
|
||||||
|
|
|
@ -17,7 +17,7 @@ public class Movement2D : MonoBehaviour
|
||||||
{
|
{
|
||||||
Jump();
|
Jump();
|
||||||
Vector3 movement = new Vector3(Input.GetAxis("platformerHorizontal"), 0f, 0f);
|
Vector3 movement = new Vector3(Input.GetAxis("platformerHorizontal"), 0f, 0f);
|
||||||
transform.position += movement * Time.deltaTime * moveSpeed;
|
transform.position += movement * (Time.deltaTime * moveSpeed);
|
||||||
|
|
||||||
if (Input.GetAxis("platformerHorizontal") > 0)
|
if (Input.GetAxis("platformerHorizontal") > 0)
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,6 +20,7 @@ public class PlatformManager : MonoBehaviour
|
||||||
platforms = GameObject.FindGameObjectsWithTag("Platform"); // Creates an array of all objects with the tag platform
|
platforms = GameObject.FindGameObjectsWithTag("Platform"); // Creates an array of all objects with the tag platform
|
||||||
index = Random.Range(0, platforms.Length); // randomly selects one platform
|
index = Random.Range(0, platforms.Length); // randomly selects one platform
|
||||||
currentPlatform = platforms[index]; // registers random platform as the one the player must get to
|
currentPlatform = platforms[index]; // registers random platform as the one the player must get to
|
||||||
coin.transform.position = new Vector2(currentPlatform.transform.position.x, currentPlatform.transform.position.y + 2f);
|
var position = currentPlatform.transform.position;
|
||||||
|
coin.transform.position = new Vector2(position.x, position.y + 2f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ public class goal : MonoBehaviour
|
||||||
{
|
{
|
||||||
private void OnCollisionEnter2D(Collision2D other)
|
private void OnCollisionEnter2D(Collision2D other)
|
||||||
{
|
{
|
||||||
if (other.collider.tag == "Player")
|
if (other.collider.CompareTag("Player"))
|
||||||
{
|
{
|
||||||
Debug.Log("You win!!!");
|
Debug.Log("You win!!!");
|
||||||
GetComponent<AudioSource>().Play();
|
GetComponent<AudioSource>().Play();
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.SceneManagement;
|
using UnityEngine.SceneManagement;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
|
@ -1,12 +1,9 @@
|
||||||
using System;
|
|
||||||
using System.Collections;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class startTrigger : MonoBehaviour
|
public class startTrigger : MonoBehaviour
|
||||||
{
|
{
|
||||||
private tetrominoSpawnManager TetrominoSpawnManager;
|
private tetrominoSpawnManager TetrominoSpawnManager;
|
||||||
private bool gameStarted = false;
|
private bool gameStarted;
|
||||||
|
|
||||||
// Start is called before the first frame update
|
// Start is called before the first frame update
|
||||||
void Start()
|
void Start()
|
||||||
|
@ -21,6 +18,7 @@ public class startTrigger : MonoBehaviour
|
||||||
GetComponent<AudioSource>().Play();
|
GetComponent<AudioSource>().Play();
|
||||||
TetrominoSpawnManager.spawnTetromino();
|
TetrominoSpawnManager.spawnTetromino();
|
||||||
gameStarted = true;
|
gameStarted = true;
|
||||||
|
gameObject.SetActive(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
using System;
|
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Random = UnityEngine.Random;
|
using Random = UnityEngine.Random;
|
||||||
|
|
||||||
|
@ -13,12 +12,12 @@ public class tetrominoSpawnManager : MonoBehaviour
|
||||||
public GameObject tetrominoT;
|
public GameObject tetrominoT;
|
||||||
public GameObject tetrominoZ;
|
public GameObject tetrominoZ;
|
||||||
|
|
||||||
private int nextTetromino = 0;
|
private int nextTetromino;
|
||||||
private GameObject[] nextTetrominoSequence = new GameObject[14];
|
private GameObject[] nextTetrominoSequence = new GameObject[14];
|
||||||
|
|
||||||
public void Start()
|
public void Start()
|
||||||
{
|
{
|
||||||
nextTetrominoSequence = new GameObject[14]
|
nextTetrominoSequence = new GameObject[]
|
||||||
{
|
{
|
||||||
tetrominoL, tetrominoL,
|
tetrominoL, tetrominoL,
|
||||||
tetrominoLine, tetrominoLine,
|
tetrominoLine, tetrominoLine,
|
||||||
|
|
|
@ -63,7 +63,7 @@ public class tetrominoUserControl : MonoBehaviour
|
||||||
activeTetromino = null;
|
activeTetromino = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool checkMoveCollisions(Vector2 direction)
|
private bool checkMoveCollisions(Vector2 direction)
|
||||||
{
|
{
|
||||||
bool wouldCollide = false;
|
bool wouldCollide = false;
|
||||||
|
|
||||||
|
@ -77,7 +77,7 @@ public class tetrominoUserControl : MonoBehaviour
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wouldCollide == true)
|
if (wouldCollide)
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ public class tetrominoUserControl : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkRotateCollisions(int degrees)
|
private void checkRotateCollisions(int degrees)
|
||||||
{
|
{
|
||||||
bool wouldCollide = false;
|
bool wouldCollide = false;
|
||||||
Collider2D[] results = new Collider2D[10];
|
Collider2D[] results = new Collider2D[10];
|
||||||
|
@ -115,7 +115,7 @@ public class tetrominoUserControl : MonoBehaviour
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
//If we collided, undo the rotation.
|
//If we collided, undo the rotation.
|
||||||
if (wouldCollide == true)
|
if (wouldCollide)
|
||||||
{
|
{
|
||||||
activeTetromino.gameObject.transform.Rotate(0,0,degrees * -1,Space.World);
|
activeTetromino.gameObject.transform.Rotate(0,0,degrees * -1,Space.World);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ guid: 7b89d79c35a61e0dfa97b02fbaca389b
|
||||||
TextureImporter:
|
TextureImporter:
|
||||||
internalIDToNameTable: []
|
internalIDToNameTable: []
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 11
|
serializedVersion: 12
|
||||||
mipmaps:
|
mipmaps:
|
||||||
mipMapMode: 0
|
mipMapMode: 0
|
||||||
enableMipMap: 0
|
enableMipMap: 0
|
||||||
|
@ -24,6 +24,7 @@ TextureImporter:
|
||||||
streamingMipmaps: 0
|
streamingMipmaps: 0
|
||||||
streamingMipmapsPriority: 0
|
streamingMipmapsPriority: 0
|
||||||
vTOnly: 0
|
vTOnly: 0
|
||||||
|
ignoreMasterTextureLimit: 0
|
||||||
grayScaleToAlpha: 0
|
grayScaleToAlpha: 0
|
||||||
generateCubemap: 6
|
generateCubemap: 6
|
||||||
cubemapConvolution: 0
|
cubemapConvolution: 0
|
||||||
|
@ -62,6 +63,7 @@ TextureImporter:
|
||||||
textureFormatSet: 0
|
textureFormatSet: 0
|
||||||
ignorePngGamma: 0
|
ignorePngGamma: 0
|
||||||
applyGammaDecoding: 0
|
applyGammaDecoding: 0
|
||||||
|
cookieLightType: 1
|
||||||
platformSettings:
|
platformSettings:
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
buildTarget: DefaultTexturePlatform
|
buildTarget: DefaultTexturePlatform
|
||||||
|
@ -111,6 +113,30 @@ TextureImporter:
|
||||||
overridden: 0
|
overridden: 0
|
||||||
androidETC2FallbackOverride: 0
|
androidETC2FallbackOverride: 0
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: Server
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: WebGL
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 0
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
spriteSheet:
|
spriteSheet:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
sprites: []
|
sprites: []
|
||||||
|
@ -124,6 +150,7 @@ TextureImporter:
|
||||||
edges: []
|
edges: []
|
||||||
weights: []
|
weights: []
|
||||||
secondaryTextures: []
|
secondaryTextures: []
|
||||||
|
nameFileIdTable: {}
|
||||||
spritePackingTag:
|
spritePackingTag:
|
||||||
pSDRemoveMatte: 0
|
pSDRemoveMatte: 0
|
||||||
pSDShowRemoveMatteOption: 0
|
pSDShowRemoveMatteOption: 0
|
||||||
|
|
|
@ -3,7 +3,7 @@ guid: d539f32dbccc14dcdb47ae762cf0af6f
|
||||||
TextureImporter:
|
TextureImporter:
|
||||||
internalIDToNameTable: []
|
internalIDToNameTable: []
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 11
|
serializedVersion: 12
|
||||||
mipmaps:
|
mipmaps:
|
||||||
mipMapMode: 0
|
mipMapMode: 0
|
||||||
enableMipMap: 0
|
enableMipMap: 0
|
||||||
|
@ -24,6 +24,7 @@ TextureImporter:
|
||||||
streamingMipmaps: 0
|
streamingMipmaps: 0
|
||||||
streamingMipmapsPriority: 0
|
streamingMipmapsPriority: 0
|
||||||
vTOnly: 0
|
vTOnly: 0
|
||||||
|
ignoreMasterTextureLimit: 0
|
||||||
grayScaleToAlpha: 0
|
grayScaleToAlpha: 0
|
||||||
generateCubemap: 6
|
generateCubemap: 6
|
||||||
cubemapConvolution: 0
|
cubemapConvolution: 0
|
||||||
|
@ -62,6 +63,7 @@ TextureImporter:
|
||||||
textureFormatSet: 0
|
textureFormatSet: 0
|
||||||
ignorePngGamma: 0
|
ignorePngGamma: 0
|
||||||
applyGammaDecoding: 0
|
applyGammaDecoding: 0
|
||||||
|
cookieLightType: 1
|
||||||
platformSettings:
|
platformSettings:
|
||||||
- serializedVersion: 3
|
- serializedVersion: 3
|
||||||
buildTarget: DefaultTexturePlatform
|
buildTarget: DefaultTexturePlatform
|
||||||
|
@ -111,6 +113,30 @@ TextureImporter:
|
||||||
overridden: 0
|
overridden: 0
|
||||||
androidETC2FallbackOverride: 0
|
androidETC2FallbackOverride: 0
|
||||||
forceMaximumCompressionQuality_BC6H_BC7: 0
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: Server
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
|
- serializedVersion: 3
|
||||||
|
buildTarget: WebGL
|
||||||
|
maxTextureSize: 2048
|
||||||
|
resizeAlgorithm: 0
|
||||||
|
textureFormat: -1
|
||||||
|
textureCompression: 1
|
||||||
|
compressionQuality: 50
|
||||||
|
crunchedCompression: 0
|
||||||
|
allowsAlphaSplitting: 0
|
||||||
|
overridden: 0
|
||||||
|
androidETC2FallbackOverride: 0
|
||||||
|
forceMaximumCompressionQuality_BC6H_BC7: 0
|
||||||
spriteSheet:
|
spriteSheet:
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
sprites: []
|
sprites: []
|
||||||
|
@ -124,6 +150,7 @@ TextureImporter:
|
||||||
edges: []
|
edges: []
|
||||||
weights: []
|
weights: []
|
||||||
secondaryTextures: []
|
secondaryTextures: []
|
||||||
|
nameFileIdTable: {}
|
||||||
spritePackingTag:
|
spritePackingTag:
|
||||||
pSDRemoveMatte: 0
|
pSDRemoveMatte: 0
|
||||||
pSDShowRemoveMatteOption: 0
|
pSDShowRemoveMatteOption: 0
|
||||||
|
|
Loading…
Reference in a new issue