예제 #1
0
    private void OnPlayspaceComplete()
    {
        canvas.SetActive(true);
        menu.SetActive(true);
        PlayspaceWall wall = Playspace.Instance.Walls[Playspace.Instance.PrimaryWall];

        canvas.transform.position = wall.Center + Vector3.up * .3f;
        canvas.transform.rotation = Quaternion.LookRotation(wall.Back, Vector3.up);
        canvas.transform.Translate(Vector3.back * .1f); // pull the canvas up a bit to avoid coverup
        //SetPositionAndRotation(wall.Center, wall.Rotation);
        beamController.enabled = true;
        wallStat = WallStat.Menu;
    }
예제 #2
0
    private (Vector3, Quaternion) GetRandomFromPlane(int index)
    {
        // [0, n - 2) are walls, n - 2 is floor, n - 1 is ceiling
        // walls take a linear algebra approach
        // ceiling/floor takes the closest point on collider bound
        Vector3    loc;
        Quaternion quat;
        bool       inside = false;

        if (index < numPlane - 2)
        {
            PlayspaceWall wall         = Playspace.Instance.Walls[index];
            float         widthRandom  = Random.Range(0f, 1f);
            float         heightRandom = Random.Range(-0.5f, 0.5f);

            loc  = widthRandom * (wall.RightEdge - wall.LeftEdge) + wall.LeftEdge;
            loc += Vector3.up * (wall.height * heightRandom);
            quat = wall.Rotation;
        }
        else if (index < numPlane - 1)
        {
            loc = Playspace.Instance.Center;
            while (!inside)
            {
                loc    = GetRandomPointAroundPlane();
                inside = Playspace.Instance.Inside(loc);
            }
            loc.y = Playspace.Instance.FloorCenter.y;
            quat  = Quaternion.Euler(90, 0, 0);
        }
        else
        {
            loc = Playspace.Instance.Center;
            while (!inside)
            {
                loc    = GetRandomPointAroundPlane();
                inside = Playspace.Instance.Inside(loc);
            }

            loc.y = Playspace.Instance.CeilingCenter.y;
            quat  = Quaternion.Euler(270, 0, 0);
        }
        return(loc, quat);
    }
    private void HandleCompleted()
    {
        //place plaques:
        PlayspaceWall primaryWall = Playspace.Instance.Walls[Playspace.Instance.PrimaryWall];

        primaryWallPlaque.gameObject.SetActive(true);
        primaryWallPlaque.position = primaryWall.Center + Vector3.up * .5f;
        primaryWallPlaque.rotation = Quaternion.LookRotation(primaryWall.Back);

        PlayspaceWall rearWall = Playspace.Instance.Walls[Playspace.Instance.RearWall];

        rearWallPlaque.gameObject.SetActive(true);
        rearWallPlaque.position = rearWall.Center + Vector3.up * .5f;
        rearWallPlaque.rotation = Quaternion.LookRotation(rearWall.Back);

        PlayspaceWall rightWall = Playspace.Instance.Walls[Playspace.Instance.RightWall];

        rightWallPlaque.gameObject.SetActive(true);
        rightWallPlaque.position = rightWall.Center + Vector3.up * .5f;
        rightWallPlaque.rotation = Quaternion.LookRotation(rightWall.Back);

        PlayspaceWall leftWall = Playspace.Instance.Walls[Playspace.Instance.LeftWall];

        leftWallPlaque.gameObject.SetActive(true);
        leftWallPlaque.position = leftWall.Center + Vector3.up * .5f;
        leftWallPlaque.rotation = Quaternion.LookRotation(leftWall.Back);

        ceilingPlaque.gameObject.SetActive(true);
        ceilingPlaque.position = Playspace.Instance.CeilingCenter;
        ceilingPlaque.rotation = Quaternion.LookRotation(Vector3.up, primaryWall.Forward);

        floorPlaque.gameObject.SetActive(true);
        floorPlaque.position = Playspace.Instance.FloorCenter;
        floorPlaque.rotation = Quaternion.LookRotation(Vector3.down, primaryWall.Back);

        centerPlaque.gameObject.SetActive(true);
        centerPlaque.position = Playspace.Instance.Center;
    }