void SetMoveDirection()
    {
        if (Input.GetKey(up))
        {
            upDown = moveDirection.up;
        }
        else if (Input.GetKey(down))
        {
            upDown = moveDirection.down;
        }
        else
        {
            upDown = moveDirection.none;
        }

        if (Input.GetKey(right))
        {
            leftRight = moveDirection.right;
        }
        else if (Input.GetKey(left))
        {
            leftRight = moveDirection.left;
        }
        else
        {
            leftRight = moveDirection.none;
        }
    }
示例#2
0
文件: Player.cs 项目: ZamTheman/BDash
 private void AddToLastClicked(moveDirection direction)
 {
     if (!lastPressed.Any(d => d == direction))
     {
         lastPressed.Add(direction);
     }
 }
示例#3
0
文件: view.cs 项目: scl8339702/2048
    /// <summary>
    /// 假装移动动画
    /// </summary>
    /// <param name="parent">初始位置</param>
    /// <param name="direction">移动方向(1。左,2.右,3.上,4.下)</param>
    /// /// <param name="veNumber">行数</param>
    /// /// <param name="hoNumber">列数</param>
    /// <param name="number">移动的数字</param>
    public void blockMove(GameObject parent, moveDirection direction, int veNumber, int hoNumber, int number)
    {
        GameObject bl = loadPreb(block, "moveAni", parent);

        setItemColor(bl, number);
        switch (direction)
        {
        case moveDirection.left:
            bl.transform.SetParent(gridGroup[veNumber * 4].transform);
            bl.transform.DOLocalMove(Vector3.zero, 0.07f).SetEase(Ease.Linear).OnComplete(() => Destroy(bl));
            break;

        case moveDirection.right:
            bl.transform.SetParent(gridGroup[veNumber * 4 + 3].transform);
            bl.transform.DOLocalMove(Vector3.zero, 0.07f).SetEase(Ease.Linear).OnComplete(() => Destroy(bl));
            break;

        case moveDirection.up:
            bl.transform.SetParent(gridGroup[hoNumber].transform);
            bl.transform.DOLocalMove(Vector3.zero, 0.07f).SetEase(Ease.Linear).OnComplete(() => Destroy(bl));
            break;

        case moveDirection.down:
            bl.transform.SetParent(gridGroup[12 + hoNumber].transform);
            bl.transform.DOLocalMove(Vector3.zero, 0.07f).SetEase(Ease.Linear).OnComplete(() => Destroy(bl));
            break;
        }
        bl.transform.SetAsFirstSibling();
    }
示例#4
0
    // Start is called before the first frame update
    void Start()
    {
        rb = GetComponent <Rigidbody2D>();
        currentDirection            = moveDirection.Down;
        grabArea.transform.position = rb.position + Vector2.zero;
        animator.SetFloat("Horizontal", 0);
        animator.SetFloat("Vertical", 0);

        print(grabArea);
    }
示例#5
0
文件: view.cs 项目: scl8339702/2048
    //前后比较,生成对应的数字
    public bool compareTZFZGrid(moveDirection direction)
    {
        bool isChange = false;

        for (int i = 0; i < 4; i++)
        {
            for (int j = 0; j < 4; j++)
            {
                if (tzfeGridBefor[i, j] < countModel.instance.tzfeGrid[i, j])
                {
                    int count = gridGroup[i * 4 + j].transform.childCount;
                    if (gridGroup[i * 4 + j].GetComponent <saveSighleBlock>().singleBlock != null)
                    {   //----如果前后对比增加了,且原来该位置有数字,直接重新设置数字的值
                        GameObject bl = gridGroup[i * 4 + j].GetComponent <saveSighleBlock>().singleBlock;
                        bl.SetActive(true);
                        setItemColor(bl, countModel.instance.tzfeGrid[i, j]);
                    }
                    else
                    {
                        //----如果前后对比增加了,且原来该位置没有数字,重新在此生成一个数字
                        GameObject bl = loadPreb(block, "singleBlock", gridGroup[i * 4 + j]);
                        gridGroup[i * 4 + j].GetComponent <saveSighleBlock>().singleBlock = bl;
                        setItemColor(bl, countModel.instance.tzfeGrid[i, j]);
                    }
                    tzfeGridBefor[i, j] = countModel.instance.tzfeGrid[i, j];
                    if (isChange == false)
                    {
                        isChange = true;
                    }
                }
                else if (tzfeGridBefor[i, j] > countModel.instance.tzfeGrid[i, j])
                {
                    GameObject bl = gridGroup[i * 4 + j].GetComponent <saveSighleBlock>().singleBlock;
                    if (countModel.instance.tzfeGrid[i, j] == 0)
                    {
                        //----如果前后对比减少了,且现在为0,直接隐藏数字
                        bl.SetActive(false);
                    }
                    else
                    {
                        //----如果前后对比减少了,且现在不为0,直接修改数字
                        setItemColor(bl, countModel.instance.tzfeGrid[i, j]);
                    }
                    blockMove(gridGroup[i * 4 + j], direction, i, j, tzfeGridBefor[i, j]);
                    tzfeGridBefor[i, j] = countModel.instance.tzfeGrid[i, j];
                    if (isChange == false)
                    {
                        isChange = true;
                    }
                }
            }
        }
        return(isChange);
    }
