Exemplo n.º 1
0
    private void SpawnTransitionObjects(bool firstTime)
    {
        // No transition object to spawn
        if (!faderPrefab)
        {
            return;
        }

        // Set a reference to this scene's transition object
        fader = Instantiate(faderPrefab);
        // Position it to cover the screen
        fader.transform.SetParent(FindObjectOfType <Canvas>().transform);
        fader.GetComponent <RectTransform>().offsetMin = Vector2.zero;
        fader.GetComponent <RectTransform>().offsetMax = Vector2.zero;
        fader.transform.localScale = Vector2.one;

        // Since we are calling this at the OnSceneLoaded event, we must be fading in to the scene
        fader.SetTransitionState(TransitionState.FadingIn);
        if (!firstTime)
        {
            fader.opacity = 1;

            fader.PlayTransitionSound();
        }
        else         // No need to play a transition when we press the play button
        {
            fader.opacity = 0;
        }
    }
Exemplo n.º 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
Exemplo n.º 3
0
    //init
    void Start()
    {
        //summarize the data
        summarizeData();

        //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
Exemplo n.º 4
0
    //init
    void Start()
    {
        //show mouse cursor
        Screen.showCursor = true;

        //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.bgmSource.time = 0; //reset playback to beginning
            AudioManager.Instance.toggleFade();
        }
    }     //end function
Exemplo n.º 5
0
    //init
    void Start()
    {
        //get game objects from scene
        cam         = Camera.main;                          //main camera
        eyeL        = GameObject.FindWithTag(TAG_EYEL);     //l eye
        eyeR        = GameObject.FindWithTag(TAG_EYER);     //r eye
        eyeScale    = eyeL.transform.localScale;            //baseline scale for eye objects
        calPointObj = GameObject.FindWithTag(TAG_CALPOINT); //calibration point
        calPointObj.renderer.enabled   = false;             //invisible to start
        calPointObj.transform.position = Vector3.zero;      //position to 0, 0, 0
        calPointList = new List <Point2D>();                //prepare to store calibration points

        //init properties
        _taskQueue        = new Queue <taskDelegate>();
        calAttempts       = 0;
        calSuccess        = false;
        hideGUI           = false;
        Screen.showCursor = true; //show cursor

        //validate gaze data
        gazeValidator = new Validator(30);

        //listen for gaze events
        GazeManager.Instance.AddGazeListener(this);

        //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 theAudioManager = AudioManager.Instance.gameObject.GetComponent<AudioManager>();
         *  theAudioManager.toggleFade();
         * }
         */
    }
Exemplo n.º 6
0
    void Start()
    {
        SetupObjectiveTextList();

        _spawnerRef    = GameObject.FindGameObjectWithTag("Manager_Spawnpoints")?.GetComponent <SpawnpointFinder>();
        _mainCameraRef = GameObject.FindGameObjectWithTag("MainCamera")?.GetComponent <Camera>();
        _npcManagerRef = GetComponent <FriendlyNPCManager>();
        _fader         = GameObject.FindObjectOfType <TransitionFade>();

        RoundTimerText?.gameObject.SetActive(false);

        if (!_tutorialPassed)
        {
            GameObject.FindGameObjectWithTag("TempUpgradeCanvas")?.SetActive(false);
        }

        Debug.Assert(_spawnerRef != null, "Did not have a spawner in the level.");
        Debug.Assert(_mainCameraRef != null, "Did not have a camera in the level.");
        Debug.Assert(_npcManagerRef != null, "Did not have a FriendlyNPCManager");

        Debug.Assert(DummyControllerForPlacementCamera != null, "Invalid dummy controller.");

        Debug.Log("Difficulty This Round is " + GameManager.Difficulty.ToString());
    }
