Exemple #1
0
    IEnumerator MoveOnStage(Vector3 point, bool firstJump)
    {
        int distanceCounter = 0;

        rotating = false;
        if (climbing)
        {
            control.JumpExt();
        }
        rb.isKinematic = false;
        float   startYBardPos = bard.transform.position.y;
        Vector3 bardPos       = bard.transform.position;
        float   prevDis;
        float   distance = Vector3.Distance(point, bardPos);

        onStage = true;
        while (distance > movement)
        {
            prevDis = distance;
            control.MoveBard("forward");
            distance = Vector3.Distance(point, bardPos);
            bardPos  = new Vector3(bard.transform.position.x, startYBardPos, bard.transform.position.z);
            yield return(new WaitForSeconds(0.01f));

            if (prevDis < distance)
            {
                distanceCounter++;
                if (distanceCounter >= 2)
                {
                    break;
                }
            }
        }
        if (distanceCounter >= 2)
        {
            control.MoveBard("backward");
        }
        if (climbing)
        {
            if (firstJump)
            {
                rb.isKinematic = true;
                // Get mid-position of stage
                //Vector3[] stageMeshVert = tavern.getBuehne().GetComponent<MeshFilter>().mesh.vertices;
                GameObject stage = tavern.getBuehne();
                //stageMid = new Vector3(stageMeshVert[5].x - ((stageMeshVert[5].x - stageMeshVert[9].x) / 2), stageMeshVert[9].y, stageMeshVert[5].z - ((stageMeshVert[5].z - stageMeshVert[9].z) / 2));
                stageMid = stage.transform.position;
                StartCoroutine(Rotate(new Vector3(point.x + 0.8f, stageMid.y, stageMid.z), false, false));
            }
            else
            {
                climbing = false;
                StartCoroutine(Rotate(stageMid, false, false));
            }
        }
        else
        {
            StartCoroutine(Rotate(new Vector3(stageMid.x, stageMid.y, stageMid.z - 1), false, true));
        }
    }
Exemple #2
0
 public void UpdateObserver(Subject subject)
 {
     if (subject is taverne)
     {
         stageRef = tavern.getBuehne();
         BuildBoard();
     }
 }