Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0) && isPlaying == true)
        {
            //クリックしたキャラを動かす
            clickedGameObject = null;

            Ray          ray   = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit2D hit2d = Physics2D.Raycast((Vector2)ray.origin, (Vector2)ray.direction);

            if (hit2d)
            {
                clickedGameObject = hit2d.transform.gameObject;
            }
            if (script_1.v_direction == 4 && script_2.v_direction == 4)
            {
                if (clickedGameObject.name == "Player_1")
                {
                    Debug.Log(clickedGameObject);
                    //        hit2d.collider.gameObject.GetComponent<MoveTest>().selected_flg = true;
                    script_1.ChangeTrue();
                    script_2.ChangeFalse();
                    script_3.ChangeFalse();
                    script_4.ChangeFalse();
                }
                else if (clickedGameObject.name == "Player_2")
                {
                    script_1.ChangeFalse();
                    script_2.ChangeTrue();
                    script_3.ChangeFalse();
                    script_4.ChangeFalse();
                }
                else if (clickedGameObject.name == "Player_3")
                {
                    script_1.ChangeFalse();
                    script_2.ChangeFalse();
                    script_3.ChangeTrue();
                    script_4.ChangeFalse();
                }
                else if (clickedGameObject.name == "Player_4")
                {
                    script_1.ChangeFalse();
                    script_2.ChangeFalse();
                    script_3.ChangeFalse();
                    script_4.ChangeTrue();
                }
            }
        }
        else if (isPlaying == false)
        {
            script_1.ChangeFalse();
            script_2.ChangeFalse();
            script_3.ChangeFalse();
            script_4.ChangeFalse();
        }
    }