Ejemplo n.º 1
0
        public void OnPlayerCameToLayer(EventArgs args)
        {
            if (args is PlayerCameToLayerEA pctl)
            {
                for (int i = 0; i < _constantDisasters.Count; ++i)
                {
                    _constantDisasters[i].End();
                }

                int constantDisasterCounter = 0;
                for (int i = 0; i < pctl.GroundLayer.NaturalDisasters.Count; ++i)
                {
                    if (pctl.GroundLayer.NaturalDisasters[i].HappeningType == NaturalDisaster.EHappeningType.Constant)
                    {
                        NaturalDisaster nd = pctl.GroundLayer.NaturalDisasters[i];
                        nd.Execute();
                        _constantDisasters.Add(nd);
                        constantDisasterCounter++;
                    }
                }

                if (constantDisasterCounter == pctl.GroundLayer.NaturalDisasters.Count)
                {
                    _isOccasionalDisasterAvailable = false;
                }
                else
                {
                    _isOccasionalDisasterAvailable = true;
                }
            }
            else
            {
                Log.Instance.Write(GetType() + " : " + new InvalidEventArgsException().Message);
            }
        }
Ejemplo n.º 2
0
        private IEnumerator CountdownToEnd(NaturalDisaster disaster)
        {
            yield return(new WaitForSeconds(disaster.Time));

            disaster.End();
            _disasterEnded.Raise();
            _occasionalDisasterInProggress = false;
            _countdownCoroutine            = null;
        }
Ejemplo n.º 3
0
        private IEnumerator CountdownToBeginning()
        {
            while (_countdownToOccasionalDisaster > 0f)
            {
                _countdownToOccasionalDisaster -= Time.deltaTime;
                yield return(null);
            }

            if (_layers[_playerLayer.Value].NaturalDisasters.Count > 0 && _occasionalDisasterInProggress == false)
            {
                _occasionalDisasterInProggress = true;
                int             disasterIndex = Random.Range(0, _layers[_playerLayer.Value].NaturalDisasters.Count);
                NaturalDisaster nd            = _layers[_playerLayer.Value].NaturalDisasters[disasterIndex];
                nd.Execute();
                _countdownCoroutine = StartCoroutine(CountdownToEnd(nd));
            }
            _countdownToOccasionalDisaster = 0f;
        }