FreezeMovement() public static method

Freezes the movement of the specified object if it has a rigid body attached.
public static FreezeMovement ( GameObject myObj ) : void
myObj GameObject My object.
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 virtual ObjectInteraction Pickup(ObjectInteraction objPicked, PlayerInventory pInv)
    {    //completes the pickup.
        objPicked.PickedUp = true;
        if (objPicked.GetComponent <Container>() != null)
        {
            Container.SetPickedUpFlag(objPicked.GetComponent <Container>(), true);
            Container.SetItemsParent(objPicked.GetComponent <Container>(), GameWorldController.instance.InventoryMarker.transform);
            Container.SetItemsPosition(objPicked.GetComponent <Container>(), GameWorldController.instance.InventoryMarker.transform.position);
        }
        UWHUD.instance.CursorIcon = objPicked.GetInventoryDisplay().texture;
        pInv.ObjectInHand         = objPicked.transform.name;
        if (objPicked.GetComponent <Rigidbody>() != null)
        {
            GameWorldController.FreezeMovement(objPicked.gameObject);
        }

        objPicked.transform.position = GameWorldController.instance.InventoryMarker.transform.position;
        objPicked.transform.parent   = GameWorldController.instance.InventoryMarker.transform;
        GameWorldController.MoveToInventory(objPicked);
        pInv.ObjectInHand = objPicked.transform.name;
        objPicked.Pickup();
        return(objPicked);
    }
Exemplo n.º 3
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);
                }
            }
        }
    }