< Summary

Class:RecipeManager
Assembly:Test
File(s):E:/Unity/Unity Project/VR-Cooking-Demo/Assets/_Scripts/RecipeManager.cs
Covered lines:27
Uncovered lines:3
Coverable lines:30
Total lines:85
Line coverage:90% (27 of 30)
Covered branches:0
Total branches:0
Covered methods:7
Total methods:7
Method coverage:100% (7 of 7)

Coverage History

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity NPath complexity Sequence coverage
RecipeManager()0%000100%
Awake()0%00066.67%
Start()0%000100%
Update()0%000100%
MoveToState(...)0%000100%

File(s)

E:/Unity/Unity Project/VR-Cooking-Demo/Assets/_Scripts/RecipeManager.cs

#LineLine coverage
 1/*
 2 *
 3 * Code by:
 4 *      Dimitrios Vlachos
 5 *      djv1@student.london.ac.uk
 6 *      dimitri.j.vlachos@gmail.com
 7 *
 8 * Adapted from our Games Dev FSM lecture
 9 *
 10 */
 11
 12using System.Collections;
 13using System.Collections.Generic;
 14using TMPro;
 15using UnityEngine;
 16
 17public class RecipeManager : MonoBehaviour
 18{
 19    #region Variables
 20    public RecipeBaseState state;
 21    public GameObject anchor;
 22
 23    [Header("States")]
 224    public RecipeState1 state1 = new();
 225    public RecipeState2 state2 = new();
 26
 27    [Header("UI")]
 28    public TextMeshProUGUI objective;
 29    public TextMeshProUGUI status;
 30
 31    [Header("Objective information")]
 32    public GameObject pot;
 33    public PotBehaviour potBehaviour;
 34    public int numberOfPotatos;
 35    public int numberOfCarrots;
 36    public int water;
 37    #endregion
 38
 39    // This makes a singleton Recipe Manager object
 40    #region Singleton declaration
 241    public static RecipeManager Recipe { get; private set; }
 42
 43    private void Awake()
 144    {
 45        // Singletone protection stuff
 146        if (Recipe != null && Recipe != this)
 047        {
 048            Destroy(this);
 049        }
 50        else
 151        {
 152            Recipe = this;
 153        }
 154    }
 55#endregion
 56
 57    // Start is called before the first frame update
 58    void Start()
 159    {
 160        objective.text = string.Empty;
 161        status.text = string.Empty;
 62
 163        numberOfPotatos = 0;
 164        numberOfCarrots = 0;
 165        water = 0;
 66
 167        potBehaviour = pot.GetComponent<PotBehaviour>();
 68
 169        MoveToState(state1);
 170    }
 71
 72    // Update is called once per frame
 73    void Update()
 168274    {
 168275        state.Update();
 168276        transform.position = anchor.transform.position;
 168277    }
 78
 79    public void MoveToState(RecipeBaseState state)
 180    {
 181        Debug.Log("Entering state: " + state);
 182        this.state = state;
 183        state.EnterState(this);
 184    }
 85}