public BetaWordTypingMonsterBox SpawnWord() { int random = Random.Range(0, 2); GameObject wordObj = null; Vector3 position = Vector3.zero; switch (random) { case 0: position = RandomPosition(originalLeftPosition.transform.position); wordObj = Instantiate(wordPrefab, position, Quaternion.identity, rectCanvas); isRight = false; break; case 1: position = RandomPosition(originalRightPosition.transform.position); wordObj = Instantiate(wordPrefab, position, Quaternion.identity, rectCanvas); isRight = true; break; } BetaWordTypingMonsterBox wordDisplay = wordObj.GetComponent <BetaWordTypingMonsterBox>(); return(wordDisplay); }
private void OnTriggerEnter2D(Collider2D collision) { switch (collision.gameObject.tag) { case INST_BOSS: if (shootBoss) { collision.gameObject.GetComponent <BetaTypingGameBossManager>().TakeDamaged(damage); UpdateState(BulletState.Explosion); } break; case INST_Monster: if (!shootBoss) { BetaWordTypingMonsterBox betaWordTypingMonster = collision.gameObject.GetComponentInChildren <BetaWordTypingMonsterBox>(); if (betaWordTypingMonster.Id.Equals(baseWordID)) { collision.gameObject.GetComponentInChildren <BetaWordTypingMonsterBox>().TakeDamage(); UpdateState(BulletState.Explosion); } } break; } }
public BaseWordBetaTypingMonster(string word, BetaWordTypingMonsterBox spawner) { this._word = word; typeIndex = 0; wordBox = spawner; spawner.SetWord(word); }