Ejemplo n.º 1
0
    public void PutObjectInColdRoom(int actorNumber)
    {
        PlayerController ownerPlayer = InGamePhotonManager.Instance.PlayersConnected[actorNumber];
        Aliment          foodToAdd   = ownerPlayer.pDatas.objectInHand.GetComponent <Aliment>();

        if (foodToAdd.alimentState == AlimentState.Stack || foodToAdd.alimentState == AlimentState.Box)         // unlimited Food
        {
            if (!foodsStocked.Contains(foodToAdd.CreateKeyPairValue()))
            {
                AddFood(foodToAdd.CreateKeyPairValue(), false);
                ownerPlayer.pInteract.ReleaseObject(false);

                foodToAdd.GetComponent <Poolable>().DelObject();                // !!! chose : put food in pool (or put it on shelf)
            }
            else
            {
                ownerPlayer.pInteract.ReleaseObject(false);
                foodToAdd.GetComponent <Poolable>().DelObject();                // !!! chose : put food in pool (or put it on shelf)
            }
        }
        else                                                                      // limited food
        {
            if (!limitedFoodsStocked.ContainsKey(foodToAdd.CreateKeyPairValue())) //first deposit
            {
                AddFood(foodToAdd.CreateKeyPairValue(), false);
                ownerPlayer.pInteract.ReleaseObject(false);

                foodToAdd.GetComponent <Poolable>().DelObject();                // !!! chose : put food in pool (or put it on shelf)
            }
            else
            {
                limitedFoodsStocked[foodToAdd.CreateKeyPairValue()] += 1;
                ownerPlayer.pInteract.ReleaseObject(false);
                foodToAdd.GetComponent <Poolable>().DelObject();                // !!! chose : put food in pool (or put it on shelf)
            }
        }
    }
Ejemplo n.º 2
0
    //Set Player who use ColdRoom
    public void Interact(PlayerController pController)
    {
        gameManager.FreeMouse();

        player = pController;

        if (player.pDatas.objectInHand == null)
        {
            ui.DisplayUiMenu(); // Display Menu
        }
        else                    // put object in coldRoom
        {
            Gastro gastroInHand = pController.pDatas.gastroInHand;

            if (gastroInHand == null)
            {
                Aliment   foodToAdd = player.pDatas.objectInHand.GetComponent <Aliment>();
                Nominator nominator = player.pDatas.objectInHand.GetComponent <Nominator>();

                if (foodToAdd == null)                 // EXIT IF NO ALIMENT FOUND
                {
                    GameManager.Instance.PopUp.CreateText("Imossible de placer " + nominator.customName + " dans la chambre froide", 50, new Vector2(0, 300), 3.0f);
                    return;
                }

                photonView.RPC("PutObjectInColdRoom", RpcTarget.Others, player.photonView.OwnerActorNr);

                if ((foodToAdd.alimentState == AlimentState.Stack || foodToAdd.alimentState == AlimentState.Box))                 // unlimited Food
                {
                    if (!foodsStocked.Contains(foodToAdd.CreateKeyPairValue()))
                    {
                        AddFood(foodToAdd.CreateKeyPairValue(), true);
                        player.pInteract.ReleaseObject(true, true, false);
                        foodToAdd.GetComponent <Poolable>().DelObject();                        // !!! chose : put food in pool (or put it on shelf)
                        GeneralError.ErrorNoOutfit(pController);
                        GameManager.Instance.PopUp.CreateText(nominator.customName + " déposé", 50, new Vector2(0, 300), 3.0f);
                    }
                    else
                    {
                        player.pInteract.ReleaseObject(true, true, false);
                        foodToAdd.GetComponent <Poolable>().DelObject();                        // !!! chose : put food in pool (or put it on shelf)
                        GeneralError.ErrorNoOutfit(pController);
                        GameManager.Instance.PopUp.CreateText(nominator.customName + " déposé", 50, new Vector2(0, 300), 3.0f);
                    }
                }
                else                                                                      // limited food
                {
                    if (!limitedFoodsStocked.ContainsKey(foodToAdd.CreateKeyPairValue())) //first deposit
                    {
                        AddFood(foodToAdd.CreateKeyPairValue(), true);
                        player.pInteract.ReleaseObject(true, true, false);
                        foodToAdd.GetComponent <Poolable>().DelObject();                        // !!! chose : put food in pool (or put it on shelf)
                        GeneralError.ErrorNoOutfit(pController);
                        GameManager.Instance.PopUp.CreateText(nominator.customName + " déposé", 50, new Vector2(0, 300), 3.0f);
                    }
                    else
                    {
                        limitedFoodsStocked[foodToAdd.CreateKeyPairValue()] += 1;
                        player.pInteract.ReleaseObject(true, true, false);
                        foodToAdd.GetComponent <Poolable>().DelObject();                        // !!! chose : put food in pool (or put it on shelf)
                        GeneralError.ErrorNoOutfit(pController);
                        GameManager.Instance.PopUp.CreateText(nominator.customName + " déposé", 50, new Vector2(0, 300), 3.0f);
                    }
                }
            }
            else
            {
                GameManager.Instance.PopUp.CreateText("Il n'est pas possible de déposer/utiliser un gastro ici", 50, new Vector2(0, 300), 3.0f);
            }
        }
    }
Ejemplo n.º 3
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);
        }
    }