Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        clickDetect           = GetComponent <ClickDetectScript>();           // Grab the click detection attached to this object
        holdDetect            = GetComponent <HoldDetectScript>();            // Grab the hold detection attached to this object
        dataObject            = GameObject.FindGameObjectWithTag("Timer");    //Grab the object that contains the data
        playerData            = dataObject.GetComponent <PlayerDataScript>(); //Grab player data
        gameTimer             = dataObject.GetComponent <GameTimerScript>();  //Grab timer data
        timeSpawned           = gameTimer.timer;                              //Sync object timer to game time
        holdAnim              = animHolder.GetComponent <Animator>();
        feedbackAnimator      = feedbackObject.GetComponent <Animator>();
        feedbackExploAnimator = feedbackExploObject.GetComponent <Animator>();

        //The following lines establish which level difficulty this button belongs to based on naming conventions
        //and then assigns the appropriate speedMod
        theSet     = theParent.transform.parent.gameObject;
        theSetName = theSet.transform.name;
        if (theSetName != "GameManagerObject")
        {
            theSetValue = theSetName[5];
            setNumber   = int.Parse(theSetValue.ToString());
            speedMod    = speedMods[setNumber - 1];
        }
        else
        {
            speedMod = 1f;
        }

        timeToDie       *= speedMod;
        timeToClick     *= speedMod;
        timeToHold      *= speedMod;
        baseTimeForGood *= speedMod;

        holdAnim.speed = (1 / speedMod);
    }
 // Use this for initialization
 void Start()
 {
     clickDetect           = GetComponent <ClickDetectScript>();           // Grab the click detection attached to this object
     holdDetect            = GetComponent <HoldDetectScript>();            // Grab the hold detection attached to this object
     dataObject            = GameObject.FindGameObjectWithTag("Timer");    //Grab the object that contains the data
     gameCam               = GameObject.FindGameObjectWithTag("UICam").GetComponent <Camera>();
     playerData            = dataObject.GetComponent <PlayerDataScript>(); //Grab player data
     gameTimer             = dataObject.GetComponent <GameTimerScript>();  //Grab timer data
     timeSpawned           = gameTimer.timer;                              //Sync object timer to game time
     feedbackAnimator      = feedbackObject.GetComponent <Animator>();     // Grab the animator for the feedback object
     feedbackExploAnimator = feedbackExploObject.GetComponent <Animator>();
 }
    // Update is called once per frame
    void Update()
    {
        gameTimer   = dataObject.GetComponent <GameTimerScript>();  // update timer
        clickDetect = GetComponent <ClickDetectScript>();           // Grab the click detection attached to this object
        playerData  = dataObject.GetComponent <PlayerDataScript>(); //Grab player data

        scoreMultiplier = playerData.multiplier;


        if (clickDetect.wasClicked) //If it has been clicked
        {
            //This is where we do stuff after the object has been clicked
            playerData.successfulHits++; //Log successful hit in data

            /* JS Needs to instantiate HitFeedbackArt prefab at parent's transform and set animator's trigger "Bad", "Good" or "Perfect", or "Miss"
             * Tried to be smart and set trigger here while HitFeedbackArt was child to this object, of course it got destroyed :~(
             */
            // Debug.Log("We clicked it reddit");
            playerData.allSuccessfulHits++;
            playerData.setSuccessfulHits++;


            if (gameTimer.timer - realTimeSpawned >= baseTimeToPerfectLow && gameTimer.timer - realTimeSpawned <= baseTimeToPerfectHigh)
            {
                feedbackObject.SetActive(true); //Activate the feedback object
                feedbackExploObject.SetActive(true);
                audioObject.SetActive(true);
                feedbackAnimator.SetTrigger("Perfect");
                feedbackExploAnimator.SetTrigger("Perfect");
                playerData.playerCombo++;
                playerData.playerScore += (400 * scoreMultiplier);
                gameObject.SetActive(false); //Deactivate the target object
            }
            else if (gameTimer.timer - realTimeSpawned > baseTimeToGoodBeforeLow & gameTimer.timer - realTimeSpawned < baseTimeToPerfectLow ||
                     gameTimer.timer - realTimeSpawned > baseTimeToPerfectHigh && gameTimer.timer - realTimeSpawned < baseTimeToGoodAfterHigh)
            {
                feedbackObject.SetActive(true); //Activate the feedback object
                feedbackExploObject.SetActive(true);
                feedbackAnimator.SetTrigger("Good");
                feedbackExploAnimator.SetTrigger("Good");
                audioObject.SetActive(true);
                playerData.playerCombo++;
                playerData.playerScore += (200 * scoreMultiplier);
                gameObject.SetActive(false); //Deactivate the target object
            }
            else
            {
                feedbackObject.SetActive(true); //Activate the feedback object
                feedbackExploObject.SetActive(true);
                feedbackAnimator.SetTrigger("Bad");
                feedbackExploAnimator.SetTrigger("Bad");
                audioObject.SetActive(true);
                playerData.playerCombo  = 0;
                playerData.playerScore += (50 * scoreMultiplier);
                gameObject.SetActive(false); //Deactivate the target object
            }



            //It's likely we need to pass some data to the feedbackObject before setting it to false, we'll want the feedbackObject to delete the parent when it's done being all flashy
        }

        if (gameTimer.timer > timeSpawned + timeToDie) //If the object has outlasted its live timer
        {
            //This should mostly be used to report a failed click/clean up unused objects
            playerData.unsuccessfulHits++; //Log failed hit in data

            /* JS Again needs to instantiate HitFeedbackArt with trigger "Miss"
             * */
            //Debug.Log("Object should die here");
            playerData.allUnsuccessfulHits++;
            playerData.setUnsuccessfulHits++;
            feedbackObject.SetActive(true); //Activate the feedback object
            feedbackExploObject.SetActive(true);
            feedbackAnimator.SetTrigger("Miss");
            feedbackExploAnimator.SetTrigger("Miss");
            playerData.playerCombo = 0;
            gameObject.SetActive(false); //Deactivate the target object
        }

        if (gameTimer.timer > timeSpawned + timeToClick)
        {
            //Shouldn't actually need this check, should be handled inside the "Was clicked" part, but hey!
            //Debug.Log("THIS WAS THE CLICK MOMENT");
        }
    }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        gameTimer   = dataObject.GetComponent <GameTimerScript>();  // update timer
        clickDetect = GetComponent <ClickDetectScript>();           // Grab the click detection attached to this object
        holdDetect  = GetComponent <HoldDetectScript>();            // Grab the hold detection attached to this object
        playerData  = dataObject.GetComponent <PlayerDataScript>(); //Grab player data

        scoreMultiplier = playerData.multiplier;

        if (clickDetect.wasClicked && holdDetect.isHeld) //If it has been clicked and is being held down
        {
            wasHeld   = true;                            //Logs that the object has been hit
            timeHeld += Time.deltaTime;

            if (startedPlaying)
            {
                holdAnim.speed = (1 / speedMod);
                audioObject.SetActive(true);
            }
            if (!startedPlaying)
            {
                holdAnim.SetBool("Held", true);
                startedPlaying = true;
                audioObject.SetActive(true);
            }
        }

        if (!clickDetect.wasClicked && wasHeld) //JS If it has been clicked and is released
        {
            holdAnim.speed = 0;                 //JS
            audioObject.SetActive(false);
            clickDetect.touchDetect = false;
        }


        /*
         *
         * if(wasHeld && !holdDetect.isHeld) // If the player held over, but released
         * {
         *  //This should mostly be used to report a failed click/clean up unused objects
         *  playerData.unsuccessfulHits++; //Log failed hit in data
         *
         *  //Debug.Log("Object should die here");
         *  Destroy(theParent);
         * }
         */



        if (gameTimer.timer > timeSpawned + timeToDie && timeHeld == 0f) //If the object has outlasted its live timer and it was never charged
        {
            //This should mostly be used to report a failed click/clean up unused objects
            playerData.unsuccessfulHits++; //Log failed hit in data
            playerData.allUnsuccessfulHits++;
            playerData.setUnsuccessfulHits++;

            //Debug.Log("Object should die here");
            feedbackObject.SetActive(true); //Activate the feedback object
            feedbackExploObject.SetActive(true);
            feedbackExploAnimator.SetTrigger("Miss");
            audioObject.SetActive(false);
            feedbackAnimator.SetTrigger("Miss");
            playerData.playerCombo = 0;

            gameObject.SetActive(false); //Deactivate the target object
        }

        if (gameTimer.timer > timeSpawned + timeToDie && timeHeld > 0f && timeHeld <= baseTimeForGood) //If the object has outlasted its live but it got charged a bit
        {
            //This should mostly be used to report a failed click/clean up unused objects
            playerData.unsuccessfulHits++; //Log failed hit in data
            playerData.allUnsuccessfulHits++;
            playerData.setUnsuccessfulHits++;

            //Debug.Log("Object should die here");
            feedbackObject.SetActive(true); //Activate the feedback object
            audioObject.SetActive(false);
            feedbackExploObject.SetActive(true);
            feedbackExploAnimator.SetTrigger("Bad");
            feedbackAnimator.SetTrigger("Bad");
            playerData.playerCombo  = 0;
            playerData.playerScore += (50 * scoreMultiplier);
            gameObject.SetActive(false); //Deactivate the target object
        }

        if (gameTimer.timer > timeSpawned + timeToDie && timeHeld > baseTimeForGood) //If the object has outlasted its live but it got charged a lot
        {
            //This should mostly be used to report a failed click/clean up unused objects
            playerData.successfulHits++; //Log failed hit in data
            playerData.allSuccessfulHits++;
            playerData.setSuccessfulHits++;

            //Debug.Log("Object should die here");
            feedbackObject.SetActive(true); //Activate the feedback object
            audioObject.SetActive(false);
            feedbackExploObject.SetActive(true);
            feedbackExploAnimator.SetTrigger("Good");
            feedbackAnimator.SetTrigger("Good");
            playerData.playerCombo++;
            playerData.playerScore += (200 * scoreMultiplier);
            gameObject.SetActive(false); //Deactivate the target object
        }

        if (timeHeld >= timeToHold) //If it has been held long enough
        {
            //This is where we do stuff after the object has been clicked
            playerData.successfulHits++; //Log successful hit in data
                                         // Debug.Log("We clicked it reddit");
            playerData.allSuccessfulHits++;
            playerData.setSuccessfulHits++;
            feedbackObject.SetActive(true); //Activate the feedback object
            feedbackExploObject.SetActive(true);
            feedbackExploAnimator.SetTrigger("Perfect");
            feedbackAnimator.SetTrigger("Perfect");
            audioObject.SetActive(false);
            playerData.playerCombo++;
            playerData.playerScore += (400 * scoreMultiplier);
            gameObject.SetActive(false); //Deactivate the target object
        }

        if (gameTimer.timer > timeSpawned + timeToClick)
        {
            //Shouldn't actually need this check, should be handled inside the "Was clicked" part, but hey!
            //Debug.Log("THIS WAS THE CLICK MOMENT");
        }
    }
    // Update is called once per frame
    void Update()
    {
        gameTimer   = dataObject.GetComponent <GameTimerScript>();  // update timer
        clickDetect = GetComponent <ClickDetectScript>();           // Grab the click detection attached to this object
        holdDetect  = GetComponent <HoldDetectScript>();            // Grab the hold detection attached to this object
        playerData  = dataObject.GetComponent <PlayerDataScript>(); //Grab player data

        scoreMultiplier = playerData.multiplier;

        if (clickDetect.wasClicked && holdDetect.isHeld) //If it has been clicked and is being held down
        {
            wasHeld = true;                              //Logs that the object has been hit
        }

        if (keepGoing)
        {
            SlideObject();
            oncePerFrame = true;
        }

        if (wasHeld && !keepGoing)
        {
            if (!oncePerFrame)
            {
                audioObject.SetActive(true);
                SlideObject();
            }
        }

        if (wasHeld && !holdDetect.isHeld && !keepGoing) // If the player held over, but released
        {
            //This should mostly be used to report a failed click/clean up unused objects
            playerData.unsuccessfulHits++; //Log failed hit in data
            playerData.allUnsuccessfulHits++;
            playerData.setUnsuccessfulHits++;
            playerData.playerCombo = 0;
            //Debug.Log("Object should die here");

            feedbackObject.SetActive(true); //Activate the feedback object
            feedbackExploObject.SetActive(true);
            audioObject.SetActive(false);   //Deactivate the button sound object
            feedbackObject.transform.eulerAngles      = new Vector3(0, 0, -theParent.transform.rotation.z);
            feedbackExploObject.transform.eulerAngles = new Vector3(0, 0, -theParent.transform.rotation.z);
            feedbackAnimator.SetTrigger("Bad");
            feedbackExploAnimator.SetTrigger("Bad");
            sliderGraphicsParent.SetActive(false); //Deactivate the target object
        }

        if (holdDetect.isHeld && clickDetect.wasClicked) //If it has been clicked and is being held down
        {
            timeHeld += Time.deltaTime;
        }

        if (gameTimer.timer > timeSpawned + timeToDie) //If the object has outlasted its live timer
        {
            //This should mostly be used to report a failed click/clean up unused objects
            playerData.unsuccessfulHits++; //Log failed hit in data
            playerData.allUnsuccessfulHits++;
            playerData.setUnsuccessfulHits++;
            playerData.playerCombo = 0;
            //Debug.Log("Object should die here");
            feedbackObject.SetActive(true); //Activate the feedback object
            feedbackExploObject.SetActive(true);
            audioObject.SetActive(false);   //Deactivate the button sound object
            feedbackObject.transform.eulerAngles      = new Vector3(0, 0, -theParent.transform.rotation.z);
            feedbackExploObject.transform.eulerAngles = new Vector3(0, 0, -theParent.transform.rotation.z);
            feedbackAnimator.SetTrigger("Bad");
            feedbackExploAnimator.SetTrigger("Bad");
            sliderGraphicsParent.SetActive(false); //Deactivate the target object
        }

        if (moveFinished) //If it has been held long enough
        {
            //This is where we do stuff after the object has been clicked
            playerData.successfulHits++; //Log successful hit in data
                                         // Debug.Log("We clicked it reddit");
            playerData.allSuccessfulHits++;
            playerData.setSuccessfulHits++;
            playerData.playerCombo++;
            playerData.playerScore += (400 * scoreMultiplier);
            feedbackObject.SetActive(true); //Activate the feedback object
            feedbackExploObject.SetActive(true);
            audioObject.SetActive(false);   //Deactivate the button sound object
            feedbackObject.transform.eulerAngles      = new Vector3(0, 0, -theParent.transform.rotation.z);
            feedbackExploObject.transform.eulerAngles = new Vector3(0, 0, -theParent.transform.rotation.z);
            feedbackAnimator.SetTrigger("Perfect");
            feedbackExploAnimator.SetTrigger("Perfect");
            sliderGraphicsParent.SetActive(false); //Deactivate the target object
        }

        if (gameTimer.timer > timeSpawned + timeToClick)
        {
            //Shouldn't actually need this check, should be handled inside the "Was clicked" part, but hey!
            //Debug.Log("THIS WAS THE CLICK MOMENT");
        }
    }
Ejemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     uiCam       = GameObject.FindGameObjectWithTag("UICam").GetComponent <Camera>(); //Grab the object that contains the timer
     clickDetect = GetComponent <ClickDetectScript>();
 }