示例#1
0
    // Moves the reality bubble to be centered on the given box
    public void RecenterRealityBubble(WorldBox boxToCenterOn)
    {
        // First remove anything from the previous tick that fell off the edge of the world
        foreach (GameObject o2 in this.objectsToUnspawn)
        {
            this.world.unloadItem(o2);
        }
        this.objectsToUnspawn.Clear();

        // Determine the location of the new reality bubble
        RealityBubble newRealityBubble = new RealityBubble(this.initialRealityBubble);

        newRealityBubble.centerOn(boxToCenterOn);
        WorldBox newExistenceRegion = newRealityBubble.getExistentRegion();
        WorldBox oldExistenceRegion = this.realityBubble.getExistentRegion();
        WorldBox newActiveRegion    = newRealityBubble.getActiveRegion();
        WorldBox oldActiveRegion    = this.realityBubble.getActiveRegion();

        // Find everything that is no longer active
        System.Collections.Generic.List <GameObject> previouslyActive = this.characterSearcher.getObjectsOnlyInA(oldActiveRegion, newActiveRegion);
        foreach (GameObject o2 in previouslyActive)
        {
            this.world.removeItem(o2);
        }
        // Find everything that is no longer present
        System.Collections.Generic.List <GameObject> oldItems = this.terrainSearcher.getObjectsOnlyInA(oldExistenceRegion, newExistenceRegion);
        foreach (GameObject o2 in oldItems)
        {
            this.world.removeItem(o2);
        }
        // Find everything that just became present
        System.Collections.Generic.List <GameObject> newItems = this.terrainSearcher.getObjectsOnlyInA(newExistenceRegion, oldExistenceRegion);
        foreach (GameObject o2 in newItems)
        {
            this.world.addItem(o2);
        }
        // Find everything that just became active
        System.Collections.Generic.List <GameObject> newlyActive = this.characterSearcher.getObjectsOnlyInA(newActiveRegion, oldActiveRegion);
        foreach (GameObject o2 in newlyActive)
        {
            this.world.addItem(o2);
        }
        this.realityBubble = newRealityBubble;
    }
示例#2
0
    // get the current screenshot and save it in the world somewhere
    public void saveScreenshotInWorld()
    {
        // find everything that is slightly to the right of the screen
        RealityBubble newBubble = this.realityBubble;
        WorldBox      realBox   = new WorldBox(newBubble.getActiveRegion());

        realBox.shift(0, 3000);
        GameObject collisionBox = new GameObject();

        collisionBox.setShape(new GameRectangle(realBox.getSize(0), realBox.getSize(1)));
        collisionBox.setCenter(realBox.getCenter());
        List <GameObject> collisions = this.terrainSearcher.getCollisions(collisionBox);
        // find a painting
        Painting bestPainting = null;

        foreach (GameObject collision in collisions)
        {
            if (collision.isAPainting())
            {
                Painting tempPainting = (Painting)collision;
                if ((tempPainting.getShape().getWidth() <= 400) && (tempPainting.getShape().getWidth() > 200))
                {
                    bestPainting = tempPainting;
                    break;
                }
            }
        }
        if (bestPainting != null)
        {
            // TODO fix this
            // get the current screenshot
            // ImageSource source = this.getScreenshot();
            // put the screenshot in the painting
            // bestPainting.setBitmap(source);
        }
    }
 public RealityBubble(RealityBubble original)
 {
     this.activeRegion   = new WorldBox(original.activeRegion);
     this.existentRegion = new WorldBox(original.existentRegion);
 }