new public void ChangeState <T>() where T : CatAIState { CatAIState nextState = GetState <T>(); nextState.catAI = this; CurrentState = nextState; }
// Update is called once per frame void Update() { if (isAIEnabled && !isProcessing) { AttributeType attributeType = SelectNextAttribute(); //Debug.Log("Next Attribute " + attributeType); CatAIState catAIState = SelectNextAIState(attributeType); //Debug.Log("Next AI state " + catAIState); NextAction(catAIState); } }
public void NextAction(CatAIState state) { currentAIState = state; isProcessing = true; switch (state) { case CatAIState.Idle: StartNoneTargetAction(typeof(IdleAction)); break; case CatAIState.Eat: StartNoneTargetAction(typeof(EatAction)); break; case CatAIState.Drink: StartNoneTargetAction(typeof(DrinkAction)); break; case CatAIState.PlayWithCustomer: // TODO need to craete customer PlayToyAction(); break; case CatAIState.Sleep: StartNoneTargetAction(typeof(SleepAction)); break; case CatAIState.PlayToy: PlayToyAction(); break; default: break; } currentAction.notifyActionEnd += OnActionEnd; }
private void OnActionEnd(Action action) { //Debug.Log("OnActionEnd " + action.name ); currentAIState = CatAIState.None; isProcessing = false; }