Example #1
0
    IEnumerator TakeFood()
    {
        photonView.RPC("TakeFoodOnline", RpcTarget.Others);
        StartDisplay(false, true);
        //Ajouter animation et timing//
        player.TeleportTo(playerPosition, true);
        player.BeginInteractionState();

        yield return(new WaitForSeconds(1.5f));

        // Affect the player
        player.EndInteractionState(this);
        objectCooked.AllowGrab(true);

        if (player.pDatas.gastroInHand != null)
        {
            if (player.pDatas.gastroInHand.StockAliment(objectCooked, true) == false)
            {
                GameManager.Instance.PopUp.CreateText("impossible de mettre " + objectCooked.GetComponent <Aliment>().alimentName + " dans le gastro", 50, new Vector2(0, 300), 3.0f);
            }
        }
        else
        {
            if (player.pInteract.GrabObject(objectCooked, true) == false)
            {
                GameManager.Instance.PopUp.CreateText("impossible de prendre " + objectCooked.GetComponent <Aliment>().alimentName + " dans vos mains", 50, new Vector2(0, 300), 3.0f);
            }
        }
    }
    void TreatObject(Aliment _aliment, bool instantiateViewID)
    {
        // instantiation of empty aliment (bag, canned food)
        GameObject newWasteAlimentObject = PoolManager.Instance.Get(_aliment.CreateKeyPairValue(_aliment.alimentName, AlimentState.Waste), instantiateViewID).gameObject;

        newWasteAlimentObject.transform.position = initPos.position;
        newWasteAlimentObject.transform.rotation = initPos.rotation;

        ObjectWaste = newWasteAlimentObject.GetComponent <GrabableObject>();

        ObjectWaste.Init();

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


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

        newTreatedAlimentObject.transform.position = FinalPos.position;
        newTreatedAlimentObject.transform.rotation = FinalPos.rotation;

        ObjectTreated = newTreatedAlimentObject.GetComponent <GrabableObject>();

        ObjectTreated.Init();

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

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

        ObjectTreated.AllowPhysic(false);
        ObjectTreated.AllowGrab(true);
        ObjectTreated.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 déconditionné", 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
    public void PutObjectOnSampleStation(int actorNumber)
    {
        PlayerController photonPlayer = InGamePhotonManager.Instance.PlayersConnected[actorNumber].GetComponent <PlayerController>();

        player = photonPlayer;

        //if (player.pDatas.gastroInHand != null)
        //{
        //    grabableReceived = player.pDatas.gastroInHand.ReleaseObject(false, false, false);
        //}
        //else
        //{
        //    grabableReceived = player.pInteract.ReleaseObject(false, false, false);
        //}
        grabableReceived = player.pInteract.ReleaseObject(false, false, false);
        grabableReceived.AllowGrab(false);
        grabableReceived.transform.position = initPos.position;
        grabableReceived.transform.rotation = initPos.rotation;
        haveAnObject = true;

        Aliment newAliment = grabableReceived.GetComponent <Aliment>();

        // Affect the player
        photonPlayer.TeleportTo(playerPosition, true);

        //if (newAliment != null)
        //{
        //    currentStartAction = StartCoroutine(StartAction(newAliment, transformationTime, false, false));
        //}
    }
Example #5
0
    void PutGastro(PlayerController _pController)
    {
        int key = -1;

        for (int i = 0; i < gastroStocked.Count; i++)
        {
            GrabableObject actualGastro = gastroStocked[i];
            if (actualGastro == null)
            {
                key = i;
                GrabableObject gastro = _pController.pInteract.ReleaseObject(false, false, false);
                gastro.AllowGrab(false);
                gastro.AllowPhysic(false);
                gastro.transform.position = gastroPos[i].position;
                gastro.transform.rotation = gastroPos[i].rotation;
                gastroStocked[i]          = gastro;

                isEmpty = false;
                break;
            }
        }

        CheckStock();

        photonView.RPC("PutGastroOnline", RpcTarget.Others, key, _pController.photonView.OwnerActorNr);
    }
    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);
        }
    }
Example #7
0
    public void GetObjectOnUnpackPost(int actorNumber)
    {
        player = InGamePhotonManager.Instance.PlayersConnected[actorNumber].GetComponent <PlayerController>();

        objectSample.AllowGrab(true);
        //player.pInteract.GrabObject(boxToGive);
        objectSample = null;
    }
Example #8
0
 public void CancelInteraction()
 {
     StopCoroutine(currentStartAction);
     if (grabableReceived != null)
     {
         grabableReceived.AllowGrab(true);
     }
     player             = null;
     currentStartAction = null;
 }
