コード例 #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);
    }
コード例 #2
0
    public override bool Interact()
    {
        if (!base.Interact())
        {
            return(false);
        }

        SetInteractable(true);

        if (zone == null)
        {
            zone = Instantiate(UI.Instance.buildZone);

            zone.SetSize(data.size);
        }
        else
        {
            if (zone.Free)
            {
                Destroy(zone.gameObject);
                Instantiate(data.building, zone.Center, Quaternion.LookRotation(Player.Instance.transform.position - zone.Center, aligner.groundUp));
                Destroy();
            }
        }

        return(true);
    }
コード例 #3
0
    void OnTriggerExit(Collider col)
    {
        BuildZone buildZoneComp = col.gameObject.GetComponent <BuildZone>();

        if (buildZoneComp != null)
        {
            BuildSpriteRenderer.color = Constants.Instance.failBuildColor;
            m_IsInValidBuildArea      = false;
        }
    }
コード例 #4
0
 // Case 2: exiting a trigger.  Unset it
 private void OnTriggerExit2D(Collider2D collision)
 {
     if (collision.CompareTag("BuildZone"))
     {
         bz = null;
     }
     if (collision.CompareTag("Cuttable"))
     {
         collision.GetComponent <SpriteRenderer>().enabled = false;
         cu = null;
     }
 }
コード例 #5
0
 // Case 1: entering a new bz / cuttable's trigger.  Replace any old one indiscriminately
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("BuildZone"))
     {
         bz = collision.GetComponentInParent <BuildZone>();
     }
     if (collision.CompareTag("Cuttable"))
     {
         if (cu)
         {
             cu.gameObject.GetComponent <SpriteRenderer>().enabled = false;
         }
         collision.GetComponent <SpriteRenderer>().enabled = true;
         cu = collision.GetComponent <Cuttable>();
     }
 }
コード例 #6
0
    // Case 3: if a piece happens to be in multiple triggers, then exits one, reset the reference to the other
    private void OnTriggerStay2D(Collider2D collision)
    {
        if (placed)
        {
            return;
        }

        if (collision.CompareTag("BuildZone"))
        {
            bz = collision.GetComponentInParent <BuildZone>();
        }
        if (collision.CompareTag("Cuttable") && !cu)
        {
            collision.gameObject.GetComponent <SpriteRenderer>().enabled = true;
            cu = collision.GetComponent <Cuttable>();
        }
    }
コード例 #7
0
        public void RecalculateZones()
        {
            BuildZone.Clear();
            CantBuildZone.Clear();

            foreach (var tile in _tiles)
            {
                var obj = tile.GridObject;
                if (obj == null)
                {
                    continue;
                }

                var build     = GridUtility.SquaredZone(tile, obj.ExpandBuildZoneSize);
                var cantBuild = GridUtility.SquaredZone(tile, obj.CantBuildZoneSize);

                BuildZone.UnionWith(build);
                CantBuildZone.UnionWith(cantBuild);
            }

            BuildZone.ExceptWith(CantBuildZone);
        }
コード例 #8
0
    void Update()
    {
        if (ClickOccurred())
        {
            // The user has clicked on a UI component.
            // Return immediately to prevent click bleeding.
            if (IsPointerOverUIComponent())
            {
                return;
            }

            // The user has clicked a build zone.
            BuildZone bz = IsPointerOverBuildZone();
            if (bz != null)
            {
                // If the user currently had a popup radial
                // open for a different build zone, we close it.
                if (lastBuildZoneClicked != null)
                {
                    lastBuildZoneClicked.CloseOut();
                    lastBuildZoneClicked = null;
                }

                // popup radial for the click build zone
                // and track what build zone we have open.
                bz.PopRadialMenu();
                lastBuildZoneClicked = bz;
            }

            // if the user has clicked anywhere else on the
            // screen, if there is a radial open, we close it.
            if (bz == null && lastBuildZoneClicked != null)
            {
                lastBuildZoneClicked.CloseOut();
                lastBuildZoneClicked = null;
            }
        }
    }
コード例 #9
0
 public void HideRadialMenu()
 {
     lastBuildZoneClicked.CloseOut();
     lastBuildZoneClicked = null;
 }
コード例 #10
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);
    }