// Use this for initialization
	void Start () {

        setupPlayerAndCam();

        inTurret = false;

        turretOriginalPosition = transform.position;
        turretOriginalRotation = transform.rotation;

        chscript = GameObject.Find("Crosshair").GetComponent<BNG_Zapper>();
        if (chscript == null) Debug.LogError("It seems like you are trying to use this script but do not have the BNG_Zapper script attached to your 'Crosshair' game object.");

        quitBtn = GameObject.Find("Quit Turret");
        quitBtn.SetActive(false);

        ogRay = chscript.rayLength;

        gunLeft.GetComponentInChildren<ParticleSystem>().Stop(false);
        gunRight.GetComponentInChildren<ParticleSystem>().Stop(false);

        canShoot = true;
        isShooting = false;

        score = 0;
    }
Пример #2
0
    public void resetBar(BNG_Zapper zap, float time) //this function changes the object's color when activated, hides the timer and tooltip, and resets the timer here and on the zapper
    {
        // if changeColor on Hover is true (and is using sprites), use New Color on Hover to change the sprite
        if ((changeColorOnHover || changeColorOnActivate) && usingSprites)
        {
            if (!isActivated)
            {
                sr.color = originalColor;
            }
            else if (isActivated && changeColorOnActivate)
            {
                sr.color = newColorOnHover;
            }
            else
            {
                sr.color = originalColor;
            }
        }

        if (tooltipOnHover && tooltipGameObject != null)
        {
            tooltipGameObject.SetActive(false);
        }

        if (timerObject != null) //if there is a timer bar, make it go away since it's no longer active, reset the time and tell the Zapper not to count up
        {
            timerObject.SetActive(false);
        }

        time             = 0;
        zap.timeOnButton = 0;
    }
    // Use this for initialization
    void Start()
    {
        setupPlayerAndCam();

        inTurret = false;

        turretOriginalPosition = transform.position;
        turretOriginalRotation = transform.rotation;

        chscript = GameObject.Find("Crosshair").GetComponent <BNG_Zapper>();
        if (chscript == null)
        {
            Debug.LogError("It seems like you are trying to use this script but do not have the BNG_Zapper script attached to your 'Crosshair' game object.");
        }

        quitBtn = GameObject.Find("Quit Turret");
        quitBtn.SetActive(false);

        ogRay = chscript.rayLength;

        gunLeft.GetComponentInChildren <ParticleSystem>().Stop(false);
        gunRight.GetComponentInChildren <ParticleSystem>().Stop(false);

        canShoot   = true;
        isShooting = false;

        score = 0;
    }
