public void LoadContent(ContentManager content)
        {
            for (int i = 0; i < prisms.Length; i++)
            {
                prisms[i] = new Prism();
                prisms[i].prism.LoadContent(content, "prism");
            }

            //Place each prism, assign its movement points, and all the points it reflects to at each point
            prisms[0].placementPoints = new ImageButton[2];
            prisms[1].placementPoints = new ImageButton[4];
            prisms[2].placementPoints = new ImageButton[0];

            for (int i = 0; i < prisms.Length; i++)
            {
                for (int j = 0; j < prisms[i].placementPoints.Length; j++)
                    prisms[i].placementPoints[j] = new ImageButton();
            }

            prisms[0].prism.position = new Vector2(50, 50);
                prisms[0].placementPoints[0].LoadContent(content, "prismPlacementPoint");
                prisms[0].placementPoints[0].position = new Vector2(50, 50);
                prisms[0].placementPoints[1].LoadContent(content, "prismPlacementPoint");
                prisms[0].placementPoints[1].position = new Vector2(50, 250);
            prisms[0].pointsConnected = new int[2][];
                prisms[0].pointsConnected[0] = new int[] { 1 };
                prisms[0].pointsConnected[1] = new int[] { 0 };
            prisms[0].prismIndexesPointedAt = new int[2][];
                prisms[0].prismIndexesPointedAt[0] = new int[] { (int)STATIC_REFLECT_POINTS.NORTH, (int)STATIC_REFLECT_POINTS.EAST, (int)STATIC_REFLECT_POINTS.SOUTH, (int)STATIC_REFLECT_POINTS.WEST};
                prisms[0].prismIndexesPointedAt[1] = new int[] { (int)STATIC_REFLECT_POINTS.GOAL, (int)STATIC_REFLECT_POINTS.EAST, (int)STATIC_REFLECT_POINTS.SOUTH, (int)STATIC_REFLECT_POINTS.WEST };

            prisms[1].prism.position = new Vector2(250, 50);
                prisms[1].placementPoints[0].LoadContent(content, "prismPlacementPoint");
                prisms[1].placementPoints[0].position = new Vector2(250, 50);
                prisms[1].placementPoints[1].LoadContent(content, "prismPlacementPoint");
                prisms[1].placementPoints[1].position = new Vector2(250, 250);
                prisms[1].placementPoints[2].LoadContent(content, "prismPlacementPoint");
                prisms[1].placementPoints[2].position = new Vector2(450, 250);
                prisms[1].placementPoints[3].LoadContent(content, "prismPlacementPoint");
                prisms[1].placementPoints[3].position = new Vector2(250, 450);
            prisms[1].pointsConnected = new int[4][];
                prisms[1].pointsConnected[0] = new int[] { 1 };
                prisms[1].pointsConnected[1] = new int[] { 0,2,3 };
                prisms[1].pointsConnected[2] = new int[] { 1 };
                prisms[1].pointsConnected[3] = new int[] { 1 };
            prisms[1].prismIndexesPointedAt = new int[4][];
                prisms[1].prismIndexesPointedAt[0] = new int[] { (int)STATIC_REFLECT_POINTS.NORTH, (int)STATIC_REFLECT_POINTS.EAST, (int)STATIC_REFLECT_POINTS.SOUTH, (int)STATIC_REFLECT_POINTS.WEST };
                prisms[1].prismIndexesPointedAt[1] = new int[] { (int)STATIC_REFLECT_POINTS.NORTH, (int)STATIC_REFLECT_POINTS.EAST, (int)STATIC_REFLECT_POINTS.SOUTH, (int)STATIC_REFLECT_POINTS.WEST };
                prisms[1].prismIndexesPointedAt[2] = new int[] { (int)STATIC_REFLECT_POINTS.GOAL, (int)STATIC_REFLECT_POINTS.EAST, (int)STATIC_REFLECT_POINTS.SOUTH, (int)STATIC_REFLECT_POINTS.WEST };
                prisms[1].prismIndexesPointedAt[3] = new int[] { (int)STATIC_REFLECT_POINTS.NORTH, (int)STATIC_REFLECT_POINTS.EAST, (int)STATIC_REFLECT_POINTS.SOUTH, (int)STATIC_REFLECT_POINTS.WEST };

            prisms[2].prism.position = new Vector2(450, 50);
            prisms[2].pointsConnected = new int[0][];
            prisms[2].prismIndexesPointedAt = new int[1][];
            prisms[2].prismIndexesPointedAt[0] = new int[] { (int)STATIC_REFLECT_POINTS.SOUTH, (int)STATIC_REFLECT_POINTS.EAST, (int)STATIC_REFLECT_POINTS.GOAL, (int)STATIC_REFLECT_POINTS.WEST };
        }
