Пример #1
0
    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();
    }
Пример #2
0
    // 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;
        }
    }
Пример #3
0
 // Use this for initialization
 void Awake()
 {
     boxState         = BoxStates.NONE;
     pointer          = GameObject.Find("Laser");
     originalPosition = transform.position;
     rb = GetComponent <Rigidbody> ();
     isGravityEnabled = (rb) ? rb.useGravity : false;
 }
Пример #4
0
    public void ChangeState(BoxStates state)
    {
        if (_state != null)
        {
            _state.Dispose();
            _state = null;
        }

        _state = _stateFactory.CreateState(state);
        _state.Start();
    }
Пример #5
0
    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();
            }
        }
    }
Пример #6
0
    private IEnumerator TurnBlue(float time)
    {
        yield return(new WaitForSeconds(time));

        State = BoxStates.blue;
    }
Пример #7
0
    public void RandomState()
    {
        int boxStatesCount = System.Enum.GetNames(typeof(BoxStates)).Length;

        State = (BoxStates)Random.Range(0, boxStatesCount);
    }
Пример #8
0
 public void PutDown()
 {
     boxState = BoxStates.PUT_DOWN;
 }
Пример #9
0
 public void PickUp()
 {
     boxState = BoxStates.PICKED_UP;
 }
Пример #10
0
 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;
     }
 }