public BoxState CreateState(BoxStates state) { switch (state) { case BoxStates.AtRest: { return(_atRestFactory.Create()); } case BoxStates.Move: { return(_moveFactory.Create()); } case BoxStates.FitPlatform: { return(_fitPlatformFactory.Create()); } case BoxStates.Stuck: { return(_stuckFactory.Create()); } } throw Assert.CreateException(); }
// Update is called once per frame void Update() { switch (boxState) { case BoxStates.NONE: break; case BoxStates.PICKED_UP: if (isGravityEnabled) { CalculateObjectVelocity(); } FollowPointer(); break; case BoxStates.PUT_DOWN: if (isGravityEnabled) { ApplyMomentumToObject(); } boxState = BoxStates.NONE; break; default: break; } }
// Use this for initialization void Awake() { boxState = BoxStates.NONE; pointer = GameObject.Find("Laser"); originalPosition = transform.position; rb = GetComponent <Rigidbody> (); isGravityEnabled = (rb) ? rb.useGravity : false; }
public void ChangeState(BoxStates state) { if (_state != null) { _state.Dispose(); _state = null; } _state = _stateFactory.CreateState(state); _state.Start(); }
private void Die(Collision collision) { BoxStates colState = collision.gameObject.GetComponent <BoxScript> ().State; if (colState == BoxStates.red) { collision.gameObject.SetActive(false); GameController.instance.EndGame(); if (playerTalk != null && deadSound != null) { playerCollect.clip = deadSound; playerCollect.Play(); } } }
private IEnumerator TurnBlue(float time) { yield return(new WaitForSeconds(time)); State = BoxStates.blue; }
public void RandomState() { int boxStatesCount = System.Enum.GetNames(typeof(BoxStates)).Length; State = (BoxStates)Random.Range(0, boxStatesCount); }
public void PutDown() { boxState = BoxStates.PUT_DOWN; }
public void PickUp() { boxState = BoxStates.PICKED_UP; }
private void TrackLeft() { boxStateLeft = FindBoxState(leftHandPosition.y); switch (boxStateLeft) { case BoxStates.LOWER: if (leftHandPosition.x > lowerXLeft) { lowerXLeft = leftHandPosition.x; } if (leftHandPosition.z > lowerZLeft) { lowerZLeft = leftHandPosition.z; } break; case BoxStates.MIDDLE: if (leftHandPosition.x > middleXLeft) { middleXLeft = leftHandPosition.x; } if (leftHandPosition.z > middleZLeft) { middleZLeft = leftHandPosition.z; } break; case BoxStates.UPPER: if (leftHandPosition.x > upperXLeft) { upperXLeft = leftHandPosition.x; } if (leftHandPosition.z > upperZLeft) { upperZLeft = leftHandPosition.z; } break; } if (upperZLeft > middleZLeft) { middleZLeft = upperZLeft; } if (upperXLeft > middleXLeft) { middleXLeft = upperXLeft; } if (middleZLeft > lowerZLeft) { lowerZLeft = middleZLeft; } if (middleXLeft > lowerXLeft) { lowerXLeft = middleXLeft; } if (leftHandPosition.y > yLeft) { yLeft = leftHandPosition.y; } }