SetWorldDisplay() public method

public SetWorldDisplay ( Sprite NewSprite ) : void
NewSprite Sprite
return void
Exemplo n.º 1
0
    public void SpillContentsX()
    {                                                               //Removes the contents of a container out in the real world.
        int     counter;
        TileMap tm = GameWorldController.instance.currentTileMap(); //GameObject.Find("Tilemap").GetComponent<TileMap>();

        GameWorldController.FreezeMovement(this.gameObject);
        ObjectInteraction objInt = this.gameObject.GetComponent <ObjectInteraction>();

        objInt.SetWorldDisplay(objInt.GetEquipDisplay());
        for (short i = 0; i <= MaxCapacity(); i++)
        {
            GameObject Spilled = GetGameObjectAt(i);            //GameObject.Find (GetItemAt (i));
            if (Spilled != null)
            {
                if (Spilled.GetComponent <trigger_base>() != null)
                {
                    Spilled.GetComponent <trigger_base>().Activate(this.gameObject);
                }
                bool    flag        = false;
                Vector3 randomPoint = this.transform.position;
                counter = 0;
                while ((flag == false) && (counter < 25))
                {
                    randomPoint = this.transform.position + Random.insideUnitSphere;
                    if (randomPoint.y < this.transform.position.y)
                    {
                        randomPoint.y = this.transform.position.y + 0.1f;
                    }
                    flag = ((!Physics.CheckSphere(randomPoint, 0.5f)) && (tm.ValidTile(randomPoint)));
                    counter++;
                }
                if (flag == true)
                {                //No object interferes with the spill
                    RemoveItemFromContainer(i);
                    Spilled.transform.position = randomPoint;
                    Spilled.GetComponent <ObjectInteraction>().PickedUp = false;
                    GameWorldController.UnFreezeMovement(Spilled);
                }
                else
                {                //No where to put the item. Put it at the containers position.
                    RemoveItemFromContainer(i);
                    Spilled.transform.position = this.transform.position;
                    Spilled.GetComponent <ObjectInteraction>().PickedUp = false;
                    GameWorldController.UnFreezeMovement(Spilled);
                }
            }
        }
        GameWorldController.UnFreezeMovement(this.gameObject);
    }
