void CutObject(Aliment _aliment, bool instantiateViewID)
    {
        // instantiation of standard aliment (bag, canned food)
        GameObject newCookedAlimentObject = PoolManager.Instance.Get(_aliment.CreateKeyPairValue(_aliment.alimentName, AlimentState.Cut), instantiateViewID).gameObject;

        objectCutted = newCookedAlimentObject.GetComponent <GrabableObject>();

        objectCutted.Init();

        Aliment alimentCooked = objectCutted.GetComponent <Aliment>();

        alimentCooked.alimentStepState = _aliment.alimentStepState;

        objectCutted.AllowPhysic(false);
        objectCutted.AllowGrab(true);
        objectCutted.transform.position = foodPos.position;
        objectCutted.transform.rotation = foodPos.rotation;
        objectCutted.onGrab            += RemoveObject;

        grabableReceived.AllowGrab(true);
        grabableReceived.gameObject.GetComponent <Poolable>().DelObject();
        grabableReceived = null;


        if (player.photonView.IsMine)
        {
            // Affect the player
            player.EndInteractionState(this);
            GameManager.Instance.PopUp.CreateText("Objet coupé", 50, new Vector2(0, 300), 3.0f);
        }
    }
    void CleanObject(Aliment _aliment, bool instantiateViewID)
    {
        // instantiation of empty aliment (bag, canned food)
        GameObject newEmptyAlimentObject = PoolManager.Instance.Get(_aliment.CreateKeyPairValue(_aliment.alimentName, AlimentState.EmptyContent), instantiateViewID).gameObject;

        newEmptyAlimentObject.transform.position = initPos.position;
        newEmptyAlimentObject.transform.rotation = initPos.rotation;

        ObjectEmpty = newEmptyAlimentObject.GetComponent <GrabableObject>();

        ObjectEmpty.Init();

        ObjectEmpty.AllowPhysic(false);
        ObjectEmpty.AllowGrab(true); // To do : change to false
        ObjectEmpty.onGrab += RemoveObject;


        // instantiation of standard aliment (bag, canned food)
        GameObject newStandardAlimentObject = PoolManager.Instance.Get(_aliment.CreateKeyPairValue(_aliment.alimentName, AlimentState.Standard), instantiateViewID).gameObject;

        newStandardAlimentObject.transform.position = FinalPos.position;
        newStandardAlimentObject.transform.rotation = FinalPos.rotation;

        ObjectStandard = newStandardAlimentObject.GetComponent <GrabableObject>();

        ObjectStandard.Init();

        Aliment alimentStandard = ObjectStandard.GetComponent <Aliment>();

        if (alimentStandard.alimentType == AlimentType.Vegetable || alimentStandard.alimentType == AlimentType.Meat || alimentStandard.alimentType == AlimentType.Fish)
        {
            alimentStandard.alimentStepState = AlimentStepState.Deconditionning;
        }
        else
        {
            alimentStandard.alimentStepState = AlimentStepState.Treated;
        }


        ObjectStandard.AllowPhysic(false);
        ObjectStandard.AllowGrab(true);
        ObjectStandard.onGrab += RemoveObject;

        grabableReceived.AllowGrab(true);
        grabableReceived.gameObject.GetComponent <Poolable>().DelObject();
        grabableReceived = null;



        if (player.photonView.IsMine)
        {
            // Affect the player
            player.EndInteractionState(this);
            GameManager.Instance.PopUp.CreateText("Objet nettoyé", 50, new Vector2(0, 300), 3.0f);
        }
    }
