// Update is called once per frame void Update() { m_oldState = m_currentState; m_currentState = expression.Resolve(); if (m_oldState != m_currentState) { obj.LogicStateChange(m_currentState); } }
// Update is called once per frame void Update() { if (expression == null) { return; } m_oldState = m_currentState; m_currentState = expression.Resolve(); if (m_oldState != m_currentState) { obj.LogicStateChange(m_currentState); } }
public bool Resolve() { bool result1 = false; bool result2 = false; if (expressionOne != null) { result1 = expressionOne.Resolve(); } else { result1 = objectOne != null ? objectOne.state : false; } if (expressionTwo != null) { result2 = expressionTwo.Resolve(); } else { result2 = objectTwo != null ? objectTwo.state : false; } if (op == LogicOperator.AND) { return(result1 && result2); } else if (op == LogicOperator.OR) { return(result1 || result2); } Debug.LogError("Expression Operator '" + op + "' not handled in resolve!"); return(false); }