예제 #1
0
    void Initiate_sliced_cube(float half_current_scale)
    {
        GameObject sl_cube = Instantiate(sliced_cube) as GameObject;

        if (!is_direction_z)
        {
            sl_cube.transform.localScale = new Vector3(Mathf.Abs(half_current_scale * 2 - transform.localScale.x), new_step, half_current_scale_z * 2);
            if (transform.position.x > current_x)
            {
                sl_cube.transform.position = new Vector3(current_x + half_current_scale_x + 0.5f * sl_cube.transform.localScale.x, transform.position.y + new_step, transform.position.z);
            }
            else
            {
                sl_cube.transform.position = new Vector3(current_x - half_current_scale_x - 0.5f * sl_cube.transform.localScale.x, transform.position.y + new_step, transform.position.z);
            }
        }
        else
        {
            sl_cube.transform.localScale = new Vector3(half_current_scale_x * 2, new_step, Mathf.Abs(half_current_scale * 2 - transform.localScale.z));
            if (transform.position.z > current_z)
            {
                sl_cube.transform.position = new Vector3(current_x, transform.position.y + new_step, current_z + half_current_scale_z + 0.5f * sl_cube.transform.localScale.z);
            }
            else
            {
                sl_cube.transform.position = new Vector3(current_x, transform.position.y + new_step, current_z - half_current_scale_z - 0.5f * sl_cube.transform.localScale.z);
            }
        }

        sl_cube.GetComponent <Renderer>().material.SetColor("_Color", CubeColor.CurrentColor());
    }
예제 #2
0
    void Restart()
    {
        string name = "Falling_cube(Clone)";

        Destroy(GameObject.Find(name));
        for (int i = 0; i < count; i++)
        {
            Destroy(GameObject.Find(name + "(Clone)"));
            name += "(Clone)";
        }

        string sliced = "Sliced_cube(Clone)";

        while (GameObject.Find(sliced) != null)
        {
            DestroyImmediate(GameObject.Find(sliced));
        }

        Camera.allCameras [0].transform.position = new Vector3(-11.8f, 23.89f, -10f);

        count = 0;

        GameObject first_cube = GameObject.Find("Falling_cube");

        first_cube.transform.localScale = new Vector3(maxSizeOfSide, new_step, maxSizeOfSide);
        first_cube.transform.position   = new Vector3(0f, new_step, 0f);
        first_cube.GetComponent <Falling_cube>().stop_cube = false;
        first_cube.GetComponent <Falling_cube>().enabled   = true;
        first_cube.GetComponent <CubeColor> ().ResetColors();
        first_cube.GetComponent <Renderer>().material.SetColor("_Color", CubeColor.CurrentColor());

        is_direction_z = false;
        is_right_side  = false;

        new_step             = 1f;
        current_x            = 0f;
        current_z            = 0f;
        half_current_scale_x = maxSizeOfSide / 2f;
        half_current_scale_z = maxSizeOfSide / 2f;

        new_game = true;

        GameObject.Find("CUBE").GetComponent <Renderer>().material.SetColor("_Color", CubeColor.CurrentColor());
        GameObject.Find("shadow").GetComponent <Renderer> ().material.SetColor("_Color", CubeColor.CurrentColor());

        background.ResetBackground();
    }
예제 #3
0
파일: StartCube.cs 프로젝트: Greeall/stack
 // Use this for initialization
 void Start()
 {
     GetComponent <Renderer> ().material.SetColor("_Color", CubeColor.CurrentColor());
 }