Example #3
0
    // transform box into crate
    public void UnpackObject(Aliment _aliment, bool instantiateViewID)
    {
        // instantiation of empty aliment (bag, canned food)
        GameObject newEmptyBoxAlimentObject = PoolManager.Instance.Get(_aliment.CreateKeyPairValue(_aliment.alimentName, AlimentState.EmptyBox), instantiateViewID).gameObject;

        newEmptyBoxAlimentObject.transform.position = initPos.position;
        newEmptyBoxAlimentObject.transform.rotation = initPos.rotation;

        ObjectEmpty = newEmptyBoxAlimentObject.GetComponent <GrabableObject>();

        ObjectEmpty.Init();

        ObjectEmpty.AllowPhysic(false);
        ObjectEmpty.AllowGrab(true); // To do : change to false
        ObjectEmpty.onGrab += RemoveObject;


        // instantiation of standard aliment (bag, canned food)
        GameObject newStackAlimentObject = PoolManager.Instance.Get(_aliment.CreateKeyPairValue(_aliment.alimentName, AlimentState.Stack), instantiateViewID).gameObject;

        newStackAlimentObject.transform.position = FinalPos.position;
        newStackAlimentObject.transform.rotation = FinalPos.rotation;

        ObjectStack = newStackAlimentObject.GetComponent <GrabableObject>();

        ObjectStack.Init();

        //Aliment alimentStandard = ObjectStack.GetComponent<Aliment>();



        ObjectStack.AllowPhysic(false);
        ObjectStack.AllowGrab(true);
        ObjectStack.onGrab += RemoveObject;

        grabableReceived.AllowGrab(true);
        grabableReceived.gameObject.GetComponent <Poolable>().DelObject();
        grabableReceived = null;



        if (player.photonView.IsMine)
        {
            // Affect the player
            player.EndInteractionState(this);
            GameManager.Instance.PopUp.CreateText("Carton déballé", 50, new Vector2(0, 300), 3.0f);
        }

        player = null;
    }
Example #4
0
    void CleanTrash(PlayerController _pController)
    {
        GrabableObject trashBag = PhotonNetwork.Instantiate("Furniture/P_TrashBag", Vector3.zero, Quaternion.identity).GetComponent <GrabableObject>();

        trashBag.Init();
        trashBag.AllowGrab(true);
        _pController.pInteract.GrabObject(trashBag, false);

        nbOfElementInTrash = 0;

        wasteItem.transform.position = initPosWasteItem;
        wasteItem.SetActive(false);

        photonView.RPC("CleanTrashOnline", RpcTarget.Others, trashBag.photonView.ViewID, _pController.photonView.OwnerActorNr);
    }
Example #5
0
    void CleanTrashOnline(int _bagViewID, int _ownerID)
    {
        GrabableObject trashBag = PhotonView.Find(_bagViewID).GetComponent <GrabableObject>();

        trashBag.Init();
        trashBag.AllowGrab(true);

        PlayerController photonPlayer = InGamePhotonManager.Instance.PlayersConnected[_ownerID];

        photonPlayer.pInteract.GrabObject(trashBag, false);

        nbOfElementInTrash = 0;

        wasteItem.transform.position = initPosWasteItem;
        wasteItem.SetActive(false);
    }
Example #6
0
    public void GetObjectInColdRoom(string _alimentName, AlimentState _alimentState, int alimentViewID, int actorNumber, bool _Remove = false)
    {
        PlayerController ownerPlayer = InGamePhotonManager.Instance.PlayersConnected[actorNumber];

        KeyValuePair <string, AlimentState> keyFood;

        keyFood = new KeyValuePair <string, AlimentState>(_alimentName, _alimentState);
        Poolable foodToGet = null;

        if (_Remove == false)
        {
            if (keyFood.Value != AlimentState.Box && keyFood.Value != AlimentState.Stack)
            {
                foodToGet = PoolManager.Instance.Get(keyFood, alimentViewID);
                limitedFoodsStocked[keyFood] -= 1;
                if (limitedFoodsStocked[keyFood] == 0)
                {
                    limitedFoodsStocked.Remove(keyFood);
                    ui.RemoveButton(keyFood);
                }
            }
            else
            {
                keyFood   = new KeyValuePair <string, AlimentState>(_alimentName, AlimentState.InContent);
                foodToGet = PoolManager.Instance.Get(keyFood, alimentViewID);
            }
        }
        else
        {
            foodToGet = PoolManager.Instance.Get(keyFood, alimentViewID);
            foodsStocked.Remove(keyFood);
            ui.RemoveButton(keyFood);
        }

        if (foodToGet != null)
        {
            GrabableObject toGrab = foodToGet.GetComponent <GrabableObject>();
            toGrab.Init();
            toGrab.AllowGrab(true);
            ownerPlayer.pInteract.GrabObject(toGrab, false);
        }
    }