Example #9
0
    public void StartActionOnline(int _actorNumber)
    {
        Debug.Log("StartActionOnline");
        PlayerController photonPlayer = InGamePhotonManager.Instance.PlayersConnected[_actorNumber];

        player = photonPlayer;

        if (player.pDatas.gastroInHand != null)
        {
            grabableReceived = player.pDatas.gastroInHand.ReleaseObject(false, false, false);
        }
        else
        {
            grabableReceived = player.pInteract.ReleaseObject(false, false, false);
        }
        grabableReceived.AllowGrab(false);
        grabableReceived.transform.position = foodPos.position;
        grabableReceived.transform.rotation = foodPos.rotation;

        haveAnObject = true;
    }
Example #10
0
    public void PutSampleOnline(int _actorNumber)
    {
        PlayerController photonPlayer = InGamePhotonManager.Instance.PlayersConnected[_actorNumber];

        Aliment alimentInHand = photonPlayer.pDatas.objectInHand.GetComponent <Aliment>();

        alimentStocked.Add(alimentInHand);
        // Affect the player
        GrabableObject grabable = photonPlayer.pInteract.ReleaseObject(false, false, false);

        grabable.AllowGrab(true);
        grabable.gameObject.GetComponent <Poolable>().DelObject();
    }
Example #11
0
    private void PutSample(PlayerController _pController)
    {
        Aliment alimentInHand = _pController.pDatas.objectInHand.GetComponent <Aliment>();

        alimentStocked.Add(alimentInHand);
        // Affect the player
        photonView.RPC("PutSampleOnline", RpcTarget.Others, _pController.photonView.OwnerActorNr);

        GrabableObject grabable = _pController.pInteract.ReleaseObject(false, false, false);

        grabable.AllowGrab(true);
        grabable.gameObject.GetComponent <Poolable>().DelObject();
    }
Example #12
0
    private void PutObjectInPost(int _actorNumber) //Online
    {
        PlayerController photonPlayer = InGamePhotonManager.Instance.PlayersConnected[_actorNumber];

        grabableReceived = photonPlayer.pInteract.ReleaseObject(false, false, false);
        grabableReceived.AllowGrab(true);
        grabableReceived.AllowPhysic(false);
        grabableReceived.transform.position = foodPos.position;
        grabableReceived.transform.rotation = foodPos.rotation;

        haveAnObject = true;

        grabableReceived.onGrab += RemoveObject;
    }
Example #13
0
    void PutObject(PlayerController _pController)
    {
        grabableReceived = _pController.pInteract.ReleaseObject(false, false, false);
        grabableReceived.AllowGrab(true);
        grabableReceived.AllowPhysic(false);
        grabableReceived.transform.position = foodPos.position;
        grabableReceived.transform.rotation = foodPos.rotation;

        haveAnObject = true;

        grabableReceived.onGrab += RemoveObject;

        GameManager.Instance.PopUp.CreateText("Objet posé", 50, new Vector2(0, 300), 3.0f);
    }
Example #14
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 #15
0
    void PutGastroOnline(int _key, int _actorNr)
    {
        PlayerController photonPlayer = InGamePhotonManager.Instance.PlayersConnected[_actorNr].GetComponent <PlayerController>();

        GrabableObject gastro = photonPlayer.pInteract.ReleaseObject(false, false, false);

        gastro.transform.position = gastroPos[_key].position;
        gastro.transform.rotation = gastroPos[_key].rotation;
        gastro.AllowGrab(false);
        gastro.AllowPhysic(false);
        gastroStocked[_key] = gastro;

        isEmpty = false;
        CheckStock();
    }
Example #16
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 #17
0
    void PutObjectInTrolley(Aliment _aliment)
    {
        // Affect the players
        Gastro gastroInHand = player.pDatas.gastroInHand;

        grabableReceived = gastroInHand.ReleaseObject(false, false, false);
        alimentStocked.Add(_aliment);
        grabableReceived.AllowGrab(true);
        grabableReceived.gameObject.GetComponent <Poolable>().DelObject();
        grabableReceived = null;

        photonView.RPC("PutObjectInTrolleyOnline", RpcTarget.Others, player.photonView.OwnerActorNr);
        player = null;
        onUse  = false;

        gastroInHand.transform.position = gastroPos.position;
        gastroInHand.gameObject.SetActive(false);
    }