示例#6
0
 public Settings()
 {
     direction      = moveDirection.motionless;
     gameOver       = false;
     snakeLength    = 100;
     score          = 0;
     scorePoints    = 10;
     snakeColor     = Brushes.DarkGreen;
     plusFoodColor  = Brushes.DarkRed;
     minusFoodColor = Brushes.DarkSlateGray;
     head           = new Point(100, 100);
 }
示例#7
0
文件: Player.cs 项目: ZamTheman/BDash
 private void RemoveFromLastClicked(moveDirection direction)
 {
     if (lastPressed != null && lastPressed.Count > 0)
     {
         for (int i = 0; i < lastPressed.Count; i++)
         {
             if (lastPressed[i] == direction)
             {
                 lastPressed.RemoveAt(i);
             }
         }
     }
 }
示例#8
0
    void moveCharacter(moveDirection dir)
    {
        switch (dir)
        {
        case moveDirection.Left: rb.transform.position = new Vector3(transform.position.x - translateValueX,
                                                                     transform.position.y, transform.position.z);
            break;

        case moveDirection.Right: rb.transform.position = new Vector3(transform.position.x + translateValueX,
                                                                      transform.position.y, transform.position.z);
            break;
        }
    }
示例#9
0
文件: p1Tank.cs 项目: Myway01/Tank
        /// <summary>
        /// 按键控制移动,开火,暂停
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void gameForm_KeyDown(object sender, KeyEventArgs e)
        {
            //游戏进行阶段有效
            if (!gameMain.gameTankWar.IsStop && !gameMain.gameTankWar.IsGameOver)
            {
                switch (e.KeyCode)
                {
                case Keys.W:
                    yMove         = moveDirection.Up;
                    xMove         = moveDirection.Stop;
                    fireDirection = moveDirection.Up;
                    image         = Properties.Resources.p1tankU;
                    break;

                case Keys.S:
                    yMove         = moveDirection.Down;
                    xMove         = moveDirection.Stop;
                    fireDirection = moveDirection.Down;
                    image         = Properties.Resources.p1tankD;
                    break;

                case Keys.A:
                    xMove         = moveDirection.Left;
                    yMove         = moveDirection.Stop;
                    fireDirection = moveDirection.Left;
                    image         = Properties.Resources.p1tankL;
                    break;

                case Keys.D:
                    xMove         = moveDirection.Right;
                    yMove         = moveDirection.Stop;
                    fireDirection = moveDirection.Right;
                    image         = Properties.Resources.p1tankR;
                    break;

                case Keys.J:    //开火
                    Bullet bullet = new Bullet(1);
                    Fire(bullet);
                    break;
                }
            }
            if (e.KeyCode == Keys.P)//暂停
            {
                gameMain.gameTankWar.IsStop = !gameMain.gameTankWar.IsStop;
                System.Media.SoundPlayer sp = new System.Media.SoundPlayer(Properties.Resources.pause2);
                sp.Play();
            }
        }
