Exemplo n.º 1
0
 public void setVision(VisionPosition objPosition, Tile obj)
 {
     objectVision[(int)objPosition] = obj;
 }
Exemplo n.º 2
0
 public Tile getVision(VisionPosition objPosition)
 {
     return(objectVision[(int)objPosition]);
 }
    public IEnumerator MoveToDirection(VisionPosition newPosition)
    {
        if (_rotating)
        {
            yield break;
        }
        if (newPosition == position)
        {
            yield break;
        }

        _rotating = true;

        float angle = 0;

        switch (position)
        {
        case VisionPosition.Front:
            if (newPosition == VisionPosition.Right)
            {
                angle = 90;
            }
            else if (newPosition == VisionPosition.Back)
            {
                angle = 180;
            }
            else if (newPosition == VisionPosition.Left)
            {
                angle = -90;
            }

            break;

        case VisionPosition.Right:
            if (newPosition == VisionPosition.Back)
            {
                angle = 90;
            }
            else if (newPosition == VisionPosition.Left)
            {
                angle = 180;
            }
            else if (newPosition == VisionPosition.Front)
            {
                angle = -90;
            }

            break;

        case VisionPosition.Back:
            if (newPosition == VisionPosition.Left)
            {
                angle = 90;
            }
            else if (newPosition == VisionPosition.Front)
            {
                angle = 180;
            }
            else if (newPosition == VisionPosition.Right)
            {
                angle = -90;
            }

            break;

        case VisionPosition.Left:
            if (newPosition == VisionPosition.Front)
            {
                angle = 90;
            }
            else if (newPosition == VisionPosition.Right)
            {
                angle = 180;
            }
            else if (newPosition == VisionPosition.Back)
            {
                angle = -90;
            }
            break;
        }

        int numFrames = (int)(angle / (rotationSpeed * Time.fixedDeltaTime));

        for (int frame = 0; frame < numFrames; frame++)
        {
            parentLookout.Rotate(0f, rotationSpeed * Time.fixedDeltaTime, 0f);

            yield return(new WaitForFixedUpdate());
        }

        _rotating = false;
    }