Exemplo n.º 2
0
    public void SpillContents()
    {
        TileMap tm = GameWorldController.instance.currentTileMap();                        //GameObject.Find("Tilemap").GetComponent<TileMap>();

        GameWorldController.FreezeMovement(this.gameObject);
        ObjectInteraction objInt = this.gameObject.GetComponent <ObjectInteraction>();

        objInt.UpdatePosition();
        objInt.SetWorldDisplay(objInt.GetEquipDisplay());
        for (short i = 0; i <= MaxCapacity(); i++)
        {
            GameObject Spilled = GetGameObjectAt(i);                                    //GameObject.Find (GetItemAt (i));
            if (Spilled != null)
            {
                if (Spilled.GetComponent <trigger_base>() != null)
                {
                    Spilled.GetComponent <trigger_base>().Activate(this.gameObject);
                }
                else
                {
                    ObjectInteraction objSpilled = Spilled.GetComponent <ObjectInteraction>();
                    Spilled.transform.position = this.transform.position;
                    objSpilled.UpdatePosition();
                    switch (tm.Tiles[objInt.tileX, objInt.tileY].tileType)
                    {
                    case TileMap.TILE_OPEN:
                    case TileMap.TILE_SLOPE_N:
                    case TileMap.TILE_SLOPE_S:
                    case TileMap.TILE_SLOPE_E:
                    case TileMap.TILE_SLOPE_W:
                        objSpilled.x = (short)Random.Range(1, 7);
                        objSpilled.y = (short)Random.Range(1, 7);
                        break;

                    case TileMap.TILE_DIAG_SE:
                        objSpilled.x = (short)Random.Range(1, 7);
                        objSpilled.y = (short)Random.Range(0, objSpilled.x);
                        break;

                    case TileMap.TILE_DIAG_SW:
                        objSpilled.x = (short)Random.Range(1, 7);
                        objSpilled.y = (short)Random.Range(1, 7 - objSpilled.x);
                        break;

                    case TileMap.TILE_DIAG_NE:
                        objSpilled.x = (short)Random.Range(1, 7);
                        objSpilled.y = (short)Random.Range(8 - objSpilled.x, 8);
                        break;

                    case TileMap.TILE_DIAG_NW:
                        objSpilled.x = (short)Random.Range(1, 7);
                        objSpilled.y = (short)Random.Range(objSpilled.x, 8);
                        break;
                    }
                    objSpilled.zpos = (short)(tm.Tiles[objInt.tileX, objInt.tileY].floorHeight * 4);
                    objSpilled.objectloaderinfo.x    = objSpilled.x;
                    objSpilled.objectloaderinfo.y    = objSpilled.y;
                    objSpilled.objectloaderinfo.zpos = objSpilled.zpos;
                    objSpilled.transform.position    = ObjectLoader.CalcObjectXYZ(_RES, tm, tm.Tiles, GameWorldController.instance.CurrentObjectList().objInfo, objSpilled.objectloaderinfo.index, this.objInt().objectloaderinfo.tileX, this.objInt().objectloaderinfo.tileY, 0);
                    RemoveItemFromContainer(i);
                    Spilled.GetComponent <ObjectInteraction>().PickedUp = false;
                    GameWorldController.UnFreezeMovement(Spilled);
                }
            }
        }
    }
    public void SpillContents()
    {
        TileMap tm = CurrentTileMap(); //GameObject.Find("Tilemap").GetComponent<TileMap>();

        FreezeMovement(this.gameObject);
        ObjectInteraction objInt = this.gameObject.GetComponent <ObjectInteraction>();

        objInt.UpdatePosition();
        objInt.SetWorldDisplay(objInt.GetEquipDisplay());
        objInt.link = 0; //So items in world will not create infinitly lopping references
        for (short i = 0; i <= MaxCapacity(); i++)
        {
            ObjectInteraction objSpilled = GetItemAt(i);
            if (objSpilled != null)
            {
                if (objSpilled.GetComponent <trigger_base>() != null)
                {
                    objSpilled.GetComponent <trigger_base>().Activate(this.gameObject);
                }
                else
                {
                    //ObjectInteraction objSpilled = Spilled.GetComponent<ObjectInteraction>();
                    objSpilled.transform.position = this.transform.position;
                    objSpilled.UpdatePosition();
                    switch (tm.Tiles[objInt.ObjectTileX, objInt.ObjectTileY].tileType)
                    {
                    case TileMap.TILE_OPEN:
                    case TileMap.TILE_SLOPE_N:
                    case TileMap.TILE_SLOPE_S:
                    case TileMap.TILE_SLOPE_E:
                    case TileMap.TILE_SLOPE_W:
                        objSpilled.xpos = (short)Random.Range(1, 7);
                        objSpilled.ypos = (short)Random.Range(1, 7);
                        break;

                    case TileMap.TILE_DIAG_SE:
                        objSpilled.xpos = (short)Random.Range(1, 7);
                        objSpilled.ypos = (short)Random.Range(0, objSpilled.xpos);
                        break;

                    case TileMap.TILE_DIAG_SW:
                        objSpilled.xpos = (short)Random.Range(1, 7);
                        objSpilled.ypos = (short)Random.Range(1, 7 - objSpilled.xpos);
                        break;

                    case TileMap.TILE_DIAG_NE:
                        objSpilled.xpos = (short)Random.Range(1, 7);
                        objSpilled.ypos = (short)Random.Range(8 - objSpilled.xpos, 8);
                        break;

                    case TileMap.TILE_DIAG_NW:
                        objSpilled.xpos = (short)Random.Range(1, 7);
                        objSpilled.ypos = (short)Random.Range(objSpilled.xpos, 8);
                        break;
                    }
                    objSpilled.zpos = (short)(tm.Tiles[objInt.ObjectTileX, objInt.ObjectTileY].floorHeight * 4);
                    objSpilled.objectloaderinfo.xpos = objSpilled.xpos;
                    objSpilled.objectloaderinfo.ypos = objSpilled.ypos;
                    objSpilled.objectloaderinfo.zpos = objSpilled.zpos;
                    objSpilled.transform.position    = ObjectLoader.CalcObjectXYZ(objSpilled.objectloaderinfo.index, 0);
                    RemoveItemFromContainer(i);
                    //FIELD PICKUP Spilled.GetComponent<ObjectInteraction>().PickedUp=false;
                    UnFreezeMovement(objSpilled);
                }
            }
        }
    }