public Card ReplaceCard(ICardModel unassignedCard, CardContainer container) { int index = model.GetIndexOf(container.GetCard().GetCardAssignment()); cardManager.UnassignCard(container.GetCard().GetCardAssignment()); return(AcceptCard(unassignedCard, index)); }
private void StartSelectionForContainerObj(GameObject containerObj, BehaviorSystem.SavedCardPack existingPack = null) { CardContainer container = containerObj.GetComponentInChildren <CardContainer>(); if (container.GetCard().GetModel().IsBuiltin()) { containerObj.SetActive(false); } else { bool startSelected = existingPack != null && existingPack.uris.Contains(container.GetCard().GetModel().GetUri()); container.StartSelectionMode( (selected) => { if (selection == null) { return; } if (selected) { selection.selectedCards.Add(container.GetCard().GetModel().GetUri()); } else { selection.selectedCards.Remove(container.GetCard().GetModel().GetUri()); } }, startSelected); } }
private Card AddCardFromModel(ICardAssignmentModel assignment) { Card card = Instantiate(cardPrefab); card.Populate(assignment); card.AddListener((eventCard, eventType, eventData) => { switch (eventType) { case Card.EventType.POINTER_DOWN: cardManager.OnPointerDownCard(eventCard); break; case Card.EventType.POINTER_UP: cardManager.OnPointerUpCard(eventCard); break; case Card.EventType.BEGIN_DRAG: cardManager.BeginDrag(); break; default: break; } }); card.OnClick = () => onCardClicked?.Invoke(card); // Create container for the card CardContainer newContainer = Instantiate(cardContainerPrefab, transform).GetComponentInChildren <CardContainer>(); int index = this.model.GetIndexOf(card.GetCardAssignment()); newContainer.rectTransform.transform.SetSiblingIndex(index); newContainer.SetSize(CardManager.BASE_CARD_SIZE); newContainer.scaleOnFocus = false; newContainer.deck = this; newContainer.onPointerDown += () => cardManager.OnPointerDownCard(newContainer.GetCard()); newContainer.onPointerUp += (dragging) => cardManager.OnPointerUpCard(newContainer.GetCard()); newContainer.onPointerEnter += () => cardManager.OnPointerEnterContainer(newContainer); newContainer.onBeginDrag += cardManager.BeginDrag; containers.Add(newContainer); newContainer.SetCard(card); newContainer.TriggerAddEffect(); ResortCards(); return(card); }
GameObject CreateCardAndContainer() { Card card = Instantiate(cardPrefab); GameObject containerObj = Instantiate(cardContainerPrefab, cardLibraryUI.libraryContainer.transform); cardContainerObjects.Add(containerObj); CardContainer container = cardContainerObjects.Last().GetComponentInChildren <CardContainer>(); container.SetSize(CARD_SCALE); container.buttonsOnFocus = false; container.offsetOnFocus = false; container.scaleOnFocus = true; container.onBeginDrag += () => OnBeginDrag(container); container.onPointerUp += (dragging) => { if (dragging) { OnEndDrag(container); } else { onClickCard?.Invoke(card); } }; container.onDrag += () => onDragCard(container.GetCard()); container.SetCard(card); card.OnCardPlaced = Close; return(containerObj); }
void OnEndDrag(CardContainer container) { onEndDragCard(container.GetCard()); currentDraggingContainer = null; // Show(); Close(); }
void OnBeginDrag(CardContainer container) { onBeginDragCard(container.GetCard()); currentDraggingContainer = container; Hide(); //Close(); }
// if current value is equal to value at destination, jump; else, continue sequential execution IEnumerator JUMP_IF_EQUAL() { // grab card reference CurrentArg = current.Arg; CardLogic card = cardContainer.GetCard((int)CurrentArg); // Computron gets a copy of the top item from the specified Card SecondValue = card.CopyFrom(); // ensure neither value is null if (CurrentValue == null || SecondValue == null) { error = true; currentState = ACTOR_STATE.REPORTING; yield return(StartCoroutine(currentState.ToString())); } yield return(new WaitForSeconds(InstructionDelay)); conditionalResult = (CurrentValue == SecondValue); // show the two values being added together DisplayMessage(CurrentValue.ToString()); yield return(new WaitForSeconds(InstructionDelay)); DisplayMessage(DisplayText.text + " == "); yield return(new WaitForSeconds(InstructionDelay)); DisplayMessage(DisplayText.text + SecondValue.ToString()); yield return(new WaitForSeconds(InstructionDelay)); DisplayMessage(DisplayText.text + " ?"); yield return(new WaitForSeconds(InstructionDelay)); DisplayMessage(conditionalResult.ToString()); yield return(new WaitForSeconds(InstructionDelay)); ShowDataCube(CurrentValue); HideTextBox(); currentState = ACTOR_STATE.REPORTING; }
private void OnBehaviorDelete(BehaviorSystem.DeleteEvent deleteEvent) { if (!IsOpen()) { return; } if (cardDetail.IsOpen() && cardDetail.GetModel().GetId() == deleteEvent.id) { cardDetail.Close(); } foreach (GameObject containerObj in cardContainerObjects) { CardContainer container = containerObj.GetComponentInChildren <CardContainer>(); if (container.GetCard().GetModel().GetId() == deleteEvent.id) { Destroy(container.GetCard().gameObject); Destroy(containerObj); cardContainerObjects.Remove(containerObj); break; } } }
public void Close() { EndSelection(); if (currentDraggingContainer != null) { onForceReleaseDragCard(currentDraggingContainer.GetCard()); } cardDetail.SetAddCardToSlotListener(null); cardDetail.Close(); onClose?.Invoke(); gameObject.SetActive(false); darkBackground.SetActive(false); // Show(); }
public void OnPointerEnterContainer(CardContainer container) { if (pointerState != PointerState.MouseOver) { return; } if (focusCard != null) { if (focusCard.container != container) { EndCardFocus(); } } focusCard = container.GetCard(); focusCard.EnterFocus(); }
private void OnBehaviorPut(BehaviorSystem.PutEvent putEvent) { if (!IsOpen()) { return; } if (putEvent.isNewBehavior) { GameObject containerObj = CreateCardAndContainer(); PopulateContainerWithUri(containerObj, BehaviorSystem.IdToEmbeddedBehaviorUri(putEvent.id)); StartCoroutine(ScrollToAndFlash(containerObj)); CardContainer container = containerObj.GetComponentInChildren <CardContainer>(); containerObj.SetActive(DoesCardMatchSearch(container.GetCard(), cardLibraryUI.inputField.text)); if (selection != null) { StartSelectionForContainerObj(containerObj); } } else { foreach (GameObject containerObj in cardContainerObjects) { CardContainer container = containerObj.GetComponentInChildren <CardContainer>(); if (container.GetCard().GetModel().GetId() == putEvent.id) { PopulateContainerWithUri(containerObj, BehaviorSystem.IdToEmbeddedBehaviorUri(putEvent.id)); break; } } } if (cardDetail.IsOpen() && cardDetail.IsModelValid() && cardDetail.GetModel().GetId() == putEvent.id) { cardDetail.Populate( new BehaviorCards.UnassignedCard(new UnassignedBehavior( BehaviorSystem.IdToEmbeddedBehaviorUri(putEvent.id), behaviorSystem))); } }