private void GameEvents_OnObjectReset(GameEvents.PhysicsInteractionData data)//change on object reset
    {
        Debug.Log("Get To hear?");
        // Here we are checking first if we have not dropped the ball, and that the object that what has entered reset world trigger
        // in this case our ball has a rigidbody and has the take of "Ball".
        if (!IsComplete && data != null && data.other.tag == "NerfDart")// or data.instigator
        {
            Debug.Log("Get To hear");
            // We can use the keyword var to hold any sort of data, i.e. a var ourData we could put anythin into it, a bool, a string, an int etc.
            // The downside is because it can be everything Unity has to assign the most amount of memory it can to accomodate it, so use var's wisely especially.
            // in big projects. If I didn't want to use a var I could write it as GameEvents.CheckListItemChangedData ourData = new GameEvents.CheckListItemChangedData(); .
            // For this case we are creating a new instance of the class CheckListItemChangedData and storing it in our var
            var ourData = new GameEvents.CheckListItemChangedData();
            // I then take ourData and get the item variable and assign the instance of this class to it, using the 'this' keyword.
            ourData.item = this;
            // From there I can set the previousItemProgress Variable of our data to our current progress in this case it return 1 as we have dropped the ball over the edge.
            // i.e. from 0 being false, to 1 being true, so the previous item progress was it hadn't been dropped over the edge to now it has been dropped over the edge.
            Dragons.Remove(data.instigator);
            ourData.previousItemProgress = GetProgress();
            // Since the ball has now gone over the edge we want to se the hasDroppedBall bool to true, so we can't do this function again as the task is complete.

            // We then tell the game events to invoke the CheckListItemChanged event and pass in our data.
            // this will take our data and up the tasks completed in the UI.
            GameEvents.InvokeCheckListItemChanged(ourData);
        }
    }
    // This is the function where all the fun stuff happens, it is also the function we need to call when the game event happens
    // i.e. when the ball falls over the edge.
    // This function takes in a type of GameEvents.ObjectResetData which is a class in GameEvents.cs, if you highlight ObjectResetData and press F12
    // it will take you to it's definition.
    private void GameEvents_OnObjectReset(GameEvents.ObjectResetData data)
    {
        // Here we are checking first if we have not dropped the ball, and that the object that what has entered reset world trigger
        // in this case our ball has a rigidbody and has the take of "Ball".
        if (!hasDroppedGun
            && data.offendingCollider.attachedRigidbody != null &&
            data.offendingCollider.attachedRigidbody.CompareTag("NerfGun"))
        {
            ///check to see if gun has been dropped
            // We can use the keyword var to hold any sort of data, i.e. a var ourData we could put anythin into it, a bool, a string, an int etc.
            // The downside is because it can be everything Unity has to assign the most amount of memory it can to accomodate it, so use var's wisely especially.
            // in big projects. If I didn't want to use a var I could write it as GameEvents.CheckListItemChangedData ourData = new GameEvents.CheckListItemChangedData(); .
            // For this case we are creating a new instance of the class CheckListItemChangedData and storing it in our var
            var ourData = new GameEvents.CheckListItemChangedData();
            ///make a new game event check list changed data
            // I then take ourData and get the item variable and assign the instance of this class to it, using the 'this' keyword.
            ourData.item = this;
            ///make that our new data
            // From there I can set the previousItemProgress Variable of our data to our current progress in this case it return 1 as we have dropped the ball over the edge.
            // i.e. from 0 being false, to 1 being true, so the previous item progress was it hadn't been dropped over the edge to now it has been dropped over the edge.
            ourData.previousItemProgress = GetProgress();
            ///call the get progress module
            // Since the ball has now gone over the edge we want to se the hasDroppedBall bool to true, so we can't do this function again as the task is complete.
            hasDroppedGun = true;
            ///set hasdroppedgun to true

            // We then tell the game events to invoke the CheckListItemChanged event and pass in our data.
            // this will take our data and up the tasks completed in the UI.
            GameEvents.InvokeCheckListItemChanged(ourData);
            ///set the new data
        }
    }
 public void OnBowlinggScored()
 {
     var ourData = new GameEvents.CheckListItemChangedData()
     ourData.item = this;
     ourData.previousItemProgress = GetProgress();
     GameEvents.InvokeCheckListItemChanged(ourData);
 }
    public void BowlingScored()
    {
        //if (numberOfHoopsScored < numberOfRequiredHoops)
        {
            var ourData = new GameEvents.CheckListItemChangedData();
            ourData.item = this;
            ourData.previousItemProgress = GetProgress();

            GameEvents.InvokeCheckListItemChanged(ourData);
        }
    }