Exemplo n.º 7
0
    }      //end function

    //check the game state and update as needed
    //used to manage levels, waves, and other content experienced during gameplay
    public void checkGameState()
    {
        //check whether the current wave has ended
        //if so, setup a new wave
        //otherwise continue with current wave
        if (theWave.isEnded == true)
        {
            //fade out and destroy tutorial object
            if (theTutorial != null)
            {
                Destroy(theTutorial);
            }
            //increment the current level
            currentLevel++;
            Debug.Log("[GameManager] Wave starting for level: " + currentLevel);
            //1, 2, 4, 8, 10, 9, 9, 6, 1
            //set up a new wave based on the current level
            switch (currentLevel)
            {
            //note: level 0 tutorial already init in start function
            //level 1: introduce random destination, two targets
            case 1:
                //one wave of two slow targets that move to a random destination and stop
                theWave = theWave.waveWithPrefabParentLimits(target_01, theTargets, 2, 2, 0);
                break;

            //level 2: introduce random destination loops, medium speed, two waves
            case 2:
                //two waves of two medium speed targets that complete random destination loops
                theWave = theWave.waveWithPrefabParentLimits(target_02, theTargets, 2, 4, 0);
                break;

            //level 3: introduce destroy on completion of random loops, three waves
            case 3:
                //three waves of two medium speed targets that complete 10 random destination loops
                theWave = theWave.waveWithPrefabParentLimits(target_03, theTargets, 2, 8, 0);
                break;

            //level 4: introduce origin loops, three targets
            case 4:
                //10 medium speed targets (three at once) that loop between origin and random destination
                theWave = theWave.waveWithPrefabParentLimits(target_04, theTargets, 3, 10, 0);
                break;

            //level 5: introduce destroy on completion of 11 origin loops
            case 5:
                //three waves of three medium speed targets that complete 11 random destination to origin loops
                theWave = theWave.waveWithPrefabParentLimits(target_05, theTargets, 3, 9, 0);
                break;

            //level 6: introduce fast speed, reduce loops
            case 6:
                //three waves of three fast targets that complete 9 random destination to origin loops
                theWave = theWave.waveWithPrefabParentLimits(target_06, theTargets, 3, 9, 0);
                break;

            //level 7: reduce waves, reduce loops
            case 7:
                //two waves of three fast targets that complete 7 random destination to origin loops
                theWave = theWave.waveWithPrefabParentLimits(target_07, theTargets, 3, 6, 0);
                break;

            //level 8: introduce most difficult speed, one shot target
            case 8:
                //an extremely fast target that makes a single random destination to origin loop
                theWave = theWave.waveWithPrefabParentLimits(target_08, theTargets, 1, 1, 0);
                break;

            //game complete
            case 9:
                //game complete
                Debug.Log("All waves completed - Game Over");
                //toggle flag
                isGameOver = true;
                //update score
                ScoreManager.Instance.totalObjects = 50;     //50 targets in demo
                ScoreManager.Instance.levelScore();
                break;

            //default
            default:
                Debug.Log("[GameManager] Error: level not found");
                break;
            } //end switch

            //reset wave if game is not over
            if (isGameOver == false)
            {
                theWave.resetWave();
            }
            //end game
            else if (isGameOver == true)
            {
                Debug.Log("[GameManager] Game Over - End Game");
                //load level summary
                //transition to next scene
                TransitionFade theTransition = StateManager.Instance.gameObject.GetComponent <TransitionFade>();
                theTransition.toggleFade();
                StateManager.Instance.switchSceneAfterDelay("summary", theTransition.duration);
                //audio
                AudioManager theAudioManager = AudioManager.Instance.gameObject.GetComponent <AudioManager>();
                theAudioManager.toggleFade();
                AudioManager.Instance.switchBgmAfterDelay(theAudioManager.bgmSummary, theAudioManager.bgmFadeDuration);
                //show mouse cursor
                Screen.showCursor = true;
            }
        } //end if
    }     //end function
 private void frm_SalirDialog_Load(object sender, EventArgs e)
 {
     TransitionFade.ShowAsyc(this);
 }
