コード例 #1
0
ファイル: edito_mgr.cs プロジェクト: kawanekoex/sep_campus
    private void set_block2(int id, Vector3Int set_index)
    {
        //サイズ更新
        if (set_index.x > max_size.x)
        {
            max_size.x = set_index.x;
        }
        if (set_index.y > max_size.y)
        {
            max_size.y = set_index.y;
        }
        if (set_index.z > max_size.z)
        {
            max_size.z = set_index.z;
        }

        if (set_index.x < min_size.x)
        {
            min_size.x = set_index.x;
        }
        if (set_index.y < min_size.x)
        {
            min_size.y = set_index.y;
        }
        if (set_index.z < min_size.x)
        {
            min_size.z = set_index.z;
        }



        //ブロック生成
        Block b = new Block();

        b.draw_frag = true;
        b.id        = id;
        b.obj       = Instantiate(draw_obj, new Vector3(0, 0, 0), Quaternion.identity);
        b.obj.transform.localScale    = transform.localScale;
        b.obj.transform.parent        = transform;
        b.obj.transform.localPosition = new Vector3(set_index.x * Define.BLOCK_SIZE, set_index.y * Define.BLOCK_SIZE, set_index.z * Define.BLOCK_SIZE);
        block_mgr b_m = b.obj.GetComponent <block_mgr>();

        b_m.block_mat = mat;
        b_m.index     = set_index;
        b_m.data      = b;
        //ログ追加
        b_log.Add(new block_log(false, set_index, b));
    }
コード例 #2
0
ファイル: edito_mgr.cs プロジェクト: kawanekoex/sep_campus
    // Start is called before the first frame update
    void Start()
    {
        //stage_size.Set(5, 5, 5);
        //block = new Block[stage_size.z, stage_size.y, stage_size.x];


        ////オブジェクト生成
        //for (int z = 0; z < stage_size.z; z++)
        //{
        //	for (int y = 0; y < stage_size.y; y++)
        //	{
        //		for (int x = 0; x < stage_size.x; x++)
        //		{
        //			block[z, y, x].draw_frag = true;
        //			block[z, y, x].obj = Instantiate(draw_obj, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity);
        //			block[z, y, x].obj.transform.localScale = transform.localScale;
        //			block[z, y, x].obj.transform.parent = transform;
        //			block[z, y, x].obj.transform.localPosition = new Vector3((1.0f * x) - (stage_size.x / 2), (1.0f * y) - (stage_size.y / 2), (1.0f * z) - (stage_size.z / 2));
        //			block_mgr mgr = block[z, y, x].obj.GetComponent<block_mgr>();
        //			mgr.block_mat = mat;
        //			mgr.data = block[z, y, x];
        //			mgr.index = new Vector3Int(x, y, z);
        //		}
        //	}
        //}

        //中心設定



        //ブロック生成
        Block b = new Block();

        b.draw_frag = true;
        b.id        = 0;
        b.obj       = Instantiate(draw_obj, new Vector3(0, 0, 0), Quaternion.identity);
        b.obj.transform.localScale    = transform.localScale;
        b.obj.transform.parent        = transform;
        b.obj.transform.localPosition = new Vector3(0, 0, 0);
        block_mgr b_m = b.obj.GetComponent <block_mgr>();

        b_m.block_mat = mat;
        b_m.index     = new Vector3Int(0, 0, 0);
        b_m.data      = b;
    }
