Beispiel #1
0
    void OnCollisionEnter(Collision col)
    {
        GameObject obj = col.gameObject;

        if (obj.CompareTag("SortBox"))
        {
            R_BoxScript script  = obj.GetComponent <R_BoxScript>();
            R_Manager   manager = FindObjectOfType <R_Manager>();

            // Find correct trigger to spawn to. If not found, spawn at default location (SpawnPoint).
            int     i     = manager.Algorithm.GetBoxIndex(script.gameObject);
            Vector3 spawn = SpawnPoint.transform.position;
            if (i >= 0 && manager.Algorithm.GetTriggerFromIndex(i).GetComponent <R_TriggerScript>().IsEmpty())
            {
                spawn = manager.Algorithm.GetTriggerFromIndex(i).transform.position;
            }

            script.Move(spawn);

            // Remove velocity and  to hinder box from falling off table again immediately
            Rigidbody boxrb = script.gameObject.GetComponent <Rigidbody>();
            if (boxrb)
            {
                boxrb.velocity = Vector3.zero;
                boxrb.rotation = Quaternion.identity;
            }
        }
    }
Beispiel #2
0
    public void InitNewManager()
    {
        //if(CurrentManager != null) return;



        //TODO: These currently override saved states.

/*         SortStateVariables.SortingAlgorithm = SortStateVariables.SortingAlgorithm == ESortingAlgorithm.None ? SortingAlgorithm : SortStateVariables.SortingAlgorithm;
 *      SortStateVariables.NumberOfBoxes = (int)NumberOfBoxes;
 *      SortStateVariables.BoxValueMax = (int)MaxValueOnBoxes;
 *      SortStateVariables.NumberVisibility = NumberVisibility;
 *      SortStateVariables.ShowTriggerColours = ShowTriggerColours;
 *      SortStateVariables.EnableHighlighting = ShowBoxHighlighting;
 */
        TriggerColourButton.State = (SortStateVariables.ShowTriggerColours ? EToggle.On : EToggle.Off);
        TriggerColourButton.SetButtonsState(SortStateVariables.ShowTriggerColours ? EToggle.On : EToggle.Off);
        BoxHighlightButton.State = (SortStateVariables.EnableHighlighting ? EToggle.On : EToggle.Off);
        BoxHighlightButton.SetButtonsState(SortStateVariables.EnableHighlighting ? EToggle.On : EToggle.Off);
        //TODO: Set NumberVisibilityPanel state
        //TODO: Set NumberOfBoxes Panel state


        GameObject manager = Instantiate(Manager);

        R_BoxResizer boxResizerScript = manager.GetComponent <R_BoxResizer>();

        boxResizerScript.leftController  = LeftController;
        boxResizerScript.rightController = RightController;

        R_Manager managerScript = manager.GetComponent <R_Manager>();

        managerScript.GameManager = this;

        //managerScript.Restart();
        //CurrentManager = manager;
    }