コード例 #1
0
ファイル: LanePlacer.cs プロジェクト: sfraguela/JesterJump
 //--------------------------------------
 public void SpawnLanes(int amountToSpawn, bool isInitialSpawn)
 {
     if(isInitialSpawn){
         //GetComponent<BiomeClass> ().SwitchBiome (BiomeClass.Biomes.Start);
         gameManager = GameObject.FindGameObjectWithTag("Manager").GetComponent<GameManager> ();
         dDA = GameObject.FindGameObjectWithTag("Manager").GetComponent<DDA> ();
         ResetLanes();
     }
     for(int i = 0; i < amountToSpawn; i++){
         GameObject newLane = (GameObject)Instantiate(ChooseType(), new Vector3(0.75f, 0, spawnerZPos), Quaternion.identity);
         newLane.transform.parent = gameObject.transform;
         newLane.GetComponent<Lane>().OnLanePlaced();
         if(newLane.GetComponent<Lane>().laneType == LaneClass.LaneTypes.Road && lastLanePlaced == LaneClass.LaneTypes.Road){
             PlaceRoadLines(spawnerZPos, newLane);
         }
         lastLanePlaced = newLane.GetComponent<Lane>().laneType;
         //setting the cells in the Grid Matrix
         for (int j = 0; j < LaneClass.laneWidth; j++){
             clutterSpawner.Grid[amountOfLanesSpawned, j] = newLane.GetComponent<Lane>().cells[j];
             //telling clutter to be placed
             clutterSpawner.SpawnClutter(amountOfLanesSpawned, j);
         }
         dynamicPlacer.PlaceDynamics(newLane);
         clutterSpawner.SpawnExtras(newLane);
         spawnerZPos += ChosenLaneWidth(newLane.GetComponent<Lane>().laneType);
         amountOfLanesSpawned ++;
         CheckBiome(amountOfLanesSpawned);
         DestroyOld(amountOfLanesSpawned - destroyLeway);
     }
     if (isInitialSpawn) {
         DonePrePlacing ();
     }
 }
コード例 #2
0
 float ChosenLaneWidth(LaneClass.LaneTypes type)
 {
     if (type == LaneClass.LaneTypes.Grass)
     {
         return(1.5f);
     }
     else if (type == LaneClass.LaneTypes.Water)
     {
         return(1.5f);
     }
     else
     {
         return(1.5f);
     }
 }
コード例 #3
0
 //--------------------------------------
 public void SpawnLanes(int amountToSpawn, bool isInitialSpawn)
 {
     if (isInitialSpawn)
     {
         //GetComponent<BiomeClass> ().SwitchBiome (BiomeClass.Biomes.Start);
         gameManager = GameObject.FindGameObjectWithTag("Manager").GetComponent <GameManager> ();
         dDA         = GameObject.FindGameObjectWithTag("Manager").GetComponent <DDA> ();
         ResetLanes();
     }
     for (int i = 0; i < amountToSpawn; i++)
     {
         GameObject newLane = (GameObject)Instantiate(ChooseType(), new Vector3(0.75f, 0, spawnerZPos), Quaternion.identity);
         newLane.transform.parent = gameObject.transform;
         newLane.GetComponent <Lane>().OnLanePlaced();
         if (newLane.GetComponent <Lane>().laneType == LaneClass.LaneTypes.Road && lastLanePlaced == LaneClass.LaneTypes.Road)
         {
             PlaceRoadLines(spawnerZPos, newLane);
         }
         lastLanePlaced = newLane.GetComponent <Lane>().laneType;
         //setting the cells in the Grid Matrix
         for (int j = 0; j < LaneClass.laneWidth; j++)
         {
             clutterSpawner.Grid[amountOfLanesSpawned, j] = newLane.GetComponent <Lane>().cells[j];
             //telling clutter to be placed
             clutterSpawner.SpawnClutter(amountOfLanesSpawned, j);
         }
         dynamicPlacer.PlaceDynamics(newLane);
         clutterSpawner.SpawnExtras(newLane);
         spawnerZPos += ChosenLaneWidth(newLane.GetComponent <Lane>().laneType);
         amountOfLanesSpawned++;
         CheckBiome(amountOfLanesSpawned);
         DestroyOld(amountOfLanesSpawned - destroyLeway);
     }
     if (isInitialSpawn)
     {
         DonePrePlacing();
     }
 }