Exemple #1
0
    /// <summary>
    /// Allocates points to the correct player based on the location of the goal
    /// </summary>
    /// <param name="isRightGoal">Which goal the puck has gone into</param>
    /// <param name="collision">The reference to the puck that had entered into the goal</param>
    public void GivePointToPlayer(bool isRightGoal, Collider2D collision)
    {
        // Begin the check for ending the game
        AH_Puck scoringPuck = collision.gameObject.GetComponent <AH_Puck>();

        scoringPuck.GetComponentInChildren <TrailRenderer>().enabled = false;
        StartCoroutine(CheckGameState(scoringPuck, isRightGoal));
    }
Exemple #2
0
    /// <summary>
    /// Handles the events that occur when a pick up is picked up.
    /// </summary>
    /// <param name="puck">The puck that picked up the pick up.</param>
    public void OnPickUp(AH_Puck puck)
    {
        // Set a reference to the puck
        afflictedPuck = puck;

        // Mark the pick up as interacted
        m_timeoutEnabled = false;

        // Disable pick up from being interacted with in the scene
        DisablePickUpRendering();

        if (ValidateOnPickUpEffects())
        {
            ActivateOnPickUpEffects();
        }
        else
        {
            PlayParticleEffect("Pick Up Failure");
        }
    }
Exemple #3
0
    /// <summary>
    /// Checks the state of the game after points have been allocated and takes appropriate actions.
    /// </summary>
    /// <param name="scoringPuck">Reference to the puck that scored the points</param>
    /// <returns>Time taken before action of the coroutine</returns>
    IEnumerator CheckGameState(AH_Puck scoringPuck, bool isRightGoal)
    {
        if (!m_winEffectsTriggered)
        {
            // Start score update
            canvasManager.OnPointEarned(isRightGoal);

            // Wait an appropriate amount of time before proceeding
            yield return(new WaitForSecondsRealtime(m_checkGameStateDelay));

            // Reset the puck location
            if (isRightGoal)
            {
                scoringPuck.ResetPuck(m_PuckResetOffsetForRightGoal.position);
            }
            else
            {
                scoringPuck.ResetPuck(m_PuckResetOffsetForLeftGoal.position);
            }

            // Check the game scene
            if (DetermineWinState() && !m_winEffectsTriggered)
            {
                // Activate win effects
                victoryParticles.SetActive(true);
                canvasManager.ActivateWinLossText();
                m_audioSource.Play();
                AH_PickUpManager.instance.m_canSpawn = false;

                // Mark effects as triggered
                m_winEffectsTriggered = true;

                // Begin end game coroutine
                StartCoroutine(EndGame());
            }
        }
    }
Exemple #4
0
    /// <summary>
    /// Re-enable the power up and resets the internal timer.
    /// [DEBUG MODE] Records that the object has been enabled.
    /// </summary>
    /// <param name="newLocation">The location at which to spawn the power up at.</param>
    public void EnablePickUp(Vector3 newLocation)
    {
        // Modify external references
        afflictedPuck = null;
        AH_PickUpManager.instance.IncreaseCurrentPickUpCount();

        // Activate the game object and it's components
        gameObject.SetActive(true);
        EnablePickUpRendering();

        // Modify Location
        transform.position = newLocation;

        // Reset timers
        m_timeoutEnabled = true;
        m_lifespanTimer  = 0.0f;
        m_effectTimer    = 0.0f;

        // Enable animation
        StartCoroutine(OnEnableStartAnimation());

        // Debug
        DebugLog(gameObject.name + " has been enabled.");
    }
Exemple #5
0
    public override void OnEffectBegin()
    {
        AH_Puck newPuck = Instantiate(afflictedPuck);

        newPuck.delete = true;
    }