/// <summary>Turns on the colliders for the given shape's type. /// Returns an AvailableSpot to hold if the player was able to fit in the current location and what location the spot was found. /// If a spot was found, the colliders were updated. /// If a spot was not found, they cannot fit in their current location and their colliders were not changed.</summary> /// <param name="colliderType">Type of collider to activate</param> /// <param name="size">The actual size of the collider to test</param> /// /// <param name="rotation">Rotation of the shape.</param> public AvailableSpot ActivateCollider(ShapeData.ShapeType colliderType, Vector2Int size, float rotation) { AvailableSpot availSpot = TestColliderChange(colliderType, size, rotation); if (availSpot.Available) { ChangeColliderType(colliderType); } return(availSpot); }
/// <summary>Should be called after shape data and size data have been given to it. /// Changes shape and size to be the specified size and shape</summary> public void ActivateFormChange() { Vector2Int facingDir = playerMoveRef.GetFacingDirection(); float shapeRot = GetShapeRotation(curShapeData, facingDir, wasShapeChanged); // Set size using facing size and size data Vector2Int size = curShapeData.Scale; if (curSizeData != null) { size *= curSizeData.Size; } //Debug.Log("Was Size Changed: " + wasSizeChanged); //Debug.Log("Was Shape Changed: " + wasShapeChanged); //Debug.Log("PreviousShapeData: " + prevShapeData); //Debug.Log("CurShapeData: " + curShapeData); //Debug.Log("Does direciton affect scale: " + curShapeData.DirectionAffectsScale); //Debug.Log("Target Size: " + size); //Debug.Log("Current Size: " + playerScaleCont.ShapeScale); //Debug.Log("Target!=Size? " + (size != playerScaleCont.ShapeScale)); //Debug.Log("ShapeRot: " + shapeRot); // Change if size or shape was changed or // if the shape's direction affects scale and the rotation has been changed because of it if (wasSizeChanged || wasShapeChanged || (curShapeData != null && curShapeData.DirectionAffectsScale && shapeRot != shapeRotation)) { // Swap the colliders // If the colliders couldn't be swapped, ergo could not fit, then do not swap the player's shape Vector2Int scaledSize = Vector2Int.Scale(size, playerScaleCont.OriginalScale); AvailableSpot availSpot = playerColContRef.ActivateCollider(curShapeData.TypeOfShape, scaledSize, shapeRot); if (availSpot.Available) { // Call the available spot found event OnAvailableSpotFound?.Invoke(); // Set the shape rotation shapeRotation = shapeRot; // Start changing form StartChangeForm(size, availSpot.Position, curShapeData.DirectionAffectsScale); // They are now the current, so reset them wasSizeChanged = false; wasShapeChanged = false; } // Player could not change here, so display the error that could not change here else { FailToChange(curShapeData, availSpot.Position); } } }