예제 #1
0
 private void InvokeDecisionEvent(bool decisionValue, MAIDecision decision)
 {
     if (decision.send == MAIDecision.WSend.SendTrue && decisionValue)
     {
         OnDecisionSucceded.Invoke(decision.MessageID);
     }
     else if (decision.send == MAIDecision.WSend.SendFalse && !decisionValue)
     {
         OnDecisionSucceded.Invoke(decision.MessageID);
     }
 }
예제 #2
0
        private void AddDecision(Type desicion, int index)
        {
            MAIDecision des = (MAIDecision)CreateInstance(desicion);

            des.hideFlags = HideFlags.None;
            des.name      = "D_" + desicion.Name;
            AssetDatabase.AddObjectToAsset(des, AssetDatabase.GetAssetPath(target));
            AssetDatabase.SaveAssets();


            m.transitions[index].decision = des; //the other way was not working

            EditorUtility.SetDirty(des);
            EditorUtility.SetDirty(target);

            transitions.serializedObject.ApplyModifiedProperties();
            serializedObject.ApplyModifiedProperties();

            Reo_List_Transitions.index = index;
            Reo_List_Tasks.index       = -1;
        }
예제 #3
0
        public virtual void TransitionToState(MAIState nextState, bool decisionValue, MAIDecision decision)
        {
            if (Time.time - TransitionLastTime >= TransitionCoolDown) //This avoid making transition on the same Frame ****IMPORTANT
            {
                if (nextState != remainInState)
                {
                    TransitionLastTime = Time.time;

                    if (debug)
                    {
                        Debug.Log($"Changed from <B>{currentState.name} </B> to <B>{nextState.name}</B> with the decision <b>{decision.name}</b> been <B>{decisionValue}</B>.");
                    }

                    InvokeDecisionEvent(decisionValue, decision);

                    StartNewState(nextState);
                }
            }
        }
예제 #4
0
        public virtual void TransitionToState(MAIState nextState, bool decisionValue, MAIDecision decision, int Index)
        {
            if (MTools.ElapsedTime(TransitionLastTime, TransitionCoolDown))                       //This avoid making transition on the same Frame ****IMPORTANT
            {
                if (nextState != null && nextState != remainInState && nextState != currentState) //Do not transition to itself!
                {
                    TransitionLastTime = Time.time;

                    decision.FinishDecision(this, Index);


                    Debuging($"<color=white>Changed AI State from <B>[{currentState.name}]</B> to <B>[{nextState.name}]</B>. Decision: <b>[{decision.name}]</b> = <B>[{decisionValue}]</B>.</color>");

                    InvokeDecisionEvent(decisionValue, decision);

                    StartNewState(nextState);
                }
            }
        }