private void PutObjectInPost(int _actorNumber) { 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 = initPos.position; grabableReceived.transform.rotation = initPos.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, 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); } }
public bool CanTakeGrabable(GrabableObject _grabable) { Aliment aliment = _grabable.GetComponent <Aliment>(); bool canGrab = aliment != null; return(canGrab); }
// Update is called once per frame void Update() { //Attack if (Input.GetMouseButtonDown(0) && equipped != null && equipped.GetComponent <MeleeWeapon>() != null) { MeleeWeapon w = equipped.GetComponent <MeleeWeapon>(); w.activate(); //if (!w.isActive) { w.activate(); } } //Unequip if (Input.GetMouseButtonDown(1) && equipped != null) { equipped.transform.parent = null; GrabableObject go = equipped.GetComponent <GrabableObject>(); go.owner = null; go.reset_y_position(); equipped.transform.localRotation = Quaternion.identity; equipped = null; anim.SetBool("isHolding", false); //play sound TempSoundPlayer sp = (Instantiate(Resources.Load("TempSoundPlayer"), transform.position, transform.rotation) as GameObject).GetComponent <TempSoundPlayer>(); sp.setVolume(0.2f); sp.playSound(drop_sound); } }
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 RemoveObject(GrabableObject _objectGrab) { if (_objectGrab == ObjectEmpty) { ObjectEmpty = null; _objectGrab.onGrab -= RemoveObject; if (ObjectStandard == null) { haveAnObject = false; } } else if (_objectGrab == ObjectStandard) { ObjectStandard = null; _objectGrab.onGrab -= RemoveObject; if (ObjectEmpty == null) { haveAnObject = false; } } else { Debug.LogError("Error Remove Object"); } }
void RemoveObject(GrabableObject _objectGrab) { if (_objectGrab == ObjectWaste) { ObjectWaste = null; _objectGrab.onGrab -= RemoveObject; if (ObjectTreated == null) { haveAnObject = false; } } else if (_objectGrab == ObjectTreated) { ObjectTreated = null; _objectGrab.onGrab -= RemoveObject; if (ObjectWaste == null) { haveAnObject = false; } } else { Debug.LogError("Error Remove Object"); } }
void RemoveObject(GrabableObject _objectGrab) { if (_objectGrab == objectCooked) { objectCooked = null; _objectGrab.onGrab -= RemoveObject; if (objectSample == null) { haveAnObject = false; } } else if (_objectGrab == objectSample) { objectSample = null; _objectGrab.onGrab -= RemoveObject; if (objectCooked == null) { haveAnObject = false; } } else { Debug.LogError("Error Remove Object"); } }
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); }
//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; } }
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); }
private void TryRelease(ref GrabableObject _grabbedObject, Transform _hand) { if (_grabbedObject) { _grabbedObject.Release(_hand); } _grabbedObject = null; }
// Start is called before the first frame update private void Start() { grabable = GetComponent <GrabableObject>(); grabable.onPlayerGrab += SetUser; grabable.onRelease += OnRelease; state = State.Not_Use; particles.Stop(); }
public void GetObjectOnUnpackPost(int actorNumber) { player = InGamePhotonManager.Instance.PlayersConnected[actorNumber].GetComponent <PlayerController>(); objectSample.AllowGrab(true); //player.pInteract.GrabObject(boxToGive); objectSample = null; }
private void NetworkReleaseObject(bool reactivatePhysic, bool searchError) { GrabableObject newGrabable = alimentStocked.GetComponent <GrabableObject>(); newGrabable.Release(reactivatePhysic, searchError); haveObject = false; alimentStocked = null; }
// Start is called before the first frame update void Init() { grabableReceived = null; objectSample = null; player = null; nameObject = GetComponent <Nominator>().customName; GameManager.Instance.PopUp.CreateText3D(nameObject, 15, posText3D.localPosition, transform); }
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); } }
private void DestroyTrashBagOnline(int _ownerID) { PlayerController _pController = InGamePhotonManager.Instance.PlayersConnected[_ownerID]; if (_pController != null) { GrabableObject grabableReceived = _pController.pInteract.ReleaseObject(false, false, false); Destroy(grabableReceived.gameObject); } }
public void Start() { pickupItemText = GameObject.FindGameObjectWithTag("PickUpItemTag").GetComponent <TextMeshProUGUI>(); gobj = GetComponent <GrabableObject>(); if (gobj) { isItem = true; promptToToggle.Add(pickupItemText); } }
private void TryGrab(Interactable _targetObject, Transform _handTransform, ref GrabableObject _grabbedObject) { if (_targetObject is GrabableObject) { if (_targetObject && !_grabbedObject) { GrabableObject obj = _targetObject as GrabableObject; _grabbedObject = obj.Grab(_handTransform); } } }
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(); }
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(); }
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; }
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); }
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); }
// 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; }
public void Grab(GameObject go) { if (state != HandState.Releasing && state != HandState.Grabbing) { grabbedObject = go.GetComponent <GrabableObject>(); Debug.Log("GRABBING"); grabbedObject.amputedHand = this; grabbedObject.OnGrab(); grabbedObject.transform.SetParent(transform); state = HandState.Grabbing; } }
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(); }
public void Release() { if (state != HandState.Releasing) { Debug.Log("RELEASING"); grabbedObject.amputedHand = null; grabbedObject.transform.SetParent(SceneController.GetContainer().transform); grabbedObject.OnRelease(); grabbedObject = null; //state = HandState.Releasing; state = HandState.Resting; } }