private void OnCollisionStay(Collision c) { //Vector3 dir = c.GetContact(0).point - transform.position; string cTag = c.gameObject.tag; //if (cTag == "pickItem" && (!driver.clawState) && !graping && c.transform != triggObj)//se encostou e não está com a gaiola levantada, violou... fora //{ // //PersistentScript.incomingMessage = "Levante sua gaiola para pegar o objeto, sem empurrar!!"; // //MenuManager_InGame.ReloadLevel(); //} if (cTag == "pickItem") { dir = c.GetContact(0).normal; c.collider.transform.position -= new Vector3(dir.x, 0, dir.z) * Time.deltaTime * 10f; } else if (cTag == "wall") { PersistentScript.incomingMessage = "Mova sem colidir nas paredes!\nSintoMuito, mas terá que tentar novamente"; MenuManager_InGame.ReloadLevel(); } }
void Update() { Time.timeScale = timescale; if (Input.GetKeyDown(KeyCode.Z)) { ExtLibControl.DeQueueAction(); //Libera a ultima ação --para casos de encurralamento } if (Input.GetKeyDown(KeyCode.X)) { ExtLibControl.ClearActionQueue(); //Limpa todas as Ações } float v = (Input.GetKeyDown(KeyCode.W) ? 1 : Input.GetKeyDown(KeyCode.S) ? -1 : 0); if (v != 0) { ExtLibControl.userActions.Enqueue(new ExtLibControl.UserAction("move", 0, .2f * v)); } v = (Input.GetKeyDown(KeyCode.D) ? 1 : Input.GetKeyDown(KeyCode.A) ? -1 : 0); if (v != 0) { ExtLibControl.userActions.Enqueue(new ExtLibControl.UserAction("rot", 0, 15f * v)); } if (Input.GetKeyDown(KeyCode.Q)) { ExtLibControl.userActions.Enqueue(new ExtLibControl.UserAction("garra", 0)); } if (Input.GetKeyDown(KeyCode.E)) { ExtLibControl.userActions.Enqueue(new ExtLibControl.UserAction("hold", -1, 3)); } if (Input.GetKeyDown(KeyCode.T)) { ExtLibControl.userActions.Enqueue(new ExtLibControl.UserAction("getTIME")); } if (Input.GetKeyDown(KeyCode.Alpha1)) { currentCamera = (currentCamera + 1) % cameraHolder.childCount; ExtLibControl.userActions.Enqueue(new ExtLibControl.UserAction("cam", -1, currentCamera)); } if (Input.GetKeyDown(KeyCode.KeypadDivide)) { DEBUGmode = !DEBUGmode; } while (ExecuteOnMainThread.Count > 0) { ExecuteOnMainThread.Dequeue().Invoke(); } if (ExtLibControl.userActions.Count > 0) { if (((ExtLibControl.currentUAction == null) ? true : ExtLibControl.currentUAction.done) && canRunUserActions && MenuManager_InGame.isPlaying) { ExtLibControl.MoveActionQueue(); } if (!(ExtLibControl.currentUAction == null) && canRunUserActions && MenuManager_InGame.isPlaying) { var u = ExtLibControl.currentUAction.userAction; switch (u.type) { case "holdReal" when u.target == -1: ExtLibControl.currentUAction.userAction.target = 1; StartCoroutine(WaitAndDo(u.value, () => ExtLibControl.DeQueueAction())); break; case "hold": if (u.target == -1) { ExtLibControl.currentUAction.userAction.target = 1; holdTime = u.value; } else if (holdTime < 1e-8) { ExtLibControl.DeQueueAction(); } else { holdTime -= Time.deltaTime; } break; case "restart" when u.target == -1: ExtLibControl.currentUAction.userAction.target = 1; MenuManager_InGame.ReloadLevel(); break; case "speed": timescale = u.value; ExtLibControl.DeQueueAction(); break; case "cam": { if (u.value < cameraHolder.childCount) { for (int i = 0; i < cameraHolder.childCount; i++) { cameraHolder.GetChild(i).gameObject.SetActive(i == u.value); } } ExtLibControl.DeQueueAction(); break; } } //feedback ActionsBehaviours switch (u.type) { case "getTIME": PipeFeedback(timeT0); break; case "getCameraCount": PipeFeedback(cameraHolder.childCount); break; case "getScore": PipeFeedback((int)currentScore); break; } } } }