/// <summary> /// Function to Enact a Pass type Effect. Used in the Enact() Function. /// </summary> /// <param name="character">The Character performing the Action.</param> public void Enact_Pass(Character_Script character) { character.StartCoroutine(character.End_Turn()); }
/// <summary> /// Reads Player Input. /// </summary> void Read_Input() { //map selection if (Input.GetKeyDown("space")) { if (curr_scenario.scenario_file == "Assets/Resources/Maps/falls_map.txt") { curr_scenario.Unload_Scenario(); curr_scenario = new Scenario("Assets/Maps/tile_map.txt"); curr_scenario.Load_Scenario(); } else if (curr_scenario.scenario_file == "Assets/Resources/Maps/tile_map.txt") { curr_scenario.Unload_Scenario(); curr_scenario = new Scenario("Assets/Maps/falls_map.txt"); curr_scenario.Load_Scenario(); } } //Action menu hotkeys Character_Script character = curr_scenario.curr_player.Peek().GetComponent <Character_Script>(); if (!character.ending_turn) { if (Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_0][0]) || Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_0][1])) { if (character.actions.Count >= 1) { character.actions[0].Select(); } } else if (Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_1][0]) || Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_1][1])) { if (character.actions.Count >= 2) { character.actions[1].Select(); } } else if (Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_2][0]) || Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_2][1])) { if (character.actions.Count >= 3) { character.actions[2].Select(); } } else if (Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_3][0]) || Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_3][1])) { if (character.actions.Count >= 4) { character.actions[3].Select(); } } else if (Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_4][0]) || Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_4][1])) { if (character.actions.Count >= 5) { character.actions[4].Select(); } } else if (Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_5][0]) || Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_5][1])) { if (character.actions.Count >= 6) { character.actions[5].Select(); } } else if (Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_6][0]) || Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_6][1])) { if (character.actions.Count >= 7) { character.actions[6].Select(); } } else if (Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_7][0]) || Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_7][1])) { if (character.actions.Count >= 8) { character.actions[7].Select(); } } else if (Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_8][0]) || Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_8][1])) { if (character.actions.Count >= 9) { character.actions[8].Select(); } } else if (Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_9][0]) || Input.GetKeyDown(controlls[Controlls.Ability_Hotkey_9][1])) { if (character.actions.Count >= 10) { character.actions[9].Select(); } } else if (Input.GetKeyDown(controlls[Controlls.Pause][0]) || Input.GetKeyDown(controlls[Controlls.Pause][1])) { if (character.curr_action != null) { if (character.curr_action.Peek().paused) { character.curr_action.Peek().Resume(); } else { character.curr_action.Peek().Pause(); } } } if (Input.GetKeyDown("k")) { character.Die(); curr_scenario.Next_Player(); } //check for mouse clicks if (Input.GetMouseButtonDown(0)) { GraphicRaycaster caster = GameObject.Find("Canvas").GetComponent <GraphicRaycaster>(); //Create the PointerEventData PointerEventData data = new PointerEventData(null); //Look at mouse position data.position = Input.mousePosition; //Create list to receive results List <RaycastResult> results = new List <RaycastResult>(); //Raycast caster.Raycast(data, results); if (results.Count == 0) { curr_scenario.clicked_tile = curr_scenario.selected_tile; } if ((character.state != Character_States.Idle || character.state != Character_States.Dead)) { foreach (Transform tile in curr_scenario.reachable_tiles) { if (tile.Equals(curr_scenario.clicked_tile)) { //Debug.Log(character.name + " num of curr_action " + character.curr_action.Count); character.StartCoroutine(character.Act(character.curr_action.Peek(), curr_scenario.clicked_tile)); } } } } } //check for mouse button up if (Input.GetMouseButtonUp(0)) { //cursor.GetComponent<Animator>().SetBool("Clicked", false); } //Next player button if (Input.GetKeyDown(controlls[Controlls.Next_Player][0]) || Input.GetKeyDown(controlls[Controlls.Next_Player][1])) { curr_scenario.Next_Player(); } //Prev player button if (Input.GetKeyDown(controlls[Controlls.Previous_Player][0]) || Input.GetKeyDown(controlls[Controlls.Previous_Player][1])) { curr_scenario.Prev_Player(); } //Camera Turning //Debug.Log(curr_scenario.curr_player.GetComponent<Character_Script>().state); if ((Input.GetKeyDown(controlls[Controlls.Camera_Turn_Right][0]) || Input.GetKeyDown(controlls[Controlls.Camera_Turn_Right][1])) && curr_scenario.curr_player.Peek().GetComponent <Character_Script>().state != Character_States.Walking) { //Debug.Log("x:" + main_camera.transform.rotation.x + ", y:" + main_camera.transform.rotation.y + "z:" + main_camera.transform.rotation.z + ", w:" + main_camera.transform.rotation.w); //transform.rotation = new Quaternion(transform.rotation.x, transform.rotation.y, transform.rotation.z, transform.rotation.w); //transform.RotateAround(transform.position, Vector3.up, -90f); //main_camera.transform.RotateAround(curr_scenario.selected_tile.transform.position, Vector3.up, 90* Time.deltaTime); //main_camera.GetComponent<Camera_Controller>().targetRotation *= Quaternion.AngleAxis(90, main_camera.transform.forward); if (!main_camera.GetComponent <Camera_Controller>().rotating) { main_camera.GetComponent <Camera_Controller>().rotating = true; main_camera.GetComponent <Camera_Controller>().rotationAmount -= 90; foreach (GameObject chara in curr_scenario.characters) { chara.GetComponent <Character_Script>().rotate = true; //chara.GetComponent<Character_Script>().camera_offset += 1; //chara.GetComponent<Character_Script>().orientation += 1; //chara.GetComponent<Character_Script>().Orient(); } } //main_camera.GetComponent<Camera_Controller>().rotationAmount -= 90; //update orientation based on camera //Debug.Log(curr_scenario.curr_player.GetComponent<Character_Script>().orientation); } if ((Input.GetKeyDown(controlls[Controlls.Camera_Turn_Left][0]) || Input.GetKeyDown(controlls[Controlls.Camera_Turn_Left][1])) && curr_scenario.curr_player.Peek().GetComponent <Character_Script>().state != Character_States.Walking) { //Debug.Log("x:" + main_camera.transform.rotation.x + ", y:" + main_camera.transform.rotation.y + "z:" + main_camera.transform.rotation.z + ", w:" + main_camera.transform.rotation.w); //transform.rotation = new Quaternion(transform.rotation.x, transform.rotation.y, transform.rotation.z, transform.rotation.w); //transform.RotateAround(transform.position, Vector3.up, 90f); if (!main_camera.GetComponent <Camera_Controller>().rotating) { main_camera.GetComponent <Camera_Controller>().rotating = true; main_camera.GetComponent <Camera_Controller>().rotationAmount += 90; foreach (GameObject chara in curr_scenario.characters) { chara.GetComponent <Character_Script>().rotate = true; //chara.GetComponent<Character_Script>().camera_offset -= 1; //chara.GetComponent<Character_Script>().orientation -= 1; //chara.GetComponent<Character_Script>().Orient(); } } //main_camera.GetComponent<Camera_Controller>().rotationAmount += 90; //Debug.Log(curr_scenario.curr_player.GetComponent<Character_Script>().orientation); } }