Example #18
0
    void PutObjectInTrolleyOnline(int _actorNumber)
    {
        PlayerController photonPlayer = InGamePhotonManager.Instance.PlayersConnected[_actorNumber];

        Gastro gastroInHand = photonPlayer.pDatas.gastroInHand;

        grabableReceived = gastroInHand.ReleaseObject(false, false, false);

        Aliment playerAliment = grabableReceived.GetComponent <Aliment>();

        alimentStocked.Add(playerAliment);
        grabableReceived.AllowGrab(true);
        grabableReceived.gameObject.GetComponent <Poolable>().DelObject();
        grabableReceived = null;
        onUse            = false;

        gastroInHand.transform.position = gastroPos.position;
        gastroInHand.gameObject.SetActive(false);
    }
Example #19
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 #20
0
    public void PutObjectOnUnpackPost(int actorNumber)
    {
        PlayerController photonPlayer = InGamePhotonManager.Instance.PlayersConnected[actorNumber];

        player = photonPlayer;

        grabableReceived = photonPlayer.pInteract.ReleaseObject(false, false);
        grabableReceived.AllowGrab(false);
        grabableReceived.transform.position = initPos.position;
        grabableReceived.transform.rotation = initPos.rotation;

        Aliment newAliment = grabableReceived.GetComponent <Aliment>();

        // Affect the player
        photonPlayer.TeleportTo(playerPosition, true);

        if (newAliment != null)
        {
            currentStartAction = StartCoroutine(StartAction(newAliment, transformationTime, false, false));
        }
    }
Example #21
0
    public void Init()
    {
        nameObject = GetComponent <Nominator>().customName;
        GameManager.Instance.PopUp.CreateText3D(nameObject, 15, posText3D.localPosition, transform);

        Gastro[] gastroInChildren = GetComponentsInChildren <Gastro>();

        for (int i = 0; i < gastroInChildren.Length; i++)
        {
            GrabableObject newGastro = gastroInChildren[i].GetComponent <GrabableObject>();
            newGastro.AllowGrab(false);
            if (newGastro != null)
            {
                gastroStocked.Add(i, newGastro);
            }
            else
            {
                Debug.LogError("gastro non ajouté à la liste au démarage");
            }
        }
    }
Example #22
0
    void TakeGastro(PlayerController _pController)
    {
        int key = -1;

        for (int i = 0; i < gastroStocked.Count; i++)
        {
            GrabableObject actualGastro = gastroStocked[i];
            if (actualGastro != null)
            {
                actualGastro.AllowGrab(true);
                key = i;
                _pController.pInteract.GrabObject(actualGastro, false);
                gastroStocked[i] = null;
                isFull           = false;
                break;
            }
        }
        CheckStock();

        photonView.RPC("TakeGastroOnline", RpcTarget.Others, key, _pController.photonView.OwnerActorNr);
    }
Example #23
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 #24
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 #25
0
    private void PutObjectInPost(int _actorNumber)
    {
        PlayerController photonPlayer = InGamePhotonManager.Instance.PlayersConnected[_actorNumber];

        player = photonPlayer;

        grabableReceived = photonPlayer.pInteract.ReleaseObject(false, false, false);
        grabableReceived.AllowGrab(false);
        grabableReceived.transform.position = foodPos.position;
        grabableReceived.transform.rotation = foodPos.rotation;

        haveAnObject = true;

        Aliment newAliment = grabableReceived.GetComponent <Aliment>();

        // Affect the player
        photonPlayer.TeleportTo(playerPosition, true);

        // transform dirty aliment into fresh aliment
        if (newAliment != null)
        {
            currentStartAction = StartCoroutine(StartAction(newAliment, transformationTime, false));
        }
    }
    /// <summary>
    /// Use of Disinfection Post
    /// </summary>
    /// <param name="pController"></param>
    public void Interact(PlayerController pController)
    {
        player = pController;
        GrabableObject objectInHand = player.pDatas.objectInHand;
        Gastro         gastroInHand = player.pDatas.gastroInHand;

        // Put object = No object on post and object in hand of player
        if (haveAnObject == false && objectInHand != null)
        {
            if (grabableReceived == null)
            {
                Aliment actualAliment;
                if (gastroInHand != null)
                {
                    actualAliment = gastroInHand.alimentStocked;
                }
                else
                {
                    actualAliment = objectInHand.GetComponent <Aliment>();
                }
                if (actualAliment != null && actualAliment.alimentState == AlimentState.InContent)
                {
                    if (player.pDatas.gastroInHand != null)
                    {
                        grabableReceived = player.pDatas.gastroInHand.ReleaseObject(false, false, false);
                    }
                    else
                    {
                        grabableReceived = player.pInteract.ReleaseObject(false, false, false);
                    }
                    grabableReceived.AllowGrab(false);
                    grabableReceived.transform.position = initPos.position;
                    grabableReceived.transform.rotation = initPos.rotation;

                    haveAnObject = true;

                    Aliment newAliment = grabableReceived.GetComponent <Aliment>();

                    // Affect the player
                    player.TeleportTo(playerPosition, true);
                    player.BeginInteractionState();

                    // transform dirty aliment into fresh aliment
                    if (newAliment != null)
                    {
                        GeneralError.ErrorNoOutfit(pController);
                        currentStartAction = StartCoroutine(StartAction(newAliment, transformationTime, true, true));
                    }

                    photonView.RPC("PutObjectInPost", RpcTarget.Others, pController.photonView.OwnerActorNr);
                }
                else
                {
                    GameManager.Instance.PopUp.CreateText("Cet object ne peut pas être déposé ici", 50, new Vector2(0, 300), 3.0f);
                }
            }
        }
        else if (objectInHand != null && haveAnObject == true)
        {
            GameManager.Instance.PopUp.CreateText("Il y a actuellement un objet sur le poste", 50, new Vector2(0, 300), 3.0f);
        }
    }
