Ejemplo n.º 1
0
    // Methods

    void OnTriggerEnter(Collider other)
    {
        var subGoal = other.gameObject.GetComponent <SubGoal>();

        // only trigger-collisions with subgoals are of interest here, so ignore the rest
        if (subGoal != null)
        {
            var subGoalManager    = SubGoalManager.GetInstance();
            var nextSubGoalNumber = subGoalManager.NextSubGoalNumber;

            // if the player went through the current sub goal ..
            if (subGoal.SubGoalNumber == nextSubGoalNumber)
            {
                // then switch to the next one
                Points++;
                subGoalManager.IncrementSubGoalNumber();

                // if it was the last one, then set flag for game end
                if (subGoal.SubGoalNumber == MaxSubGoalNumber)
                {
                    _gameEnded       = true;
                    _gameEndTimeSpan = DateTime.UtcNow - _startTime;
                }
            }
        }
    }
Ejemplo n.º 2
0
    public void Returns_Correct_Value_After_Increment()
    {
        var subGoalManager = SubGoalManager.GetInstance();

        subGoalManager.IncrementSubGoalNumber();
        Assert.AreEqual(2, subGoalManager.NextSubGoalNumber);
    }
Ejemplo n.º 3
0
    // Methods

    void FixedUpdate()
    {
        var subGoalManager = SubGoalManager.GetInstance();
        var isActiveNow    = subGoalManager.NextSubGoalNumber == SubGoalNumber;

        // if active state changed ..
        if (_isActive != isActiveNow)
        {
            // .. switch out material
            var meshRenderer = GetComponentInChildren <MeshRenderer>();
            if (isActiveNow)
            {
                meshRenderer.material = ActiveMaterial;
            }
            else
            {
                meshRenderer.material = InactiveMaterial;
            }

            _isActive = isActiveNow;
        }
    }
Ejemplo n.º 4
0
 /// <summary>
 /// Basically reset the whole game, including object positions and states aswell as accumulated points and timers
 /// </summary>
 private void ResetLevel()
 {
     SceneManager.LoadScene(SceneManager.GetActiveScene().name);
     SubGoalManager.GetInstance().Reset();
 }
Ejemplo n.º 5
0
    public void Initializes_With_Correct_Values()
    {
        var subGoalManager = SubGoalManager.GetInstance();

        Assert.AreEqual(1, subGoalManager.NextSubGoalNumber);
    }