private void Awake() { instance = this; aSource = this.GetComponent <AudioSource>(); ExtLibControl.OnCommandCalled += UserActionControl; tasksToDisp = TaskQueueList.childCount - 1; TaskQueueList.parent.GetComponent <Toggle>().onValueChanged .AddListener(v => { PersistentScript.ClickSfx(); TaskQueueList.gameObject.SetActive(v); if (v) { UpdateTaskQueueList(); } }); //tasklist FileMenuContent = FileMenu.GetChild(0).GetChild(0); FileMenu.GetComponentInChildren <TextMeshProUGUI>().text = PersistentScript.currentMap?.name + "-Menu"; FileMenu.GetComponent <Toggle>().onValueChanged //FileMenuButton .AddListener(v => { PersistentScript.ClickSfx(); FileMenuContent.gameObject.SetActive(v); }); FileMenuContent.GetChild(0).GetComponent <Toggle>().onValueChanged //PauseButton .AddListener(v => { PersistentScript.ClickSfx(); PauseLevel(v); }); FileMenuContent.GetChild(1).GetComponent <Toggle>().onValueChanged //RestartButton .AddListener(v => { PersistentScript.ClickSfx(); ReloadLevel(); }); FileMenuContent.GetChild(2).GetComponent <Toggle>().onValueChanged //NewFileButton .AddListener(v => { PersistentScript.ClickSfx(); NewFile(); }); FileMenuContent.GetChild(3).GetComponent <Toggle>().onValueChanged //MainMenuButton .AddListener(delegate { PersistentScript.ClickSfx(); SceneManager.LoadScene(0); PersistentScript.currentMap = null; }); //MessageBox MessageBoxOkButton.onClick.AddListener(delegate { PersistentScript.ClickSfx(); MessageBox.gameObject.SetActive(false); PauseLevel(false); PersistentScript.incomingMessage = null; }); //GameoverBox GameOverBoxSendButton.onClick.AddListener(delegate { PersistentScript.ClickSfx(); GameOverBox.gameObject.SetActive(false); if (PersistentScript.usr != null) { instance.GameOverBoxInput.text = PersistentScript.usr.givenName; } var name = instance.GameOverBoxInput.text; if (!string.IsNullOrEmpty(name)) { name = name.Replace('*', ' ').Replace('|', ' '); Highscores.AddNewHighscore(name + "§§" + DateTime.Now.ToOADate() + "§§" + PersistentScript.userSecretValue, (int)PersistentScript.lastScore); } ReloadLevel();/*send score*/ }); //{ name = name.Replace('*', ' ').Replace('|', ' '); Highscores.AddNewHighscore(name + "§§" + DateTime.Now.ToOADate(), (int)PersistentScript.lastScore); } }
private void OnTriggerStay(Collider other) { if (other.tag == "pickItem") { //Debug.Log($"Item Parent:{other.transform.parent.name}"); if (other.transform.parent.name == "ItemCollection") { PersistentScript.currentScore += (PersistentScript.playType == 0) ? Random.Range(1, 3) : (PersistentScript.currentScore > 0) ? -1 : 0; other.GetComponent <Item>().PadParent.SpawnItem(); Destroy(other.gameObject); //Spawn destructed version that has a rb with collider in a different mask ocluded by the itemHandler if (PersistentScript.playType == 1 && PersistentScript.currentScore == 0) { MenuManager_InGame.ShowGOverMessage((int)(1000f / PersistentScript.timeT0)); /*MenuManager_InGame.ShowInfoMessage($"Congrats , you got all the itens in {PersistentScript.timeT0}",true);*/ } } } }
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; } } } }
public static void DeQueueAction() //tira a ultima ação de fila *sem rodar { currentUAction = null; // quando pronta é nula MenuManager_InGame.UpdateTaskQueueList(); }