示例#10
0
    void movement(moveDirection MoveDirection, KeyCode keyCode)
    {
        Vector3 v = vertices[num];

        if (keyCode == KeyCode.RightArrow || keyCode == KeyCode.LeftArrow)
        {
            v.x = MoveDirection();
        }
        else if (keyCode == KeyCode.UpArrow || keyCode == KeyCode.DownArrow)
        {
            v.z = MoveDirection();
        }



        cubesNodes[num].SetVertices(v, num);

        //cubesNodes[num].SetPosition(vertices[num]);
    }
示例#11
0
        public void MoveCanvas(Canvas moveCanvas, Canvas prevCanvas, moveDirection direction = moveDirection.horizontal,
                               int?newHeight = null)
        {
            double currentHeight = Application.Current.MainWindow.Height;

            moveCanvas.Visibility = Visibility.Visible;

            if ((newHeight != null) && (currentHeight > newHeight))
            {
                WindowResize(null, null, (int)newHeight);
            }

            double left = (direction == moveDirection.horizontal ? 0 : moveCanvas.Margin.Left);
            double top  = (direction == moveDirection.vertical ? 0 : moveCanvas.Margin.Top);

            ThicknessAnimation move = new ThicknessAnimation();

            move.Duration = TimeSpan.FromSeconds(0.2);
            move.From     = moveCanvas.Margin;

            move.To = new Thickness(left, top, moveCanvas.Margin.Right, moveCanvas.Margin.Bottom);

            moveCanvas.BeginAnimation(MarginProperty, move);

            left = (direction == moveDirection.horizontal ?
                    prevCanvas.Margin.Left - moveCanvas.Margin.Left : prevCanvas.Margin.Left);
            top = (direction == moveDirection.vertical ?
                   prevCanvas.Margin.Top - moveCanvas.Margin.Top : prevCanvas.Margin.Top);

            move.From = prevCanvas.Margin;

            move.To = new Thickness(left, top, prevCanvas.Margin.Right, prevCanvas.Margin.Bottom);

            move.Completed += new EventHandler((sender, e) => HidePrevCanvas(sender, e, prevCanvas));

            if ((newHeight != null) && (currentHeight < newHeight))
            {
                move.Completed += new EventHandler((sender, e) => WindowResize(sender, e, (int)newHeight));
            }

            prevCanvas.BeginAnimation(MarginProperty, move);
        }
示例#12
0
文件: p1Tank.cs 项目: Myway01/Tank
        /// <summary>
        /// 按键抬起移动停止,重新开始,退出
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        void gameForm_KeyUp(object sender, KeyEventArgs e)
        {
            switch (e.KeyCode)
            {
            case Keys.W:
            case Keys.S:
                yMove = moveDirection.Stop;
                break;

            case Keys.A:
            case Keys.D:
                xMove = moveDirection.Stop;
                break;

            case Keys.J:
                break;

            case Keys.O:
                //游戏结束状态下松开O键重新开始
                if (gameMain.gameTankWar.IsGameOver || gameMain.gameTankWar.IsGameWin)
                {
                    gameMain.gameForm.KeyUp   -= new KeyEventHandler(gameForm_KeyUp);
                    gameMain.gameForm.KeyDown -= new KeyEventHandler(gameForm_KeyDown);
                    gameMain.ListAnimation     = new List <Animation>();
                    gameMain.gamep1Tank        = new p1Tank();
                    gameMain.gameProductTank   = new ProductTank();
                    gameMain.gameMap           = new Map();
                    gameMain.gameCheckHit      = new CheckHit();
                    gameMain.ListBullet        = new List <Bullet>();
                    gameMain.ListeTank         = new List <eTank>();
                    gameMain.gameTankWar       = new TankWar();
                    gameMain.gamePanelDraw     = new PanelDraw();
                    System.Media.SoundPlayer sp = new System.Media.SoundPlayer(Properties.Resources.start);
                    sp.Play();
                }
                break;

            case Keys.Escape:
                Application.Exit();    //退出
                break;
            }
        }
示例#13
0
文件: Player.cs 项目: exlted/Why
 public bool Move(moveDirection MoveDirection, float Distance = 1)
 {
     switch(MoveDirection)
     {
         case moveDirection.Up:
             pos.Y -= Distance;
             return true;
         case moveDirection.Down:
             pos.Y += Distance;
             return true;
         case moveDirection.Left:
             pos.X -= Distance;
             return true;
         case moveDirection.Right:
             pos.X += Distance;
             return true;
         default:
             return false;
     }
 }
