GameObject GetSpawnObject(FoodSpawnerParams fsp) { GameObject objToSpawn = null; if (foodClasses.ContainsKey(fsp.foodClassName)) { objToSpawn = foodClasses[fsp.foodClassName].GetRandomItem(); } else { Debug.Log("No food class called " + fsp.foodClassName); } return(objToSpawn); }
void RunCurrentLevel(float dt) { LevelParams lp = GetCurrentLevelParams(); for (int i = 0; i < lp.spawnerParams.Length; i++) { FoodSpawnerParams fsp = lp.spawnerParams[i]; if (fsp.Step(dt)) { GameObject g = GetSpawnObject(fsp); GameObject spawned = Instantiate(g, GetSpawnPos(), Quaternion.identity); //See if we can set the movement speed of objects. Move m = spawned.GetComponent <Move>(); if (m != null) { m.moveSpeed = lp.foodMoveSpeed; } } } }