public void NextStage() { if (type == Type.npc || type == Type.mom) { if (stage >= dialogue.Length) { if (npcGive) { GameCat._.npcTalked = true; player.GetComponent <Game_Player>().hold = item; } if (type == Type.mom) { GameCat._.npcTalked = true; GetComponentInChildren <SpriteRenderer>().sprite = momNoHands; player.GetComponent <Game_Player>().GetHands(); } ui.ChangetText(""); stage = 0; } else { ui.ChangetText(dialogue[stage]); stage += 1; } } else if (type == Type.truck) { if (stage >= dialogue.Length && goingOut == false) { goingOut = true; GameCat._.state = GameCat.State.end; } else { ui.ChangetText(dialogue[stage]); stage += 1; } } }
// Update is called once per frame void Update() { if (state == State.thought) { if (Input.anyKeyDown) { stage++; if (stage >= selfThoughts.Length) { state = State.normal; ui.ChangetText(""); } } if (stage <= selfThoughts.Length - 1) { ui.ChangetText(selfThoughts[stage]); } } if (state == State.normal) { ShowHolding(); //Method to draw the ray in scene for debug purpose Debug.DrawRay(transform.position, input, Color.red); if (canAct == true) { input.x = Input.GetAxisRaw("Horizontal"); input.y = Input.GetAxisRaw("Vertical"); var right = Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D); var down = Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S); var left = Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A); var up = Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W); //right if (right) { if (!WallAhead(new Vector2(1, 0))) { Move(1, 0); } InteractionCheck(new Vector2(1, 0)); } //down else if (down) { if (!WallAhead(new Vector2(0, -1))) { Move(0, -1); } InteractionCheck(new Vector2(0, -1)); } //left else if (left) { if (!WallAhead(new Vector2(-1, 0))) { Move(-1, 0); } InteractionCheck(new Vector2(-1, 0)); } //up else if (up) { if (!WallAhead(new Vector2(0, 1))) { Move(0, 1); } InteractionCheck(new Vector2(-1, 0)); } } if (canAct == false) { moveTimer += Time.deltaTime; if (moveTimer >= moveTimeCheck) { moveTimer = 0; canAct = true; } } } }