コード例 #1
0
    private void standWatch()
    {
        anim.enabled = false;
        switch (direction)
        {
        case Direction.Up:
            spriteR.sprite = sprites[6];
            ChildCatchPlayer.turn(180);
            break;

        case Direction.Left:
            spriteR.sprite = sprites[0];
            ChildCatchPlayer.turn(270);
            break;

        case Direction.Down:
            spriteR.sprite = sprites[2];
            ChildCatchPlayer.turn(0);
            break;

        case Direction.Right:
            spriteR.sprite = sprites[5];
            ChildCatchPlayer.turn(90);
            break;
        }
    }
コード例 #2
0
    private void move(float turnValue)
    {
        float currentX = transform.position.x;
        float currentY = transform.position.y;
        float x;
        float y;
        float xDiff = lastX - currentX;
        float yDiff = lastY - currentY;

        if (xDiff > turnValue)
        {
            // moving left
            x = -1f;
            ChildCatchPlayer.turn(270);
        }
        else if (xDiff < -turnValue)
        {
            // moving right
            x = 1f;
            ChildCatchPlayer.turn(90);
        }
        else
        {
            // not moving horizontally
            x = 0f;
        }
        if (yDiff > turnValue)
        {
            // moving down
            y = -1f;
            ChildCatchPlayer.turn(0);
        }
        else if (yDiff < -turnValue)
        {
            // moving up
            y = 1f;
            ChildCatchPlayer.turn(180);
        }
        else
        {
            // not moving vertically
            y = 0f;
        }
        lastX = transform.position.x;
        lastY = transform.position.y;
        anim.SetFloat("MoveX", x);
        anim.SetFloat("MoveY", y);
    }
コード例 #3
0
 private void rotate(string direction)
 {
     if (direction == up)
     {
         ChildCatchPlayer.turn(180);
         spriteR.sprite = sprites[6];
     }
     else if (direction == left)
     {
         ChildCatchPlayer.turn(270);
         spriteR.sprite = sprites[0];
     }
     else if (direction == down)
     {
         ChildCatchPlayer.turn(0);
         spriteR.sprite = sprites[2];
     }
     else if (direction == right)
     {
         ChildCatchPlayer.turn(90);
         spriteR.sprite = sprites[5];
     }
 }