public void MoveTo(Transform newParent, CardLocations newLocation, int childPlacement = 0) { if (newParent == null) { Debug.LogError("Moving to null", this); } var ph = Instantiate(GameManager.Instance.CardPlaceholderPrefab); ph.transform.SetParent(newParent); if (childPlacement < 0) { ph.transform.SetAsFirstSibling(); } if (childPlacement > 0) { ph.transform.SetAsLastSibling(); } _placeholders.Enqueue(new CardDestination(ph, newLocation)); }
void DoMovement() { if (_placeholder == null && _placeholders.Any()) { Interactable = false; var ph = _placeholders.Dequeue(); _placeholder = ph._placeholder; _newLocation = ph._location; transform.SetParent(GameManager.Instance.Canvas, true); if (_audioLoop != null) { _audioLoop.Play(); } } if (_placeholder == null) { Interactable = true; } else { transform.position = Vector3.MoveTowards(transform.position, _placeholder.transform.position, 1000f * Time.deltaTime); if (Vector3.Distance(_placeholder.transform.position, transform.position) < 1f) { var newParent = _placeholder.transform.parent; var newIndex = _placeholder.transform.GetSiblingIndex(); Location = _newLocation; Destroy(_placeholder); _placeholder = null; if (_placeholders.Count == 0) { transform.SetParent(newParent); transform.SetSiblingIndex(newIndex); Interactable = true; } } } }
public CardNotPresentException(string message, Exception innerException, byte card, CardLocations location = CardLocations.UNKNOWN) : base(DetailedMessage(message, card, location), innerException) { this.Card = card; this.Location = location; }
private static string DetailedMessage(string message, byte card, CardLocations location) { return(message + "\nCard ID: " + card.ToString() + "\nLocation: " + location.ToString()); }
public void readStory() { if (inkStory.canContinue && !cardChooing) { Debug.Log("Start reading"); StartCoroutine("WaitForClick", inkStory.Continue()); if (inkStory.currentTags.Count >= 1) { if (inkStory.currentTags[0] == "F") { Debug.Log("Frank is talking"); speakerTag.GetComponentInChildren <TextMeshProUGUI>().text = "Frank"; speakerTag.gameObject.SetActive(true); } else if (inkStory.currentTags[0] == "K") { Debug.Log("Karen is talking"); speakerTag.GetComponentInChildren <TextMeshProUGUI>().text = "Karen"; speakerTag.gameObject.SetActive(true); } else if (inkStory.currentTags[0].Length >= 6 && inkStory.currentTags[0].Substring(0, 6) == "Cards-") { Debug.Log("Change Scene to: " + inkStory.currentTags[0]); StopAllCoroutines(); SceneManager.LoadScene(inkStory.currentTags[0]); Karen.gameObject.SetActive(false); Frank.gameObject.SetActive(false); PlaceCards(); } else if (inkStory.currentTags[0].Length >= 5 && inkStory.currentTags[0].Substring(0, 5) == "Chair") { if (inkStory.currentTags[0].Substring(5) == "Frank") { Frank.gameObject.SetActive(true); } else if (inkStory.currentTags[0].Substring(5) == "Karen") { Karen.gameObject.SetActive(true); } Debug.Log(inkStory.currentTags[0]); contintueButton.gameObject.SetActive(false); SceneManager.LoadScene(inkStory.currentTags[0]); } else if (inkStory.currentTags[0].Length >= 7 && inkStory.currentTags[0].Substring(0, 7) == "Endings") { Debug.Log("Endings"); if (inkStory.currentTags[0].Substring(7) == "Frank") { ShowEndings(CardLocations.Endings("Frank")); } else if (inkStory.currentTags[0].Substring(7) == "Karen") { ShowEndings(CardLocations.Endings("Karen")); } } switch (inkStory.currentTags[0]) { /* * case "Chair": * contintueButton.gameObject.SetActive(false); * SceneManager.LoadScene("Chair"); * if (isFrank) * { * audScript.audSource.clip = audScript.frankAud; * } * else * { * audScript.audSource.clip = audScript.karenAud; * } * break; */ case "Frank": Debug.Log("Frank"); Frank.gameObject.SetActive(true); break; case "DisableFrank": Debug.Log("DisableFrank"); Frank.gameObject.SetActive(false); break; case "Karen": Debug.Log("Karen"); Karen.gameObject.SetActive(true); break; case "DisableKaren": Debug.Log("DisableKaren"); Karen.gameObject.SetActive(false); break; case "DisableCards": Debug.Log("Disable Cards: " + s.isDisabled); s.isDisabled = true; break; default: Debug.Log("Nothing to see here..."); break; } } } else { if (inkStory.currentChoices.Count > 0 && !cardChooing) { makeChoice(); } } }
/// <summary> /// Handy little method that matches ambiguous cards with their full local representation, as well as determines if /// such an association exists. If encountering a problem, will throw errors, expect to handle them by providing location. /// </summary> private static List <byte> GetCorrespondingCards(List <byte> expectedCards, List <byte> evaluatingDeck, CardLocations location = CardLocations.UNKNOWN) { //TODO: check for duplicates - so that, for example "44" doesn't result in an error for a deck with only 4h and 4s List <byte> modifiableDeck = new List <byte>(evaluatingDeck); //temp deck List <byte> updatedCards = new List <byte>(); //includes filled out suits foreach (byte card in expectedCards) { try { byte modifiedCard = 0; if (!CardHasASuit(card)) { modifiedCard = GetCardByValue(card, modifiableDeck); updatedCards.Add(modifiedCard); //solves ambiguity } else { if (modifiableDeck.Contains(card)) { modifiedCard = card; updatedCards.Add(card); } else { throw new CardNotPresentException(); } } modifiableDeck.Remove(modifiedCard); } catch (CardNotPresentException cnp) { throw new CardNotPresentException("Card is not present in " + location.ToString(), cnp, card, location); } catch (AmbiguousCardException ac) { throw new AmbiguousCardException("Card is ambiguous and can refer to several cards in " + location.ToString(), ac, card, location); } catch { throw; } } return(updatedCards); }
public CardDestination(GameObject placeholder, CardLocations location) { this._placeholder = placeholder; this._location = location; }
public AmbiguousCardException(string message, byte card, CardLocations location = CardLocations.UNKNOWN) : base(DetailedMessage(message, card, location)) { this.Card = card; this.Location = location; }