Assets/Characters/Player/Player.prefab | ●●●●● patch | view | raw | blame | history | |
Assets/Scenes/GameplayScene.unity | ●●●●● patch | view | raw | blame | history | |
Assets/Scripts/Events/CharacterEvents.cs | ●●●●● patch | view | raw | blame | history | |
Assets/Scripts/Managers/GameManager.cs | ●●●●● patch | view | raw | blame | history | |
Assets/Scripts/PlayerController.cs | ●●●●● patch | view | raw | blame | history | |
TODOs | ●●●●● patch | view | raw | blame | history |
Assets/Characters/Player/Player.prefab
@@ -223,7 +223,7 @@ m_Bits: 0 m_Interpolate: 0 m_SleepingMode: 1 m_CollisionDetection: 0 m_CollisionDetection: 1 m_Constraints: 4 --- !u!114 &1512638649171213079 MonoBehaviour: @@ -386,7 +386,7 @@ adaptiveTiling: 0 m_AutoTiling: 0 serializedVersion: 2 m_Size: {x: 0.7205616, y: 0.7178567} m_Size: {x: 0.7, y: 0.7} m_EdgeRadius: 0 --- !u!95 &2451348752795735853 Animator: @@ -435,8 +435,8 @@ maxDepth: 0 minNormalAngle: 0 maxNormalAngle: 0 groundDistance: 0.05 wallDistance: 0.2 groundDistance: 0.02 wallDistance: 0.02 ceilingDistance: 0.05 rotorGO: {fileID: 1519978218308964847} _isGrounded: 1 Assets/Scenes/GameplayScene.unity
@@ -3188,7 +3188,7 @@ m_Color: {r: 1, g: 1, b: 1, a: 1} m_Origin: {x: 0, y: -1, z: 0} m_Size: {x: 14, y: 7, z: 1} m_TileAnchor: {x: 0.5, y: 0.5, z: 0} m_TileAnchor: {x: 0, y: 0, z: 0} m_TileOrientation: 0 m_TileOrientationMatrix: e00: 1 @@ -4323,25 +4323,25 @@ e33: 0 - m_RefCount: 0 m_Data: e00: 0 e00: 5.0497e-41 e01: 0 e02: 5.5000076 e03: 5.5000076 e10: 0 e11: 0 e12: 6.95e-43 e13: 6.95e-43 e20: 1.1215021e-15 e21: 14.638138 e22: -1.3211928e-28 e23: -1.093541e-19 e30: 4.5905e-41 e31: 6.98e-43 e32: 6.95e-43 e33: 6.98e-43 e12: 5.55e-43 e13: 5.55e-43 e20: 0.000116169685 e21: 8.914042e-18 e22: -8.137887e-29 e23: -1.1375036e-19 e30: 4.5904e-41 e31: 5.58e-43 e32: 5.55e-43 e33: 5.58e-43 m_TileColorArray: - m_RefCount: 0 m_Data: {r: 4.4012e-41, g: 4.4012e-41, b: 4.4012e-41, a: 4.4012e-41} m_Data: {r: 4.2084e-41, g: 4.2084e-41, b: 4.2084e-41, a: 4.2084e-41} m_TileObjectToInstantiateArray: [] m_AnimationFrameRate: 1 m_Color: {r: 1, g: 1, b: 1, a: 1} @@ -4990,30 +4990,6 @@ - target: {fileID: 3345854317100013954, guid: c220ec455fce341408d66d880b464cad, type: 3} propertyPath: m_Name value: Player objectReference: {fileID: 0} - target: {fileID: 3884295854780712968, guid: c220ec455fce341408d66d880b464cad, type: 3} propertyPath: m_Size.x value: 0.7 objectReference: {fileID: 0} - target: {fileID: 3884295854780712968, guid: c220ec455fce341408d66d880b464cad, type: 3} propertyPath: m_Size.y value: 0.7 objectReference: {fileID: 0} - target: {fileID: 3884295854780712968, guid: c220ec455fce341408d66d880b464cad, type: 3} propertyPath: m_EdgeRadius value: 0 objectReference: {fileID: 0} - target: {fileID: 4941032555966952991, guid: c220ec455fce341408d66d880b464cad, type: 3} propertyPath: m_CollisionDetection value: 1 objectReference: {fileID: 0} - target: {fileID: 5338311196462064651, guid: c220ec455fce341408d66d880b464cad, type: 3} propertyPath: wallDistance value: 0.02 objectReference: {fileID: 0} - target: {fileID: 5338311196462064651, guid: c220ec455fce341408d66d880b464cad, type: 3} propertyPath: groundDistance value: 0.02 objectReference: {fileID: 0} m_RemovedComponents: [] m_RemovedGameObjects: [] Assets/Scripts/Events/CharacterEvents.cs
@@ -9,4 +9,5 @@ public static UnityAction<GameObject, int> characterDamaged; public static UnityAction<GameObject, int> characterHealed; public static UnityAction<ContactPoint2D, DrillDirection> characterDrill; public static UnityAction<Vector3> characterDrillingToPosition; } Assets/Scripts/Managers/GameManager.cs
@@ -59,7 +59,8 @@ } public void CharacterDrill(ContactPoint2D contact, DrillDirection drillDirection) { Vector3Int cellCoord = tilemap.transform.GetComponentInParent<GridLayout>().WorldToCell(contact.point); GridLayout grid = tilemap.transform.GetComponentInParent<GridLayout>(); Vector3Int cellCoord = grid.WorldToCell(contact.point); switch(drillDirection) { case DrillDirection.Left: @@ -72,7 +73,17 @@ cellCoord.y = cellCoord.y - 1; break; } //Debug.Log("cellCoord: " + grid.CellToWorld(cellCoord)); //Debug.Log(tilemap.HasTile(cellCoord)); if (tilemap.HasTile(cellCoord)) { tilemap.SetTile(cellCoord, null); Vector3 moveToPosition = grid.CellToWorld(cellCoord); moveToPosition.x += 0.5f; moveToPosition.y += 0.5f; CharacterEvents.characterDrillingToPosition.Invoke(moveToPosition); } } public void GameLoaded() { Assets/Scripts/PlayerController.cs
@@ -19,16 +19,21 @@ [NonSerialized] public Rigidbody2D rb; [NonSerialized] public Damageable health; BoxCollider2D boxCollider; Animator animator; Animator animator_rotor; public GameObject rotorGO; TouchingDirections touchingDirections; [NonSerialized] public Damageable health; // Time it takes to drill public float drillingTime = 1f; private float timeSinceDrill = 0f; private bool drillToPosition; private Vector3 drillTilePosition; private Vector3 drillOriginalPosition; [SerializeField] private bool _isMoving; @@ -89,7 +94,15 @@ } } private void OnEnable() { CharacterEvents.characterDrillingToPosition += (DrillingToPosition); } private void OnDisable() { CharacterEvents.characterDrillingToPosition -= (DrillingToPosition); } private void Awake() { @@ -98,6 +111,7 @@ animator_rotor = rotorGO.GetComponent<Animator>(); touchingDirections = GetComponent<TouchingDirections>(); health = GetComponent<Damageable>(); boxCollider = GetComponent<BoxCollider2D>(); if (SaveSystem.isGameLoaded) { GameObject uiManager = GameObject.Find("GameManager"); @@ -181,14 +195,22 @@ if (IsDrilling) { rb.velocity = Vector2.zero; if (timeSinceDrill > drillingTime) if (drillToPosition) { IsDrilling = false; timeSinceDrill = 0; if (timeSinceDrill < drillingTime) { gameObject.transform.position = Vector3.Lerp(drillOriginalPosition, drillTilePosition, timeSinceDrill / drillingTime); //Debug.Log("drillTilePosition: " + drillTilePosition); //Debug.Log("timeSinceDrill: " + timeSinceDrill); timeSinceDrill += Time.deltaTime; } else { timeSinceDrill += Time.deltaTime; boxCollider.enabled = true; IsDrilling = false; drillToPosition = false; timeSinceDrill = 0; } } } } @@ -207,15 +229,12 @@ IsMoving = false; IsFlying = false; //moveInput = Vector2.zero; } } private void Drill(DrillDirection drillDirection) { IsDrilling = true; ContactPoint2D[] contactPoints = new ContactPoint2D[1]; Debug.Log("drillDirection: " + drillDirection.ToString()); //rb.GetContacts(contactPoints); switch (drillDirection) { @@ -229,8 +248,25 @@ touchingDirections.groundHits[0].collider.GetContacts(contactPoints); break; } //Debug.Log(contactPoints[0].otherRigidbody?.gameObject.name); if (contactPoints[0].otherRigidbody?.name == "Tilemap") { boxCollider.enabled = false; IsDrilling = true; CharacterEvents.characterDrill.Invoke(contactPoints[0], drillDirection); } } private void DrillingToPosition(Vector3 tilePosition) { //Debug.Log("DrillingToPosition() called"); //Debug.Log(gameObject.transform.position); drillToPosition = true; drillTilePosition = tilePosition; //Debug.Log("drillTilePosition: " + drillTilePosition); drillOriginalPosition = gameObject.transform.position; //Debug.Log("drillOriginalPosition: " + drillOriginalPosition); } //private void DrillLeftOrRight() //{ TODOs
@@ -12,7 +12,6 @@ NEXT Move player to drill tile Animate drilling Add borders to map Add background to map