Skip to content

Commit

Permalink
Fix movement between zones
Browse files Browse the repository at this point in the history
  • Loading branch information
davidmfinol committed Nov 1, 2017
1 parent 4883e48 commit baa096d
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 35 deletions.
8 changes: 4 additions & 4 deletions Assets/Prefabs/Card Stack.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ RectTransform:
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 0, y: 0}
m_AnchorMin: {x: 0, y: 1}
m_AnchorMax: {x: 0, y: 1}
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 280, y: 0}
m_Pivot: {x: 0, y: 0.5}
m_SizeDelta: {x: 280, y: 500}
m_Pivot: {x: 0, y: 1}
30 changes: 15 additions & 15 deletions Assets/Scenes/DeckEditor.unity
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ Prefab:
- target: {fileID: 224252938770132402, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
propertyPath: m_SizeDelta.x
value: -81.55502
value: -81.81122
objectReference: {fileID: 0}
- target: {fileID: 224673017872509486, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
Expand All @@ -508,17 +508,17 @@ Prefab:
- target: {fileID: 224673017872509486, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
propertyPath: m_AnchoredPosition.y
value: -74.25
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224673017872509486, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
propertyPath: m_SizeDelta.x
value: 522
value: 522.2241
objectReference: {fileID: 0}
- target: {fileID: 224673017872509486, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
propertyPath: m_SizeDelta.y
value: 148.5
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224174961411463182, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
Expand All @@ -533,22 +533,22 @@ Prefab:
- target: {fileID: 224174961411463182, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
propertyPath: m_AnchoredPosition.x
value: 522
value: 522.2241
objectReference: {fileID: 0}
- target: {fileID: 224174961411463182, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
propertyPath: m_AnchoredPosition.y
value: -74.25
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224174961411463182, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
propertyPath: m_SizeDelta.x
value: 522
value: 522.2241
objectReference: {fileID: 0}
- target: {fileID: 224174961411463182, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
propertyPath: m_SizeDelta.y
value: 148.5
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224677791729663838, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
Expand All @@ -563,32 +563,32 @@ Prefab:
- target: {fileID: 224677791729663838, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
propertyPath: m_AnchoredPosition.x
value: 1044
value: 1044.4482
objectReference: {fileID: 0}
- target: {fileID: 224677791729663838, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
propertyPath: m_AnchoredPosition.y
value: -74.25
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224677791729663838, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
propertyPath: m_SizeDelta.x
value: 492
value: 492.2241
objectReference: {fileID: 0}
- target: {fileID: 224677791729663838, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
propertyPath: m_SizeDelta.y
value: 148.5
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224143448842205196, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
propertyPath: m_SizeDelta.y
value: -255.34616
value: 0
objectReference: {fileID: 0}
- target: {fileID: 224560339167716316, guid: 09ee4d14818c1ba47b96c322e8a36f1d,
type: 2}
propertyPath: m_SizeDelta.y
value: -148.5
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_ParentPrefab: {fileID: 100100000, guid: 09ee4d14818c1ba47b96c322e8a36f1d, type: 2}
Expand Down Expand Up @@ -2793,7 +2793,7 @@ MonoBehaviour:
m_TargetGraphic: {fileID: 335690431}
m_HandleRect: {fileID: 335690429}
m_Direction: 0
m_Value: 1
m_Value: 0
m_Size: 1
m_NumberOfSteps: 0
m_OnValueChanged:
Expand Down
25 changes: 17 additions & 8 deletions Assets/Scripts/CardModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,13 @@ public void OnPointerUp(PointerEventData eventData)
else if (PlaceHolder == null)
EventSystem.current.SetSelectedGameObject(this.gameObject, eventData);
}

CurrentPointerEventData = eventData;
CurrentDragPhase = DragPhase.End;

UpdatePosition();
if (SecondaryDragAction != null && IsProcessingSecondaryDragAction)
SecondaryDragAction();

PointerPositions.Remove(eventData.pointerId);
PointerDragOffsets.Remove(eventData.pointerId);
if (CurrentDragPhase != DragPhase.Drag) {
PointerPositions.Remove(eventData.pointerId);
PointerDragOffsets.Remove(eventData.pointerId);
}
}

public void OnSelect(BaseEventData eventData)
Expand All @@ -113,8 +110,12 @@ public void OnBeginDrag(PointerEventData eventData)

CardModel cardModel = this;
if (DoesCloneOnDrag) {
PointerPositions.Remove(eventData.pointerId);
PointerDragOffsets.Remove(eventData.pointerId);
DraggedClones [eventData.pointerId] = Clone(this.gameObject.FindInParents<Canvas>().transform);
cardModel = DraggedClones [eventData.pointerId];
cardModel.PointerPositions [eventData.pointerId] = eventData.position;
cardModel.PointerDragOffsets [eventData.pointerId] = ((Vector2)cardModel.transform.position) - eventData.position;
cardModel.GetComponent<CanvasGroup>().blocksRaycasts = false;
}

Expand Down Expand Up @@ -151,6 +152,14 @@ public void OnEndDrag(PointerEventData eventData)
DraggedClones.Remove(eventData.pointerId);

cardModel.CurrentPointerEventData = eventData;
cardModel.CurrentDragPhase = DragPhase.End;

cardModel.UpdatePosition();
if (cardModel.SecondaryDragAction != null && cardModel.IsProcessingSecondaryDragAction)
cardModel.SecondaryDragAction();

cardModel.PointerPositions.Remove(eventData.pointerId);
cardModel.PointerDragOffsets.Remove(eventData.pointerId);

if (!cardModel.IsProcessingSecondaryDragAction) {
if (cardModel.PlaceHolder != null)
Expand Down
2 changes: 1 addition & 1 deletion Assets/Scripts/PlayMode/ExtensibleCardZone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ void Start()
{
foreach (CardDropZone dropZone in cardDropZones)
dropZone.dropHandler = this;
extensionContent.gameObject.GetOrAddComponent<CardStack>().OnAddCardActions.Add(OnAddCardModel);
OnStart();
}

public virtual void OnStart()
{
extensionContent.gameObject.GetOrAddComponent<CardStack>().OnAddCardActions.Add(OnAddCardModel);
}

public virtual void OnDrop(CardModel cardModel)
Expand Down
11 changes: 6 additions & 5 deletions Assets/Scripts/PlayMode/StackedZone.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,12 @@ public class StackedZone : ExtensibleCardZone, ICardDropHandler
public override void OnStart()
{
DropZone = this.gameObject.GetOrAddComponent<CardDropZone>();
ZoneCardStack = GetComponent<CardStack>();
ExtensionCardStack = extensionContent.GetComponent<CardStack>();

ZoneCardStack.OnAddCardActions.Add(CardModel.ResetRotation);
ZoneCardStack = GetComponent<CardStack>();
ZoneCardStack.OnAddCardActions.Add(OnAddCardModel);
ZoneCardStack.OnRemoveCardActions.Add(OnRemoveCardModel);

ExtensionCardStack.OnAddCardActions.Remove(CardModel.ShowCard);
ExtensionCardStack = extensionContent.GetComponent<CardStack>();
ExtensionCardStack.OnAddCardActions.Add(OnAddCardModel);
ExtensionCardStack.OnRemoveCardActions.Add(OnRemoveCardModel);
}
Expand All @@ -44,9 +42,12 @@ public override void OnAddCardModel(CardStack cardStack, CardModel cardModel)
{
if (cardStack == null || cardModel == null)
return;


cardModel.transform.rotation = Quaternion.identity;
cardModel.DoubleClickAction = ToggleExtension;
cardModel.SecondaryDragAction = Shuffle;
if (IsExtended)
cardModel.IsFacedown = false;

int cardIndex = CardModels.Count;
if (cardStack == ExtensionCardStack)
Expand Down
4 changes: 2 additions & 2 deletions ProjectSettings/ProjectSettings.asset
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ PlayerSettings:
16:10: 1
16:9: 1
Others: 0
bundleVersion: 0.8.0
bundleVersion: 0.8.5
preloadedAssets: []
metroInputSource: 0
m_HolographicPauseOnTrackingLoss: 1
Expand All @@ -149,7 +149,7 @@ PlayerSettings:
buildNumber:
Standalone: 8
iOS: 20171010
AndroidBundleVersionCode: 8
AndroidBundleVersionCode: 9
AndroidMinSdkVersion: 16
AndroidTargetSdkVersion: 0
AndroidPreferredInstallLocation: 1
Expand Down

0 comments on commit baa096d

Please sign in to comment.