Esempio n. 1
0
 private void CreateObstacles(LevelConfig config)
 {
     for (int i = 0; i < config.GetPositions().Count; i++)
     {
         var temp = InstantiatePlatform(config.GetObstacleConfig()[i],
                                        config.GetPositions()[i] + new Vector3(0, 16, 0),
                                        config.GetObstacleScales()[i]);
         temp.GetComponent <SpriteRenderer>().sortingLayerName = "Obstacle";
         temp.transform.rotation = Quaternion.Euler(config.GetObstacleRotations()[i].x,
                                                    config.GetObstacleRotations()[i].y,
                                                    config.GetObstacleRotations()[i].z);
         if (config.GetBreakCount()[i] != 0)
         {
             temp.AddComponent(typeof(Breakable));
             if (!config.DependsOnPrevBallCount())
             {
                 temp.GetComponent <Breakable>().SetBreakCount(config.GetBreakCount()[i]);
             }
             else
             {
                 temp.GetComponent <Breakable>().SetBreakCount((FindObjectOfType <Target>().GetCount() / 3) + 1);
             }
         }
         platforms.Add(temp);
     }
 }