Exemplo n.º 2
0
    private static void addDonutFragment(int[,,] mapData)
    {
        int voxelCode = junkTheme.getRandomCode ();
        int diameter = Random.Range (5, Mathf.Min (size.x, size.y, size.z));

        Prism negativePrism = new Prism (0, 0, 0, Random.Range (1, diameter), 1, Random.Range (1, diameter));
        IntVector3 negativeOffset = new IntVector3 (Random.Range (0, diameter), 0, Random.Range (0, diameter));

        int[,,] donutData = ShapeGenerator.genDonut (voxelCode, diameter);
        donutData = MDController.subtract (donutData, ShapeGenerator.genPrism (1, negativePrism), negativeOffset);
        IntVector3 targetPoint = new IntVector3 (size.x / 2, size.y / 2, size.z / 2);
        addPiece (mapData, donutData, targetPoint);
    }
Exemplo n.º 3
0
    void OnEnable()
    {
        _prism = GetComponent<Prism>();
        _lineMesh = new Mesh();
        _roots = new Vector3[nSamples];

        var mf = GetComponent<MeshFilter>();
        mf.sharedMesh = _lineMesh;

        var m = _prism.layerMesh;
        for (var i = 0; i < nSamples; i++)
            _roots[i] = m.Sample();
    }
Exemplo n.º 4
0
    private static int[,,] genBasic(VoxelTheme voxelTheme, IntVector3 destination, int width, bool rotate)
    {
        //generally used when size requirements are not met but a catwalk must be made.
        int[,,] newData = genMapDataFromPoint (destination, width);
        int voxelCode = voxelTheme.getCode ("block");

        Prism prism = new Prism (0, 0, 0, 1, newData.GetLength (1), newData.GetLength (2));
        newData = MDController.combine (newData, ShapeGenerator.genPrism (voxelCode, prism));

        prism = new Prism (0, 0, 0, newData.GetLength (0), 1, newData.GetLength (2));
        IntVector3 offset = new IntVector3 (0, 0, 0);
        newData = MDController.combine (newData, ShapeGenerator.genPrism (voxelCode, prism), offset);

        if (rotate)
            return rotateMapData (newData, destination);
        return newData;
    }
Exemplo n.º 5
0
        public MainWindowViewModel(Prism.Events.IEventAggregator eventAggregator)
        {
            eventAggregator.GetEvent<Paver.Common.TileDataSelectedEvent>()
                .Subscribe((data) => SelectedTileData = data,Prism.Events.ThreadOption.UIThread);

        }
Exemplo n.º 6
0
 // Use this for initialization
 void Start()
 {
     _prism = GetComponent<Prism>();
 }
Exemplo n.º 7
0
 private void Start()
 {
     changeCharacter(selectedCharacter);
     prismScript = ucgen.GetComponent<Prism>();
 }
Exemplo n.º 8
0
    public void updateWorldDomain(Prism blobPrism)
    {
        /*
        enlarges the world domain to include blobPrism
        */

        IntVector3[] points = new IntVector3[4]{
            worldPrism.getLowestPoint (),
            worldPrism.getHighestPoint (),
            blobPrism.getLowestPoint (),
            blobPrism.getHighestPoint ()};

        worldPrism = ZTools.getPrismFromPoints (points);
    }
Exemplo n.º 9
0
 public Prism genPrism()
 {
     /*
     returns a prism which is an approximation of where that blob is.
     */
     IntVector3 realPosition = getRealPosition ();
     prism = new Prism (realPosition.x, realPosition.y, realPosition.z, iSize, jSize, kSize);
     return prism;
 }
Exemplo n.º 10
0
    private void setStart()
    {
        //only one collisionManager should be in progress at the same time for the whole scene
        isStarted = true;

        blobs = new ArrayList ();

        if (blobName1 == "main blob")
            blobName1 = worldManager.getMainBlobName ();
        blob1 = (BlobManager)worldManager.blobs [blobName1];
        blob2 = (BlobManager)worldManager.blobs [blobName2];

        blob1.setName (true);
        blob2.setName (true);
        if (newBlobManager != null)
            newBlobManager.setName (true);

        blobs.Add (blob2);

        if (isBlob2InsideBlob1) {
            //case: when blob2 collided with blob1, it was completely within blob1 bounds
            //Debug.Log ("inside collision");
            newBlobManager = blob1;

            iterPrism = blob2.genPrism ();
            combinedPrism = blob1.getPrism ();

            iterOffset = new IntVector3 (iterPrism.x - combinedPrism.x, iterPrism.y - combinedPrism.y, iterPrism.z - combinedPrism.z);

            //ZTools.show ("combinedPrism ", combinedPrism);
            newMapData = blob1.mapData;
            newVoxelGrid = blob1.voxels;
            newContagiousList = blob1.getContagiousList ();
        } else {
            //case: blob2 hit the outside of blob1. newblob bounds must become larger
            //Debug.Log ("outside collision");
            blobs.Add (blob1);
            iterPrism = getPrismFromBlobs (blob1, blob2);
            iterOffset = new IntVector3 (0, 0, 0);

            combinedPrism = iterPrism;
            newMapData = new int[iterPrism.width, iterPrism.height, iterPrism.depth];
            newVoxelGrid = new GameObject[iterPrism.width, iterPrism.height, iterPrism.depth];
            newContagiousList = new ArrayList ();
            newBlobManager.gameObject.transform.position = new Vector3 (iterPrism.x, iterPrism.y, iterPrism.z);
        }
        //ZTools.show("combined prism",combinedPrism);
    }
