示例#1
0
    //for moving object based on gaze coordinates from tracker
    //based on resolution of window
    //receives object, renderer, bounds script, and data script
    //returns vector3 position in world coordinates
    public Vector3 positionObjectWithRendererBoundsData(GameObject theObject, Renderer theRenderer, Bounds theBounds, GazeDataManager theData) {
        //verify the gaze data
        if (theData.gazeCoords != null) {
            //convert gaze coords to screen coords
            Point2D screenCoords = DataUtilities.gazePointToWindowPoint(theData.gazeCoords);

            //convert window coords to viewport coords
            Point2D viewCoords = DataUtilities.windowPointToViewPoint(screenCoords);
            Vector3 viewVector = new Vector3((float)viewCoords.X, (float)(viewCoords.Y), 0);

            //check bounds
            //use the object with the outermost bounds and a renderer to make the check
            Vector3 boundsVector = theBounds.checkBoundsForRenderer(theRenderer, viewVector);

            //convert viewport vector to world position vector
            Vector3 worldPos = Camera.main.ViewportToWorldPoint(boundsVector);
            worldPos.z = theObject.transform.position.z; //maintain z position for object

            //return new world position
            return worldPos;

        }
        //error
        else {
            //Debug.Log("[GazeMove] Null gaze data, " + theObject.name + " cannot be positioned");
            return Vector3.zero;
        }
    } //end function
示例#2
0
    //init
    void Start()
    {
        //debug
        debugOn = false; //default to off

        //properties
        currentLevel = 0;     //initial level
        isGameOver   = false; //initial flag

        //objects
        theCam            = Camera.main;                                 //main camera in scene
        theGame           = GameObject.FindWithTag(TAG_GAME);            //game manager object in scene
        theDimView        = GameObject.FindWithTag(TAG_DIMVIEW);         //dim view game object in scene
        theVisor          = GameObject.FindWithTag(TAG_VISOR);           //visor object in scene
        theVisorFrameView = GameObject.FindWithTag(TAG_VISOR_FRAMEVIEW); //visor frame view object in scene
        theTargets        = GameObject.FindWithTag(TAG_TARGETS);         //targets game object container in scene
        theTutorial       = GameObject.FindWithTag(TAG_TUTORIAL);        //tutorial game object container in scene

        //scripts
        theBounds = theGame.AddComponent <Bounds>();                 //add new bounds script
        theData   = theGame.AddComponent <GazeDataManager>();        //add new data manager script
        theWave   = theGame.AddComponent <Wave>();                   //add new wave script
        theVisorRechargeScript = theVisor.GetComponent <Recharge>(); //visor recharge script
        theVisorGazeMoveScript = theVisor.GetComponent <GazeMove>(); //visor gazemove script

        //init tutorial wave
        //a single target that must be destroyed to advance
        theWave = theWave.waveWithPrefabParentLimits(target_00, theTargets, 1, 1, 0);

        //update score
        ScoreManager.Instance.resetScore();

        UnityEngine.Debug.Log("[GameManager] Starting the game!");

        //transition into scene via state manager
        if (StateManager.Instance != null)
        {
            TransitionFade theTransition = StateManager.Instance.gameObject.GetComponent <TransitionFade>();
            theTransition.toggleFade();
        }

        //audio
        if (AudioManager.Instance != null)
        {
            AudioManager.Instance.toggleFade();
        }
    }      //end function
示例#3
0
	//init
	void Start () {
        
        //debug
        debugOn = false; //default to off

        //properties
        currentLevel = 0; //initial level
        isGameOver = false; //initial flag

        //objects
        theCam = Camera.main; //main camera in scene
        theGame = GameObject.FindWithTag(TAG_GAME); //game manager object in scene
        theDimView = GameObject.FindWithTag(TAG_DIMVIEW); //dim view game object in scene
		theVisor = GameObject.FindWithTag(TAG_VISOR); //visor object in scene
        theVisorFrameView = GameObject.FindWithTag(TAG_VISOR_FRAMEVIEW); //visor frame view object in scene
        theTargets = GameObject.FindWithTag(TAG_TARGETS); //targets game object container in scene
        theTutorial = GameObject.FindWithTag(TAG_TUTORIAL); //tutorial game object container in scene

		//scripts
		theBounds = theGame.AddComponent<Bounds>(); //add new bounds script
		theData = theGame.AddComponent<GazeDataManager>(); //add new data manager script
        theWave = theGame.AddComponent<Wave>(); //add new wave script
		theVisorRechargeScript = theVisor.GetComponent<Recharge>(); //visor recharge script
        theVisorGazeMoveScript = theVisor.GetComponent<GazeMove>(); //visor gazemove script

        //init tutorial wave
        //a single target that must be destroyed to advance
        theWave = theWave.waveWithPrefabParentLimits(target_00, theTargets, 1, 1, 0);

        //update score
        ScoreManager.Instance.resetScore();
        
        UnityEngine.Debug.Log("[GameManager] Starting the game!");

        //transition into scene via state manager
        if (StateManager.Instance != null) {
            TransitionFade theTransition = StateManager.Instance.gameObject.GetComponent<TransitionFade>();
            theTransition.toggleFade();
        }

        //audio
        if (AudioManager.Instance != null) {
            AudioManager.Instance.toggleFade();
        }

	}  //end function
示例#4
0
    //for moving object based on gaze coordinates from tracker
    //based on resolution of window
    //receives object, renderer, bounds script, and data script
    //returns vector3 position in world coordinates
    public Vector3 positionObjectWithRendererBoundsData(GameObject theObject, Renderer theRenderer, Bounds theBounds, GazeDataManager theData)
    {
        //verify the gaze data
        if (theData.gazeCoords != null)
        {
            //convert gaze coords to screen coords
            Point2D screenCoords = DataUtilities.gazePointToWindowPoint(theData.gazeCoords);

            //convert window coords to viewport coords
            Point2D viewCoords = DataUtilities.windowPointToViewPoint(screenCoords);
            Vector3 viewVector = new Vector3((float)viewCoords.X, (float)(viewCoords.Y), 0);

            //check bounds
            //use the object with the outermost bounds and a renderer to make the check
            Vector3 boundsVector = theBounds.checkBoundsForRenderer(theRenderer, viewVector);

            //convert viewport vector to world position vector
            Vector3 worldPos = Camera.main.ViewportToWorldPoint(boundsVector);
            worldPos.z = theObject.transform.position.z; //maintain z position for object

            //return new world position
            return(worldPos);
        }
        //error
        else
        {
            //Debug.Log("[GazeMove] Null gaze data, " + theObject.name + " cannot be positioned");
            return(Vector3.zero);
        }
    } //end function