Exemplo n.º 9
0
    } //end function

    //TODO: TEMP GUI FOR TESTING
    void OnGUI() {
        //set gui skin
        if (GameObject.FindWithTag("global")) {
            GUI.skin = GameObject.FindWithTag("global").GetComponent<Global>().menuGUI;
        }

        //create buttons
        int btnW = 300;
        int btnH = 100;
        float btnX = Screen.width / 2 - btnW / 2;
        float btnY = Screen.height - btnH; //aligned to bottom of screen
        int btnBuffer = btnH + btnH / 4;

        //connect button
        float btnConnectY = btnY - btnH / 2 - btnBuffer * 2;
        Rect btnConnectRect = new Rect(btnX, btnConnectY, btnW, btnH);
        string btnConnectText;
        if (globalScript.tetConnected == true) {
            //set text
            btnConnectText = "Connected!";
            //disable button
            GUI.enabled = false;
            //draw button
            GUI.Button(btnConnectRect, btnConnectText);
        }
        else {
            //set text
            btnConnectText = "1. Connect";
            //enable button
            GUI.enabled = true;
            //draw button
            if (GUI.Button(btnConnectRect, btnConnectText)) {
                //connect
                UnityEngine.Debug.Log("1. Setup Connecting...");
                //enable script
                connectScript.enabled = true;
                //audio
                AudioManager.Instance.playBtnClick(); //sfx
            }
        }
        //activate button
        float btnActivateY = btnY - btnH / 2 - btnBuffer;
        Rect btnActivateRect = new Rect(btnX, btnActivateY, btnW, btnH);
        string btnActivateText;
        if (globalScript.tetActive == true) {
            //set text
            btnActivateText = "Activated!";
            //disable button
            GUI.enabled = false;
            //draw button
            GUI.Button(btnActivateRect, btnActivateText);
        }
        else {
            //set text
            btnActivateText = "2. Activate";
            //enable button only if tet server already connected
            if (globalScript.tetConnected == true) {
                GUI.enabled = true;
            }
            else {
                GUI.enabled = false;
            }
            //draw button
            if (GUI.Button(btnActivateRect, btnActivateText)) {
                //activate
                UnityEngine.Debug.Log("2. Setup Activating...");
                //enable script
                activateScript.enabled = true;
                //audio
                AudioManager.Instance.playBtnClick(); //sfx
            }
        }

        //calibrate button
        float btnCalY = btnY - btnH / 2;
        Rect btnCalRect = new Rect(btnX, btnCalY, btnW, btnH);
        string btnCalText = "3. Calibrate";
        //TODO
        //if (GazeManager.Instance.IsActivated == true) {
        if (globalScript.tetConnected == true && globalScript.tetActive == true) {
            //enable button
            GUI.enabled = true;
            //draw button
            if (GUI.Button(btnCalRect, btnCalText)) {
                //activate
                UnityEngine.Debug.Log("3. Setup Calibrating...");
                //transition to next scene
                TransitionFade theTransition = StateManager.Instance.gameObject.GetComponent<TransitionFade>();
                theTransition.toggleFade();
                StateManager.Instance.switchSceneAfterDelay("calibrate", theTransition.duration);
                //audio
                AudioManager.Instance.playBtnClick(); //sfx
                AudioManager.Instance.toggleFade(); //bgm
            }
        }
        else {
            //disable button
            GUI.enabled = false;
            //draw button
            GUI.Button(btnCalRect, btnCalText);
        }
        
        //reenable GUI by default
        GUI.enabled = true;

    } //end function
Exemplo n.º 10
0
 // Start is called before the first frame update
 void Start()
 {
     _fader = GameObject.FindObjectOfType <TransitionFade>();
 }