Пример #4
0
    public void ActivateTimer(BNG_Zapper zap, float time)
    {
        // if changeColor on Hover is true (and is using sprites), use New Color on Hover to change the sprite
        if (changeColorOnHover && usingSprites)
        {
            sr.color = newColorOnHover;
        }


        if (canActivate) //if you can activate the timer (not in cooldown period)
        {
            if (requireTimer)
            {
                timerObject.SetActive(true);                //turn the timer on
            }
            if (tooltipOnHover)
            {
                tooltipGameObject.SetActive(true); // if tooltipOnHover is true display it
            }
            if (!isActivated)                      // if it's not activated yet
            {
                if (requireTimer)
                {
                    scaleTimer(time);       //start the timer bar filling up
                }
                if (time >= timeToActivate) // if you have reached the amount of time to activate, activate the button
                {
                    resetBar(zap, time);    //this resets the bar and let's the zapper know to stop counting up

                    //wait cool down time before registering a hit.
                    canActivate = false;

                    StartCoroutine(WaitToActivate(waitTime));
                }
            }
            else // it is already activated so use the deactivation time
            {
                if (requireTimer)
                {
                    scaleTimer(time);         //start the timer bar filling up
                }
                if (time >= timeToDeactivate) // if you have reached the amount of time to deactivate, deactivate the button
                {
                    resetBar(zap, time);      //this resets the bar and let's the zapper know to stop counting up

                    //wait cool down time before registering a hit.
                    canActivate = false;
                    StartCoroutine(WaitToActivate(waitTime));
                }
            }
        }
        else //if it shouldn't be activated, don't let the timer count up
        {
            time = 0;
        }
    }
    public void setupCC() //this is a fake singleton that will setup some static references for the character controller to use. FLAG: This may be an issue if you want to have more than 1 Zapper Script.
    {
        if (doOnce < 1)
        {

            print("Character Controller has been successfully setup. You are free to move about the demo.");

            GameObject tempPlayer = GameObject.Find("NON VR PLAYER");

            if (tempPlayer != null)
            {
                Player = tempPlayer;

                CamGroup = GameObject.Find("CAM SYSTEM");
                walkButton = GameObject.Find("NON VR PLAYER/UI ELEMENTS/walkBtn");

                if(Player.GetComponent<CharacterController>() != null) pcc = Player.GetComponent<CharacterController>();
                chscript = GameObject.FindObjectOfType<BNG_Zapper>(); //there is only one zapper so only one script to find
                ogRay = chscript.rayLength;
            }
            else
            {
                //check for our VR Player Types
                tempPlayer = GameObject.Find("Player for VR");
                if (tempPlayer == null || !tempPlayer.activeInHierarchy) tempPlayer = GameObject.Find("VR Player for Durovis Dive");
                if (tempPlayer == null || !tempPlayer.activeInHierarchy) tempPlayer = GameObject.Find("VR Player for Google Cardboard"); //for some reason it doesn't like an if/else stmt here
                
                if (tempPlayer != null)
                {
                    Player = tempPlayer;
                    
                    if (tempPlayer.name == "VR Player for Durovis Dive" || tempPlayer.name == "Player for VR") CamGroup = GameObject.Find("Dive_Camera");
                    else if (tempPlayer.name == "VR Player for Google Cardboard") CamGroup = GameObject.Find("Head");

                    if (tempPlayer.name == "Player for VR") walkButton = GameObject.Find("Player for VR/UI ELEMENTS/walkBtn");
                    else if (tempPlayer.name == "VR Player for Durovis Dive") walkButton = GameObject.Find("VR Player for Durovis Dive/UI ELEMENTS/walkBtn");
                    else if (tempPlayer.name == "VR Player for Google Cardboard") walkButton = GameObject.Find("VR Player for Google Cardboard/UI ELEMENTS/walkBtn");

                    if (Player.GetComponent<CharacterController>() != null) pcc = Player.GetComponent<CharacterController>();
                    chscript = GameObject.FindObjectOfType<BNG_Zapper>(); //there is only one [active] zapper so only one script to find
                    ogRay = chscript.rayLength;
                }
                else
                {
                    Debug.LogError("No Active Player Found on this Scene. Please activate one of the Players (NON VR PLAYER or Player for VR)");
                    return;
                }
            }

            doOnce++;
        }
    }
    public void resetBar(BNG_Zapper zap, float time) //this function changes the object's color when activated, hides the timer and tooltip, and resets the timer here and on the zapper
    {
        // if changeColor on Hover is true (and is using sprites), use New Color on Hover to change the sprite
        if ((changeColorOnHover || changeColorOnActivate) && usingSprites)
        {
            if (!isActivated)
            {
                sr.color = originalColor;                
            }
            else if (isActivated && changeColorOnActivate)
            {
                sr.color = newColorOnHover;                
            }
            else
            {
                sr.color = originalColor;                
            }
        }
        
        if (tooltipOnHover && tooltipGameObject != null) tooltipGameObject.SetActive(false);

        if (timerObject != null) //if there is a timer bar, make it go away since it's no longer active, reset the time and tell the Zapper not to count up
        {
            timerObject.SetActive(false);            
        }

        time = 0;
        zap.timeOnButton = 0;

    }
    public void ActivateTimer(BNG_Zapper zap, float time)
    { 
        
        // if changeColor on Hover is true (and is using sprites), use New Color on Hover to change the sprite
        if (changeColorOnHover && usingSprites)
        {
            sr.color = newColorOnHover;
        }


        if (canActivate) //if you can activate the timer (not in cooldown period)
        {
            if (requireTimer)  timerObject.SetActive(true); //turn the timer on

            if (tooltipOnHover) tooltipGameObject.SetActive(true); // if tooltipOnHover is true display it

            if (!isActivated) // if it's not activated yet
            {
                if(requireTimer) scaleTimer(time); //start the timer bar filling up

                if (time >= timeToActivate) // if you have reached the amount of time to activate, activate the button
                {                    
                    resetBar(zap, time); //this resets the bar and let's the zapper know to stop counting up

                    //wait cool down time before registering a hit.
                    canActivate = false;

                    StartCoroutine(WaitToActivate(waitTime));
                }

            }
            else // it is already activated so use the deactivation time
            {
               
                if (requireTimer) scaleTimer(time); //start the timer bar filling up
               

                if (time >= timeToDeactivate) // if you have reached the amount of time to deactivate, deactivate the button
                {
                    resetBar(zap, time); //this resets the bar and let's the zapper know to stop counting up

                    //wait cool down time before registering a hit.
                    canActivate = false;
                    StartCoroutine(WaitToActivate(waitTime));
                }
               
            }

        }
        else //if it shouldn't be activated, don't let the timer count up
        {
            time = 0;

        }

    }
    public void setupCC() //this is a fake singleton that will setup some static references for the character controller to use. FLAG: This may be an issue if you want to have more than 1 Zapper Script.
    {
        if (doOnce < 1)
        {
            print("Character Controller has been successfully setup. You are free to move about the demo.");

            GameObject tempPlayer = GameObject.Find("NON VR PLAYER");

            if (tempPlayer != null)
            {
                Player = tempPlayer;

                CamGroup   = GameObject.Find("CAM SYSTEM");
                walkButton = GameObject.Find("NON VR PLAYER/UI ELEMENTS/walkBtn");

                if (Player.GetComponent <CharacterController>() != null)
                {
                    pcc = Player.GetComponent <CharacterController>();
                }
                chscript = GameObject.FindObjectOfType <BNG_Zapper>(); //there is only one zapper so only one script to find
                ogRay    = chscript.rayLength;
            }
            else
            {
                //check for our VR Player Types
                tempPlayer = GameObject.Find("Player for VR");
                if (tempPlayer == null || !tempPlayer.activeInHierarchy)
                {
                    tempPlayer = GameObject.Find("VR Player for Durovis Dive");
                }
                if (tempPlayer == null || !tempPlayer.activeInHierarchy)
                {
                    tempPlayer = GameObject.Find("VR Player for Google Cardboard");                                                      //for some reason it doesn't like an if/else stmt here
                }
                if (tempPlayer != null)
                {
                    Player = tempPlayer;

                    if (tempPlayer.name == "VR Player for Durovis Dive" || tempPlayer.name == "Player for VR")
                    {
                        CamGroup = GameObject.Find("Dive_Camera");
                    }
                    else if (tempPlayer.name == "VR Player for Google Cardboard")
                    {
                        CamGroup = GameObject.Find("Head");
                    }

                    if (tempPlayer.name == "Player for VR")
                    {
                        walkButton = GameObject.Find("Player for VR/UI ELEMENTS/walkBtn");
                    }
                    else if (tempPlayer.name == "VR Player for Durovis Dive")
                    {
                        walkButton = GameObject.Find("VR Player for Durovis Dive/UI ELEMENTS/walkBtn");
                    }
                    else if (tempPlayer.name == "VR Player for Google Cardboard")
                    {
                        walkButton = GameObject.Find("VR Player for Google Cardboard/UI ELEMENTS/walkBtn");
                    }

                    if (Player.GetComponent <CharacterController>() != null)
                    {
                        pcc = Player.GetComponent <CharacterController>();
                    }
                    chscript = GameObject.FindObjectOfType <BNG_Zapper>(); //there is only one [active] zapper so only one script to find
                    ogRay    = chscript.rayLength;
                }
                else
                {
                    Debug.LogError("No Active Player Found on this Scene. Please activate one of the Players (NON VR PLAYER or Player for VR)");
                    return;
                }
            }

            doOnce++;
        }
    }