示例#14
0
    public void moveNumber(moveDirection direction)
    {
        switch (direction)
        {
        case moveDirection.left:
            moveLeft();
            break;

        case moveDirection.right:
            moveRight();
            break;

        case moveDirection.up:
            moveUp();
            break;

        case moveDirection.down:
            moveDown();
            break;
        }
    }
示例#15
0
    // --------------------------------------------------------------------
    //                                      Input
    // --------------------------------------------------------------------
    void Update()
    {
        moveDir = Vector2.zero;
        // Get raw so that we go directly to 0 - 1
        moveDir.x = Input.GetAxisRaw("Horizontal");
        moveDir.y = Input.GetAxisRaw("Vertical");

        float absX = Mathf.Abs(moveDir.x);
        float absY = Mathf.Abs(moveDir.y);

        if (absX > absY)
        {
            if (moveDir.x > 0)
            {
                currentDirection            = moveDirection.Right;
                grabArea.transform.position = rb.position + Vector2.right;
            }
            else if (moveDir.x < 0)
            {
                currentDirection            = moveDirection.Left;
                grabArea.transform.position = rb.position + Vector2.left;
            }
        }
        else if (absX < absY)
        {
            if (moveDir.y > 0)
            {
                currentDirection            = moveDirection.Up;
                grabArea.transform.position = rb.position + Vector2.up / 2;
            }
            else if (moveDir.y < 0)
            {
                currentDirection            = moveDirection.Down;
                grabArea.transform.position = rb.position + Vector2.down;
            }
        }

        //print("{" + absX + "," + absY + "}" + "- " + currentDirection.ToString());
    }
示例#16
0
  /*  void BackgroundMoveLeftOrRight()
    {


        if (backgroundDirection == moveDirection.RIGHT && counter < BackgroundImages.Length -1  )
        {
            BackgroundImages[counter].transform.position = new Vector2(xLeftBackground, 0);
            backgroundcounter++;
            BackgroundImages[counter].transform.position = new Vector2(middleBackground, 0);

        }


        if (backgroundDirection == moveDirection.LEFT && backgroundcounter > 0)
        {
            BackgroundImages[backgroundcounter].transform.localPosition = new Vector2(xRightBacground, 0);
            backgroundcounter--;
            BackgroundImages[backgroundcounter].transform.localPosition = new Vector2(middleBackground, 0);
        }
      

        backgroundDirection = moveDirection.MIDDLE;

    }*/
    public void moveRight()
    { 
        panelDirection = moveDirection.RIGHT;

        backgroundDirection = moveDirection.RIGHT;
    }
示例#17
0
 public void moveLeft()
 {
     panelDirection = moveDirection.LEFT;
     backgroundDirection = moveDirection.LEFT;
     
 }
