void OnTriggerExit2D(Collider2D collider) { if (tabbleState == TabbleState.atTabbleNotLooking) { tabbleState = TabbleState.NotAtTabble; } }
// Update is called once per frame void Update() { if (tabbleState == TabbleState.atTabbleAndLooking) { escText.active = true; } else { escText.active = false; } switch (tabbleState) { case TabbleState.atTabbleNotLooking: if (inisiate) { newMovement.canMove = true; inisiate = false; } if (Input.GetButtonDown("Submit")) { tabbleState = TabbleState.atTabbleAndLooking; inisiate = true; } break; case TabbleState.atTabbleAndLooking: if (inisiate) { #region create tabble GameObject newTabble = Instantiate(tabble); newTabble.transform.position = new Vector3( newTabble.transform.position.x, newTabble.transform.position.y, 0); GOInTabbleOverlay.Add(newTabble); #endregion #region create cards for (int i = 0; i < cards.Length; i++) { GameObject newCard = Instantiate( cards[i], camera.ScreenToWorldPoint( new Vector3( Screen.width * 0.5f, Screen.height * 0.5f, 0)), Quaternion.identity); //position fix if (cards.Length % 2 == 0) { newCard.transform.position = new Vector3( newCard.transform.position.x + startOfset + (-(ofset * cards.Length * 0.5f) + ofset * i), newCard.transform.position.y, 0); } else { newCard.transform.position = new Vector3( newCard.transform.position.x + startOfset + (-((ofset * cards.Length * 0.5f) - ofset * 0.5f) + ofset * i), newCard.transform.position.y, 0); pointerAtIndex = cards.Length / 2; } for (int child = 0; child < newCard.transform.childCount; child++) { if (newCard.transform.GetChild(child).GetComponent <SpriteRenderer>() != null) { newCard.transform.GetChild(child).GetComponent <SpriteRenderer>().sortingOrder = cardOrder; } } GOInTabbleOverlay.Add(newCard); Cards newCards; newCards.card = newCard; newCards.pos = newCard.transform.position; existingCards.Add(newCards); } #endregion if (!keyQuestMain.Instance.hasLookedAtCards) { firstTimeEvent.Invoke(); keyQuestMain.Instance.hasLookedAtCards = true; } updateMaterial(); inisiate = false; } if (Input.GetButtonDown("Submit") && !DialogManager.Instance.isInDialogue) { if (!aCardIsZoomedIn) { aCardIsZoomedIn = true; existingCards[pointerAtIndex].card.GetComponent <keyQuestCardScript>().playCardAnimation(pickUpAnimation); } else if (aCardIsZoomedIn) { existingCards[pointerAtIndex].card.GetComponent <keyQuestCardScript>().playCardAnimation(putDownAnimation); aCardIsZoomedIn = false; } } if (!aCardIsZoomedIn) { if ((Input.GetKeyDown(KeyCode.D) && !DialogManager.Instance.isInDialogue) || (Input.GetKeyDown(KeyCode.RightArrow) && !DialogManager.Instance.isInDialogue)) { pointerAtIndex++; if (pointerAtIndex >= existingCards.Count - 1) { pointerAtIndex = existingCards.Count - 1; } updateMaterial(); } if ((Input.GetKeyDown(KeyCode.A) && !DialogManager.Instance.isInDialogue) || (Input.GetKeyDown(KeyCode.LeftArrow) && !DialogManager.Instance.isInDialogue)) { pointerAtIndex--; if (pointerAtIndex <= 0) { pointerAtIndex = 0; } updateMaterial(); } } if (Input.GetButtonDown("Cancel")) { if (aCardIsZoomedIn) { existingCards[pointerAtIndex].card.GetComponent <keyQuestCardScript>().playCardAnimation(putDownAnimation); aCardIsZoomedIn = false; } else if (!aCardIsZoomedIn) { for (int i = 0; i < GOInTabbleOverlay.Count; i++) { Destroy(GOInTabbleOverlay[i]); } GOInTabbleOverlay.Clear(); existingCards.Clear(); tabbleState = TabbleState.atTabbleNotLooking; inisiate = true; } } break; case TabbleState.NotAtTabble: break; } if (tabbleState == TabbleState.atTabbleAndLooking) { newMovement.canMove = false; } }