Exemplo n.º 1
0
    void doMergeMove()
    {
        float t = (Time.time - startTime) / totalTime;

        transform.position = Vector3.Lerp(transform.position, origin, Mathf.SmoothStep(0, 1, t));

        if (t >= 1)
        {
            transform.position = origin;
            parent.SendMessage("call_parent_merge_ok");
            state = SplitBoxState.merge_move_end;
        }
    }
Exemplo n.º 2
0
    void doSplitMove()
    {
        float t = (Time.time - startTime) / totalTime;

        transform.position = Vector3.Lerp(transform.position, target, Mathf.SmoothStep(0, 1, t));

        if (t >= 1)
        {
            transform.position = target;
            state = SplitBoxState.split_move_end;
            parent.SendMessage("call_parent_separate_ok");
        }
    }
Exemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        float Epsilon = 0.01f;
        if (state == SplitBoxState.split_move)
        {
            transform.position = Vector3.Lerp(transform.position, target, speed*Time.deltaTime);

            if ((transform.position - target).magnitude < Epsilon)
            {
                transform.position = target;
                state = SplitBoxState.split_move_end;
                parent.SendMessage("call_parent_separate_ok");
            }
        }
        else if (state == SplitBoxState.split_move_end)
        {

        }
        else if (state == SplitBoxState.merge_move)
        {
            transform.position = Vector3.Lerp(transform.position, origin, speed*Time.deltaTime);

            if ((transform.position - origin).magnitude < Epsilon)
            {
                transform.position = origin;
                parent.SendMessage("call_parent_merger_ok");
                state = SplitBoxState.merge_move_end;
            }
        }
        else if (state == SplitBoxState.merge_move_end)
        {
            Destroy(this.gameObject);
        }
    }
Exemplo n.º 4
0
 void goTarget()
 {
     state = SplitBoxState.split_move;
 }
Exemplo n.º 5
0
 void backToOrigin()
 {
     state = SplitBoxState.merge_move;
 }
Exemplo n.º 6
0
 void backToOrigin()
 {
     startTime = Time.time;
     state     = SplitBoxState.merge_move;
 }
Exemplo n.º 7
0
 void goTarget()
 {
     totalTime = Vector3.Distance(transform.position, target) / speed;
     startTime = Time.time;
     state     = SplitBoxState.split_move;
 }