示例#18
0
    void PanelMoveLeftOrRight()
    {
        
        
            if (panelDirection == moveDirection.RIGHT && counter < 5)
            {
                if (!hasReachedDestination)
                {
                    Panel[counter].transform.localPosition = Vector2.MoveTowards(Panel[counter].transform.localPosition, new Vector2(xLeft, 0), 100);
                    BackgroundImages[counter].transform.position =  Vector2.MoveTowards( BackgroundImages[counter].transform.position,new Vector2 (xLeftBackground, 0),1);

                    if (Panel[counter].transform.localPosition == new Vector3(xLeft, 0, 0) && BackgroundImages[counter].transform.position == new Vector3(xLeftBackground,0) )
                    {
                        
                        
                            counter++;
                            hasReachedDestination = true;
                        
                    }
                }

                if (hasReachedDestination)
                {
                    Panel[counter].transform.localPosition =Vector2.MoveTowards(Panel[counter].transform.localPosition, new Vector2(middle, 0),100);
                    BackgroundImages[counter].transform.position = Vector2.MoveTowards(BackgroundImages[counter].transform.position, new Vector2(middleBackground, 0), 1);
                }
                if (Panel[counter].transform.localPosition == new Vector3(middle, 0, 0) && BackgroundImages[counter].transform.position == new Vector3(middleBackground, 0, 0))
                {
                    hasReachedDestination = false;
                    hasCheckedStage = true;
                    panelDirection = moveDirection.MIDDLE;
                }
               
            }
        


            if (panelDirection == moveDirection.LEFT && counter >= 0 )
            {
                if (!hasReachedDestination)
                {
                    Panel[counter].transform.localPosition = Vector2.MoveTowards(Panel[counter].transform.localPosition, new Vector2(xRight, 0), 100);
                    BackgroundImages[counter].transform.position =  Vector2.MoveTowards( BackgroundImages[counter].transform.position,new Vector2 (xRightBackground, 0),1);



                    if (Panel[counter].transform.localPosition == new Vector3(xRight, 0, 0) && BackgroundImages[counter].transform.position == new Vector3(xRightBackground, 0,0))
                    {
                        counter--;
                        hasReachedDestination = true;
                    }
                }

                if (hasReachedDestination)
                {
                    Panel[counter].transform.localPosition = Vector2.MoveTowards(Panel[counter].transform.localPosition, new Vector2(middle, 0), 100);
                    BackgroundImages[counter].transform.position = Vector2.MoveTowards(BackgroundImages[counter].transform.position, new Vector2(middleBackground, 0), 1);

                    if (Panel[counter].transform.localPosition == new Vector3(middle, 0, 0) && BackgroundImages[counter].transform.position == new Vector3(middleBackground, 0,0))
                    {
                        hasReachedDestination = false;
                        hasCheckedStage = true;
                        panelDirection = moveDirection.MIDDLE;
                    }
                }
              
            }
            if (counter == Panel.Length -1)
            {
                rightButton.enabled = false;
                rightButton.interactable = false;
                rightButton.GetComponentInChildren<CanvasRenderer>().SetAlpha(0);

            }
            else
            {
                rightButton.enabled = true;
                rightButton.interactable = true;
                rightButton.GetComponentInChildren<CanvasRenderer>().SetAlpha(1);
            }
            if (counter == 0)
            {
                leftButton.enabled = false;
                leftButton.interactable = false;
                leftButton.GetComponentInChildren<CanvasRenderer>().SetAlpha(0);

            }
            else
            {
               leftButton.enabled = true;
               leftButton.interactable = true;
               leftButton.GetComponentInChildren<CanvasRenderer>().SetAlpha(1);
            }
        
   //   panelDirection = moveDirection.MIDDLE;
    
    }
示例#19
0
 // Use this for initialization
 void Start()
 {
     curMoveDirection = moveDirection.down;
 }