Exemplo n.º 11
0
    //GUI
    void OnGUI()
    {
        //set gui skin
        if (GameObject.FindWithTag("global"))
        {
            GUI.skin = GameObject.FindWithTag("global").GetComponent <Global>().menuGUI;
        }

        //check whether GUI should be shown
        if (hideGUI == false)
        {
            //create calibration button
            int    btnW    = 300;
            int    btnH    = 100;
            float  btnX    = Screen.width / 2 - btnW / 2;
            float  btnY    = Screen.height / 2 - btnH / 2;
            Rect   btnRect = new Rect(btnX, btnY, btnW, btnH);
            string btnText = "Click to calibrate";
            if (calAttempts > 0)
            {
                btnText = "Calibration failed: Recalibrate";
            }
            if (calSuccess == true)
            {
                btnText = "Calibration successful: Continue";
            }
            if (GUI.Button(btnRect, btnText))
            {
                //proceed to next scene
                if (calSuccess == true)
                {
                    UnityEngine.Debug.Log("Load Main Menu");
                    //remove gaze listener
                    GazeManager.Instance.RemoveGazeListener(this);
                    //handle in task queue
                    addTaskToQueue(new taskDelegate(delegate {
                        //transition to next scene
                        TransitionFade theTransition = StateManager.Instance.gameObject.GetComponent <TransitionFade>();
                        theTransition.toggleFade();
                        StateManager.Instance.switchSceneAfterDelay("mainMenu", theTransition.duration);
                        //audio
                        AudioManager theAudioManager = AudioManager.Instance.gameObject.GetComponent <AudioManager>();
                        theAudioManager.playBtnClick(); //sfx
                        //theAudioManager.toggleFade(); //bgm
                    }));
                }
                //restart calibration process
                else if (GazeManager.Instance.IsCalibrating == false && calSuccess == false)
                {
                    //reset attempts
                    calAttempts = 0;
                    //generate calibration points
                    generateCalPoints(MIN_CAL_POINTS);
                    //CalibrationStart(num points {min = 9}, calibration process handler)
                    GazeManager.Instance.CalibrationStart(MIN_CAL_POINTS, this);
                    //audio
                    AudioManager theAudioManager = AudioManager.Instance.gameObject.GetComponent <AudioManager>();
                    theAudioManager.playBtnClick(); //sfx
                }

                //hide GUI
                hideGUI = true;
            } //end inner if
        }     //end outer if
    }         //end function
Exemplo n.º 12
0
    } //end function

    //GUI
    void OnGUI()
    {
        //set gui skin
        if (GameObject.FindWithTag("global"))
        {
            GUI.skin = GameObject.FindWithTag("global").GetComponent <Global>().menuGUI;
        }

        //create buttons
        int   btnW      = 300;
        int   btnH      = 100;
        float btnX      = Screen.width / 2 - btnW / 2;
        float btnY      = Screen.height - btnH; //aligned to bottom of screen
        int   btnBuffer = btnH + btnH / 2;

        //play button
        float  btnPlayY    = btnY - btnH / 2 - btnBuffer;
        Rect   btnPlayRect = new Rect(btnX, btnPlayY, btnW, btnH);
        string btnPlayText = "Play Again";

        //menu button
        float  btnMenuY    = btnPlayY + btnBuffer;
        Rect   btnMenuRect = new Rect(btnX, btnMenuY, btnW, btnH);
        string btnMenuText = "Return to Main Menu";

        //create text
        float summaryW    = btnW;
        float summaryH    = btnH * 2;
        float summaryX    = Screen.width / 2 - summaryW / 2;
        float summaryY    = btnPlayY - summaryH;
        Rect  summaryRect = new Rect(summaryX, summaryY, summaryW, summaryH);

        GUI.Label(summaryRect, _summaryText);

        //play button pressed
        if (GUI.Button(btnPlayRect, btnPlayText))
        {
            //return to game
            Debug.Log("Load Game");
            //transition to next scene
            TransitionFade theTransition = StateManager.Instance.gameObject.GetComponent <TransitionFade>();
            theTransition.toggleFade();
            StateManager.Instance.switchSceneAfterDelay("game", theTransition.duration);
            //audio
            AudioManager.Instance.playBtnClick(); //sfx
            AudioManager.Instance.toggleFade();
            AudioManager.Instance.switchBgmAfterDelay(AudioManager.Instance.bgmGame, AudioManager.Instance.bgmFadeDuration);
        }

        //calibrate button pressed
        if (GUI.Button(btnMenuRect, btnMenuText))
        {
            //return to main menu
            Debug.Log("Load Main Menu");
            //transition to next scene
            TransitionFade theTransition = StateManager.Instance.gameObject.GetComponent <TransitionFade>();
            theTransition.toggleFade();
            StateManager.Instance.switchSceneAfterDelay("mainMenu", theTransition.duration);
            //audio
            AudioManager.Instance.playBtnClick(); //sfx
            AudioManager.Instance.toggleFade();
            AudioManager.Instance.switchBgmAfterDelay(AudioManager.Instance.bgmMenu, AudioManager.Instance.bgmFadeDuration);
        }
    } //end function