コード例 #3
0
ファイル: edito_mgr.cs プロジェクト: kawanekoex/sep_campus
    // Update is called once per frame
    void Update()
    {
        ray = m_camera.ScreenPointToRay(Input.mousePosition);

        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            GameObject obj = hit.collider.gameObject;
            block_mgr  mgr = obj.GetComponent <block_mgr>();
            mgr.hit_frag = true;
            Block b = mgr.data;

            if (mode == Define.MODE_NUM.MAIN)
            {
                //置く
                if (Input.GetMouseButtonDown(0))
                {
                    Vector3 inst = hit.point - hit.collider.gameObject.transform.localPosition;

                    Vector3Int index_pos = mgr.index;
                    //int list_index_pos = mgr.list_index;

                    if (inst.x >= 0.5)
                    {
                        Vector3Int set_index = new Vector3Int(index_pos.x + 1, index_pos.y, index_pos.z);
                        //if (set_index.x < stage_size.x && !block[set_index.z, set_index.y, set_index.x].draw_frag)
                        //{
                        //	set_block(set_index);

                        //}
                        if (b.draw_frag)
                        {
                            set_block2(1, set_index);
                        }
                    }
                    else if (inst.x <= -0.5)
                    {
                        Vector3Int set_index = new Vector3Int(index_pos.x - 1, index_pos.y, index_pos.z);
                        //if (set_index.x >= 0 && !block[set_index.z, set_index.y, set_index.x].draw_frag)
                        //{
                        //	set_block(set_index);

                        //}
                        if (b.draw_frag)
                        {
                            set_block2(1, set_index);
                        }
                    }
                    else if (inst.y >= 0.5)
                    {
                        Vector3Int set_index = new Vector3Int(index_pos.x, index_pos.y + 1, index_pos.z);
                        //if (set_index.y < stage_size.y && !block[set_index.z, set_index.y, set_index.x].draw_frag)
                        //{
                        //	set_block(set_index);

                        //}
                        if (b.draw_frag)
                        {
                            set_block2(1, set_index);
                        }
                    }
                    else if (inst.y <= -0.5)
                    {
                        Vector3Int set_index = new Vector3Int(index_pos.x, index_pos.y - 1, index_pos.z);
                        //if (set_index.y >= 0 && !block[set_index.z, set_index.y, set_index.x].draw_frag)
                        //{
                        //	set_block(set_index);

                        //}
                        if (b.draw_frag)
                        {
                            set_block2(1, set_index);
                        }
                    }
                    else if (inst.z >= 0.5)
                    {
                        Vector3Int set_index = new Vector3Int(index_pos.x, index_pos.y, index_pos.z + 1);
                        //if (set_index.z < stage_size.y && !block[set_index.z, set_index.y, set_index.x].draw_frag)
                        //{
                        //	set_block(set_index);

                        //}
                        if (b.draw_frag)
                        {
                            set_block2(1, set_index);
                        }
                    }
                    else if (inst.z <= -0.5)
                    {
                        Vector3Int set_index = new Vector3Int(index_pos.x, index_pos.y, index_pos.z - 1);
                        //if (set_index.z >= 0 && !block[set_index.z, set_index.y, set_index.x].draw_frag)
                        //{
                        //	set_block(set_index);

                        //}
                        if (b.draw_frag)
                        {
                            set_block2(1, set_index);
                        }
                    }

                    //block[index_pos.z, index_pos.y, index_pos.x].draw_frag = false;
                    //Destroy(hit.collider.gameObject);
                }

                //削る
                if (Input.GetMouseButtonDown(1))
                {
                    if (b.id != 0)
                    {
                        Vector3Int index_pos = mgr.index;
                        //int list_index_pos = mgr.list_index;

                        b_log.Add(new block_log(true, index_pos, b));
                        Destroy(hit.collider.gameObject);
                    }
                }
            }
            else if (mode == Define.MODE_NUM.MAT_SET)
            {
                //色変更
                if (Input.GetMouseButtonDown(0))
                {
                    //int index_pos = hit.collider.gameObject.GetComponent<block_mgr>().list_index;
                    b.obj.GetComponent <MeshRenderer>().material.color = c;
                    //hit.collider.gameObject.GetComponent<MeshRenderer>().material.color = c;
                }
            }
            //Debug.Log(hit.collider.gameObject.transform.position);
        }


        if (b_log.Count > 20)
        {
            b_log.RemoveAt(0);
        }
    }
