// Update is called once per frame
 void move()
 {
     if (!automatic_play)
     {
         key_lock = false;
         foreach (KeyCode k in keys)
         {
             if (Input.GetKeyDown(k))
             {
                 if (!key_lock)
                 {
                     key_lock = true;
                     StageController.instance.movecount += 1;
                     grid_node target = sg.get_neighbour(current_node,
                                                         (SquareGrid.orientation)arrow_to_orientation[k]);
                     move_to_grid(sg, target);
                     StageController.instance.Stage_switch();
                 }
             }
         }
     }
     else
     {
         int       i      = Random.Range(0, 4);
         grid_node target = sg.get_neighbour(current_node, SquareGrid.Four_dir[i]);
         move_to_grid(sg, target);
         StageController.instance.movecount += 1;
         StageController.instance.Stage_switch();
     }
 }
Exemplo n.º 2
0
    //================================Visial Elements=====================================


    //===============================Random move=====================================
    void move(SquareGrid.orientation o)
    {
        //before move: chech whether go die


        grid_node target = sg.get_neighbour(current_node, o);

        move_to_grid(sg, target);

        if (target != null)
        {
            if (target.state == SquareGrid.grid_stat.exit)
            {
                StageController.instance.score_evador += 1;
                //remove self from board
                current_node.occupied = false;
                explode(Color.green);
                DestroyImmediate(gameObject);
            }
        }
    }
    void move(SquareGrid.orientation o)
    {
        grid_node target = sg.get_neighbour(current_node, o);

        move_to_grid(sg, target);
    }