private void Awake()
 {
     if (_dieCollection == null)
     {
         _dieCollection = GetComponent <DieCollection>();
     }
 }
Exemplo n.º 2
0
        public DieCollectionResult(DieCollection pDieCollection)
        {
            //to be exact we cannot be rolling
            isExact = !pDieCollection.isRolling;

            //go through all items in the collection, get the results and add them together
            int rollableCount = pDieCollection.Count;

            for (int i = 0; i < rollableCount; i++)
            {
                IRollResult result = pDieCollection.Get(i).GetRollResult();

                //the collection is only exact if every item is exact
                isExact &= result.isExact;

                //make sure the valueTotals list contains enough items and add the totals
                for (int j = 0; j < result.valueCount; j++)
                {
                    if (_valueTotals.Count < j + 1)
                    {
                        _valueTotals.Add(0);
                    }
                    _valueTotals[j] += result.Value(j);
                }
            }

            _valuesAsString = StringUtility.ToString(_valueTotals);
        }
Exemplo n.º 3
0
 private void Awake()
 {
     if (_dieCollection == null)
     {
         _dieCollection = GetComponent <DieCollection>();
     }
     _dieCollection.OnRollBegin             += (a) => { statusChanged("OnRollBegin", a); enabled = true; };
     _dieCollection.OnRollEnd               += (a) => { statusChanged("OnRollEnd", a); enabled = false; };
     _dieCollection.OnEndResultCleared      += (a) => { statusChanged("OnEndResultCleared", a); };
     _dieCollection.OnChildRollBegin        += (a, b) => { statusChanged("OnChildRollBegin", a, b); };
     _dieCollection.OnChildRollEnd          += (a, b) => { statusChanged("OnChildRollEnd", a, b); };
     _dieCollection.OnChildEndResultCleared += (a, b) => { statusChanged("OnChildEndResultCleared", a, b); };
 }