/// <summary> /// Function to Enact a Move Type Action. Used in the Enact() Function. /// </summary> /// <param name="character">The Character performing the Move Action</param> /// <param name="movetype">The Type of Movement the Character is performing. </param> /// <param name="target">The Target destination for the Move.</param> public void Enact_Move(Character_Script character, string movetype, Target target) { //mover types // 1 = standard move // 2 = push/pull // 3 = fly // 4 = warp if (target.game_object.GetComponent <Tile>()) { Tile target_tile = target.game_object.GetComponent <Tile>(); //Actually move character.GetComponent <Character_Script>().MoveTo(target.game_object.transform); //reset current tile information character.curr_tile.GetComponent <Tile>().traversible = true; character.curr_tile.GetComponent <Tile>().obj = null; //set new tile information character.curr_tile = target_tile.transform; character.curr_tile.GetComponent <Tile>().traversible = false; character.curr_tile.GetComponent <Tile>().obj = character.gameObject; } else { Debug.Log("Invalid target for move."); } }
/// <summary> /// Function to Enact a Damage type Effect. Used in the Enact() Function. /// </summary> /// <param name="character">The Character triggering the Effect</param> /// <param name="value">The String with the damage equation.</param> public void Enact_Damage(Character_Script character, String value) { int damage = (int)(Convert_To_Double(value, character.gameObject, character.gameObject) * modifier); //TODO ADD TILE EFFECT PIERCE VALUE character.Take_Damage(damage, character.weapon.pierce); }
private void OnTriggerExit2D(Collider2D other) { if (other.gameObject.tag == "mainchar" && other != null) { MainCharacter = other.gameObject.GetComponent <Character_Script>(); MainCharacter.removeForInterraction(self); } }
private void OnTriggerEnter2D(Collider2D other) { if (other.gameObject.tag == "mainchar" && other != null) { MainCharacter = other.gameObject.GetComponent <Character_Script>(); //passes the parents Interractable script for the player for further interraction at "F" press MainCharacter.addForInterraction(self); } }
/// <summary> /// Function to Enact an Elevate type Effect. Used in the Enact() Function. /// </summary> /// <param name="character">The Character triggering the Effect </param> /// <param name="value">The String with the equation for how much to Elevate.</param> public void Enact_Elevate(Character_Script character, String value) { if (current_tile.GetComponent <Tile>()) { int elevation = (int)(Convert_To_Double(value, character.gameObject, character.gameObject) * modifier); character.controller.curr_scenario.tile_grid.Elevate(current_tile.transform, elevation); } else { Debug.Log("Invalid target for Elevate."); } }
/// <summary> /// Displays the GUI for the player. /// Creates: /// Prev and Next Buttons. /// Stat Screen and Preview Screen. /// </summary> void OnGUI() { style = new GUIStyle("TextArea"); style.richText = true; /*if (GUI.Button (new Rect (10, 100, 100, 30), "Save")) { * Game_Controller.controller.Save(); * } * if (GUI.Button (new Rect (10, 140, 100, 30), "Load")) { * Game_Controller.controller.Save(); * }*/ if (GUI.Button(new Rect(10, Screen.height - 160, 50, 30), "Prev")) { Game_Controller.controller.curr_scenario.Prev_Player(); } if (GUI.Button(new Rect(70, Screen.height - 160, 50, 30), "Next")) { Game_Controller.controller.curr_scenario.Next_Player(); } //print (controller.curr_scenario.curr_player.GetComponent<Character_Script> ().character_name); if (controller.curr_scenario.curr_player.Count > 0) { if (!curr_player.Equals(controller.curr_scenario.curr_player.Peek().GetComponent <Character_Script>())) { curr_player = controller.curr_scenario.curr_player.Peek().GetComponent <Character_Script>(); Update_Turn_Order(); } //Debug.Log("Current player " + curr_player.name + " action count " + curr_player.curr_action.Count); if (curr_player.curr_action.Count > 0) { //Debug.Log(curr_player.curr_action.Peek().name); Current_Character_Preview(); } } Turn_Order_Preview(); Current_Tile_Preview(); if (controller.curr_scenario.selected_tile.GetComponent <Tile>() != null) { //Debug.Log("Selecting"); Current_Target_Preview(); } }
/// <summary> /// Change the current turn order string being held by the camera. /// </summary> public void Update_Turn_Order() { string text = ""; foreach (GameObject obj in Game_Controller.controller.curr_scenario.turn_order) { Character_Script chara = obj.GetComponent <Character_Script>(); if (chara.Equals(curr_player)) { text = text + "<color=red>" + chara.name + " " + chara.character_num + "</color> \n"; } else { text = text + chara.name + " " + chara.character_num + "\n"; } } turn_order = text; }
/// <summary> /// Function to Enact a Status type Effect. Used in the Enact() Function. /// </summary> /// <param name="character">The Character triggering the Effect</param> /// <param name="value">The equation for what Status to apply. </param> public void Enact_Status(Character_Script character, String[] values) { //First we need to resolve the Condition //Check for a power and attribute double power = 0; string attribute = ""; if (values.Length >= 3 && values[2] != null) { power = Convert_To_Double(values[2], character.gameObject, character.gameObject); } if (values.Length == 4 && values[3] != null) { attribute = values[3]; } int duration = (int)Convert_To_Double(values[1], character.gameObject, character.gameObject); Condition condi = new Condition(values[0], duration, power * modifier, attribute); //Now we add the Condition to the target. character.Add_Condition(condi); }
/// <summary> /// Function to Enact an Enable type Effect. Used in the Enact() Function. /// </summary> /// <param name="character">The Character performing the Action. </param> /// <param name="value">The String with the euqation for what to do. Should be an action name and a bool pair.</param> public void Enact_Enable(Character_Script character, String[] value) { foreach (Character_Action act in character.GetComponent <Character_Script>().actions) { //Debug.Log("act.name: " + act.name + ", eff.value: " + eff.value[0]); if (act.name == value[0]) { //Debug.Log("MATCH"); if (value[1] == "false" || value[1] == "False" || value[1] == "FALSE") { //Debug.Log("Skill " + act.name + " is disabled."); act.enabled = false; } if (value[1] == "true" || value[1] == "True" || value[1] == "TRUE") { //Debug.Log("Skill " + act.name + " is enabled."); act.enabled = true; } } } }
/// <summary> /// Coroutine for triggering the Effect. /// Calls the various Enact_<>() Functions depending on the Actions's Action_Effects. /// </summary> /// <param name="character">Character triggering this Effect.</param> /// <returns>An IEnumerator with the current Coroutine progress. </returns> public IEnumerator Enact(Character_Script character) { while (character.curr_action.Peek().paused) { yield return(new WaitForEndOfFrame()); } if (type == Types.Move) { //Enact_Move(character, value[0]); } else if (type == Types.Damage) { Enact_Damage(character, value[0]); } else if (type == Types.Heal) { Enact_Healing(character, value); } else if (type == Types.Status) { Enact_Status(character, value); } else if (type == Types.Enable) { Enact_Enable(character, value); } else if (type == Types.Elevate) { Enact_Elevate(character, value[0]); } else if (type == Types.Pass) { Enact_Pass(character); } character.curr_action.Peek().Resume(); gameObject.tag = "Delete"; }
/// <summary> /// Function to Enact a Healing type Effect. Used in the Enact() Function. /// </summary> /// <param name="character">The Character triggering the Effect</param> /// <param name="value">The String with the healing equation.</param> public void Enact_Healing(Character_Script character, String[] value) { int healing = (int)(Convert_To_Double(value[1], character.gameObject, character.gameObject) * modifier); if (value[0] == Accepted_Shortcuts.CAUC.ToString() || value[0] == Accepted_Shortcuts.CAUC.ToString()) { Debug.Log("Character " + character.character_name + " Triggered: " + name + "; for " + healing + " Aura"); character.Recover_Aura(healing); } else if (value[0] == Accepted_Shortcuts.CMPC.ToString() || value[0] == Accepted_Shortcuts.TMPC.ToString()) { Debug.Log("Character " + character.character_name + " Triggered: " + name + "; for " + healing + " MP"); character.Recover_Mana(healing); } else if (value[0] == Accepted_Shortcuts.CAPC.ToString() || value[0] == Accepted_Shortcuts.TAPC.ToString()) { Debug.Log("Character " + character.character_name + " Triggered: " + name + "; for " + healing + " AP"); character.Recover_Actions(healing); } else { Debug.Log(value[0] + " is an invalid Healing prefix."); } }
/// <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); } }
Character_Script[] ReadCharacterData(string file) { string[] lines = System.IO.File.ReadAllLines(file); Character_Script[] objects = new Character_Script[lines.Length / 13]; int count = 0; string name = ""; int level = 1; int strength = 1; int coordination = 1; int spirit = 1; int dexterity = 1; int vitality = 1; int speed = 5; int canister_max = 1; string weapon = "Sword"; string armor = "Light"; foreach (string line in lines) { string[] elements = line.Split(':'); if (!elements[0].Contains("#") && elements.Length > 1) { if (elements[0] == "name") { name = elements[1]; } else if (elements[0] == "level") { if (int.TryParse(elements[1], out level)) { } } else if (elements[0] == "strength") { if (int.TryParse(elements[1], out strength)) { } } else if (elements[0] == "coordination") { if (int.TryParse(elements[1], out coordination)) { } } else if (elements[0] == "spirit") { if (int.TryParse(elements[1], out spirit)) { } } else if (elements[0] == "dexterity") { if (int.TryParse(elements[1], out dexterity)) { } } else if (elements[0] == "vitality") { if (int.TryParse(elements[1], out vitality)) { } } else if (elements[0] == "speed") { if (int.TryParse(elements[1], out speed)) { } } else if (elements[0] == "canister_max") { if (int.TryParse(elements[1], out canister_max)) { } } else if (elements[0] == "weapon") { weapon = elements[1]; } else if (elements[0] == "armor") { armor = elements[1]; } else if (elements[0] == "accessories") { } } if (elements[0] == "") { objects[count] = new Character_Script(name, level, strength, coordination, spirit, dexterity, vitality, speed, canister_max, weapon, armor); count++; name = ""; level = 1; strength = 1; coordination = 1; spirit = 1; dexterity = 1; vitality = 1; speed = 5; canister_max = 1; weapon = "Sword"; armor = "Light"; } } return objects; }
/// <summary> /// Function to Instantiate all of the relevant Scenario Tiles, Objects and Characters. Basically the Start method. /// </summary> public void Load_Scenario() { //Instantiate the actual tile objects tile_grid.Instantiate(); //Load player and monster stats and come up with turn order player_character_data = Read_Character_Data(PLAYER_STATS_FILE); monster_character_data = Read_Character_Data(MONSTER_STATS_FILE); Character_Script[] character_data; int char_num = 0; characters = new ArrayList(); cursor = GameObject.FindGameObjectWithTag("Cursor"); cursors = new List <GameObject>(); GameObject[] objects = GameObject.FindGameObjectsWithTag("Character (Friend)"); tile_effects = new List <GameObject>(); if (GameObject.FindGameObjectWithTag("Tile Effect")) { foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Tile Effects")) { tile_effects.Add(obj); } } //set starting positions for players //TODO change this to read positions from the scenario file. foreach (GameObject game_object in objects) { characters.Add(game_object); //Get the character ID from the tile grid int char_id = game_object.GetComponent <Character_Script>().character_id; Character_Script char_data; if (char_id / 10000 == 1) { //Player char_data = new Character_Script(player_character_data[char_id % 100 - 1]); game_object.tag = "Character (Friend)"; } else if (char_id / 10000 == 2) { //Monster char_data = new Character_Script(monster_character_data[char_id % 100 - 1]); game_object.tag = "Character (Enemy)"; } else { char_data = monster_character_data[0]; } game_object.GetComponent <Character_Script>().Instantiate(char_data, char_id, char_num, char_id / 1000 % 10); turn_order.Add(game_object); char_num++; } //Get Objects objects = GameObject.FindGameObjectsWithTag("Object"); foreach (GameObject game_object in objects) { tile_objects.Add(game_object); } turn_order.Sort(Sort_By_Dex); curr_character_num = characters.Count - 1; curr_player = new Stack <GameObject>(); curr_player.Push(turn_order[curr_character_num]); curr_player.Peek().GetComponent <Animator>().SetBool("Selected", true); char_num = 0; curr_player.Peek().GetComponent <Character_Script>().Find_Action_Local("Move").Select(); //GetComponent<Character_Script>().state = Character_Script.States.Moving; //FindReachable(curr_player.GetComponent<Character_Script>().action_curr, curr_player.GetComponent<Character_Script>().SPEED); //MarkReachable(); //set initial values for selected and clicked tiles. selected_tile = tile_grid.tiles[0, 0]; clicked_tile = tile_grid.tiles[0, 0]; }
/// <summary> /// Function to read in Character data from a file. Returns a Character_Script array from the data within the file. /// </summary> /// <param name="file">The file from which to read in Character Scripts.</param> /// <returns>Character_Script Array constructed from the given file.</returns> Character_Script[] Read_Character_Data(string file) { string[] lines = System.IO.File.ReadAllLines(file); Character_Script[] objects = new Character_Script[lines.Length / 15]; int count = 0; string name = ""; int level = 1; int strength = 1; int coordination = 1; int spirit = 1; int dexterity = 1; int vitality = 1; int speed = 6; int canister_max = 1; string weapon = "Sword"; string armor = "Light"; string animator = "Beetleboar"; float[] scale = new float[3]; foreach (string line in lines) { string[] elements = line.Split(':'); if (!elements[0].Contains("#") && elements.Length > 1) { if (elements[0] == "name") { name = elements[1].Trim(); } else if (elements[0] == "level") { if (int.TryParse(elements[1], out level)) { } } else if (elements[0] == "strength") { if (int.TryParse(elements[1], out strength)) { } } else if (elements[0] == "coordination") { if (int.TryParse(elements[1], out coordination)) { } } else if (elements[0] == "spirit") { if (int.TryParse(elements[1], out spirit)) { } } else if (elements[0] == "dexterity") { if (int.TryParse(elements[1], out dexterity)) { } } else if (elements[0] == "vitality") { if (int.TryParse(elements[1], out vitality)) { } } else if (elements[0] == "speed") { if (int.TryParse(elements[1], out speed)) { } } else if (elements[0] == "canister_max") { if (int.TryParse(elements[1], out canister_max)) { } } else if (elements[0] == "weapon") { weapon = elements[1]; } else if (elements[0] == "armor") { armor = elements[1]; } else if (elements[0] == "accessories") { } else if (elements[0] == "animator") { animator = elements[1].Trim(); } else if (elements[0] == "scale") { string[] scales = elements[1].Split(','); scale = new float[3]; int x = 0; foreach (string s in scales) { if (float.TryParse(s.Trim(), out scale[x])) { } x++; } if (x == 1) { scale[1] = scale[0]; scale[2] = scale[0]; } } } if (elements[0] == "") { objects[count] = new Character_Script(name, level, strength, coordination, spirit, dexterity, vitality, speed, canister_max, weapon, armor, animator, scale); count++; } } return(objects); }
/// <summary> /// Move the curr_player to the next available player in the turn_order. Turn_order is sorted in order of Dexterity. /// </summary> public void Next_Player() { for (int i = 0; i < characters.Count; i++) { Character_Script character = ((GameObject)characters[i]).GetComponent <Character_Script>(); //Debug.Log("Processing " + character.name + " " + character.character_num); character.Reset_Combo_Mod(); character.Update_Conditions(); character.Progress_Conditions(); if (character.state == Character_States.Dead) { i--; } } /*foreach (GameObject chara in characters) { * * chara.GetComponent<Character_Script>().Reset_Combo_Mod(); * //Every turn update the conditions and progress them. * chara.GetComponent<Character_Script>().Update_Conditions(); * chara.GetComponent<Character_Script>().Progress_Conditions(); * }*/ Progress_Effects(); if (curr_character_num % 2 == 0) { Spawn_Mana_Orb(); Spawn_Mana_Orb(); } curr_character_num = curr_character_num - 1; if (curr_character_num < 0) { Next_Round(); curr_character_num = characters.Count - 1; } if (curr_character_num > characters.Count - 1) { curr_character_num = characters.Count - 1; } curr_player.Peek().GetComponent <Animator>().SetBool("Selected", false); curr_player.Pop(); //Debug.Log("Current char num: " + curr_character_num); //Debug.Log("Current char name: " + turn_order[curr_character_num].name + " " + turn_order[curr_character_num].GetComponent<Character_Script>().character_num); curr_player.Push(turn_order[curr_character_num]); if (curr_player.Peek().GetComponent <Character_Script>().state == Character_States.Dead) { Next_Player(); } else { curr_player.Peek().GetComponent <Animator>().SetBool("Selected", true); } //curr_player.Peek().GetComponent<Character_Script>().state = Character_Script.States.Moving; //FindReachable(curr_player.Peek().GetComponent<Character_Script>().action_curr, curr_player.Peek().GetComponent<Character_Script>().SPEED); Reset_Reachable(); //Start new player's turn curr_player.Peek().GetComponent <Character_Script>().Start_Turn(); }
/// <summary> /// Converts the String parameters from the Tile_Effect into a double. /// Parses Accepted_Shortcuts in the String based on stats from the provided Character_Script. /// </summary> /// <param name="input">The String to convert to a Double</param> /// <param name="character">The Character performing the action. Used to parse ACCEPTED_SHORTCUTS beginning with C.</param> /// <param name="target">The target receiving the action. Used to parse ACCEPTED_SHORTCUTS beginning with T.</param> /// <returns></returns> public double Convert_To_Double(string input, GameObject character, GameObject target) { double output = 0.0; if (double.TryParse(input, out output)) { return(output); } else { //Remove acronyms from equation Array values = Enum.GetValues(typeof(Accepted_Shortcuts)); foreach (Accepted_Shortcuts val in values) { Character_Script source = character.GetComponent <Character_Script>(); if (val.ToString()[0] == 'T') { source = target.GetComponent <Character_Script>(); } if (source != null) { if (input.Contains(val.ToString())) { Debug.Log(val.ToString()); if (val.ToString().Contains("AUM")) { input = input.Replace(val.ToString(), "" + source.aura_max); } else if (val.ToString().Contains("AUC")) { input = input.Replace(val.ToString(), "" + source.aura_curr); } else if (val.ToString().Contains("APM")) { input = input.Replace(val.ToString(), "" + source.action_max); } else if (val.ToString().Contains("APC")) { input = input.Replace(val.ToString(), "" + source.action_curr); } else if (val.ToString().Contains("MPM")) { input = input.Replace(val.ToString(), "" + source.mana_max); } else if (val.ToString().Contains("MPC")) { input = input.Replace(val.ToString(), "" + source.mana_curr); } else if (val.ToString().Contains("CAM")) { input = input.Replace(val.ToString(), "" + source.canister_max); } else if (val.ToString().Contains("CAC")) { input = input.Replace(val.ToString(), "" + source.canister_curr); } else if (val.ToString().Contains("SPD")) { input = input.Replace(val.ToString(), "" + source.speed); } else if (val.ToString().Contains("STR")) { input = input.Replace(val.ToString(), "" + source.strength); } else if (val.ToString().Contains("CRD")) { input = input.Replace(val.ToString(), "" + source.coordination); } else if (val.ToString().Contains("SPT")) { input = input.Replace(val.ToString(), "" + source.spirit); } else if (val.ToString().Contains("DEX")) { input = input.Replace(val.ToString(), "" + source.dexterity); } else if (val.ToString().Contains("VIT")) { input = input.Replace(val.ToString(), "" + source.vitality); } else if (val.ToString().Contains("LVL")) { input = input.Replace(val.ToString(), "" + source.level); } else if (val.ToString().Contains("WPR")) { input = input.Replace(val.ToString(), "" + source.weapon.modifier.GetLength(0) / 2); } else if (val.ToString().Contains("WPD")) { input = input.Replace(val.ToString(), "" + source.weapon.attack); } else if (val.ToString().Contains("WPN")) { input = input.Replace(val.ToString(), "" + source.weapon.name); } else if (val.ToString().Contains("ARM")) { input = input.Replace(val.ToString(), "" + source.armor.armor); } else if (val.ToString().Contains("WGT")) { input = input.Replace(val.ToString(), "" + source.armor.weight); } else if (val.ToString().Contains("MOC")) { input = input.Replace(val.ToString(), "" + source.action_curr); } else if (val.ToString().Contains("DST")) { input = input.Replace(val.ToString(), "" + source.aura_max); } else if (val.ToString().Contains("NUL")) { input = input.Replace(val.ToString(), "" + 0.0); } } } } //try to convert to double after converting if (double.TryParse(input, out output)) { return(output); } else if (input.Contains("+") || input.Contains("/") || input.Contains("*") || input.Contains("-") || input.Contains("^") || input.Contains("(") || input.Contains(")")) { return(Parse_Equation(input)); } return(-1.0); } }
/// <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> /// Converts the String parameters from the File into a double. /// Parses Accepted_Shortcuts in the String based on stats from the provided Character_Script. /// </summary> /// <param name="input">The String to convert to a Double</param> /// <param name="obj">The Character_Script to use for converting the Accepted_Shortcuts into numbers</param> /// <returns></returns> public double Convert_To_Double(string input, Character_Script obj) { double output = 0.0; if (double.TryParse(input, out output)) { return(output); } else { //Remove acronyms from equation Array values = Enum.GetValues(typeof(Accepted_Shortcuts)); foreach (Accepted_Shortcuts val in values) { if (input.Contains(val.ToString())) { if (val.ToString() == "AUM") { input = input.Replace(val.ToString(), "" + obj.aura_max); } else if (val.ToString() == "AUC") { input = input.Replace(val.ToString(), "" + obj.aura_curr); } else if (val.ToString() == "APM") { input = input.Replace(val.ToString(), "" + obj.action_max); } else if (val.ToString() == "APC") { input = input.Replace(val.ToString(), "" + obj.action_curr); } else if (val.ToString() == "MPM") { input = input.Replace(val.ToString(), "" + obj.mana_max); } else if (val.ToString() == "MPC") { input = input.Replace(val.ToString(), "" + obj.mana_curr); } else if (val.ToString() == "CAM") { input = input.Replace(val.ToString(), "" + obj.canister_max); } else if (val.ToString() == "CAC") { input = input.Replace(val.ToString(), "" + obj.canister_curr); } else if (val.ToString() == "SPD") { input = input.Replace(val.ToString(), "" + obj.speed); } else if (val.ToString() == "STR") { input = input.Replace(val.ToString(), "" + obj.strength); } else if (val.ToString() == "CRD") { input = input.Replace(val.ToString(), "" + obj.coordination); } else if (val.ToString() == "SPT") { input = input.Replace(val.ToString(), "" + obj.spirit); } else if (val.ToString() == "DEX") { input = input.Replace(val.ToString(), "" + obj.dexterity); } else if (val.ToString() == "VIT") { input = input.Replace(val.ToString(), "" + obj.vitality); } else if (val.ToString() == "LVL") { input = input.Replace(val.ToString(), "" + obj.level); } else if (val.ToString() == "WPR") { input = input.Replace(val.ToString(), "" + obj.weapon.modifier.Length / 2); } else if (val.ToString() == "WPD") { input = input.Replace(val.ToString(), "" + obj.weapon.attack); } else if (val.ToString() == "WPN") { input = input.Replace(val.ToString(), "" + obj.weapon.name); } else if (val.ToString() == "ARM") { input = input.Replace(val.ToString(), "" + obj.armor.armor); } else if (val.ToString() == "WGT") { input = input.Replace(val.ToString(), "" + obj.armor.weight); } else if (val.ToString() == "MOC") { input = input.Replace(val.ToString(), "" + obj.action_curr); } else if (val.ToString() == "DST") { input = input.Replace(val.ToString(), "" + obj.aura_max); } else if (val.ToString() == "NUL") { input = input.Replace(val.ToString(), "" + 0.0); } } } //try to convert to double after converting if (double.TryParse(input, out output)) { return(output); } else if (input.Contains("+") || input.Contains("/") || input.Contains("*") || input.Contains("-") || input.Contains("^") || input.Contains("(") || input.Contains(")")) { return(Parse_Equation(input)); } return(-1.0); } }
/// <summary> /// Method to create a GUI window displaying the information /// on the Object or Character on the currently selected tile. /// </summary> public void Current_Target_Preview() { highlighted_obj = controller.curr_scenario.selected_tile.GetComponent <Tile>().obj; if (highlighted_obj != null) { Character_Script highlighted_character = highlighted_obj.GetComponent <Character_Script>(); if (highlighted_character != null) { if (curr_player.curr_action.Count > 0 && curr_player.state != Character_States.Acting) { bool preview = false; foreach (Action_Effect eff in curr_player.curr_action.Peek().effects) { if (eff.type.ToString() == "Damage") { //TODO: This is inaccurate because it doesn't take into account the target modifier. int damage_dealt = highlighted_character.Estimate_Damage(curr_player.curr_action.Peek().Convert_To_Double(eff.values[0], highlighted_character.gameObject), (int)curr_player.weapon.pierce); int new_aura = highlighted_character.aura_curr - damage_dealt; if (new_aura < 0) { new_aura = 0; } else if (new_aura > highlighted_character.aura_curr) { new_aura = highlighted_character.aura_curr; } GUI.TextArea(new Rect(Screen.width - 320, Screen.height - 120, 200, 110), highlighted_character.character_name + "\n" + "AU: <color=red>" + (new_aura) + "</color> / " + highlighted_character.aura_max + " " + "MP: " + highlighted_character.mana_curr + " / " + highlighted_character.mana_max + "\n" + "AP: " + highlighted_character.action_curr + " / " + highlighted_character.action_max + " " + "RP: " + highlighted_character.reaction_curr + " / " + highlighted_character.reaction_max + "\n" + "Str: " + highlighted_character.strength + " Crd: " + highlighted_character.coordination + " Spt: " + highlighted_character.spirit + "\n" + "Dex: " + highlighted_character.dexterity + " Vit: " + highlighted_character.vitality + " Spd: " + highlighted_character.speed + "\n" + "Wep: " + highlighted_character.weapon.name + " Armor: " + highlighted_character.armor.name, style); preview = true; break; } else if (eff.type.ToString() == "Heal") { int healing = (int)curr_player.curr_action.Peek().Convert_To_Double(eff.values[0], highlighted_character.gameObject); int new_aura = highlighted_character.aura_curr + healing; if (new_aura < 0) { new_aura = 0; } else if (new_aura > highlighted_character.aura_max) { new_aura = highlighted_character.aura_max; } GUI.TextArea(new Rect(Screen.width - 320, Screen.height - 120, 200, 110), highlighted_character.character_name + "\n" + "AU: <color=green>" + new_aura + "</color> / " + highlighted_character.aura_max + " " + "MP: " + highlighted_character.mana_curr + " / " + highlighted_character.mana_max + "\n" + "AP: " + highlighted_character.action_curr + " / " + highlighted_character.action_max + " " + "RP: " + highlighted_character.reaction_curr + " / " + highlighted_character.reaction_max + "\n" + "Str: " + highlighted_character.strength + " Crd: " + highlighted_character.coordination + " Spt: " + highlighted_character.spirit + "\n" + "Dex: " + highlighted_character.dexterity + " Vit: " + highlighted_character.vitality + " Spd: " + highlighted_character.speed + "\n" + "Wep: " + highlighted_character.weapon.name + " Armor: " + highlighted_character.armor.name, style); preview = true; break; } } if (!preview) { GUI.TextArea(new Rect(Screen.width - 320, Screen.height - 120, 200, 110), highlighted_character.character_name + "\n" + "AU: " + highlighted_character.aura_curr + " / " + highlighted_character.aura_max + " " + "MP: " + highlighted_character.mana_curr + " / " + highlighted_character.mana_max + "\n" + "AP: " + highlighted_character.action_curr + " / " + highlighted_character.action_max + " " + "RP: " + highlighted_character.reaction_curr + " / " + highlighted_character.reaction_max + "\n" + "Str: " + highlighted_character.strength + " Crd: " + highlighted_character.coordination + " Spt: " + highlighted_character.spirit + "\n" + "Dex: " + highlighted_character.dexterity + " Vit: " + highlighted_character.vitality + " Spd: " + highlighted_character.speed + "\n" + "Wep: " + highlighted_character.weapon.name + " Armor: " + highlighted_character.armor.name, style); } } else { GUI.TextArea(new Rect(Screen.width - 320, Screen.height - 120, 200, 110), highlighted_character.character_name + "\n" + "AU: " + highlighted_character.aura_curr + " / " + highlighted_character.aura_max + " " + "MP: " + highlighted_character.mana_curr + " / " + highlighted_character.mana_max + "\n" + "AP: " + highlighted_character.action_curr + " / " + highlighted_character.action_max + " " + "RP: " + highlighted_character.reaction_curr + " / " + highlighted_character.reaction_max + "\n" + "Str: " + highlighted_character.strength + " Crd: " + highlighted_character.coordination + " Spt: " + highlighted_character.spirit + "\n" + "Dex: " + highlighted_character.dexterity + " Vit: " + highlighted_character.vitality + " Spd: " + highlighted_character.speed + "\n" + "Wep: " + highlighted_character.weapon.name + " Armor: " + highlighted_character.armor.name, style); } } else { //Object GUI.TextArea(new Rect(Screen.width - 320, Screen.height - 120, 200, 110), "Object \n"); } } }