コード例 #4
0
ファイル: edito_mgr.cs プロジェクト: kawanekoex/sep_campus
    public void back()
    {
        int max_index = b_log.Count - 1;

        if (max_index < 0)
        {
            return;
        }
        //生成
        if (b_log[max_index].del_frag)
        {
            //サイズ更新
            if (b_log[max_index].index_pos.x > max_size.x)
            {
                max_size.x = b_log[max_index].index_pos.x;
            }
            if (b_log[max_index].index_pos.y > max_size.y)
            {
                max_size.y = b_log[max_index].index_pos.y;
            }
            if (b_log[max_index].index_pos.z > max_size.z)
            {
                max_size.z = b_log[max_index].index_pos.z;
            }

            if (b_log[max_index].index_pos.x < min_size.x)
            {
                min_size.x = b_log[max_index].index_pos.x;
            }
            if (b_log[max_index].index_pos.y < min_size.x)
            {
                min_size.y = b_log[max_index].index_pos.y;
            }
            if (b_log[max_index].index_pos.z < min_size.x)
            {
                min_size.z = b_log[max_index].index_pos.z;
            }



            //ブロック生成
            Block b = new Block();
            b.draw_frag = true;
            b.id        = b_log[max_index].date.id;
            b.obj       = Instantiate(draw_obj, new Vector3(0, 0, 0), Quaternion.identity);
            b.obj.transform.localScale    = transform.localScale;
            b.obj.transform.parent        = transform;
            b.obj.transform.localPosition = new Vector3(b_log[max_index].index_pos.x * Define.BLOCK_SIZE, b_log[max_index].index_pos.y * Define.BLOCK_SIZE, b_log[max_index].index_pos.z * Define.BLOCK_SIZE);
            block_mgr b_m = b.obj.GetComponent <block_mgr>();
            b_m.block_mat = mat;
            b_m.index     = b_log[max_index].index_pos;
            b_m.data      = b;
            //block[b_log[max_index].index_pos.z, b_log[max_index].index_pos.y, b_log[max_index].index_pos.x].draw_frag = true;
            //block[b_log[max_index].index_pos.z, b_log[max_index].index_pos.y, b_log[max_index].index_pos.x].obj = Instantiate(draw_obj, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity);
            //block[b_log[max_index].index_pos.z, b_log[max_index].index_pos.y, b_log[max_index].index_pos.x].obj.transform.localScale = transform.localScale;
            //block[b_log[max_index].index_pos.z, b_log[max_index].index_pos.y, b_log[max_index].index_pos.x].obj.transform.parent = transform;
            //block[b_log[max_index].index_pos.z, b_log[max_index].index_pos.y, b_log[max_index].index_pos.x].obj.transform.localPosition = new Vector3((1.0f * b_log[max_index].index_pos.x) - (stage_size.x / 2), (1.0f * b_log[max_index].index_pos.y) - (stage_size.y / 2), (1.0f * b_log[max_index].index_pos.z) - (stage_size.z / 2));
            //block_mgr mgr_c = block[b_log[max_index].index_pos.z, b_log[max_index].index_pos.y, b_log[max_index].index_pos.x].obj.GetComponent<block_mgr>();
            //mgr_c.block_mat = mat;
            //mgr_c.data = block[b_log[max_index].index_pos.z, b_log[max_index].index_pos.y, b_log[max_index].index_pos.x];
            //mgr_c.index = new Vector3Int(b_log[max_index].index_pos.x, b_log[max_index].index_pos.y, b_log[max_index].index_pos.z);
        }
        else
        {
            //block_mgr mgr = obj.GetComponent<block_mgr>();
            //Vector3Int index_pos = hit.collider.gameObject.GetComponent<block_mgr>().index;
            //block[b_log[max_index].index_pos.z, b_log[max_index].index_pos.y, b_log[max_index].index_pos.x].draw_frag = false;
            Destroy(b_log[max_index].date.obj);
        }
        b_log.RemoveAt(max_index);
    }
