private void Awake() { stateMachine = new StateMachine(); var closed = new StandClosed(this); var opening = new OpeningDoor(this); var opened = new StandOpen(this); var closing = new ClosingDoor(this); stateMachine.AddTransition(closed, opening, HasReceivedOpenRequest()); stateMachine.AddTransition(opening, opened, HasFullyDisplaced()); stateMachine.AddTransition(opened, closing, HasReceivedCloseRequest()); stateMachine.AddTransition(closing, closed, HasFullyDisplaced()); Func <bool> HasReceivedOpenRequest() => () => IsToggleRequestReceived; Func <bool> HasReceivedCloseRequest() => () => IsToggleRequestReceived; Func <bool> HasFullyDisplaced() => () => currentDisplacement >= movementParameters.maximum; // Func<bool> IsSatisfied() => () => prices == bAffordable && menu.Supports("GF"); //Func<int, int, int> arithmeticFunc = add; //Func<int, int, double> func2 = (x, y) => { return x / y; }; stateMachine.SetState(closed); }
// Use this for initialization void Start() { doorScript = this.GetComponent<OpeningDoor>(); colliders = this.GetComponents<Collider>(); }