private void Update() { if (this.Yanmont.transform.position.y > 0f) { this.ID = 0; this.SpawnTimer += Time.deltaTime; if (this.SpawnTimer > 1f) { while (this.ID < 4) { if (this.Zombies[this.ID] == null) { this.SpawnSide = UnityEngine.Random.Range(1, 3); if (this.Yanmont.transform.position.x < this.LeftBoundary + 5f) { this.SpawnSide = 2; } if (this.Yanmont.transform.position.x > this.RightBoundary - 5f) { this.SpawnSide = 1; } if (this.Yanmont.transform.position.x < this.LeftBoundary) { this.RelativePoint = this.LeftBoundary; } else if (this.Yanmont.transform.position.x > this.RightBoundary) { this.RelativePoint = this.RightBoundary; } else { this.RelativePoint = this.Yanmont.transform.position.x; } if (this.SpawnSide == 1) { this.SpawnPoints[0].x = this.RelativePoint - 2.5f; this.SpawnPoints[1].x = this.RelativePoint - 3.5f; this.SpawnPoints[2].x = this.RelativePoint - 4.5f; this.SpawnPoints[3].x = this.RelativePoint - 5.5f; } else { this.SpawnPoints[0].x = this.RelativePoint + 2.5f; this.SpawnPoints[1].x = this.RelativePoint + 3.5f; this.SpawnPoints[2].x = this.RelativePoint + 4.5f; this.SpawnPoints[3].x = this.RelativePoint + 5.5f; } this.Zombies[this.ID] = UnityEngine.Object.Instantiate <GameObject>(this.Zombie, this.SpawnPoints[this.ID], Quaternion.identity); this.NewZombieScript = this.Zombies[this.ID].GetComponent <YanvaniaZombieScript>(); this.NewZombieScript.LeftBoundary = this.LeftBoundary; this.NewZombieScript.RightBoundary = this.RightBoundary; this.NewZombieScript.Yanmont = this.Yanmont; break; } this.ID++; } this.SpawnTimer = 0f; } } }
private void Start() { this.Yanmont = GameObject.Find("YanmontChan").GetComponent <YanvaniaYanmontScript>(); }