Example #27
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);
        }
    }
Example #28
0
    public void Interact(PlayerController pController)
    {
        player = pController;

        GrabableObject objectInHand = player.pDatas.objectInHand;

#if UNITY_EDITOR
        Debug.Log("objectInHand is NUll :" + (objectInHand == null));
        Debug.Log("boxToUnpack is NUll : " + (grabableReceived == null));
        Debug.Log("boxToGive is NUll: " + (ObjectStack == null));
#endif

        if (objectInHand != null && haveAnObject == false)
        {
            if (grabableReceived == null)
            {
                Aliment actualAliment = objectInHand.GetComponent <Aliment>();

                if (actualAliment != null && actualAliment.alimentState == AlimentState.Box)
                {
                    BoxDatasController boxReceived = actualAliment.GetComponent <BoxDatasController>();

                    // ERROR CHECK
                    if (!boxReceived.IsClean())
                    {
                        string str = "Décartonnage d'un carton de " + actualAliment.alimentName + " n'étant ni au norme, ni en bonne état.";
                        GameManager.Instance.Score.myScore.AddError(Score.HygieneCounter.DecartonnageDirtyCardboard, pController.GetGridCellPos(), str);
                    }

                    // Put Object on post
                    grabableReceived = player.pInteract.ReleaseObject(false, false);
                    grabableReceived.AllowGrab(false);
                    grabableReceived.transform.position = initPos.position;
                    grabableReceived.transform.rotation = initPos.rotation;

                    haveAnObject = true;

                    Aliment newAliment = grabableReceived.GetComponent <Aliment>();

                    // Affect the player
                    player.TeleportTo(playerPosition, true);
                    player.BeginInteractionState();


                    // transform box into crate
                    if (newAliment != null)
                    {
                        currentStartAction = StartCoroutine(StartAction(newAliment, transformationTime, true, true));
                    }

                    photonView.RPC("PutObjectOnUnpackPost", RpcTarget.Others, player.photonView.OwnerActorNr);
                }
                else
                {
                    GameManager.Instance.PopUp.CreateText("Uniquement les boîtes peuvent être déballées", 50, new Vector2(0, 300), 3.0f);
                }
            }
        }
        else if (objectInHand != null && haveAnObject == true)
        {
            GameManager.Instance.PopUp.CreateText("Il y a actuellement un objet sur le poste", 50, new Vector2(0, 300), 3.0f);
        }
    }