示例#20
0
    public override string GetMark()
    {
        // if detect hands change state machine.
        //Debug.Log(currDirection);

        if (handTrackingValue != null && handTrackingValue.PalmDetections != null && handTrackingValue.PalmDetections.Count > 0)
        {
            // blue color one...

            float width  = (float)handTrackingValue.PalmDetections[0].LocationData.RelativeBoundingBox.Width;
            float height = (float)handTrackingValue.PalmDetections[0].LocationData.RelativeBoundingBox.Height;
            // center of the X and Y
            float currX = width / 2 + (float)handTrackingValue.PalmDetections[0].LocationData.RelativeBoundingBox.Xmin;
            float currY = height / 2 + (float)handTrackingValue.PalmDetections[0].LocationData.RelativeBoundingBox.Ymin;

            // the filter to remove noise rect...
            if (width >= noise_radio_ratio && height >= noise_radio_ratio)
            {
                // send landmark here:
                if (handTrackingValue.HandLandmarkLists != null && handTrackingValue.HandLandmarkLists.Count > 0)
                {
                    NormalizedLandmarkList landmarks = handTrackingValue.HandLandmarkLists[0];
                    for (int i = 0; i < landmarks.Landmark.Count; i++)
                    {
                        float tempX, tempY, tempZ;
                        tempX = landmarks.Landmark[i].X;
                        tempY = landmarks.Landmark[i].Y;
                        tempZ = landmarks.Landmark[i].Z;
                        string temp = handsLandmarkMessage + "X=&" + tempX + "Y=&" + tempY + "Z=&" + tempZ;
                        MessageMgr.GetIns().Dispatch("HandMessage", temp);
                    }
                    //Debug.Log(landmarks.Landmark[0].X + "  ,  " + landmarks.Landmark[0].Y);
                }

                if (currState == handState.outScreen)
                {
                    /*
                     *   outScreen state.
                     *   once we detect the hand show in screen, There will be two situation,
                     *   1. first time came into the screen.
                     *   2. the hand left screen because of the move command..
                     *   For the first situation, We set a 3s frozon time,( just change the handState to move. and set time);
                     *   For the second situation. We should not change the original time,
                     *   because it's an instant state, we don't need to update location data, the location will be modified inside move state.
                     *
                     *   by combining this two situations, we need set a relative small time, (say frozen_time/2) to fit the both cases.
                     */

                    currState  = handState.move;
                    originTime = Time.time - freeze_time / 2;
                }
                else if (currState == handState.move)
                {
                    /*
                     *
                     *   move state
                     *   we set a frozon time, within it the program won't detect any move you've down.
                     *   but we will track your current position.
                     *   Time.time return current program running time.  1.0000s,  2.38491s......
                     */

                    originX = currX;
                    originY = currY;
                    if ((Time.time - originTime) > freeze_time)
                    {
                        // Frozon time end, change state to idle, ready to detect new action, Sync the time to current time.
                        currState     = handState.idle;
                        originTime    = Time.time;
                        currDirection = moveDirection.direction_idle;
                    }
                    else
                    {
                        // Frozon time, do nothing here..
                    }
                }
                else if (currState == handState.idle)
                {
                    /*
                     *
                     *   idle state
                     *   In this state, we detect hand shape instantly, (hand spread out, fist)
                     *   And we are ready to detect hand move direction (left, right, up, down)
                     *   If we detect a long range move, we change state to idle, change hand position to move direction, and start frozon time.
                     *
                     */


                    // detect hand shape by calculate vector.

                    if (handTrackingValue != null && handTrackingValue.HandLandmarkLists != null && handTrackingValue.HandLandmarkLists.Count > 0)
                    {
                        NormalizedLandmarkList landmarks = handTrackingValue.HandLandmarkLists[0];
                        Vector2[] cordinates             = new Vector2[landmarks.Landmark.Count];
                        for (int i = 0; i < cordinates.Length; i++)
                        {
                            cordinates[i] = new Vector2(landmarks.Landmark[i].X, landmarks.Landmark[i].Y);
                        }
                        Vector2 vector68   = cordinates[8] - cordinates[6];
                        Vector2 vector56   = cordinates[6] - cordinates[5];
                        Vector2 vector1012 = cordinates[12] - cordinates[10];
                        Vector2 vector910  = cordinates[10] - cordinates[9];
                        Vector2 vector1416 = cordinates[16] - cordinates[14];
                        Vector2 vector1314 = cordinates[14] - cordinates[13];
                        Vector2 vector1820 = cordinates[20] - cordinates[18];
                        Vector2 vector1718 = cordinates[18] - cordinates[17];

                        // the angle between some knuckles.

                        float angle_index  = Vector2.Angle(vector68, vector56);
                        float angle_middle = Vector2.Angle(vector910, vector1012);
                        float angle_ring   = Vector2.Angle(vector1314, vector1416);
                        float angle_pinky  = Vector2.Angle(vector1718, vector1820);

                        if (angle_index <= hand_spread_out_angle && angle_middle <= hand_spread_out_angle &&
                            angle_ring <= hand_spread_out_angle && angle_pinky <= hand_spread_out_angle)
                        {
                            //Debug.Log("finger_spread_out");
                            currShape = handShape.finger_spread_out;
                        }
                        else if (angle_index >= fist_angle && angle_middle >= fist_angle &&
                                 angle_ring >= fist_angle && angle_pinky >= fist_angle)
                        {
                            //Debug.Log("fist");
                            currShape = handShape.fist;
                        }
                        else
                        {
                            // none shape
                            currShape = handShape.none;
                        }
                    }


                    // calculate hand move direction.
                    float diffX = currX - originX;
                    float diffY = currY - originY;
                    if (Mathf.Abs(diffX) > 0.15 || Mathf.Abs(originY - currY) > 0.15)
                    {
                        currState  = handState.move;
                        originX    = currX;
                        originY    = currY;
                        originTime = Time.time;

                        // define which derection it move...
                        // first we just compare diff scale regrad horizontal and vertical...
                        if (Mathf.Pow(diffX, 2) - Mathf.Pow(diffY, 2) > 0)
                        {
                            // x is larger.
                            if (diffX > 0)
                            {
                                currDirection = moveDirection.right;
                            }
                            else
                            {
                                currDirection = moveDirection.left;
                            }
                        }
                        else
                        {
                            if (diffY > 0)
                            {
                                currDirection = moveDirection.down;
                            }
                            else
                            {
                                currDirection = moveDirection.up;
                            }
                        }
                    }
                    string temp = handShapeDirectionMessage + "Gesture=&" + currShape + "Direction=&" + currDirection;
                    MessageMgr.GetIns().Dispatch("HandMessage", temp);
                    Debug.Log(currShape + "  ,  " + currDirection);
                }
            }
        }
        else
        {
            currState = handState.outScreen;
        }
        return(null);
    }
