Exemplo n.º 1
0
    public IEnumerator OnGapFilled()
    {
        EffectsManager.Instance.PlayEffect(EffectsManager.Effects.Construction);
        lastInteractedBuildZone.Sparkle();

        /* Speed up the coaster */
        CoasterManager.Instance.SpeedUp();

        yield return(new WaitForSeconds(delayOnWin));

        /* Hide the old build zone */
        lastInteractedBuildZone.HideBuildZone();

        // set the new build zone
        lastInteractedBuildZone = null;
        clearedBuildZones++;
        if (clearedBuildZones == numBuildZones)
        {
            //EndGame(true); /* CMB: EndGame is now triggered by a game object in the scene */
        }
        else
        {
            lastInteractedBuildZone = activeBuildZones[clearedBuildZones];
            lastInteractedBuildZone.Activate();
        }

        yield return(null);
    }
Exemplo n.º 2
0
    void Start()
    {
        Constants.gameOver = false;
        if (Constants.difficulty == Constants.Difficulty.HARD || Constants.difficulty == Constants.Difficulty.IMPOSSIBLE)
        {
            Constants.numSections = 3;
        }
        else
        {
            Constants.numSections = 2;
        }
        Time.timeScale   = 1;
        inv              = Inventory.Instance;
        activeBuildZones = new List <BuildZone>();
        List <SplinePoint> splinePoints = new List <SplinePoint>();

        splinePoints.AddRange(masterSpline.GetPoints());

        for (int i = 0; i <= Constants.numSections; i++)
        {
            GameObject current = null;
            if (i == Constants.numSections)
            {
                current = Instantiate(sections[0], new Vector3(19.2f + (38.4f * i), sections[0].transform.position.y, 0), Quaternion.identity);
            }
            else
            {
                int ind = Random.Range(1, sections.Length);
                current = Instantiate(sections[ind], new Vector3(28.8f + (38.4f * i), sections[ind].transform.position.y, 0), Quaternion.identity);
                Section currentSection = current.GetComponent <Section>();
                activeBuildZones.AddRange(currentSection.SetupBuildZones());
            }

            SplineComputer currentSpline = current.GetComponentInChildren <SplineComputer>();
            splinePoints.AddRange(currentSpline.GetPoints().Skip(1).ToArray());
            currentSpline.gameObject.SetActive(false);
        }

        masterSpline.SetPoints(splinePoints.ToArray());
        masterSpline.Rebuild();
        masterSpline.GetComponent <SplineRenderer>().color = Constants.trackColor;


        if (Constants.unlimitedInventory)    // set inventory unlimited
        {
            inv.SetUnlimited();
        }
        else    // distribute inventory
        {
            foreach (BuildZone bz in activeBuildZones)
            {
                foreach (FractionTools.Fraction f in bz.GetGapComponents())
                {
                    inv.Increase((Constants.PieceLength)f.denominator, 1);
                }
            }
        }

        numBuildZones = activeBuildZones.Count;
        if (numBuildZones != 0)
        {
            lastInteractedBuildZone = activeBuildZones[0];
            lastInteractedBuildZone.Activate();
        }

        /* Start the coaster */
        CoasterManager.Instance.StartCoasterAlongSpline(masterSpline);
    }