void TriggerSpawn() { SpawnerScript.Spawn(); spawnTime -= .3f; Invoke("TriggerSpawn", spawnTime); }
//function to trigger the spawning of a new sphere void TriggerSpawn() { spawnerScript.Spawn(); //use spawnerScript to create a new sphere spawnTime -= .3f; //decrease spawnTime by .3f if (spawnTime < spawnMinTime) //if the spawnTime is less than spawnMinTime { spawnTime = spawnMinTime; //set the spawnTime to spawnMinTime } Invoke("TriggerSpawn", spawnTime); //use invoke to call TriggerSpawn again in spawnTime seconds }
/// <summary> /// [COROUTINE] called by effects to spawn enemies mid-wave /// </summary> /// <param name="wave">the wave to spawn</param> /// <param name="spawnLocation">where to spawn it</param> /// <param name="firstDestination">the first location for them to travel to before pathfinding. This should be the start or end of a path segment.</param> public IEnumerator spawnWaveAt(WaveData wave, Vector2 spawnLocation, Vector2 firstDestination) { //flag the wave as started wavesSpawning++; totalSpawnCount += wave.spawnCount; //init float timeBetweenSpawns = wave.time / wave.spawnCount; //delay between each spawn SpawnerScript spawner = ((GameObject)Instantiate(spawnerPrefab)).GetComponent <SpawnerScript>(); spawner.forceFirstPath(spawnLocation, firstDestination); //slight delay before spawning yield return(new WaitForSeconds(0.1f)); //spawn monsters. float timeToNextSpawn = 0; while ((wave.spawnCount - wave.spawnedThisWave) > 0) { yield return(null); //wait for the next frame timeToNextSpawn -= Time.deltaTime; //reduce time until next spawn by amount of time between frames wave.time -= Time.deltaTime; //update the wave data also so that the status text can update while (timeToNextSpawn < 0.0) //this is a loop in case multiple spawns happen in one frame { spawner.Spawn(-timeToNextSpawn, wave.enemyData); //spawn enemy. spawn timer provided so the enemy can place itself properly when framerate is low timeToNextSpawn += timeBetweenSpawns; //update spawn timer //update spawn counters wave.spawnedThisWave++; totalSpawnedThisWave++; //bail if we have finished spawning baddies if (wave.spawnedThisWave == wave.spawnCount) { break; } } } //wave is over wavesSpawning--; Destroy(spawner.gameObject); yield break; }
/// <summary> /// プレイヤーが足場に侵入したか判定する /// </summary> /// <param name="other">当たり判定の対象</param> void OnTriggerEnter(Collider other) { // 未使用の足場のみ処理を行う if (other.CompareTag("Player") && !isStepped) { // 使用済みの足場であることを記憶する isStepped = true; render.material = steppedMaterial; // プレイヤーが足場に侵入したら新しい足場を生成する spawner.Spawn(); // ポイントを追加する pointManager.AddPoint(Point); // 足場の効果音を鳴らす touchSEManager.TouchScaffold(); } }
private void CreateItem() { var item = spawer.Spawn(); BehaviourPhysics.Move(item, Vector3.back, speed); }