Esempio n. 1
0
    // When changing a graphic state - change physical interactable tiles

    public void ChangePIInTiles(PhysicalInteractable physicalInteractable, GraphicState newState)
    {
        //Debug.Log ("ChangePIInTiles");

        List <Tile> oldTiles;

        if (physicalInteractable.CurrentGraphicState().coordsList.Count > 0)
        {
            //Debug.Log ("get list from coords");
            oldTiles = GetMyTiles(MyGrid, physicalInteractable.CurrentGraphicState().coordsList);
        }
        else
        {
            //Debug.Log ("get list from size");
            oldTiles = GetMyTiles(MyGrid, physicalInteractable.mySize, physicalInteractable.x, physicalInteractable.y);
        }

        List <Tile> newTiles;

        if (newState.coordsList.Count > 0)
        {
            newTiles = GetMyTiles(MyGrid, newState.coordsList);
        }
        else
        {
            newTiles = GetMyTiles(MyGrid, physicalInteractable.mySize, physicalInteractable.x, physicalInteractable.y);
        }

        if (physicalInteractable is Furniture)
        {
            foreach (Tile oldTile in oldTiles)
            {
                oldTile.myFurniture = null;
            }

            foreach (Tile newTile in newTiles)
            {
                newTile.myFurniture = (Furniture)physicalInteractable;
            }
        }

        if (physicalInteractable is Character)
        {
            foreach (Tile oldTile in oldTiles)
            {
                oldTile.myCharacter = null;
            }

            foreach (Tile newTile in newTiles)
            {
                newTile.myCharacter = (Character)physicalInteractable;
            }
        }

        EventsHandler.Invoke_cb_tileLayoutChanged();
    }
Esempio n. 2
0
    public static List <Vector3> GetPhysicalInteractableFrameBounds(PhysicalInteractable myPhysicalInt)
    {
        // declerations

        Vector2 frameBounds = myPhysicalInt.CurrentGraphicState().frameExtents;

        List <Vector3> positions = new List <Vector3> ();

        SpriteRenderer sr = PI_Handler.instance.PI_gameObjectMap [myPhysicalInt].GetComponentInChildren <SpriteRenderer>();

        Vector3 center = sr.bounds.center + new Vector3(myPhysicalInt.currentGraphicState.frameOffsetX, myPhysicalInt.currentGraphicState.frameOffsetY, 0);

        // center

        positions.Add(center);

        // positioning frame pieces

        if (frameBounds == Vector2.zero)
        {
            frameBounds = sr.bounds.extents;
        }

        //down left
        positions.Add(new Vector3(-frameBounds.x, -frameBounds.y, 0));

        //down right
        positions.Add(new Vector3(frameBounds.x, -frameBounds.y, 0));

        //up left
        positions.Add(new Vector3(-frameBounds.x, frameBounds.y, 0));

        //up right
        positions.Add(new Vector3(frameBounds.x, frameBounds.y, 0));



        return(positions);
    }
Esempio n. 3
0
    // When changing a graphic state - change physical interactable tiles

    public void ChangePIInTiles(PhysicalInteractable physicalInteractable, GraphicState newState, List <Grid> grids = null)
    {
        if (grids == null)
        {
            grids = new List <Grid> ()
            {
                MyGrid
            };
        }

        foreach (Grid grid in grids)
        {
            List <Tile> oldTiles;

            if (physicalInteractable.CurrentGraphicState().coordsList.Count > 0)
            {
                oldTiles = GetMyTiles(grid, physicalInteractable.CurrentGraphicState().coordsList);
            }
            else
            {
                oldTiles = GetMyTiles(grid, physicalInteractable.mySize, physicalInteractable.x, physicalInteractable.y);
            }

            List <Tile> newTiles;

            if (newState.coordsList.Count > 0)
            {
                newTiles = GetMyTiles(grid, newState.coordsList);
            }
            else
            {
                newTiles = GetMyTiles(grid, physicalInteractable.mySize, physicalInteractable.x, physicalInteractable.y);
            }

            if (physicalInteractable is Furniture)
            {
                foreach (Tile oldTile in oldTiles)
                {
                    oldTile.myFurniture = null;
                }

                foreach (Tile newTile in newTiles)
                {
                    newTile.myFurniture = (Furniture)physicalInteractable;
                }
            }

            if (physicalInteractable is Character)
            {
                foreach (Tile oldTile in oldTiles)
                {
                    oldTile.myCharacter = null;
                }

                foreach (Tile newTile in newTiles)
                {
                    newTile.myCharacter = (Character)physicalInteractable;
                }
            }
        }

        //EventsHandler.Invoke_cb_tileLayoutChanged ();
    }