public override void UpdateState(bool success, MachineStates finishedState) { Debug.Log(finishedState); if (Vector2.Distance(transform.position, player.transform.position) > 5) { comedorPatrollingAction.StartAction(); actualState = MachineStates.Patrolling; } else { if (actualState == MachineStates.MoveToPlayer && finishedState == MachineStates.MoveToPlayer && success) { comedorattackAction.StartAction(); actualState = MachineStates.Attack; } } if (actualState == MachineStates.Attack && finishedState == MachineStates.Attack && success) { if (!reachedEva) { comedorMoveToPlayer.StartAction(); actualState = MachineStates.MoveToPlayer; } else { comedorattackAction.StartAction(); actualState = MachineStates.Attack; } } }
protected override void Start() { comedorPatrollingAction = GetComponent <ComedorPatrollingAction>() as BaseActionComponent; comedorMoveToPlayer = GetComponent <ComedorMoveToPlayer>() as BaseActionComponent; comedorattackAction = GetComponent <ComedorAttackAction>() as BaseActionComponent; player = EvaMovement.Instance.gameObject; actualState = MachineStates.Patrolling; comedorPatrollingAction.StartAction(); }
public override void UpdateState(bool success, MachineStates thisState) { actualState = thisState; switch (nextState) { case 1: patrollingAction.StartAction(); thisState = MachineStates.Patrolling; break; case 2: sleepAction.StartAction(); thisState = MachineStates.Sleep; break; } }