Browse Source

Controls + Discs + Size rules

master
Felipe Martin 3 years ago
parent
commit
ae9b1f06b9
  1. 94
      Assets/Controls.cs
  2. 61
      Assets/Cylinder.cs
  3. 11
      Assets/Cylinder.cs.meta
  4. 14
      Assets/Disc.cs
  5. 11
      Assets/Disc.cs.meta
  6. 4
      Assets/Materials/wood2.mat
  7. 400
      Assets/Scenes/Main.unity
  8. 2
      ProjectSettings/ProjectVersion.txt

94
Assets/Controls.cs

@ -4,32 +4,100 @@ using UnityEngine;
public class Controls : MonoBehaviour
{
public GameObject control;
private int separation = 8;
private Vector3 position = new Vector3(0, 10, 0);
public Light control;
public GameObject column1;
public GameObject column2;
public GameObject column3;
public GameObject selectedDisc;
public GameObject selectedColumn;
public List<GameObject> discs;
// Start is called before the first frame update
void Start()
{
this.ResetGame();
}
void ResetGame()
{
List<GameObject> reversedDiscs = this.discs;
reversedDiscs.Reverse();
int i = 1;
foreach (GameObject disc in reversedDiscs)
{
this.column1.GetComponent<Cylinder>().discs.Add(disc);
i++;
}
this.column1.GetComponent<Cylinder>().selected = true;
this.column2.GetComponent<Cylinder>().selected = false;
this.column3.GetComponent<Cylinder>().selected = false;
}
GameObject GetSelectedColumn()
{
if (this.column1.GetComponent<Cylinder>().selected)
{
return this.column1;
}
if (this.column2.GetComponent<Cylinder>().selected)
{
return this.column2;
}
return this.column3;
}
void RenderDisc()
{
if (this.selectedDisc)
{
this.selectedDisc.transform.position = this.control.transform.position;
}
}
// Update is called once per frame
void Update()
{
if (Input.GetKeyUp("a"))
this.RenderDisc();
GameObject selectedColumn = this.GetSelectedColumn();
if (Input.GetKeyUp("a") && selectedColumn != this.column1)
{
if (this.position.x > -1)
selectedColumn.GetComponent<Cylinder>().selected = false;
if (selectedColumn == this.column3)
{
this.column2.GetComponent<Cylinder>().selected = true;
}
else
{
this.position.x = this.position.x - this.separation;
this.column1.GetComponent<Cylinder>().selected = true;
}
}
if (Input.GetKeyUp("d"))
if (Input.GetKeyUp("d") && selectedColumn != this.column3)
{
if (this.position.x < 1)
selectedColumn.GetComponent<Cylinder>().selected = false;
if (selectedColumn == this.column1)
{
this.column2.GetComponent<Cylinder>().selected = true;
} else
{
this.position.x = this.position.x + this.separation;
this.column3.GetComponent<Cylinder>().selected = true;
}
}
}
void FixedUpdate()
{
this.control.transform.position = this.position;
if (Input.GetKeyUp("w") && !this.selectedDisc)
{
this.selectedDisc = selectedColumn.GetComponent<Cylinder>().GetTopDisc();
}
if (Input.GetKeyUp("s") && this.selectedDisc != null)
{
if (selectedColumn.GetComponent<Cylinder>().CanPutDisc(this.selectedDisc)) {
selectedColumn.GetComponent<Cylinder>().discs.Add(this.selectedDisc);
this.selectedDisc = null;
}
}
}
}

61
Assets/Cylinder.cs

@ -0,0 +1,61 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Cylinder : MonoBehaviour
{
public List<GameObject> discs;
public float baseX;
public float baseY;
public float baseZ;
private float diffY = 1.5f;
private float startY = -6.5f;
public bool selected = false;
public GameObject light;
// Start is called before the first frame update
void Start()
{
}
void UpdateLight()
{
if (this.selected)
{
this.light.transform.position = new Vector3(this.baseX, 10, this.baseZ);
}
}
public bool CanPutDisc(GameObject disc)
{
if (this.discs.Count == 0)
{
return true;
}
return this.discs[this.discs.Count - 1].GetComponent<Disc>().size > disc.GetComponent<Disc>().size;
}
public GameObject GetTopDisc()
{
GameObject topDisc = this.discs[this.discs.Count - 1];
this.discs.RemoveAt(this.discs.Count - 1);
return topDisc;
}
// Update is called once per frame
void FixedUpdate()
{
float y = this.startY;
foreach (GameObject disc in this.discs)
{
disc.transform.position = new Vector3(this.baseX, y, this.baseZ);
y += this.diffY;
}
this.UpdateLight();
}
}