Example #29
0
    public void Interact(PlayerController pController)
    {
        player = pController;

        GrabableObject objectInHand = player.pDatas.objectInHand;
        Gastro         gastroInHand = player.pDatas.gastroInHand;

#if UNITY_EDITOR
        Debug.Log("objectInHand is NUll :" + (objectInHand == null));
        Debug.Log("boxToUnpack is NUll : " + (grabableReceived == null));
        Debug.Log("boxToGive is NUll: " + (objectSample == null));
#endif

        if (objectInHand != null && haveAnObject == false)
        {
            if (grabableReceived == null)
            {
                Aliment actualAliment;
                if (gastroInHand != null)
                {
                    actualAliment = gastroInHand.alimentStocked;
                }
                else
                {
                    actualAliment = objectInHand.GetComponent <Aliment>();
                }

                if (actualAliment != null && (actualAliment.alimentState == AlimentState.Cooked || actualAliment.alimentState == AlimentState.Cut || actualAliment.alimentState == AlimentState.Standard || actualAliment.alimentState == AlimentState.Clean))
                {
                    // Put Object on post
                    grabableReceived = player.pInteract.ReleaseObject(false, false, false);
                    grabableReceived.AllowGrab(false);
                    grabableReceived.transform.position = initPos.position;
                    grabableReceived.transform.rotation = initPos.rotation;

                    haveAnObject = true;

                    // Affect the player
                    player.TeleportTo(playerPosition, true);
                    player.BeginInteractionState();


                    // transform box into crate
                    if (actualAliment != null)
                    {
                        currentStartAction = StartCoroutine(StartAction(actualAliment, transformationTime, true, true));
                    }

                    //photonView.RPC("PutObjectOnSampleStation", RpcTarget.Others, player.photonView.OwnerActorNr);
                }
                else
                {
                    GameManager.Instance.PopUp.CreateText("L'aliment n'est pas préparé", 50, new Vector2(0, 300), 3.0f);
                }
            }
        }
        else if (objectInHand != null && haveAnObject == true)
        {
            GameManager.Instance.PopUp.CreateText("Il y a actuellement un objet sur le poste", 50, new Vector2(0, 300), 3.0f);
        }
    }
    public void Interact(PlayerController pController)
    {
        player = pController;
        GrabableObject objectInHand = player.pDatas.objectInHand;
        Gastro         gastroInHand = pController.pDatas.gastroInHand;

        // Put object = No object on post and object in hand of player
        if (haveAnObject == false && objectInHand != null)
        {
            if (gastroInHand == null)
            {
                if (grabableReceived == null)
                {
                    Aliment actualAliment = objectInHand.GetComponent <Aliment>();
                    string  alimentType   = actualAliment.alimentType.ToString();
                    string  postType      = typeOfTreament.ToString();

                    if (alimentType == postType)
                    {
                        sameState = true;
                    }
                    else
                    {
                        sameState = false;
                    }

                    Debug.Log(alimentType);
                    Debug.Log(postType);
                    Debug.Log(sameState);

                    if (actualAliment != null && (actualAliment.alimentState == AlimentState.InContent || actualAliment.alimentState == AlimentState.Standard))
                    {
                        AlimentObject actualAlimentObject = FoodDatabase.mapAlimentObject[actualAliment.alimentName];

                        bool alimenStateExist = false;
                        for (int i = 0; i < actualAlimentObject.listState.Count; i++)
                        {
                            if (actualAlimentObject.listState[i].state == AlimentState.Clean)
                            {
                                alimenStateExist = true;
                                break;
                            }
                        }

                        if (sameState && alimenStateExist)
                        {
                            grabableReceived = player.pInteract.ReleaseObject(false, false, false);
                            grabableReceived.AllowGrab(false);
                            grabableReceived.AllowPhysic(false);
                            grabableReceived.transform.position = initPos.position;
                            grabableReceived.transform.rotation = initPos.rotation;

                            haveAnObject = true;

                            Aliment newAliment = grabableReceived.GetComponent <Aliment>();

                            // Affect the player
                            player.TeleportTo(playerPosition, true);
                            player.BeginInteractionState();

                            // transform dirty aliment into fresh aliment
                            if (newAliment != null)
                            {
                                GeneralError.ErrorNoOutfit(pController);
                                currentStartAction = StartCoroutine(StartAction(newAliment, transformationTime, true, true));
                            }

                            photonView.RPC("PutObjectInPost", RpcTarget.Others, pController.photonView.OwnerActorNr);
                        }
                        else
                        {
                            GameManager.Instance.PopUp.CreateText("Cet Objet ne peut pas être déposé ici", 50, new Vector2(0, 300), 3.0f);
                        }
                    }
                    else if (objectInHand != null && haveAnObject == true)
                    {
                        GameManager.Instance.PopUp.CreateText("Il y a actuellement un objet sur le poste", 50, new Vector2(0, 300), 3.0f);
                    }
                    else
                    {
                        GameManager.Instance.PopUp.CreateText("Cet Objet ne peut pas être déposé ici", 50, new Vector2(0, 300), 3.0f);
                    }
                }
            }
            else
            {
                GameManager.Instance.PopUp.CreateText("Il n'est pas possible d'utiliser un gastro ici", 50, new Vector2(0, 300), 3.0f);
            }
        }
        else
        {
            GameManager.Instance.PopUp.CreateText("Cet object ne peut pas être déposé ici", 50, new Vector2(0, 300), 3.0f);
        }
    }