Пример #1
0
 /// <summary>
 /// is01SameValue check same return 0 or 1 , for math calculate
 /// </summary>
 /// <param name="c1"></param>
 /// <param name="c2"></param>
 /// <returns></returns>
 int is01SameValue(CtrolObject c1, CtrolObject c2)
 {
     if (c1 == c2)
     {
         return(1);
     }
     return(0);
 }
Пример #2
0
    /// <summary>
    /// up / left key handle
    /// change value by CtrolObject type
    /// </summary>
    void holdDirKey()
    {
        if (Input.GetKey(KeyCode.R))
        {
            ctrol_object = CtrolObject.C_COLOR_R;
            showInfor("change color red now");
        }
        else if (Input.GetKey(KeyCode.G))
        {
            ctrol_object = CtrolObject.C_COLOR_G;
            showInfor("change color green now");
        }
        else if (Input.GetKey(KeyCode.B))
        {
            ctrol_object = CtrolObject.C_COLOR_B;
            showInfor("change color blue now");
        }
        else if (Input.GetKey(KeyCode.M))
        {
            ctrol_object = CtrolObject.C_GRID;
            //showInfor("change grid now");
        }

        if (ctrol_object == CtrolObject.C_GRID && showGrid)
        {
            if (Input.GetKeyUp(KeyCode.D))
            {
                int[] move_dir = new int[] { 1, 0 };
                move_ctrl_pt(move_dir);
            }
            if (Input.GetKeyUp(KeyCode.A))
            {
                int[] move_dir = new int[] { -1, 0 };
                move_ctrl_pt(move_dir);
            }
            if (Input.GetKeyUp(KeyCode.W))
            {
                int[] move_dir = new int[] { 0, 1 };
                move_ctrl_pt(move_dir);
            }
            if (Input.GetKeyUp(KeyCode.S))
            {
                int[] move_dir = new int[] { 0, -1 };
                move_ctrl_pt(move_dir);
            }

            Vector2 move_shift = Vector2.zero;
            bool    findMove   = false;
            if (Input.GetKey(KeyCode.UpArrow))
            {
                move_shift = new Vector2(0, 0.0005f * shift_amount);
                findMove   = true;
            }
            if (Input.GetKey(KeyCode.DownArrow))
            {
                move_shift = new Vector2(0, -0.0005f * shift_amount);
                findMove   = true;
            }
            if (Input.GetKey(KeyCode.LeftArrow))
            {
                move_shift = new Vector2(-0.0005f * shift_amount, 0);
                findMove   = true;
            }
            if (Input.GetKey(KeyCode.RightArrow))
            {
                move_shift = new Vector2(0.0005f * shift_amount, 0);
                findMove   = true;
            }
            if (findMove)
            {
                getActiveScreen().set_move_gird(move_shift);
            }
        }
        else if (ctrol_object == CtrolObject.C_COLOR_R || ctrol_object == CtrolObject.C_COLOR_G || ctrol_object == CtrolObject.C_COLOR_B)
        {
            Vector3 color_shift = Vector3.zero;
            bool    findMove    = false;
            if (Input.GetKey(KeyCode.UpArrow) || Input.GetKey(KeyCode.LeftArrow))
            {
                float mount = -0.001f * shift_amount;
                color_shift = new Vector3(is01SameValue(ctrol_object, CtrolObject.C_COLOR_R),
                                          is01SameValue(ctrol_object, CtrolObject.C_COLOR_G),
                                          is01SameValue(ctrol_object, CtrolObject.C_COLOR_B)) * mount;
                findMove = true;
            }
            if (Input.GetKey(KeyCode.DownArrow) || Input.GetKey(KeyCode.RightArrow))
            {
                float mount = 0.001f * shift_amount;
                color_shift = new Vector3(is01SameValue(ctrol_object, CtrolObject.C_COLOR_R),
                                          is01SameValue(ctrol_object, CtrolObject.C_COLOR_G),
                                          is01SameValue(ctrol_object, CtrolObject.C_COLOR_B)) * mount;
                findMove = true;
            }
            if (findMove)
            {
                getActiveScreen().set_screen_color(color_shift);
                RGB_base = getActiveScreen().get_screen_color();
            }
        }
    }