Exemplo n.º 13
0
    }     //end function

    //GUI
    void OnGUI()
    {
        //set gui skin
        if (GameObject.FindWithTag("global"))
        {
            GUI.skin = GameObject.FindWithTag("global").GetComponent <Global>().menuGUI;
        }

        //create buttons
        int   btnW      = 300;
        int   btnH      = 100;
        float btnX      = Screen.width / 2 - btnW / 2;
        float btnY      = Screen.height - btnH; //aligned to bottom of screen
        int   btnBuffer = btnH + btnH / 2;

        //play button
        float  btnPlayY    = btnY - btnH / 2 - btnBuffer;
        Rect   btnPlayRect = new Rect(btnX, btnPlayY, btnW, btnH);
        string btnPlayText = "Play";

        //calibrate button
        float  btnCalY    = btnPlayY + btnBuffer;
        Rect   btnCalRect = new Rect(btnX, btnCalY, btnW, btnH);
        string btnCalText = "Recalibrate";

        //quit button
        float  btnQuitW      = 100;
        float  btnQuitH      = 50;
        float  btnQuitBuffer = 10;
        float  btnQuitX      = Screen.width - btnQuitW - btnQuitBuffer; //aligned to bottom-right of screen
        float  btnQuitY      = Screen.height - btnQuitH - btnQuitBuffer;
        Rect   btnQuitRect   = new Rect(btnQuitX, btnQuitY, btnQuitW, btnQuitH);
        string btnQuitText   = "Quit";

        //play button pressed
        if (GUI.Button(btnPlayRect, btnPlayText))
        {
            //proceed to game scene
            Debug.Log("Load Game");
            //transition to next scene
            TransitionFade theTransition = StateManager.Instance.gameObject.GetComponent <TransitionFade>();
            theTransition.toggleFade();
            StateManager.Instance.switchSceneAfterDelay("game", theTransition.duration);
            //audio
            AudioManager.Instance.playBtnClick(); //sfx
            AudioManager.Instance.toggleFade();   //bgm
            AudioManager.Instance.switchBgmAfterDelay(AudioManager.Instance.bgmGame, AudioManager.Instance.bgmFadeDuration);
        }

        //calibrate button pressed
        if (GUI.Button(btnCalRect, btnCalText))
        {
            //proceed to calibration scene
            Debug.Log("Load Calibration");
            //transition to next scene
            TransitionFade theTransition = StateManager.Instance.gameObject.GetComponent <TransitionFade>();
            theTransition.toggleFade();
            StateManager.Instance.switchSceneAfterDelay("calibrate", theTransition.duration);
            //audio
            AudioManager.Instance.playBtnClick(); //sfx
            AudioManager.Instance.toggleFade();   //bgm
        }

        //quit button pressed
        if (GUI.Button(btnQuitRect, btnQuitText))
        {
            //quit application
            Debug.Log("Quit Application");
            Application.Quit();
        }
    } //end function