Exemple #1
0
 /* Takes in a dummy manager script, a slider field script, a speed band script, and a personal dummy index and intializes its private variables.
  * Also sets it inactive initially.*/
 public void Initialize(ref DummyManagerScript DMSParam, ref SliderFieldScript sliderFieldScriptParam, ref SpeedBandScript speedBandScriptParam,
                        int personalDummyIndexParam)
 {
     DMS = DMSParam;
     sliderFieldScript  = sliderFieldScriptParam;
     speedBandScript    = speedBandScriptParam;
     personalDummyIndex = personalDummyIndexParam;
     gameObject.SetActive(false);
 }
Exemple #2
0
    public GameObject dummyIndicator;               // The dummy indicator game object

    private void Awake()
    {
        // Initialize all private scripts
        speedBandScript       = speedBand.GetComponent <SpeedBandScript>();
        playBandScript        = playBand.GetComponent <PlayBandScript>();
        undoBandScript        = undoBand.GetComponent <UndoBandScript>();
        sliderFieldScript     = sliderField.GetComponent <SliderFieldScript>();
        leftGloveScript       = leftGlove.GetComponent <GloveScript>();
        refineGuideScript     = refineGuide.GetComponent <RefineGuideScript>();
        leftOVRGrabberScript  = leftHandAnchor.GetComponent <OVRGrabber>();
        rightOVRGrabberScript = rightHandAnchor.GetComponent <OVRGrabber>();
        // Create arrays based on number of dummies in the scene
        dummies   = GameObject.FindGameObjectsWithTag("Dummy");
        startAids = new GameObject[dummies.Length];
        endAids   = new GameObject[dummies.Length];
        ghosts    = new GameObject[dummies.Length];

        for (int i = 0; i < dummies.Length; i++)
        {
            DummyManagerScript DMS = gameObject.GetComponent <DummyManagerScript>();
            // Instantiate aids and ghosts
            GameObject dummy         = dummies[i];
            GameObject startAid      = Instantiate(dummy);
            GameObject endAid        = Instantiate(dummy);
            GameObject ghost         = Instantiate(dummy);
            float      newScalar     = dummy.transform.localScale.x * 0.999f; // Prevents mesh clashing when overlaid
            Vector3    newLocalScale = new Vector3(newScalar, newScalar, newScalar);
            // Add components to each dummy
            dummy.AddComponent <DummyScript>();
            sampleCount = (int)Mathf.Ceil(animationSeconds / speedBandScript.GetSampleRate()); // Ceil to make a nice, even number
            dummy.GetComponent <DummyScript>().Initialize(ref DMS, sampleCount);
            dummy.AddComponent <Rigidbody>();
            dummy.GetComponent <Rigidbody>().useGravity  = false;
            dummy.GetComponent <Rigidbody>().isKinematic = true;
            dummy.AddComponent <BoxCollider>();
            // Edit start aid components
            startAid.name = dummy.name + "StartAid";
            startAid.transform.localScale = newLocalScale;
            startAid.GetComponent <Renderer>().material = startAidMaterial;
            startAids[i] = startAid;
            // Edit end aid components
            endAid.name = dummy.name + "EndAid";
            endAid.transform.localScale = newLocalScale;
            endAid.GetComponent <Renderer>().material = endAidMaterial;
            endAids[i] = endAid;
            // Edit ghost components
            ghost.AddComponent <GhostScript>();
            ghost.GetComponent <GhostScript>().Initialize(ref DMS, ref sliderFieldScript, ref speedBandScript, i);
            ghost.name = dummy.name + "Ghost";
            ghost.transform.localScale = newLocalScale;
            ghost.GetComponent <Renderer>().material = ghostMaterial;
            ghosts[i] = ghost;
        }
        // Set the selected dummy to the first dummy found, add the OVRGrabble script (so only the selected dummy can be grabbed),
        // and parent dummy indicator with the selected dummy and place it above the dummy
        selectedDummyIndex = 0;
        dummies[selectedDummyIndex].AddComponent <OVRGrabbable>();
        dummyIndicator.transform.localScale    = new Vector3(4.0f, 4.0f, 4.0f);
        dummyIndicator.transform.parent        = dummies[selectedDummyIndex].transform;
        dummyIndicator.transform.localPosition = new Vector3(0.0f, (dummies[selectedDummyIndex].GetComponent <BoxCollider>().size.y / 2.0f) + dummyIndicatorOffset, 0.0f);
        dummyIndicator.transform.localRotation = Quaternion.Euler(90.0f, 0.0f, 0.0f);
    }