Documentation for the Unity C# Library
Loading...
Searching...
No Matches
GenerateBreakdown.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using PixoVR.Core;
4using UnityEngine;
5
6namespace PixoVR.Event
7{
11 public class GenerateBreakdown : IStep
12 {
13 public event Action OnFunctionFinished;
14
15 public void StartStep(StepItem stepItem, StepFunction function, List<InteractableClass> interactables = null, Action onStepSkipped = null)
16 {
17 if (interactables == null) return;
18
19 var stringsOfPercent = function.value.Split(new char[] { '#' });
20 bool isOneForAll = stringsOfPercent.Length < interactables.Count;
21
22 if (stringsOfPercent.Length < interactables.Count)
23 {
24 Debug.Log("You don't have enough parameters, the first one will be used for all!");
25 }
26
27 for (int i = 0; i < interactables.Count; i++)
28 {
29 int percents = isOneForAll ? int.Parse(stringsOfPercent[0]) : int.Parse(stringsOfPercent[i]);
30 interactables[i].GenerateBreakdown(percents);
31 }
32
34 }
35
36 public void FunctionFinished()
37 {
38 OnFunctionFinished?.Invoke();
39 }
40 }
41}
Function of generating a random breakdown for an object with a certain probability.
void StartStep(StepItem stepItem, StepFunction function, List< InteractableClass > interactables=null, Action onStepSkipped=null)
void FunctionFinished()
Called to end current step and start a next one.
[Serializable]
Definition StepItem.cs:12
Basic interface of functions. (Please note that iStep is a wrong name)
Definition IStep.cs:10