From cb8fbbafce5d3f2bb0cd3f31347bb204dc5d4783 Mon Sep 17 00:00:00 2001 From: dddushesss <37773701+dddushesss@users.noreply.github.com> Date: Mon, 14 Feb 2022 05:01:53 +0300 Subject: [PATCH] fixed CaptureAbility.cs --- .../Resources/Data/Items/CaptureTAbility.asset | 4 ++-- Assets/Scripts/Items/CaptureAbility.cs | 17 ++++++++++++++--- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/Assets/Resources/Data/Items/CaptureTAbility.asset b/Assets/Resources/Data/Items/CaptureTAbility.asset index 6d644bf9..4c0ee8fa 100644 --- a/Assets/Resources/Data/Items/CaptureTAbility.asset +++ b/Assets/Resources/Data/Items/CaptureTAbility.asset @@ -12,8 +12,8 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 461496314fe84e509ae72dd06538b62c, type: 3} m_Name: CaptureTAbility m_EditorClassIdentifier: - iconPrefab: {fileID: 3197816592181874056, guid: 2704c4f795b0d7748a3e3fa53be4d893, type: 3} icon: {fileID: 21300000, guid: 543c4732bd2d47a41bdbbf2156eb358c, type: 3} + type: 0 aimCanvas: {fileID: 2273039178377770117, guid: 09a0317cbdff9fa479a18c9e20743a8e, type: 3} - itterationMove: 000000000000000000000000040000000500000001000000 + itterationMove: 0000000000000000040000000500000001000000 animName: SuperJump diff --git a/Assets/Scripts/Items/CaptureAbility.cs b/Assets/Scripts/Items/CaptureAbility.cs index a433af76..e9f01f19 100644 --- a/Assets/Scripts/Items/CaptureAbility.cs +++ b/Assets/Scripts/Items/CaptureAbility.cs @@ -43,8 +43,13 @@ namespace Items if(_aimInstance == null) _aimInstance = Object.Instantiate(aimCanvas, unit.Instance.transform); _aimInstance.SetActive(true); - _aimInstance.transform.LookAt(HexManager.UnitCurrentCell[unit.Color].cell - .GetNeighbor(direction).transform); + var cell = HexManager.UnitCurrentCell[unit.Color].cell + .GetNeighbor(direction); + if (cell == null) + { + return; + } + _aimInstance.transform.LookAt(cell.transform); _direction = direction; } @@ -56,8 +61,9 @@ namespace Items private void DoPaint(Unit unit) { unit.UseItem(this); + HexManager.UnitCurrentCell[unit.Color].cell.PaintHex(unit.Color); var cell = HexManager.UnitCurrentCell[unit.Color].cell.GetNeighbor(_direction); - cell.PaintHex(unit.Color); + cell.PaintHex(unit.Color); bool keepGoing = true; var moveDir = _direction; itterationMove.ForEach(dir => @@ -94,6 +100,11 @@ namespace Items { var cell = HexManager.UnitCurrentCell[unit.Color].cell.GetNeighbor(_direction); + if (cell == null) + { + DeAim(); + return; + } unit.RotateUnit(new Vector2((cell.transform.position - unit.Instance.transform.position).normalized.x, (cell.transform.position - unit.Instance.transform.position).normalized.z)); unit.Animator.SetTrigger(animName);