Automatically spawn new tetrominoes as needed.
This commit is contained in:
parent
1ff4b9cd05
commit
c12dc03059
7 changed files with 142 additions and 12 deletions
|
@ -220,7 +220,7 @@ SpriteRenderer:
|
|||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_Sprite: {fileID: 21300000, guid: 4fa2b2dea4f24c074ad58f2bbe2b0acc, type: 3}
|
||||
m_Sprite: {fileID: 21300000, guid: 13dafb3a4746f6886b8da12ba1c8f74c, type: 3}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
|
@ -572,7 +572,7 @@ GameObject:
|
|||
- component: {fileID: 729893852}
|
||||
- component: {fileID: 729893853}
|
||||
m_Layer: 0
|
||||
m_Name: Wall
|
||||
m_Name: left
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
|
@ -695,7 +695,7 @@ GameObject:
|
|||
- component: {fileID: 978697294}
|
||||
- component: {fileID: 978697295}
|
||||
m_Layer: 0
|
||||
m_Name: Wall (2)
|
||||
m_Name: top
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
|
@ -1092,7 +1092,7 @@ GameObject:
|
|||
- component: {fileID: 1643835946}
|
||||
- component: {fileID: 1643835947}
|
||||
m_Layer: 0
|
||||
m_Name: Wall (1)
|
||||
m_Name: right
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
|
@ -1192,3 +1192,86 @@ Transform:
|
|||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 6
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!1 &2113729827
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2113729829}
|
||||
- component: {fileID: 2113729828}
|
||||
m_Layer: 0
|
||||
m_Name: backgroundStatic
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!212 &2113729828
|
||||
SpriteRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2113729827}
|
||||
m_Enabled: 1
|
||||
m_CastShadows: 0
|
||||
m_ReceiveShadows: 0
|
||||
m_DynamicOccludee: 1
|
||||
m_StaticShadowCaster: 0
|
||||
m_MotionVectors: 1
|
||||
m_LightProbeUsage: 1
|
||||
m_ReflectionProbeUsage: 1
|
||||
m_RayTracingMode: 0
|
||||
m_RayTraceProcedural: 0
|
||||
m_RenderingLayerMask: 1
|
||||
m_RendererPriority: 0
|
||||
m_Materials:
|
||||
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_StaticBatchInfo:
|
||||
firstSubMesh: 0
|
||||
subMeshCount: 0
|
||||
m_StaticBatchRoot: {fileID: 0}
|
||||
m_ProbeAnchor: {fileID: 0}
|
||||
m_LightProbeVolumeOverride: {fileID: 0}
|
||||
m_ScaleInLightmap: 1
|
||||
m_ReceiveGI: 1
|
||||
m_PreserveUVs: 0
|
||||
m_IgnoreNormalsForChartDetection: 0
|
||||
m_ImportantGI: 0
|
||||
m_StitchLightmapSeams: 1
|
||||
m_SelectedEditorRenderState: 0
|
||||
m_MinimumChartSize: 4
|
||||
m_AutoUVMaxDistance: 0.5
|
||||
m_AutoUVMaxAngle: 89
|
||||
m_LightmapParameters: {fileID: 0}
|
||||
m_SortingLayerID: 0
|
||||
m_SortingLayer: 0
|
||||
m_SortingOrder: 0
|
||||
m_Sprite: {fileID: 21300000, guid: b77f39928043c4f4d9d79b8597c9810f, type: 3}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_FlipX: 0
|
||||
m_FlipY: 0
|
||||
m_DrawMode: 0
|
||||
m_Size: {x: 100, y: 75}
|
||||
m_AdaptiveModeThreshold: 0.5
|
||||
m_SpriteTileMode: 0
|
||||
m_WasSpriteAssigned: 1
|
||||
m_MaskInteraction: 0
|
||||
m_SpriteSortPoint: 0
|
||||
--- !u!4 &2113729829
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 2113729827}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: -13.13523, y: -0.14690661, z: 500}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 8
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
|
27
Assets/Scripts/goal.cs
Normal file
27
Assets/Scripts/goal.cs
Normal file
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
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")
|
||||
{
|
||||
Debug.Log("You win!!!");
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/goal.cs.meta
Normal file
11
Assets/Scripts/goal.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: a6096fcbbaecfc626a61d28cfe652871
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -8,7 +8,8 @@ public class tetromino : MonoBehaviour
|
|||
{
|
||||
public float timeBetweenSteps;
|
||||
public bool active = true;
|
||||
public tetrominoUserControl TetrominoUserControl;
|
||||
private tetrominoUserControl TetrominoUserControl;
|
||||
private tetrominoSpawnManager TetrominoSpawnManager;
|
||||
|
||||
private float stepTimer = 0.0f;
|
||||
private bool wouldCollide = false;
|
||||
|
@ -16,6 +17,7 @@ public class tetromino : MonoBehaviour
|
|||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
TetrominoSpawnManager = FindObjectOfType<tetrominoSpawnManager>();
|
||||
TetrominoUserControl = FindObjectOfType<tetrominoUserControl>();
|
||||
TetrominoUserControl.setActiveTetromino(gameObject);
|
||||
}
|
||||
|
@ -56,6 +58,8 @@ public class tetromino : MonoBehaviour
|
|||
else
|
||||
{
|
||||
active = false;
|
||||
TetrominoUserControl.unsetActiveTetromino();
|
||||
TetrominoSpawnManager.spawnTetromino();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -20,20 +20,20 @@ public class tetrominoSpawnManager : MonoBehaviour
|
|||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
|
||||
spawnTetromino();
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//DEBUG: Spawn a new tetromino on click.
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
spawnTetromino();
|
||||
}
|
||||
// if (Input.GetMouseButtonDown(0))
|
||||
// {
|
||||
// spawnTetromino();
|
||||
// }
|
||||
}
|
||||
|
||||
void spawnTetromino()
|
||||
public void spawnTetromino()
|
||||
{
|
||||
nextTetromino = Random.Range(1, 7);
|
||||
switch (nextTetromino)
|
||||
|
|
|
@ -45,4 +45,9 @@ public class tetrominoUserControl : MonoBehaviour
|
|||
{
|
||||
activeTetromino = tetromino;
|
||||
}
|
||||
|
||||
public void unsetActiveTetromino()
|
||||
{
|
||||
activeTetromino = null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -46,7 +46,7 @@ TextureImporter:
|
|||
spriteMeshType: 0
|
||||
alignment: 0
|
||||
spritePivot: {x: 0.5, y: 0.5}
|
||||
spritePixelsToUnits: 16
|
||||
spritePixelsToUnits: 8
|
||||
spriteBorder: {x: 0, y: 0, z: 0, w: 0}
|
||||
spriteGenerateFallbackPhysicsShape: 1
|
||||
alphaUsage: 1
|
||||
|
|
Loading…
Reference in a new issue