Beispiel #1
0
    /// <summary>
    /// Set reference to instances.
    /// Find all UI element instances within the descendants of InteractionObjects
    /// </summary>
    void Start()
    {
        // Dirty Engineering for final Demo, necessary because SenseGloves not in same Scene
        // Unfortunately no
        if (AcivateOnFadeOut && ElementToActivate == null)
        {
            ElementToActivate = GameObject.FindGameObjectWithTag("SenseGloveLeft").transform.GetChild(1).gameObject;
        }
        if (HookToOpenMenuButton)
        {
            openMenuButton = GameObject.FindGameObjectWithTag("SenseGloveLeft").transform.GetChild(1).GetChild(1).GetComponent <FrameClickDetection>();
            if (openMenuButton != null)
            {
                openMenuButton.onPress[0].AddListener(new UnityAction(FadeIn));
            }
            else
            {
                Debug.LogError("SenseGloveLeft not found during Start.");
                HookToOpenMenuButton = false;
            }
        }

        currentState       = -1;
        newRequest         = false;
        fadeIn             = true;
        animator           = transform.parent.GetComponent <Animator>();
        interactionPrefabs = new List <InteractionPrefab>();

        interactionPrefabs.Add(new InteractionPrefab("Button3D", safemodeOnButton3D, safemodeOffButton3D));
        interactionPrefabs.Add(new InteractionPrefab("Slider3D", safemodeOnSlider3D, safemodeOffSlider3D));

        if (!IsNested)
        {
            foreach (InteractionPrefab prefab in interactionPrefabs)
            {
                List <GameObject> currentList = new List <GameObject>();
                for (int i = 0; i < transform.childCount; i++)
                {
                    if (transform.GetChild(i).CompareTag(prefab.TagName))
                    {
                        currentList.Add(transform.GetChild(i).gameObject);
                    }
                }
                prefab.FoundObjects.AddRange(currentList);
            }
        }
        else
        {
            foreach (InteractionPrefab prefab in interactionPrefabs)
            {
                prefab.FoundObjects.AddRange(findObjectsWithTagInAllChildren(prefab.TagName, transform));
            }
        }

        safeModeOn();
        animator.SetTrigger("Go");
    }
Beispiel #2
0
    /// <summary>
    /// Logic that is executed right after the construct scene has been loaded.
    /// Set roboy model to the position of the operator.
    /// Hook up quest button (what to do if pressed).
    /// Attach menu to the camera.
    /// Activate construct visual effects.
    /// </summary>
    void DelegateAfterConstructLoad()
    {
        if (!KillConstruct)
        {
            Transform cameraOrigin     = GameObject.FindGameObjectWithTag("CameraOrigin").transform;
            Transform constructObjects = GameObject.FindGameObjectWithTag("ConstructObjects").transform;
            Transform roboy            = GameObject.FindGameObjectWithTag("Roboy").transform;

            roboy.SetParent(GameObject.FindGameObjectWithTag("FinalScenePlaceholder").transform);
            roboy.position         = cameraOrigin.position + new Vector3(0f, 1.4f, 0f);
            roboy.localEulerAngles = cameraOrigin.transform.localEulerAngles;//Quaternion.Euler(roboy.rotation.eulerAngles + cameraOrigin.rotation.eulerAngles);//cameraOrigin.GetChild(1).rotation;//roboy.rotation * cameraOrigin.GetChild(1).rotation;

            FrameClickDetection questButton = constructObjects.GetChild(0).GetComponentInChildren <FrameClickDetection>();
            questButton.onPress[0].AddListener(GameObject.FindGameObjectWithTag("FinalsDemoScriptManager").GetComponent <FinalsDemoScriptManager>().StartQuest);
            questButton.onPress[1].AddListener(GameObject.FindGameObjectWithTag("FinalsDemoScriptManager").GetComponent <FinalsDemoScriptManager>().StopQuest);
            constructObjects.GetChild(0).SetParent(cameraOrigin, false);

            constructFXManager.ToggleEffects(true);
        }
    }