示例#1
0
 private void OnEnable()
 {
     _current = Instantiate(startState);
     _current.OnEnter(gameObject);
     if (UnityEngine.Random.value > 0.99f)
     {
         PlayerAudioBehaviour.PlaySound(EAudioEventType.zombieGrowl, transform.position);
     }
 }
示例#2
0
        private void Update()
        {
            _current.Update();
            if (_current.IsCompleted())
            {
                _current.OnLeave();
                var transitsTo = _current.TransitTo();
                if (transitsTo != null && states.Contains(transitsTo))
                {
                    Destroy(_current);
                    _current = Instantiate(transitsTo);

                    _current.OnEnter(gameObject);
                }
                else
                {
                    Debug.LogError(string.Format("Next logical step for {0} is oblivion!", gameObject.name));
                    Destroy(gameObject);
                }
            }
        }