event controls WIP

This commit is contained in:
2020-02-01 14:39:17 -05:00
parent 588df6407f
commit a3e6a4e304
5 changed files with 378 additions and 495 deletions

View File

@@ -121,10 +121,11 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: e5f777aa09d2ced42baa1cc6bf9dbe54, type: 3}
m_Name:
m_EditorClassIdentifier:
secondsGoingLeft: 1
secondsGoingRight: 1
movementSpeed: 5
secondsGoingLeft: 0.8
secondsGoingRight: 0.8
movementSpeed: 2
playerCollider: {fileID: 0}
eventControls: {fileID: 0}
--- !u!50 &3827363133515929334
Rigidbody2D:
serializedVersion: 4

View File

@@ -169,8 +169,9 @@ MonoBehaviour:
tile: {fileID: 11400000, guid: 7ece7857530facb42b843eed2526c86a, type: 2}
successTile: {fileID: 11400000, guid: 6cf7a50810d16f2468acc06180743d07, type: 2}
framesPerControlTile: 15
nextControlYOffset: 4
nextControlXOffset: 2.5
nextControlYOffset: 2
nextControlXOffset: -1
tileMapClearDelayInSeconds: 0.5
--- !u!483693784 &1491656
TilemapRenderer:
m_ObjectHideFlags: 0
@@ -935,456 +936,284 @@ CompositeCollider2D:
m_ColliderPaths:
- m_Collider: {fileID: 2120494080}
m_ColliderPaths:
- - X: 710000100
Y: 179999959
- X: 710000100
Y: 200000041
- X: 710000041
Y: 200000100
- X: 689999959
Y: 200000100
- X: 689999900
Y: 200000041
- X: 689999900
Y: 179999959
- X: 689999959
Y: 179999900
- X: 710000041
Y: 179999900
- - X: 450000100
Y: 159999959
- X: 450000100
Y: 180000041
- X: 450000041
Y: 180000100
- X: 389999959
Y: 180000100
- X: 389999900
Y: 180000041
- X: 389999900
Y: 159999959
- X: 389999959
Y: 159999900
- X: 450000041
Y: 159999900
- - X: 730000100
Y: 129999959
- X: 730000100
Y: 150000041
- X: 730000041
Y: 150000100
- X: 709999959
Y: 150000100
- X: 709999900
Y: 150000041
- X: 709999900
Y: 129999959
- X: 709999959
Y: 129999900
- X: 730000041
Y: 129999900
- - X: 510000100
Y: 119999959
- X: 510000100
Y: 140000041
- X: 510000041
Y: 140000100
- X: 449999959
Y: 140000100
- X: 449999900
Y: 140000041
- X: 449999900
Y: 119999959
- X: 449999959
Y: 119999900
- X: 510000041
Y: 119999900
- - X: 540000100
Y: 79999959
- X: 540000100
Y: 100000041
- X: 540000041
Y: 100000100
- X: 519999959
Y: 100000100
- X: 519999900
Y: 100000041
- X: 519999900
Y: 79999959
- X: 519999959
Y: 79999900
- X: 540000041
Y: 79999900
- - X: 720000100
Y: 79999959
- X: 720000100
Y: 100000041
- X: 720000041
Y: 100000100
- X: 699999959
Y: 100000100
- X: 699999900
Y: 100000041
- X: 699999900
Y: 79999959
- X: 699999959
Y: 79999900
- X: 720000041
Y: 79999900
- - X: 980000100
Y: 69999959
- X: 980000100
Y: 90000041
- X: 980000041
Y: 90000100
- X: 859999959
Y: 90000100
- X: 859999900
Y: 90000041
- X: 859999900
Y: 69999959
- X: 859999959
Y: 69999900
- X: 980000041
Y: 69999900
- - X: 630000100
Y: 59999959
- X: 630000100
Y: 80000041
- X: 630000041
Y: 80000100
- X: 589999959
Y: 80000100
- X: 589999900
Y: 80000041
- X: 589999900
Y: 59999959
- X: 589999959
Y: 59999900
- X: 630000041
Y: 59999900
- - X: 560000100
Y: 39999959
- X: 560000100
Y: 60000041
- X: 560000041
Y: 60000100
- X: 489999959
Y: 60000100
- X: 489999900
Y: 60000041
- X: 489999900
Y: 39999959
- X: 489999959
Y: 39999900
- X: 560000041
Y: 39999900
- - X: 910000100
Y: -170000041
- X: 910000100
Y: -19999959
- X: 910000041
Y: -19999900
- X: 700000100
Y: -19999900
- X: 700000100
Y: 20000041
- X: 700000041
Y: 20000100
- X: 680000100
Y: 20000100
- X: 680000100
Y: 60000041
- X: 680000041
Y: 60000100
- X: 659999959
Y: 60000100
- X: 659999900
Y: 60000041
- X: 659999900
Y: 40000100
- X: 639999959
Y: 40000100
- X: 639999900
Y: 40000041
- X: 639999900
Y: 20000100
- X: 619999959
Y: 20000100
- X: 619999900
Y: 20000041
- X: 619999900
Y: 100
- X: 599999959
Y: 100
- X: 599999900
Y: 41
- X: 599999900
Y: -19999900
- X: 259999959
Y: -19999900
- X: 259999900
Y: -19999959
- X: 259999900
Y: -170000041
- X: 259999959
Y: -170000100
- X: 910000041
Y: -170000100
- - X: 1010000100
Y: 29999959
- X: 1010000100
Y: 50000041
- X: 1010000041
Y: 50000100
- X: 969999959
Y: 50000100
- X: 969999900
Y: 50000041
- X: 969999900
Y: 29999959
- X: 969999959
Y: 29999900
- X: 1010000041
Y: 29999900
- - X: 190000100
Y: 19999959
- X: 190000100
Y: 40000041
- X: 190000041
Y: 40000100
- X: 139999959
Y: 40000100
- X: 139999900
Y: 40000041
- X: 139999900
Y: 19999959
- X: 139999959
Y: 19999900
- X: 190000041
Y: 19999900
- - X: 470000100
Y: 19999959
- X: 470000100
Y: 40000041
- X: 470000041
Y: 40000100
- X: 399999959
Y: 40000100
- X: 399999900
Y: 40000041
- X: 399999900
Y: 19999959
- X: 399999959
Y: 19999900
- X: 470000041
Y: 19999900
- - X: 850000100
Y: 19999959
- X: 850000100
Y: 40000041
- X: 850000041
Y: 40000100
- X: 739999959
Y: 40000100
- X: 739999900
Y: 40000041
- X: 739999900
Y: 19999959
- X: 739999959
Y: 19999900
- X: 850000041
Y: 19999900
- - X: 380000100
Y: -41
- X: 380000100
Y: 20000041
- X: 380000041
Y: 20000100
- X: 309999959
Y: 20000100
- X: 309999900
Y: 20000041
- X: 309999900
Y: -41
- X: 309999959
Y: -100
- X: 380000041
Y: -100
- - X: 250000100
Y: -20000041
- X: 250000100
Y: 41
- X: 250000041
Y: 100
- X: 199999959
Y: 100
- X: 199999900
Y: 41
- X: 199999900
Y: -20000041
- X: 199999959
Y: -20000100
- X: 250000041
Y: -20000100
- - X: 1160000100
Y: -30000041
- X: 1160000100
Y: -9999959
- X: 1160000041
Y: -9999900
- X: 1089999959
Y: -9999900
- X: 1089999900
Y: -9999959
- X: 1089999900
Y: -30000041
- X: 1089999959
Y: -30000100
- X: 1160000041
Y: -30000100
- - X: 180000100
Y: -40000041
- X: 180000100
Y: -19999959
- X: 180000041
Y: -19999900
- X: 89999959
Y: -19999900
- X: 89999900
Y: -19999959
- X: 89999900
Y: -40000041
- X: 89999959
Y: -40000100
- X: 180000041
Y: -40000100
- - X: 80000100
Y: -170000041
- X: 80000100
Y: -39999959
- X: 80000041
Y: -39999900
- X: -180000041
Y: -39999900
- X: -180000100
Y: -39999959
- X: -180000100
Y: -170000041
- X: -180000041
Y: -170000100
- X: 80000041
Y: -170000100
- - X: 1090000100
Y: -70000041
- X: 1090000100
Y: -49999959
- X: 1090000041
Y: -49999900
- X: 999999959
Y: -49999900
- X: 999999900
Y: -49999959
- X: 999999900
Y: -70000041
- X: 999999959
Y: -70000100
- X: 1090000041
Y: -70000100
- - X: 710000000
Y: 200000000
- X: 690000000
Y: 200000000
- X: 690000000
Y: 180000000
- X: 710000000
Y: 180000000
- - X: 450000000
Y: 180000000
- X: 390000000
Y: 180000000
- X: 390000000
Y: 160000000
- X: 450000000
Y: 160000000
- - X: 730000000
Y: 150000000
- X: 710000000
Y: 150000000
- X: 710000000
Y: 130000000
- X: 730000000
Y: 130000000
- - X: 510000000
Y: 140000000
- X: 450000000
Y: 140000000
- X: 450000000
Y: 120000000
- X: 510000000
Y: 120000000
- - X: 720000000
Y: 100000000
- X: 700000000
Y: 100000000
- X: 700000000
Y: 80000000
- X: 720000000
Y: 80000000
- - X: 540000000
Y: 100000000
- X: 520000000
Y: 100000000
- X: 520000000
Y: 80000000
- X: 540000000
Y: 80000000
- - X: 980000000
Y: 90000000
- X: 860000000
Y: 90000000
- X: 860000000
Y: 70000000
- X: 980000000
Y: 70000000
- - X: 630000000
Y: 80000000
- X: 590000000
Y: 80000000
- X: 590000000
Y: 60000000
- X: 630000000
Y: 60000000
- - X: 910000000
Y: -20000000
- X: 700000000
Y: -20000000
- X: 700000000
Y: 20000000
- X: 680000000
Y: 20000000
- X: 680000000
Y: 60000000
- X: 660000000
Y: 60000000
- X: 660000000
Y: 40000000
- X: 640000000
Y: 40000000
- X: 640000000
Y: 20000000
- X: 620000000
Y: 20000000
- X: 620000000
Y: 0
- X: 600000000
Y: 0
- X: 600000000
Y: -20000000
- X: 260000000
Y: -20000000
- X: 260000000
Y: -170000000
- X: 910000000
Y: -170000000
- - X: 560000000
Y: 60000000
- X: 490000000
Y: 60000000
- X: 490000000
Y: 40000000
- X: 560000000
Y: 40000000
- - X: 1010000000
Y: 50000000
- X: 970000000
Y: 50000000
- X: 970000000
Y: 30000000
- X: 1010000000
Y: 30000000
- - X: 850000000
Y: 40000000
- X: 740000000
Y: 40000000
- X: 740000000
Y: 20000000
- X: 850000000
Y: 20000000
- - X: 470000000
Y: 40000000
- X: 400000000
Y: 40000000
- X: 400000000
Y: 20000000
- X: 470000000
Y: 20000000
- - X: 190000000
Y: 40000000
- X: 140000000
Y: 40000000
- X: 140000000
Y: 20000000
- X: 190000000
Y: 20000000
- - X: 380000000
Y: 20000000
- X: 310000000
Y: 20000000
- X: 310000000
Y: 0
- X: 380000000
Y: 0
- - X: 250000000
Y: 0
- X: 200000000
Y: 0
- X: 200000000
Y: -20000000
- X: 250000000
Y: -20000000
- - X: 1160000000
Y: -10000000
- X: 1090000000
Y: -10000000
- X: 1090000000
Y: -30000000
- X: 1160000000
Y: -30000000
- - X: 180000000
Y: -20000000
- X: 90000000
Y: -20000000
- X: 90000000
Y: -40000000
- X: 180000000
Y: -40000000
- - X: 80000000
Y: -40000000
- X: -180000000
Y: -40000000
- X: -180000000
Y: -170000000
- X: 80000000
Y: -170000000
- - X: 1090000000
Y: -50000000
- X: 1000000000
Y: -50000000
- X: 1000000000
Y: -70000000
- X: 1090000000
Y: -70000000
m_CompositePaths:
m_Paths:
- - {x: 70.99998, y: 17.99999}
- {x: 70.99998, y: 20.00001}
- {x: 68.999985, y: 19.999975}
- {x: 69.00002, y: 17.99999}
- - {x: 44.999973, y: 15.99999}
- {x: 44.999973, y: 18.00001}
- {x: 38.999992, y: 17.999975}
- {x: 39.000027, y: 15.99999}
- - {x: 72.99998, y: 12.99999}
- {x: 72.99998, y: 15.00001}
- {x: 70.999985, y: 14.999974}
- {x: 71.00002, y: 12.99999}
- - {x: 50.999973, y: 11.99999}
- {x: 50.999973, y: 14.00001}
- {x: 44.999992, y: 13.999974}
- {x: 45.000027, y: 11.99999}
- - {x: 53.999973, y: 7.9999905}
- {x: 53.999973, y: 10.00001}
- {x: 51.999992, y: 9.999974}
- {x: 52.000027, y: 7.9999905}
- - {x: 71.99998, y: 7.9999905}
- {x: 71.99998, y: 10.00001}
- {x: 69.999985, y: 9.999974}
- {x: 70.00002, y: 7.9999905}
- - {x: 97.99998, y: 6.9999905}
- {x: 97.99998, y: 9.00001}
- {x: 85.999985, y: 8.999974}
- {x: 86.00002, y: 6.9999905}
- - {x: 62.999973, y: 5.99999}
- {x: 62.999973, y: 8.00001}
- {x: 58.99999, y: 7.9999747}
- {x: 59.000027, y: 5.99999}
- - {x: 55.999973, y: 3.99999}
- {x: 55.999973, y: 6.00001}
- {x: 48.999992, y: 5.9999747}
- {x: 49.000027, y: 3.99999}
- - {x: 90.99998, y: -17.00001}
- {x: 90.99998, y: -1.99999}
- {x: 70.000015, y: -1.9999607}
- {x: 69.99998, y: 2.00001}
- {x: 68.000015, y: 2.0000393}
- {x: 67.99998, y: 6.00001}
- {x: 65.999985, y: 5.9999747}
- {x: 65.99996, y: 4.00001}
- {x: 63.99999, y: 3.9999747}
- {x: 63.99996, y: 2.00001}
- {x: 61.99999, y: 1.9999748}
- {x: 61.99996, y: 0.00001}
- {x: 59.99999, y: -0.0000252}
- {x: 59.99996, y: -1.99999}
- {x: 25.99999, y: -2.0000253}
- {x: 26.000027, y: -17.00001}
- - {x: 100.99998, y: 2.99999}
- {x: 100.99998, y: 5.00001}
- {x: 96.999985, y: 4.9999747}
- {x: 97.00003, y: 2.99999}
- - {x: 18.999975, y: 1.99999}
- {x: 18.999975, y: 4.00001}
- {x: 13.99999, y: 3.9999747}
- {x: 14.000026, y: 1.99999}
- - {x: 46.999973, y: 1.99999}
- {x: 46.999973, y: 4.00001}
- {x: 39.999992, y: 3.9999747}
- {x: 40.000027, y: 1.99999}
- - {x: 84.99998, y: 1.99999}
- {x: 84.99998, y: 4.00001}
- {x: 73.999985, y: 3.9999747}
- {x: 74.00002, y: 1.99999}
- - {x: 37.999973, y: -0.00001}
- {x: 37.999973, y: 2.00001}
- {x: 30.99999, y: 1.9999748}
- {x: 31.000027, y: -0.00001}
- - {x: 24.999975, y: -2.00001}
- {x: 24.999975, y: 0.00001}
- {x: 19.99999, y: -0.0000252}
- {x: 20.000027, y: -2.00001}
- - {x: 115.99998, y: -3.00001}
- {x: 115.99998, y: -0.99999}
- {x: 108.999985, y: -1.0000252}
- {x: 109.00003, y: -3.00001}
- - {x: 17.999975, y: -4.00001}
- {x: 17.999975, y: -1.99999}
- {x: 8.99999, y: -2.0000253}
- {x: 9.000026, y: -4.00001}
- - {x: 7.9999747, y: -17.00001}
- {x: 7.9999747, y: -3.99999}
- {x: -18.00001, y: -4.0000253}
- {x: -17.999975, y: -17.00001}
- - {x: 108.99998, y: -7.0000095}
- {x: 108.99998, y: -4.99999}
- {x: 99.999985, y: -5.0000253}
- {x: 100.00003, y: -7.0000095}
- - {x: 70.99997, y: 18}
- {x: 70.99997, y: 20}
- {x: 69, y: 19.999971}
- {x: 69.00003, y: 18}
- - {x: 44.999973, y: 16}
- {x: 44.999973, y: 18}
- {x: 39, y: 17.999971}
- {x: 39.00003, y: 16}
- - {x: 72.99997, y: 13}
- {x: 72.99997, y: 15}
- {x: 71, y: 14.999971}
- {x: 71.00003, y: 13}
- - {x: 50.999973, y: 12}
- {x: 50.999973, y: 14}
- {x: 45, y: 13.999971}
- {x: 45.00003, y: 12}
- - {x: 71.99997, y: 8}
- {x: 71.99997, y: 10}
- {x: 70, y: 9.99997}
- {x: 70.00003, y: 8}
- - {x: 53.99997, y: 8}
- {x: 53.99997, y: 10}
- {x: 52, y: 9.99997}
- {x: 52.00003, y: 8}
- - {x: 97.99997, y: 7}
- {x: 97.99997, y: 9}
- {x: 86, y: 8.99997}
- {x: 86.00003, y: 7}
- - {x: 62.99997, y: 6}
- {x: 62.99997, y: 8}
- {x: 59, y: 7.9999704}
- {x: 59.000034, y: 6}
- - {x: 90.99997, y: -17}
- {x: 90.99997, y: -2}
- {x: 70, y: -1.9999707}
- {x: 69.99997, y: 2}
- {x: 68, y: 2.0000293}
- {x: 67.99997, y: 6}
- {x: 66, y: 5.999971}
- {x: 65.99997, y: 4}
- {x: 64, y: 3.999971}
- {x: 63.99997, y: 2}
- {x: 62, y: 1.9999708}
- {x: 61.99997, y: 0}
- {x: 60, y: -0.000029300001}
- {x: 59.99997, y: -2}
- {x: 26, y: -2.0000293}
- {x: 26.000029, y: -17}
- - {x: 55.99997, y: 4}
- {x: 55.99997, y: 6}
- {x: 49, y: 5.999971}
- {x: 49.00003, y: 4}
- - {x: 100.99997, y: 3}
- {x: 100.99997, y: 5}
- {x: 97, y: 4.999971}
- {x: 97.00003, y: 3}
- - {x: 84.99997, y: 2}
- {x: 84.99997, y: 4}
- {x: 74, y: 3.999971}
- {x: 74.00003, y: 2}
- - {x: 46.999973, y: 2}
- {x: 46.999973, y: 4}
- {x: 40, y: 3.999971}
- {x: 40.00003, y: 2}
- - {x: 18.999971, y: 2}
- {x: 18.999971, y: 4}
- {x: 14, y: 3.999971}
- {x: 14.000029, y: 2}
- - {x: 37.999973, y: 0}
- {x: 37.999973, y: 2}
- {x: 31, y: 1.9999708}
- {x: 31.000029, y: 0}
- - {x: 24.999971, y: -2}
- {x: 24.999971, y: 0}
- {x: 20, y: -0.000029300001}
- {x: 20.000029, y: -2}
- - {x: 115.99998, y: -3}
- {x: 115.99998, y: -1}
- {x: 109, y: -1.0000293}
- {x: 109.00003, y: -3}
- - {x: 17.999971, y: -4}
- {x: 17.999971, y: -2}
- {x: 9, y: -2.0000293}
- {x: 9.00003, y: -4}
- - {x: 7.9999704, y: -17}
- {x: 7.9999704, y: -4}
- {x: -18, y: -4.000029}
- {x: -17.999971, y: -17}
- - {x: 108.99998, y: -7}
- {x: 108.99998, y: -5}
- {x: 100, y: -5.000029}
- {x: 100.00003, y: -7}
m_VertexDistance: 0.0005
m_OffsetDistance: 0.00005
--- !u!50 &2120494079
@@ -15892,5 +15721,10 @@ PrefabInstance:
propertyPath: playerCollider
value:
objectReference: {fileID: 1671840919}
- target: {fileID: 3827363133515929335, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a,
type: 3}
propertyPath: eventControls
value:
objectReference: {fileID: 1491655}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: ef13d4cb4d0a2b043b4f2a6cc75ca48a, type: 3}