コード例 #5
0
    // Update is called once per frame
    void Update()
    {
        /*//回転
         * if (Input.GetKey(KeyCode.W))
         * {
         *
         *      transform.Rotate(new Vector3(5, 0, 0), Space.World);
         * }
         * if (Input.GetKey(KeyCode.S))
         * {
         *      transform.Rotate(new Vector3(-5, 0, 0), Space.World);
         * }
         * if (Input.GetKey(KeyCode.D))
         * {
         *      transform.Rotate(new Vector3(0, -5, 0), Space.World);
         * }
         * if (Input.GetKey(KeyCode.A))
         * {
         *      transform.Rotate(new Vector3(0, 5, 0), Space.World);
         * }
         *
         * //拡縮
         * float scroll = Input.GetAxis("Mouse ScrollWheel");
         * Vector3 pos_inst = camera.transform.position + new Vector3(0, 0, scroll * Define.ZOOM_SPEED);
         * if (scroll > 0 && pos_inst.z > Define.ZOOM_MAX)
         * {
         *      pos_inst.z = Define.ZOOM_MAX;
         * }
         * else if (scroll < 0 && pos_inst.z < Define.ZOOM_MIN)
         * {
         *      pos_inst.z = Define.ZOOM_MIN;
         * }
         * camera.transform.position = pos_inst;
         *
         *
         * Ray ray = camera.ScreenPointToRay(Input.mousePosition);*/

        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            GameObject obj = hit.collider.gameObject;
            obj.GetComponent <block_mgr>().hit_frag = true;
            if (Input.GetMouseButtonDown(0))
            {
                Instantiate(ef_obj, hit.point, Quaternion.identity);
                //Instantiate(ef_b_obj, hit.point, Quaternion.identity);
                block_mgr mgr = obj.GetComponent <block_mgr>();
                if (!mgr.data.correct)
                {
                    Vector3Int index_pos = hit.collider.gameObject.GetComponent <block_mgr>().index;
                    block[index_pos.z, index_pos.y, index_pos.x].draw_frag = false;
                    Instantiate(ef_b_obj, hit.collider.gameObject.transform.position, hit.collider.gameObject.transform.rotation);
                    Destroy(hit.collider.gameObject);
                    miss_count--;
                }
                else
                {
                    game_over = true;
                }
            }
            //Debug.Log(hit.collider.gameObject.transform.position);
        }

        if (miss_count <= 0)
        {
            clear = true;
        }

        //Debug.Log(block[0,0,0].obj.transform.position);
    }
コード例 #6
0
    public void load()
    {
        //オブジェクト削除
        for (int z = 0; z < stage_size.z; z++)
        {
            for (int y = 0; y < stage_size.y; y++)
            {
                for (int x = 0; x < stage_size.x; x++)
                {
                    Destroy(block[z, y, x].obj);
                }
            }
        }
        //変数初期化
        correct_count         = 0;
        miss_count            = 0;
        transform.position    = Vector3.zero;
        transform.eulerAngles = Vector3.zero;
        //配列解放
        block = null;

        FileStream fs = new FileStream("Assets/save",
                                       FileMode.Open,
                                       FileAccess.Read);
        BinaryReader br = new BinaryReader(fs);

        if (Define.VERSION != br.ReadInt32())
        {
            return;
        }
        stage_size.Set(br.ReadInt32(), br.ReadInt32(), br.ReadInt32());

        //ブロック
        block = new Block[stage_size.z, stage_size.y, stage_size.x];
        for (int z = 0; z < stage_size.z; z++)
        {
            for (int y = 0; y < stage_size.y; y++)
            {
                for (int x = 0; x < stage_size.x; x++)
                {
                    block[z, y, x].correct   = br.ReadBoolean();
                    block[z, y, x].draw_frag = br.ReadBoolean();
                    //block[z, y, x].hint = br.ReadInt32();

                    //オブジェクト生成
                    if (block[z, y, x].draw_frag)
                    {
                        block[z, y, x].obj = Instantiate(draw_obj, new Vector3(0.0f, 0.0f, 0.0f), Quaternion.identity);
                        block[z, y, x].obj.transform.localScale    = transform.localScale;
                        block[z, y, x].obj.transform.parent        = transform;
                        block[z, y, x].obj.transform.localPosition = new Vector3((1.0f * x) - (stage_size.x / 2), (1.0f * y) - (stage_size.y / 2), (1.0f * z) - (stage_size.z / 2));
                        block_mgr mgr = block[z, y, x].obj.GetComponent <block_mgr>();

                        mgr.data  = block[z, y, x];
                        mgr.index = new Vector3Int(x, y, z);
                        if (mgr.data.correct)
                        {
                            correct_count++;
                        }
                        else
                        {
                            miss_count++;
                        }
                    }
                }
            }
        }

        //ヒント判定
        for (int z = 0; z < stage_size.z; z++)
        {
            for (int y = 0; y < stage_size.y; y++)
            {
                for (int x = 0; x < stage_size.x; x++)
                {
                    block_mgr mgr = block[z, y, x].obj.GetComponent <block_mgr>();
                    hint_counter(new Vector3Int(x, y, z));
                    mgr.block_mat = num_mat[block[z, y, x].hint];
                }
            }
        }
        //k.correct = br.ReadBoolean();
        //k.draw_frag = br.ReadBoolean();

        fs.Close();
    }