private IEnumerator UpdateWords() { while (PhotonNetwork.InRoom) { yield return(new WaitForSeconds(0.1f)); for (int i = ActiveWordSet.Count() - 1; i >= 0; i--) { FallingWord word = ActiveWordSet._items[i]; if (!word) { continue; } if (word.BrokeCombo && PhotonNetwork.LocalPlayer.ActorNumber == ValidPlayerID) { Score.BreakCombo(); audioSource.PlayOneShot(ComboBreakSound); } if (word.RequiresDeletion) { ActiveWordSet.Remove(word); Destroy(word.gameObject); } } } }
public GameObject InstantiateWord(WordWrapper p_word) { GameObject go = Instantiate(wordPrefab, spawnParent); FallingWord word = go.GetComponent <FallingWord>(); if (word) { word.Init(p_word, activeWordSet); activeWordSet.Add(word); } return(go); }
private void OnTriggerEnter2D(Collider2D other) { if (destroyMask == (destroyMask | (1 << other.gameObject.layer))) { FallingWord word = other.gameObject.GetComponent <FallingWord>(); if (word.tag == "BonusWord") { word.DestroyWord(false); } else if (word) { word.DestroyWord(true); word.CreatePopUp(0, transform.parent, true); } } }
private void SpawnWord(string p_word, int p_difficulty, float p_randomPositionX, float p_randomPositionY, int p_eventCode, float p_speedMult, int p_points) { Word w = ScriptableObject.CreateInstance <Word>(); w.Text = p_word; w.EventCode = p_eventCode; w.Points = p_points; WordWrapper ww = new WordWrapper() { Word = w, Difficulty = p_difficulty, Probability = 0 }; GameObject word = Dictionary.InstantiateWord(ww); FallingWord fWord = word.GetComponent <FallingWord>(); fWord.Falling.speed = m_speed * p_speedMult; float wordLength = fWord.Text.preferredWidth; float wordHeight = fWord.Text.preferredHeight; float randomMovementX = RandomizeLocations ? (SpawnZone.rect.width - wordLength) * (p_randomPositionX / 100f) : 0f; float randomMovementY = RandomizeLocations ? (SpawnZone.rect.height - wordHeight) * (p_randomPositionY / 100f) : 0f; if (randomMovementX > (SpawnZone.rect.width - wordLength) / 2) { randomMovementX = (SpawnZone.rect.width - wordLength) / 2 - randomMovementX; } if (randomMovementY > (SpawnZone.rect.height - wordHeight) / 2) { randomMovementY = (SpawnZone.rect.height - wordHeight) / 2 - randomMovementY; } word.transform.localPosition = new Vector3(SpawnZone.localPosition.x + randomMovementX, SpawnZone.localPosition.y + randomMovementY); }