View File

@@ -8,6 +8,7 @@ public class BugMovement : MonoBehaviour
[SerializeField] private float secondsGoingRight = 1;
[SerializeField] private float movementSpeed = 10;
[SerializeField] BoxCollider2D playerCollider;
[SerializeField] EventControls eventControls;
private int leftAccumalator = 0;
private int rightAccumalator = 0;
@@ -17,13 +18,15 @@ public class BugMovement : MonoBehaviour
private void Start()
{
Physics2D.IgnoreCollision(GetComponent<BoxCollider2D>(), playerCollider);
rigidBody = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
private void Update()
{
if (HasEncounteredPlayer())
eventControls.TriggerEvent(playerCollider, GetComponent<BoxCollider2D>());
var totalFramesGoingLeft = framesPerSecond * secondsGoingLeft;
var totalFramesGoingRight = framesPerSecond * secondsGoingRight;
@@ -56,4 +59,9 @@ public class BugMovement : MonoBehaviour
var actualSpeed = movementSpeed;
rigidBody.velocity = new Vector2(actualSpeed, rigidBody.velocity.y);
}
private bool HasEncounteredPlayer()
{
return rigidBody.IsTouchingLayers(LayerMask.GetMask(LayerNames.Player));
}
}

View File

@@ -10,8 +10,8 @@ public class EventControls : MonoBehaviour
[SerializeField] private Tile tile;
[SerializeField] private Tile successTile;
[SerializeField] private float framesPerControlTile = 15;
[SerializeField] private float nextControlYOffset = 0;
[SerializeField] private float nextControlXOffset = 0;
[SerializeField] private int nextControlYOffset = 0;
[SerializeField] private int nextControlXOffset = 0;
[SerializeField] private float tileMapClearDelayInSeconds = 0.5f;
private Tilemap tilemap;
@@ -24,20 +24,38 @@ public class EventControls : MonoBehaviour
private bool eventDrawn = false;
private bool eventTriggered = false;
private int eventCycleInSeconds = 4;
private int eventCycleInSeconds = 2;
private int eventCycleAccumalator = 0;
private int tileMapClearDelayAccumalator = 0;
private EventControlTile currentEventControl;
private Collider2D currentPlayerCollider;
private Collider2D currentEnemyCollider;
private Queue<EventControlTile> eventControlTilesInCycle;
private int framesPerSecond => 60;
private Vector3Int nextControlOffSetAsVector => new Vector3Int(nextControlXOffset, nextControlYOffset, 0);
public void TriggerEvent(Collider2D playerCollider, Collider2D enemyCollider)
{
currentPlayerCollider = playerCollider;
currentEnemyCollider = enemyCollider;
Physics2D.IgnoreCollision(playerCollider, enemyCollider, true);
eventTriggered = true;
}
public bool IsEventTriggered()
{
return eventTriggered;
}
private void Start()
{
tilemap = GetComponent<Tilemap>();
eventControlTilesInCycle = new Queue<EventControlTile>();
eventTriggered = true; // TODO: TEST
}
private void Update()
@@ -45,42 +63,17 @@ public class EventControls : MonoBehaviour
if (eventTriggered)
{
SetTile();
SetTileMapPosition();
}
else
{
nextControlAccumalator = 0;
//SetTileMapPosition();
}
if (eventDrawn && eventTriggered)
{
if (currentEventControl == null)
currentEventControl = eventControlTilesInCycle.Dequeue();
if (Input.GetKeyDown(currentEventControl.keyCode))
{
tilemap.SetTile(currentEventControl.position, currentEventControl.successTile);
currentEventControl = null;
if (eventControlTilesInCycle.Count == 0)
{
eventTriggered = false;
}
}
PerformControlEvent();
}
if (eventDrawn && !eventTriggered)
{
if (tileMapClearDelayAccumalator >= tileMapClearDelayInSeconds * framesPerSecond)
{
tilemap.ClearAllTiles();
tileMapClearDelayAccumalator = 0;
eventDrawn = false;
}
else
{
tileMapClearDelayAccumalator++;
}
Reset();
}
}
@@ -92,7 +85,7 @@ public class EventControls : MonoBehaviour
initialCameraPosition = GetCameraPosition();
// Store tiles for event cycle
var eventControlTile = new EventControlTile(KeyCode.W, tile, successTile, GetNextTilePosition()); /* TODO: Hard code */
var eventControlTile = new EventControlTile(KeyCode.W, tile, successTile, GetNextTilePosition() + nextControlOffSetAsVector); /* TODO: Hard code */
eventControlTilesInCycle.Enqueue(eventControlTile);
tilemap.SetTile(eventControlTile.position, tile);
@@ -105,8 +98,10 @@ public class EventControls : MonoBehaviour
initialCameraPosition = null;
eventDrawn = true;
}
nextControlAccumalator++;
else
{
nextControlAccumalator++;
}
}
private Vector3Int GetCameraPosition()
@@ -122,9 +117,56 @@ public class EventControls : MonoBehaviour
.GetValueOrDefault();
}
private void PerformControlEvent()
{
nextControlAccumalator = 0;
if (currentEventControl == null)
currentEventControl = eventControlTilesInCycle.Dequeue();
if (Input.GetKeyDown(currentEventControl.keyCode))
{
tilemap.SetTile(currentEventControl.position, currentEventControl.successTile);
currentEventControl = null;
if (eventControlTilesInCycle.Count == 0)
{
eventTriggered = false;
eventCycleAccumalator = 0;
}
}
else if (eventCycleAccumalator >= eventCycleInSeconds * framesPerSecond)
{
}
else
{
eventCycleAccumalator++;
}
}
private void Reset()
{
if (tileMapClearDelayAccumalator >= tileMapClearDelayInSeconds * framesPerSecond)
{
tilemap.ClearAllTiles();
tileMapClearDelayAccumalator = 0;
eventDrawn = false;
numberOfControlTilesSet = 0;
Physics2D.IgnoreCollision(currentPlayerCollider, currentEnemyCollider, false);
currentPlayerCollider = null;
currentEnemyCollider = null;
}
else
{
tileMapClearDelayAccumalator++;
}
}
private void SetTileMapPosition()
{
transform.position = camera.transform.position +
new Vector3(nextControlXOffset, nextControlYOffset, 0); // offset
new Vector3Int(nextControlXOffset, nextControlYOffset, 0); // offset
}
}

View File

@@ -1,4 +1,5 @@
using System.Collections;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
@@ -10,9 +11,8 @@ public class Player : MonoBehaviour
[SerializeField] private float groundErrorThreshold = 0.01f;
private Rigidbody2D rigidBody;
private BoxCollider2D collider;
new private BoxCollider2D collider;
private Animator animator;
private bool isInEncounter = false;
private void Start()
{
@@ -23,8 +23,6 @@ public class Player : MonoBehaviour
private void Update()
{
//isInEncounter = HasEncounteredEnemy();
//if (isInEncounter)
MovePlayer();
}