Exemplo n.º 5
0
    public void OnBollowingScored()
    //this function is used to see if any data in this class was changed which is the score and if it is then it shows you the new score.
    {
        {
            var ourData = new GameEvents.CheckListItemChangedData();
            ourData.item = this;
            ourData.previousItemProgress = GetProgress();

            GameEvents.InvokeCheckListItemChanged(ourData);
        }
        //if (numberofHoopsScored < numberOfRequiredHoops)
    }
Exemplo n.º 6
0
    public void GameEvents_OnObjectReset(GameEvents.ObjectResetData data)
    {
        if (!hasDroppedBall && data.offendingCollider.attachedRigidbody != null && data.offendingCollider.attachedRigidbody.CompareTag("Ball"))
        {
            var ourData = new GameEvents.CheckListItemChangedData();
            ourData.item = this;
            ourData.previousItemProgress = GetProgress();

            hasDroppedBall = true;

            GameEvents.InvokeCheckListItemChanged(ourData);
        }
    }
Exemplo n.º 7
0
    public void OnBasketScored()
    {
        if (NumberOfCubesDilivered < NumberOfCubesRequired)
        {
            var ourData = new GameEvents.CheckListItemChangedData();
            ourData.item = this;
            ourData.previousItemProgress = GetProgress();

            NumberOfCubesDilivered++;

            GameEvents.InvokeCheckListItemChanged(ourData);
        }
    }
    void OnBasketScored()
    {
        if (numberOfHoopsScored < numberOfRequiredHoops)
        {
            var ourData = new GameEvents.CheckListItemChangedData();
            ourData.item = this;
            ourData.previousItemProgress = GetProgress();

            numberOfHoopsScored++;

            GameEvents.InvokeCheckListItemChanged(ourData);
        }
    }
    public void OnBasketScored()
    {
        if (TargetRangeHighScore < TargetRangeReqiredScore)
        {
            var ourData = new GameEvents.CheckListItemChangedData();
            ourData.item = this;
            ourData.previousItemProgress = GetProgress();

            TargetRangeHighScore++;

            GameEvents.InvokeCheckListItemChanged(ourData);
        }
    }
 public void OnDragonHit()
 {
     //on dragon hit run this code
     //Check to see if number of dragons is less then number of dragons in the list
     if (numberOfDragonsHit < Dragons.Count)
     {
         //check the checklistitem changed data
         var ourData = new GameEvents.CheckListItemChangedData();
         //change it to this
         ourData.item = this;
         ourData.previousItemProgress = GetProgress();
         //add 1 to the numberOfDragonsHit
         numberOfDragonsHit++;
         // add the change to the data
         GameEvents.InvokeCheckListItemChanged(ourData);
     }
 }
    public void OnCheckPointPassed()
    {
        if (numberOfCheckpointsScored < numberOfRequiredCheckpoints)
        {
            //if when a checkpoint is passed a number of checkpoints are scored is less then number of required checkpoints
            var ourData = new GameEvents.CheckListItemChangedData();
            //create a new gameevents checklistitemchangeddata
            ourData.item = this;
            // make the new data this
            ourData.previousItemProgress = GetProgress();
            // get new data progress and set it to ourdata

            numberOfCheckpointsScored++;
            // add one to the numberOfCheckpointsScored to ourData

            GameEvents.InvokeCheckListItemChanged(ourData);
            //Update data to ourData
        }
    }
Exemplo n.º 12
0
    private void GameEvents_OnCheckListItemChanged(GameEvents.CheckListItemChangedData data)
    {
        var locatedIndex = checkListItems.IndexOf(data.item);

        if (locatedIndex != -1)
        {
            RefreshItemText(locatedIndex);
        }

        if (data.item.IsComplete)
        {
            completeSFX.Play2D();
        }
        else if (data.previousItemProgress > data.item.GetProgress())
        {
            lostProgressSFX.Play2D();
        }
        else
        {
            progressSFX.Play2D();
        }
    }