示例#21
0
 // Use this for initialization
 void Start()
 {
     curMoveDirection = moveDirection.down;
 }
示例#22
0
    private void NpcMove(moveDirection direction)
    {
        RaycastHit hit1, hit2, hit3, hit4;

        switch (direction)
        {
        case moveDirection.up:
            Ray rayup = new Ray(transform.parent.transform.position, transform.parent.transform.transform.up);
            if (Physics.Raycast(rayup, out hit1, rayheight))
            {
                if (hit1.collider.tag == "cube")
                {
                    Debug.Log(this.transform.parent.name + " " + this.name + "hit up");
                    this.transform.parent           = hit1.transform;
                    this.transform.localPosition    = new Vector3(0f, -0.4f, -0.25f);
                    this.transform.localEulerAngles = new Vector3(0f, 180f, 0f);
                    this.transform.localScale       = new Vector3(0.15f, 0.15f, 0.6f);
                }
            }
            break;

        case moveDirection.down:
            Ray raydown = new Ray(transform.parent.transform.position, -transform.parent.transform.up);
            if (Physics.Raycast(raydown, out hit2, rayheight))
            {
                if (hit2.collider.tag == "cube")
                {
                    Debug.Log(this.transform.parent.name + " " + this.name + "hit down");
                    this.transform.parent           = hit2.transform;
                    this.transform.localPosition    = new Vector3(0f, -0.4f, -0.25f);
                    this.transform.localEulerAngles = new Vector3(0f, 180f, 0f);
                    this.transform.localScale       = new Vector3(0.15f, 0.15f, 0.6f);
                }
            }
            break;

        case moveDirection.left:
            Ray rayleft = new Ray(transform.parent.transform.position, -transform.parent.transform.right);
            if (Physics.Raycast(rayleft, out hit3, rayheight))
            {
                if (hit3.collider.tag == "cube")
                {
                    Debug.Log(this.transform.parent.name + " " + this.name + "hit left");
                    this.transform.parent           = hit3.transform;
                    this.transform.localPosition    = new Vector3(0f, -0.4f, -0.25f);
                    this.transform.localEulerAngles = new Vector3(0f, 180f, 0f);
                    this.transform.localScale       = new Vector3(0.15f, 0.15f, 0.6f);
                }
            }
            break;

        case moveDirection.right:
            Ray rayright = new Ray(transform.parent.transform.position, transform.parent.transform.right);
            if (Physics.Raycast(rayright, out hit4, rayheight))
            {
                if (hit4.collider.tag == "cube")
                {
                    Debug.Log(this.transform.parent.name + " " + this.name + "hit right");
                    this.transform.parent           = hit4.transform;
                    this.transform.localPosition    = new Vector3(0f, -0.4f, -0.25f);
                    this.transform.localEulerAngles = new Vector3(0f, 180f, 0f);
                    this.transform.localScale       = new Vector3(0.15f, 0.15f, 0.6f);
                }
            }
            break;

        default:
            break;
        }
    }