//Open fridge and play opening animation public void Interact(PlayerController pController) { GrabableObject handPlayer = pController.pDatas.objectInHand; if (handPlayer != null) { TrashBag trashBag = handPlayer.GetComponent <TrashBag>(); if (trashBag != null) { GrabableObject grabableReceived = pController.pInteract.ReleaseObject(false, false, false); Destroy(grabableReceived.gameObject); photonView.RPC("DestroyTrashBagOnline", RpcTarget.Others, pController.photonView.OwnerActorNr); } else { Poolable food = handPlayer.GetComponent <Poolable>(); if (food != null) { GameManager.Instance.Audio.PlaySound("Trash", AudioManager.Canal.SoundEffect); pController.pInteract.ReleaseObject(true); food.photonView.RPC("DelObjectOnline", RpcTarget.Others); food.DelObject(); } } } }
void ReleaseObject(object sender, ControllerEventArgs e) { if (e.isLeft && leftActive != null) { if (leftActive.GetComponent <Rigidbody>() != null) { leftActive.GetComponent <Rigidbody>().velocity = SteamVR_Controller.Input((int)e.controller.index).velocity; leftActive.GetComponent <Rigidbody>().angularVelocity = SteamVR_Controller.Input((int)e.controller.index).angularVelocity; } leftActive.Release(); leftActive = null; //controllers.GetComponent<ControllerAnimation>().isLeftGrabbing = false; } else if (!e.isLeft && rightActive != null) { if (rightActive.GetComponent <Rigidbody>() != null) { rightActive.GetComponent <Rigidbody>().velocity = SteamVR_Controller.Input((int)e.controller.index).velocity; rightActive.GetComponent <Rigidbody>().angularVelocity = SteamVR_Controller.Input((int)e.controller.index).angularVelocity; } rightActive.Release(); rightActive = null; //controllers.GetComponent<ControllerAnimation>().isRightGrabbing = false; } }
private void FinishAction(Aliment _aliment, int _transformationTime, bool instantiateViewID) { CookObject(_aliment, instantiateViewID); int ObjectCookedViewID = objectCooked.GetComponent <PhotonView>().ViewID; currentStartAction = null; photonView.RPC("FinishActionOnline", RpcTarget.Others, _aliment.alimentName, (int)_aliment.alimentState, _transformationTime, false, ObjectCookedViewID); }
private void FinishAction(Aliment _aliment, int _timeInSecond, bool instantiateViewID, bool _owner) { if (_owner) { CutObject(_aliment, instantiateViewID); int ObjectCuttedViewID = objectCutted.GetComponent <PhotonView>().ViewID; currentStartAction = null; photonView.RPC("FinishActionOnline", RpcTarget.Others, _aliment.alimentName, _aliment.alimentState, _timeInSecond, false, ObjectCuttedViewID); } }
private void FinishActionOnline(string _nameAliment, int _alimentState, int _timeInSecond, bool instantiateViewID, int _objectCookedViewID) { Aliment aliment = grabableReceived.GetComponent <Aliment>(); aliment.alimentName = _nameAliment; aliment.alimentState = (AlimentState)_alimentState; CookObject(aliment, instantiateViewID); objectCooked.GetComponent <PhotonView>().ViewID = _objectCookedViewID; currentStartAction = null; }
private void FinishAction(Aliment _aliment, int _timeInSecond, bool instantiateViewID, bool _owner) { if (_owner) { TakeSample(_aliment, instantiateViewID); int objectEmptyViewID = objectCooked.GetComponent <PhotonView>().ViewID; int objectStackViewID = objectSample.GetComponent <PhotonView>().ViewID; currentStartAction = null; photonView.RPC("FinishActionOnline", RpcTarget.Others, _aliment.alimentName, (int)_aliment.alimentState, _timeInSecond, false, objectEmptyViewID, objectStackViewID); } }
private void FinishAction(Aliment _aliment, int _timeInSecond, bool instantiateViewID, bool _owner) { if (_owner) { CleanObject(_aliment, instantiateViewID); waterParticleSystem.gameObject.SetActive(false); foamParticleSystem.gameObject.SetActive(false); int objectEmptyViewID = ObjectEmpty.GetComponent <PhotonView>().ViewID; int objectStandardViewID = ObjectStandard.GetComponent <PhotonView>().ViewID; currentStartAction = null; photonView.RPC("FinishActionOnline", RpcTarget.Others, _aliment.alimentName, _aliment.alimentState, _timeInSecond, false, objectEmptyViewID, objectStandardViewID); } }
public bool StockAliment(GrabableObject _grabable, bool _sendOnline) { if (haveObject == false) { Debug.Log("Gastro"); Aliment newAliment = _grabable.GetComponent <Aliment>(); if (newAliment != null && _grabable.Grab(null, transform, false)) { Debug.Log("Take"); alimentStocked = newAliment; alimentStocked.transform.position = posAliment.transform.position; alimentStocked.transform.rotation = posAliment.transform.rotation; haveObject = true; isClean = false; if (_sendOnline) { photonView.RPC("NetworkStockAliment", RpcTarget.Others, _grabable.photonView.ViewID); } return(true); } return(false); } return(false); }
public bool CanTakeGrabable(GrabableObject _grabable) { Aliment aliment = _grabable.GetComponent <Aliment>(); bool canGrab = aliment != null; return(canGrab); }
private void FinishActionOnline(string _nameAliment, AlimentState _alimentState, int _timeInSecond, bool instantiateViewID, int _objectEmptyViewID, int _objectStandardViewID) { Aliment aliment = grabableReceived.GetComponent <Aliment>(); aliment.alimentName = _nameAliment; aliment.alimentState = _alimentState; CleanObject(aliment, instantiateViewID); waterParticleSystem.gameObject.SetActive(false); foamParticleSystem.gameObject.SetActive(false); ObjectEmpty.GetComponent <PhotonView>().ViewID = _objectEmptyViewID; ObjectStandard.GetComponent <PhotonView>().ViewID = _objectStandardViewID; currentStartAction = null; }
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)); //} }
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); } }
public bool CanInteract(PlayerController pController) { GrabableObject objectInHand = pController.pDatas.objectInHand; if (objectInHand != null) { Aliment alimentInHand = objectInHand.GetComponent <Aliment>(); if (alimentInHand != null) { return(true); } } return(false); }
private void FinishActionOnline(string _nameAliment, int _alimentState, int _timeInSecond, bool instantiateViewID, int _objectEmptyViewID, int _objectStackViewID) { Gastro gastroOnPost = grabableReceived.GetComponent <Gastro>(); Aliment aliment; if (gastroOnPost != null) { aliment = gastroOnPost.alimentStocked; } else { aliment = grabableReceived.GetComponent <Aliment>(); } aliment.alimentName = _nameAliment; aliment.alimentState = (AlimentState)_alimentState; TakeSample(aliment, instantiateViewID); objectCooked.GetComponent <PhotonView>().ViewID = _objectEmptyViewID; objectSample.GetComponent <PhotonView>().ViewID = _objectStackViewID; currentStartAction = null; }
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); }
//Open fridge and play opening animation public void Interact(PlayerController pController) { Gastro gastroInHand = pController.pDatas.gastroInHand; GrabableObject handPlayer = pController.pDatas.objectInHand; if (handPlayer != null) { Poolable food; if (gastroInHand != null) { Aliment alimentToThrow = gastroInHand.alimentStocked; if (alimentToThrow != null) { food = gastroInHand.alimentStocked.GetComponent <Poolable>(); } else { GameManager.Instance.PopUp.CreateText("Aucun élément à jeter", 50, new Vector2(0, 300), 3.0f); return; } } else { food = handPlayer.GetComponent <Poolable>(); } if (food != null) { if (nbOfElementInTrash == nbMaxOfElement) { GameManager.Instance.PopUp.CreateText("Poubelle pleine", 50, new Vector2(0, 300), 3.0f); } else { ThrowObject(pController, food); } } } else if (nbOfElementInTrash > 0) { CleanTrash(pController); } }
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)); } }
private void OnGrabBox(GrabableObject _grabableObject) { BoxDatasController box = _grabableObject.GetComponent <BoxDatasController>(); PosFree.Add(boxInPos[box]); boxInPos.Remove(box); UpdateBoxPosition(); StartCoroutine(InstantiateBox()); _grabableObject.onGrab -= OnGrabBox; if (boxInPos.Count == 0) { deliveryMan.Leave(); } // sound GameManager.Instance.Audio.PlaySound("FastConveyorBelt", AudioManager.Canal.SoundEffect); }
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; }
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); } }
/// <summary> /// Use of Disinfection Post /// </summary> /// <param name="pController"></param> public void Interact(PlayerController pController) { player = pController; GrabableObject objectInHand = pController.pDatas.objectInHand; Gastro gastroInHand = player.pDatas.gastroInHand; // Put object = No object in furnace and object in hand of player if (haveAnObject == false) { if (grabableReceived == null) { Aliment actualAliment; if (gastroInHand != null) { actualAliment = gastroInHand.alimentStocked; } else { actualAliment = objectInHand.GetComponent <Aliment>(); } if (actualAliment != null && actualAliment.alimentState >= AlimentState.Standard && actualAliment.alimentState <= AlimentState.Sample) { AlimentObject actualAlimentObject = FoodDatabase.mapAlimentObject[actualAliment.alimentName]; bool alimenStateExist = false; for (int i = 0; i < actualAlimentObject.listState.Count; i++) { if (actualAlimentObject.listState[i].state == AlimentState.Cooked) { alimenStateExist = true; break; } } if (alimenStateExist) { if (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; Aliment newAliment = grabableReceived.GetComponent <Aliment>(); // Affect the player player.TeleportTo(playerPosition, true); player.BeginInteractionState(); // transform dirty aliment into fresh aliment if (newAliment != null) { currentStartAction = StartCoroutine(StartAction(newAliment, transformationTime, true)); photonView.RPC("StartActionOnline", RpcTarget.Others, pController.photonView.OwnerActorNr); } } else { GameManager.Instance.PopUp.CreateText("Cet aliment ne peut pas être cuit", 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); } } } else if (haveAnObject == true && objectInHand != null) { if (gastroInHand != null && gastroInHand.alimentStocked == null) { StartCoroutine(TakeFood()); } } else if (objectInHand == null && haveAnObject == true) // Take object = object in furnace and no object in hand of player { StartCoroutine(TakeFood()); } else if (gastroInHand != null && haveAnObject == true) // put object impossible = object in furnace and object in hand of player { GameManager.Instance.PopUp.CreateText("Il y a actuellement un objet dans la sauteuse", 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); } }
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); } }
/// <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 in furnace 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.Standard || actualAliment.alimentState == AlimentState.Clean)) { AlimentObject actualAlimentObject = FoodDatabase.mapAlimentObject[actualAliment.alimentName]; bool alimenStateExist = false; for (int i = 0; i < actualAlimentObject.listState.Count; i++) { if (actualAlimentObject.listState[i].state == AlimentState.Cut) { alimenStateExist = true; break; } } if (alimenStateExist) { 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; 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 aliment ne peut pas être coupé", 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); } } } else if (objectInHand == null && haveAnObject == true) // Take object = object in furnace and no object in hand of player { if (player.pDatas.gastroInHand != null) { if (player.pDatas.gastroInHand.StockAliment(objectCutted, true) == false) { GameManager.Instance.PopUp.CreateText("impossible de mettre " + objectCutted.GetComponent <Aliment>().alimentName + " dans le gastro", 50, new Vector2(0, 300), 3.0f); } } else { if (player.pInteract.GrabObject(objectCutted, true) == false) { GameManager.Instance.PopUp.CreateText("impossible de prendre " + objectCutted.GetComponent <Aliment>().alimentName + " dans vos mains", 50, new Vector2(0, 300), 3.0f); } } } else if (objectInHand != null && haveAnObject == true) // put object impossible = object in furnace and object in hand of player { 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; #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); } }