11
Assets/Cylinder.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 19bd60d6d3d0b4340aa3c5b9b80ec22a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

14
Assets/Disc.cs

@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Disc : MonoBehaviour
{
public int size;
// Update is called once per frame
void Update()
{
}
}

11
Assets/Disc.cs.meta

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d52ddeb1d10bede4fa5d1520c0d9e6ba
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

4
Assets/Materials/wood2.mat

@ -40,7 +40,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MainTex:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 16eff6369dc43094abfda360db207294, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _MetallicGlossMap:
@ -48,7 +48,7 @@ Material:
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _OcclusionMap:
m_Texture: {fileID: 0}
m_Texture: {fileID: 2800000, guid: 16eff6369dc43094abfda360db207294, type: 3}
m_Scale: {x: 1, y: 1}
m_Offset: {x: 0, y: 0}
- _ParallaxMap:

400
Assets/Scenes/Main.unity

@ -124,8 +124,9 @@ GameObject:
- component: {fileID: 84957042}
- component: {fileID: 84957041}
- component: {fileID: 84957040}
- component: {fileID: 84957044}
m_Layer: 0
m_Name: Cylinder2
m_Name: Cylinder1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -202,8 +203,26 @@ Transform:
m_LocalScale: {x: 1, y: 8, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 4
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &84957044
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 84957039}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 19bd60d6d3d0b4340aa3c5b9b80ec22a, type: 3}
m_Name:
m_EditorClassIdentifier:
discs: []
baseX: -8
baseY: 0
baseZ: 0
selected: 0
light: {fileID: 818142332}
--- !u!1 &170076733
GameObject:
m_ObjectHideFlags: 0
@ -285,6 +304,7 @@ GameObject:
- component: {fileID: 226402587}
- component: {fileID: 226402586}
- component: {fileID: 226402585}
- component: {fileID: 226402589}
m_Layer: 0
m_Name: Cylinder3
m_TagString: Untagged
@ -365,6 +385,24 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &226402589
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 226402584}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 19bd60d6d3d0b4340aa3c5b9b80ec22a, type: 3}
m_Name:
m_EditorClassIdentifier:
discs: []
baseX: 8
baseY: 0
baseZ: 0
selected: 0
light: {fileID: 818142332}
--- !u!1 &534669902
GameObject:
m_ObjectHideFlags: 0
@ -461,7 +499,7 @@ GameObject:
m_Layer: 0
m_Name: Control
m_TagString: Untagged
m_Icon: {fileID: 0}
m_Icon: {fileID: 5721338939258241955, guid: 0000000000000000d000000000000000, type: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
@ -475,7 +513,7 @@ Light:
m_Enabled: 1
serializedVersion: 8
m_Type: 1
m_Color: {r: 1, g: 0, b: 0, a: 1}
m_Color: {r: 0, g: 0.34663105, b: 1, a: 1}
m_Intensity: 1
m_Range: 10
m_SpotAngle: 30
@ -511,7 +549,7 @@ Transform:
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 818142332}
m_LocalRotation: {x: 0.7071068, y: 0, z: 0, w: 0.7071068}
m_LocalPosition: {x: 0, y: 10, z: 0}
m_LocalPosition: {x: 100, y: 100, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
@ -529,7 +567,334 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 9e1b66f8ec737b34d9c16ab60c30acb3, type: 3}
m_Name:
m_EditorClassIdentifier:
control: {fileID: 818142332}
control: {fileID: 818142333}
column1: {fileID: 84957039}
column2: {fileID: 2064264025}
column3: {fileID: 226402584}
selectedDisc: {fileID: 0}
selectedColumn: {fileID: 0}
discs:
- {fileID: 919226499}
- {fileID: 1001971730}
- {fileID: 1428406534}
--- !u!1 &919226499
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 919226503}
- component: {fileID: 919226502}
- component: {fileID: 919226501}
- component: {fileID: 919226500}
- component: {fileID: 919226504}
m_Layer: 0
m_Name: Disc1
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!136 &919226500
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 919226499}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.5000001
m_Height: 2
m_Direction: 1
m_Center: {x: 0.000000059604645, y: 0, z: -0.00000008940697}
--- !u!23 &919226501
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 919226499}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: bb0747ef0c370fd4a8a88d533cfc6f40, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &919226502
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 919226499}
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &919226503
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 919226499}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 100, y: 100, z: 100}
m_LocalScale: {x: 2, y: 0.5, z: 2}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 7
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &919226504
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 919226499}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d52ddeb1d10bede4fa5d1520c0d9e6ba, type: 3}
m_Name:
m_EditorClassIdentifier:
size: 1
--- !u!1 &1001971730
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1001971734}
- component: {fileID: 1001971733}
- component: {fileID: 1001971732}
- component: {fileID: 1001971731}
- component: {fileID: 1001971735}
m_Layer: 0
m_Name: Disc2
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!136 &1001971731
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1001971730}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.5000001
m_Height: 2
m_Direction: 1
m_Center: {x: 0.000000059604645, y: 0, z: -0.00000008940697}
--- !u!23 &1001971732
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1001971730}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: bb0747ef0c370fd4a8a88d533cfc6f40, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &1001971733
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1001971730}
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1001971734
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1001971730}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 100, y: 100, z: 100}
m_LocalScale: {x: 3, y: 0.5, z: 3}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1001971735
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1001971730}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d52ddeb1d10bede4fa5d1520c0d9e6ba, type: 3}
m_Name:
m_EditorClassIdentifier:
size: 2
--- !u!1 &1428406534
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1428406538}
- component: {fileID: 1428406537}
- component: {fileID: 1428406536}
- component: {fileID: 1428406535}
- component: {fileID: 1428406539}
m_Layer: 0
m_Name: Disc3
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!136 &1428406535
CapsuleCollider:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1428406534}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Enabled: 1
m_Radius: 0.5000001
m_Height: 2
m_Direction: 1
m_Center: {x: 0.000000059604645, y: 0, z: -0.00000008940697}
--- !u!23 &1428406536
MeshRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1428406534}
m_Enabled: 1
m_CastShadows: 1
m_ReceiveShadows: 1
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 1
m_RendererPriority: 0
m_Materials:
- {fileID: 2100000, guid: bb0747ef0c370fd4a8a88d533cfc6f40, type: 2}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_StitchLightmapSeams: 0
m_SelectedEditorRenderState: 3
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingLayer: 0
m_SortingOrder: 0
--- !u!33 &1428406537
MeshFilter:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1428406534}
m_Mesh: {fileID: 10206, guid: 0000000000000000e000000000000000, type: 0}
--- !u!4 &1428406538
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1428406534}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 100, y: 100, z: 100}
m_LocalScale: {x: 4, y: 0.5, z: 4}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 9
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &1428406539
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1428406534}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: d52ddeb1d10bede4fa5d1520c0d9e6ba, type: 3}
m_Name:
m_EditorClassIdentifier:
size: 3
--- !u!1 &1878136433
GameObject:
m_ObjectHideFlags: 0
@ -633,8 +998,9 @@ GameObject:
- component: {fileID: 2064264028}
- component: {fileID: 2064264027}
- component: {fileID: 2064264026}
- component: {fileID: 2064264030}
m_Layer: 0
m_Name: Cylinder1
m_Name: Cylinder2
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
@ -711,5 +1077,23 @@ Transform:
m_LocalScale: {x: 1, y: 8, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 3
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &2064264030
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2064264025}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 19bd60d6d3d0b4340aa3c5b9b80ec22a, type: 3}
m_Name:
m_EditorClassIdentifier:
discs: []
baseX: 0
baseY: 0
baseZ: 0
selected: 0
light: {fileID: 818142332}

2
ProjectSettings/ProjectVersion.txt

@ -1 +1 @@
m_EditorVersion: 2018.3.6f1
m_EditorVersion: 2018.3.7f1

Loading…
Cancel
Save