Beispiel #1
0
    void Awake() {
        // setup icons
        {
            var solutionCount = SolutionLineAngles.Length + SolutionTriangles + SolutionSquares + SolutionPentagons;
            var x = (float)(solutionCount - 1) * -IconGap / 2;
            for (int i = 0; i < solutionCount; i++) {
                GameObject newIcon = null;
                if (i < SolutionLineAngles.Length) {
                    newIcon = Instantiate(IconLinePrefab);
                } else if (i < SolutionLineAngles.Length + SolutionTriangles) {
                    newIcon = Instantiate(IconTrianglePrefab);
                } else if (i < SolutionLineAngles.Length + SolutionTriangles + SolutionSquares) {
                    newIcon = Instantiate(IconSquarePrefab);
                } else if (i < SolutionLineAngles.Length + SolutionTriangles + SolutionSquares + SolutionPentagons) {
                    newIcon = Instantiate(IconPentagonPrefab);
                }
                newIcon.transform.parent = transform;
                newIcon.transform.localPosition = new Vector3(x + i * IconGap, IconY, 10);
                if (i < SolutionLineAngles.Length) {
                    newIcon.transform.rotation = Quaternion.Euler(0, 0, SolutionLineAngles[i]);
                }
            }
        }

        loader = FindObjectOfType<Loader>();
        polygonSolver = FindObjectOfType<PolygonSolver>();
        torches = GetComponentsInChildren<Torch>();
        
        for (int i = 0; i < MAX_LINES; i++) {
            lines[i] = Instantiate(LinePrefab);
            lines[i].transform.parent = transform;
            lines[i].transform.localPosition = Vector3.zero;
            LineColliders[i] = lines[i].GetComponentInChildren<Collider2D>();
        }
    }
Beispiel #2
0
    IEnumerator Start() {
        polygonSolver = FindObjectOfType<PolygonSolver>();

        Levels = new Level[LevelCount];
        for (int i = 0; i < LevelCount; i++) {
            yield return SceneManager.LoadSceneAsync(LevelPrefix + i, LoadSceneMode.Additive);
            Levels[i] = FindObjectOfType<Level>();
            Levels[i].gameObject.SetActive(false);
            Levels[i].transform.position = transform.position.plusX(LevelGap * i);
        }
        ActivateLevel(0, true);
	}
Beispiel #3
0
    void Awake() {
        var solutionCount = SolutionLineAngles.Length + SolutionTriangles + SolutionSquares;

        loader = FindObjectOfType<Loader>();
        polygonSolver = FindObjectOfType<PolygonSolver>();
        torches = GetComponentsInChildren<Torch>();
        
        for (int i = 0; i < MAX_LINES; i++) {
            lines[i] = Instantiate(LinePrefab);
            lines[i].transform.parent = transform;
            lines[i].transform.localPosition = Vector3.zero;
            lineSprites[i] = lines[i].GetComponentInChildren<SpriteRenderer>().gameObject;
            LineColliders[i] = lines[i].GetComponentInChildren<Collider2D>();
        }
    }
 void OnDestroy()
 {
     if (Positions != null)
     {
         Positions.Dispose();
     }
     if (Velocities != null)
     {
         Velocities.Dispose();
     }
     if (Lifes != null)
     {
         Lifes.Dispose();
     }
     if (Constants != null)
     {
         Constants.Dispose();
     }
     if (Polygons != null)
     {
         Polygons.Dispose();
     }
     if (VelSimulation != null)
     {
         VelSimulation.Dispose();
     }
     if (PosSimulation != null)
     {
         PosSimulation.Dispose();
     }
     if (Collisions != null)
     {
         Collisions.Dispose();
     }
     if (PolygonSolver != null)
     {
         PolygonSolver.Dispose();
     }
     if (ParticleSolver != null)
     {
         ParticleSolver.Dispose();
     }
     if (Combiner != null)
     {
         Combiner.Dispose();
     }
 }
 void FixedUpdate()
 {
     Constants.SetConstants(compute, constants.FixedDeltaTime);
     VelSimulation.Simulate();
     if (particleCollisionEnabled)
     {
         Collisions.Detect(2f * constants.radius);
     }
     for (var i = 0; i < 10; i++)
     {
         PolygonSolver.Solve();
         if (particleCollisionEnabled)
         {
             ParticleSolver.Solve();
         }
         Velocities.ClampMagnitude();
     }
     PosSimulation.Simulate();
     BoundsChecker.Check();
     Lifes.Simulate();
 }