Example #7
0
    void CookObject(Aliment _aliment, bool instantiateViewID)
    {
        // instantiation of standard aliment (bag, canned food)
        GameObject newCookedAlimentObject = PoolManager.Instance.Get(_aliment.CreateKeyPairValue(_aliment.alimentName, AlimentState.Cooked), instantiateViewID).gameObject;

        objectCooked = newCookedAlimentObject.GetComponent <GrabableObject>();

        objectCooked.Init();

        Aliment alimentCooked = objectCooked.GetComponent <Aliment>();

        alimentCooked.alimentStepState = _aliment.alimentStepState;

        objectCooked.AllowPhysic(false);
        objectCooked.AllowGrab(true);
        objectCooked.transform.position = foodPos.position;
        objectCooked.transform.rotation = foodPos.rotation;
        objectCooked.onGrab            += RemoveObject;

        grabableReceived.AllowGrab(true);
        grabableReceived.gameObject.GetComponent <Poolable>().DelObject();
        grabableReceived = null;
    }
Example #8
0
    // transform box into crate
    public void TakeSample(Aliment _aliment, bool instantiateViewID)
    {
        objectCooked = grabableReceived;

        objectCooked.AllowPhysic(false);
        objectCooked.AllowGrab(true); // To do : change to false
        objectCooked.onGrab += RemoveObject;


        // instantiation of sample aliment (bag, canned food)
        GameObject newSampleAlimentObject = PoolManager.Instance.Get(_aliment.CreateKeyPairValue(_aliment.alimentName, AlimentState.Sample), instantiateViewID).gameObject;

        newSampleAlimentObject.transform.position = FinalPos.position;
        newSampleAlimentObject.transform.rotation = FinalPos.rotation;

        objectSample = newSampleAlimentObject.GetComponent <GrabableObject>();

        objectSample.Init();

        //Aliment alimentStandard = objectSample.GetComponent<Aliment>();

        objectSample.AllowPhysic(false);
        objectSample.AllowGrab(true);
        objectSample.onGrab += RemoveObject;

        grabableReceived = null;

        if (player.photonView.IsMine)
        {
            // Affect the player
            player.EndInteractionState(this);
            GameManager.Instance.PopUp.CreateText("Echantillon prélevé", 50, new Vector2(0, 300), 3.0f);
        }

        player = null;
    }
Example #9
0
    // instantiate food object in hand of player
    public void GetFood(bool _Remove = false)
    {
        KeyValuePair <string, AlimentState> keyFood;
        Poolable foodToGet = null;

        if (_Remove == false)         // "se servir" button
        {
            // Take the key of prefab stock in slected button
            keyFood = ui.GetPoolableFromSelectedButton();
            // change state of the prefab stock in selected button if it's a box
            if (keyFood.Value == AlimentState.Box || keyFood.Value == AlimentState.Stack)
            {
                KeyValuePair <string, AlimentState> newKeyFood = new KeyValuePair <string, AlimentState>(keyFood.Key, AlimentState.InContent);
                foodToGet = PoolManager.Instance.Get(newKeyFood, true);
            }
            else             // remove object if state different of box or stack (limited food)
            {
                limitedFoodsStocked[keyFood] -= 1;
                if (limitedFoodsStocked[keyFood] == 0)
                {
                    if (ui.RemoveButton(out keyFood))
                    {
                        limitedFoodsStocked.Remove(keyFood);

                        foodToGet = PoolManager.Instance.Get(keyFood, true);
                    }
                }
                else
                {
                    foodToGet = PoolManager.Instance.Get(keyFood, true);
                }
            }
        }
        else        // remove object "Tout prendre" button
        {
            if (ui.RemoveButton(out keyFood))
            {
                foodsStocked.Remove(keyFood);
                foodToGet = PoolManager.Instance.Get(keyFood, true);


                if (keyFood.Value == AlimentState.Box)
                {
                    foodToGet.GetComponent <BoxDatasController>().Init();
                }
            }
        }

        GrabableObject toGrab = foodToGet.GetComponent <GrabableObject>();

        toGrab.Init();
        toGrab.AllowGrab(true);

        if (!player.pInteract.GrabObject(toGrab, false))
        {
            // player can't grab object.
            Debug.Log("grab");
        }
        else
        {
            photonView.RPC("GetObjectInColdRoom", RpcTarget.Others, keyFood.Key, keyFood.Value, foodToGet.photonView.ViewID, player.photonView.OwnerActorNr, _Remove);
            StopInteraction();

            GameManager.Instance.Audio.PlaySound("GrabCardboard", AudioManager.Canal.SoundEffect);
        }
    }