//takes actions bitflag to process various inputs void HandleActions() { if ((currentAction & action.forward) == action.forward) { MoveForwards(true); } if ((currentAction & action.backward) == action.backward) { MoveForwards(false); } if ((currentAction & action.left) == action.left) { MoveHorizontally(false); } if ((currentAction & action.right) == action.right) { MoveHorizontally(true); } if ((currentAction & action.up) == action.up) { MoveVertically(true); } if ((currentAction & action.down) == action.down) { MoveVertically(false); } if ((currentAction & action.turn_left) == action.turn_left) { transform.eulerAngles = new Vector3(transform.eulerAngles.x, (transform.eulerAngles.y + (Time.deltaTime * rotateSpeed)), transform.eulerAngles.z); } if ((currentAction & action.turn_right) == action.turn_right) { transform.eulerAngles = new Vector3(transform.eulerAngles.x, (transform.eulerAngles.y - (Time.deltaTime * rotateSpeed)), transform.eulerAngles.z); } //wait till its open/closed? nah if ((currentAction & action.toggle) == action.toggle) { if (currentGrabState == grabState.open) { currentGrabState = grabState.closed; } else if (currentGrabState == grabState.closed) { currentGrabState = grabState.open; } Grab(); } currentAction = 0; }
// Start is called before the first frame update // Use this for initialization void Start() { currentMovementState = movementState_t.idle; startPosition = transform.localPosition; clawHinges = new List <HingeJoint>(); //ok grab all mandible and chuck them into vector foreach (var iter in GetComponentsInChildren <HingeJoint>()) { clawHinges.Add(iter); } currentGrabState = grabState.open; Grab(); //SetupCallbacks(); }
public void Toggle() { //ok now set current toggle state and then call grab if (currentGrabState == grabState.closed) { currentGrabState = grabState.open; Grab(); return; } else if (currentGrabState == grabState.open) { currentGrabState = grabState.closed; Grab(); return; } }
public virtual void ChangeState(movementState_t newState) { currentMovementState = newState; switch (currentMovementState) { case movementState_t.idle: case movementState_t.forwards: case movementState_t.horizontally: case movementState_t.descending: { break; } case movementState_t.grabbing: { //open the crane, wait one second then start ascending currentGrabState = grabState.closed; Grab(); //onGrab(); break; } case movementState_t.ascending: { break; } case movementState_t.return_horizontally: { currentGrabState = grabState.open; Grab(); break; } case movementState_t.return_backwards: { OnReturnProc(System.EventArgs.Empty); break; } } }