Exemplo n.º 11
0
    public static int[,,] genComb(int voxelCode, int width, int height, int depth)
    {
        //Debug.Log("genComb "+width+" "+height+" "+depth);
        int[,,] newData = new int[width, height, depth];

        int stepSize = Random.Range (2, width / 10);
        stepSize = stepSize < 2 ? 2 : stepSize;
        for (int i=0; i<width; i+=stepSize) {
            int[,,] triangleData = ShapeGenerator.genTriangle (voxelCode, width, height);
            triangleData = MDController.iRotate (triangleData, 90);
            triangleData = MDController.jRotate (triangleData, 90);
            newData = MDController.combine (newData, triangleData, i, 0, 0);
        }

        //ensure all combs are connected
        Prism prism=new Prism(0,0,0,width,1,1);
        newData=MDController.combine(newData,ShapeGenerator.genPrism (voxelCode,prism));

        return newData;
    }
Exemplo n.º 12
0
    private static void addPlane(int[,,] mapData)
    {
        int voxelCode = junkTheme.getRandomCode ();

        ArrayList sizes = new ArrayList ();
        sizes.Add (size.x);
        sizes.Add (size.y);
        sizes.Add (size.z);
        ZTools.shuffleArraylist (sizes);

        Prism prism = new Prism (0, 0, 0, Random.Range (1, (int)sizes [0]), 1, Random.Range (1, (int)sizes [1]));
        int[,,] planeData = ShapeGenerator.genPrism (voxelCode, prism);

        //create random gaps in the plane
        Prism negativePrism;
        IntVector3 offset;
        int iterMax = (int)Mathf.Sqrt (Mathf.Min (size.x, size.y, size.z));
        for (int i=0; i<Random.Range(1,iterMax); i++) {
            negativePrism = new Prism (0, 0, 0, Random.Range (1, prism.width), 1, Random.Range (1, prism.depth));
            offset = new IntVector3 (Random.Range (0, prism.width), 0, Random.Range (0, prism.depth));
            planeData = MDController.subtract (planeData, ShapeGenerator.genPrism (voxelCode, negativePrism), offset);
        }
        //ensure planeData is never completely blank
        planeData [0, 0, 0] = voxelCode;

        IntVector3 targetPoint = new IntVector3 (size.x / 2, size.y / 2, size.z / 2);
        addPiece (mapData, planeData, targetPoint);
    }
Exemplo n.º 13
0
 public virtual void OnNavigatedTo(Prism.Navigation.NavigationParameters parameters)
 {
 }
Exemplo n.º 14
0
    public static IntVector3 getCollisionDirection(int[,,]movingData, int[,,]mapData, IntVector3 offset)
    {
        /*
        where movingData starts at offsets, find the direction it must move to collide with mapData.
        mapData starts at 0,0,0

        returns a unit vector, iff an orthogonal collision is possible.
        */
        IntVector3 direction = new IntVector3 (0, 0, 0);

        Prism movingPrism = new Prism (offset.x, offset.y, offset.z, movingData.GetLength (0), movingData.GetLength (1), movingData.GetLength (2));
        Prism mapPrism = new Prism (0, 0, 0, mapData.GetLength (0), mapData.GetLength (1), mapData.GetLength (2));

        bool iInside = isRangeInside (movingPrism.x, movingPrism.width, mapPrism.x, mapPrism.width);
        bool jInside = isRangeInside (movingPrism.y, movingPrism.height, mapPrism.y, mapPrism.height);
        bool kInside = isRangeInside (movingPrism.z, movingPrism.depth, mapPrism.z, mapPrism.depth);

        int insideCount = 0;
        if (iInside)
            insideCount++;
        if (jInside)
            insideCount++;
        if (kInside)
            insideCount++;

        IntVector3 emptyDirection = new IntVector3 (0, 0, 0);
        if (insideCount < 2) {
            //Debug.Log ("getCollisionDirection called with no possible orthogonal collision. insideCount: " + insideCount);
            return emptyDirection;
        } else if (insideCount == 3) {
            Debug.Log ("getCollisionDirection called when movingData is inside mapData.");
            return emptyDirection;
        }

        if (! iInside)
            direction.x = movingPrism.x < mapPrism.x ? 1 : -1;
        if (! jInside)
            direction.y = movingPrism.y < mapPrism.y ? 1 : -1;
        if (! kInside)
            direction.z = movingPrism.z < mapPrism.z ? 1 : -1;

        //Debug.Log ("getCollisionDirection i: " + direction.i + " j: " + direction.j + " k: " + direction.k);
        return direction;
    }
