public void AddFragment(char alphabet) { TrainFragment fragment = Instantiate(trainFragment).GetComponent <TrainFragment>(); if (GameplayMaster.Instance) { fragment.transform.parent = GameplayMaster.Instance.trainsParent; } fragment.Initial(alphabet); if (fragments.Count > 0) { fragment.transform.position = fragments[fragments.Count - 1].transform.position; } else { fragment.transform.position = transform.position; } fragments.Add(fragment); health = true; GameplayMaster.AddPoints(1); CheckFormedWord(); if (AttachmentSpawner.Instance) { AttachmentSpawner.Instance.SpawnAttachment(alphabet); } }
private void CheckFormedWord() { if (formedWord != string.Empty) { Debug.Log(formedWord); if (GameplayMaster.CheckWord(formedWord) > 0) { //Success int n = fragments.Count; for (int i = 0; i < n; i++) { DetachLastFragment(); } } } }
private void OnTriggerEnter2D(Collider2D other) { if (other.tag == "Fragments") { if (fragments.Count > 1) { health = false; } if (health == false) { GameplayMaster.GameOver(); Debug.Log("Kill Us"); } health = false; } else if (other.tag == "Obstacle") { GameplayMaster.GameOver(); } }