Ejemplo n.º 1
0
        /// <summary>
        /// Updates the behaviour (include the active mode and the active rule).
        /// </summary>
        public void EarlyUpdate(StatusObject _status)
        {
            m_BehaviourModeChanged      = false;
            m_BehaviourModeRulesChanged = false;
            m_BehaviourModeRuleChanged  = false;

            m_BehaviourTimer         += Time.deltaTime;
            m_BehaviourModeRuleTimer += Time.deltaTime;

            BehaviourAudioPlayer.Update();

            //if( ActiveBehaviourModeRule != null )
            //	ActiveBehaviourModeRule.Inventory.Update( _status.Inventory );
        }
Ejemplo n.º 2
0
        public void NextBehaviorModeRule(bool _update = false)
        {
            if (!ActiveBehaviourIsValid)
            {
                PrintDebugLog(this, "NextBehaviorModeRule : invalid Behaviour '" + ActiveBehaviourModeKey + "', please check this mode and its rules!");
            }
            else
            {
                // NextRule will be false if there are no rules but also no new rule, the first
                // case should never be true so we can use _forced to run a simulated rule change
                // to refresh the parameter and/or start animation and audio files, effects and events
                // etc.
                if (m_ActiveBehaviourMode.NextRule() || _update)
                {
                    if (m_ActiveBehaviourMode.LastRule != null)
                    {
                        BehaviourAnimation.Stop(m_ActiveBehaviourMode.Rule.Animation);
                        m_ActiveBehaviourMode.LastRule.Stop();
                    }

                    if (m_ActiveBehaviourMode.Rule != null)
                    {
                        if (DebugLogIsEnabled)
                        {
                            PrintDebugLog(this, "NextBehaviorModeRule : Start rule #" + m_ActiveBehaviourMode.Rule.Index + " of Behaviour Mode " + ActiveBehaviourModeKey + "!");
                        }

                        m_ActiveBehaviourMode.Rule.Start(OwnerComponent);

                        BehaviourAnimation.Play(m_ActiveBehaviourMode.Rule.Animation);
                        BehaviourAudioPlayer.Play(m_ActiveBehaviourMode.Rule.Audio);
                        BehaviourLook.Adapt(m_ActiveBehaviourMode.Rule.Look);
                        //BehaviourMessage.Send( m_ActiveBehaviourMode.Rule.Message );
                    }

                    m_BehaviourModeRuleLength = m_ActiveBehaviourMode.RuleLength();
                    m_BehaviourModeRuleTimer  = 0;

                    m_BehaviourModeRuleChanged = m_ActiveBehaviourMode.RuleChanged;
                    if (OnBehaviourModeRuleChanged != null && m_BehaviourModeRuleChanged == true)
                    {
                        OnBehaviourModeRuleChanged(Owner, m_ActiveBehaviourMode.Rule, m_ActiveBehaviourMode.LastRule);
                    }
                }
            }
        }