Exemplo n.º 15
0
    public bool isPrismEqual(Prism prism)
    {
        if (x != prism.x || y != prism.y || z != prism.z)
            return false;

        if (width != prism.width || height != prism.height || depth != prism.depth)
            return false;

        return true;
    }
Exemplo n.º 16
0
    public static Prism getPrismFromPoints(params IntVector3[] points)
    {
        //returns the smallest prism containing all points
        IntVector3 lowest = new IntVector3 (0, 0, 0);
        IntVector3 highest = new IntVector3 (0, 0, 0);

        bool firstRun = true;
        foreach (IntVector3 point in points) {
            if (firstRun) {
                firstRun = false;
                lowest = point;
                highest = point;
                continue;
            }

            if (point.x < lowest.x)
                lowest.x = point.x;
            if (point.y < lowest.y)
                lowest.y = point.y;
            if (point.z < lowest.z)
                lowest.z = point.z;

            if (point.x > highest.x)
                highest.x = point.x;
            if (point.y > highest.y)
                highest.y = point.y;
            if (point.z > highest.z)
                highest.z = point.z;
        }

        int width = Mathf.Abs (highest.x - lowest.x) + 1;
        int height = Mathf.Abs (highest.y - lowest.y) + 1;
        int depth = Mathf.Abs (highest.z - lowest.z) + 1;

        Prism prism = new Prism (lowest.x, lowest.y, lowest.z, width, height, depth);
        return prism;
    }
Exemplo n.º 17
0
 public NavigationServiceBase(Prism.Windows.Interfaces.INavigationService navigationService)
 {
     this.navigationService = navigationService;
 }
Exemplo n.º 18
0
    public static IntVector3 getRandomPointFromFaces(Prism prism)
    {
        //given a prism, returns a point chosen randomly from all points on the prism faces

        IntVector3 direction = Angles.getRandomDirection ();

        int i = Random.Range (0, prism.width);
        int j = Random.Range (0, prism.height);
        int k = Random.Range (0, prism.depth);

        if (direction.x != 0)
            i = direction.x == 1 ? 0 : prism.width - 1;
        if (direction.y != 0)
            j = direction.y == 1 ? 0 : prism.height - 1;
        if (direction.z != 0)
            k = direction.z == 1 ? 0 : prism.depth - 1;

        return new IntVector3 (prism.x + i, prism.y + j, prism.z + k);
    }
Exemplo n.º 19
0
 void Awake()
 {
     viroidManager = new ViroidManager (this);
     worldManager = (WorldManager)FindObjectOfType (typeof(WorldManager));
     prism = new Prism (0, 0, 0, 0, 0, 0);
     redTimer = 0;
     lastDistanceTravelled = 0;
     driftFuel = 0;
     voxelCount = 0;
     isInitialized = false;
     isColliding = false;
     isDrifting = false;
     blobActions = new ArrayList ();
 }
Exemplo n.º 20
0
 public static void show(Prism prism)
 {
     Debug.Log (" x: " + prism.x + " y: " + prism.y + " z: " + prism.z + " w: " + prism.width + " h: " + prism.height + " d: " + prism.depth);
 }
Exemplo n.º 21
0
    private void setFirstBlob()
    {
        blobCount = 0;
        BlobData blobData = getLevelData ().getFirstBlob ();
        int [,,] mapData = blobData.genMapData ();

        BlobManager blobManager = startBlob (getNewBlob (), mapData, new IntVector3 (0, 0, 0));
        mainBlobName = blobManager.blobName;
        blobManager.setBlobData (blobData);
        blobManager.createVoxels ();

        worldPrism = blobManager.getPrism ();
    }
Exemplo n.º 22
0
 public static int[,,] genPrism(int voxelCode, Prism prism)
 {
     return genPrism (voxelCode, prism.width, prism.height, prism.depth);
 }