Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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;
float timeBetweenBlocks = 3f; // seconds, not implemented
// Start is called before the first frame update
void Start()
{
UpdateTotalRuntime();
}
// 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++;
}
}
}