Newer
Older
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TMPro;
public class ProtocolHandler : MonoBehaviour
{
public GameObject numCyclesInput;
public GameObject blockControl;
public float TotalRuntime { get; private set; }
BlockHandler blockHandler;
List<GameObject> blockStack = new List<GameObject>();
int nCycles = 1;
int currentBlockIndex = 0;
int currentCycle = 0;
static float timeBetweenBlocks = 3f; // seconds, not implemented
private void Awake()
{
if (Instance != null)
{
Destroy(gameObject);
return;
}
Instance = this;
DontDestroyOnLoad(gameObject);
}
// Start is called before the first frame update
void Start()
{
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
}
// Update is called once per frame
void Update()
{
}
// Update runtime by adding each block runtime, adding 3s for each block,
// and multiplying by cycles
public void UpdateTotalRuntime()
{
blockHandler = blockControl.GetComponent<BlockHandler>();
TotalRuntime = blockHandler.blockStackRuntime;
TotalRuntime *= nCycles;
}
public void UpdateNumCycles()
{
TMP_InputField inputField = numCyclesInput.GetComponent<TMP_InputField>();
nCycles = (int)Convert.ToInt32(inputField.text);
}
public void SetBlockStack()
{
blockStack = blockHandler.GetBlockStack();
int i = 0;
foreach (var block in blockStack)
{
BlockObjectClass boc = block.GetComponent<BlockObjectClass>();
Debug.Log("boc " + i + " inhale: " + boc.InhalePeriod);
i++;
}
}
public void PrintBlockStack()
{
int i = 0;
foreach (var block in blockStack)
{
BlockObjectClass boc = block.GetComponent<BlockObjectClass>();
Debug.Log("boc " + i + " inhale: " + boc.InhalePeriod);
i++;
}
}
}
public class ProtocolVariables
{
List<BlockObjectClass>