public override bool activate(rpg_character attacker, attack_entity triggering_attack) { bool made_attack = false; for (int i = 0; i < triggering_attack.target_squares.Count; i++) { //If the square is occupied, call the take damage method on the enemy at that point if (util_ref.e_manager.is_occupied(triggering_attack.target_squares[i])) { if (attacker.tag != "Enemy") { made_attack = true; attack_data data = new attack_data(); data.attacker = attacker; data.attack_ref = triggering_attack; util_ref.e_manager.get_at_square(triggering_attack.target_squares[i]). GetComponent <rpg_character>().take_damage(data); } } else if (util_ref.p_manager.get_p_pos() == triggering_attack.target_squares[i]) { if (attacker.gameObject.tag != "Player") { made_attack = true; attack_data data = new attack_data(); data.attacker = attacker; data.attack_ref = triggering_attack; util_ref.p_manager.cur_player.GetComponent <rpg_character>().take_damage(data); } } } return(made_attack); }
public void add_attack_to_hotbar(attack_entity new_attack) { GameObject new_hotbar = GameObject.Instantiate(util_ref.hotbar_prefab); new_hotbar.GetComponent <Image>().sprite = new_attack.icon; new_hotbar.transform.SetParent(hotbar.transform); }
public override void editor_layout(attack_entity attack_ref) { projectile = (GameObject)EditorGUILayout.ObjectField( projectile, typeof(GameObject), false); type = (projectile_type)EditorGUILayout.EnumPopup(type); }
public override void editor_layout(attack_entity attack_ref) { EditorGUILayout.BeginHorizontal(); charge_name = EditorGUILayout.TextField(charge_name); int cost = EditorGUILayout.IntField(attack_ref.stats.get_stat_value("cost")); attack_ref.stats.set_stat("cost", cost); EditorGUILayout.EndHorizontal(); }
/* * public void set_passive(Conditional condition) * { * passive.GetComponent<Text>().text = condition.conditional_name; * } */ private string attack_description(attack_entity template) { string return_string = template.name; return_string += "\n" + template.stats.get_stat_value("Damage").ToString() + " Dmg / "; return_string += template.stats.get_stat_value("Range") + " Range"; return(return_string); }
public void swap_skill(attack_entity current_skill, attack_entity new_skill) { int index = skills.IndexOf(current_skill); skills[index] = new_skill; if (attached_character.get_character().queued_attack == current_skill) { attached_character.get_character().queued_attack = new_skill; } hotbar.GetComponent <hotbar_script>().change_sprite(index, skills[index].icon); hotbar.GetComponent <hotbar_script>().set_all_white(); }
public override bool activate(rpg_character attacker, attack_entity triggering_attack) { if (triggering_attack.activated_effect) { temporary_condition new_condition = Object.Instantiate(condition) as temporary_condition; new_condition.source_character = attacker; new_condition.source_attack = triggering_attack; new_condition.add_effect(attacker); return(true); } else { return(false); } }
public override bool activate(rpg_character attacker, attack_entity triggering_attack) { if (triggering_attack.activated_effect) { if (attacker.type == character_type.enemy) { attacker.queued_attack = replacement_skill; } else if (attacker.type == character_type.player) { attacker.GetComponent <player_script>().inv.swap_skill(triggering_attack, replacement_skill); } } return(triggering_attack.activated_effect); }
public override void editor_layout(attack_entity attack_ref) { //string old_name = charge_name; charge_name = EditorGUILayout.TextField(charge_name); max_charge = EditorGUILayout.IntField(max_charge); /* * if(attack_ref.stats.has_stat(old_name)) * { * attack_ref.stats.remove_stat(attack_ref.stats.get_stat(old_name)); * } * * attack_ref.stats.init_stat(charge_name); * attack_ref.stats.set_stat_max(charge_name, max_charge); */ }
public override bool activate(rpg_character attacker, attack_entity triggering_attack) { bool did_apply = false; for (int i = 0; i < triggering_attack.target_squares.Count; i++) { if (util_ref.e_manager.is_occupied(triggering_attack.target_squares[i])) { temporary_condition new_condition = Object.Instantiate(condition) as temporary_condition; new_condition.source_character = attacker; new_condition.source_attack = triggering_attack; new_condition.add_effect(util_ref.e_manager.get_at_square(triggering_attack.target_squares[i]).GetComponent <rpg_character>()); did_apply = true; } } return(did_apply); }
public override bool activate(rpg_character attacker, attack_entity triggering_attack) { Debug.Log("Looping through target squares list of length " + triggering_attack.target_squares.Count); for (int i = 0; i < triggering_attack.target_squares.Count; i++) { GameObject new_projectile = GameObject.Instantiate(projectile); new_projectile.transform.position = attacker.transform.position + new Vector3(.5f, .5f, 0f); Vector3 target_square = new Vector3(triggering_attack.target_squares[i].x + .5f, triggering_attack.target_squares[i].y + .5f); new_projectile.GetComponent <projectile_script>().generate_midpoint(attacker.transform.position, target_square); Debug.Log("Created projectile targeting " + target_square.ToString()); new_projectile.GetComponent <projectile_script>().target = target_square; new_projectile.GetComponent <projectile_script>().type = type; } if (triggering_attack.target_squares.Count > 0) { return(true); } return(false); }
public override bool activate(rpg_character attacker, attack_entity triggering_attack) { if (cur_cooldown > 0) { triggering_attack.target_squares.Clear(); return(false); } else { cur_cooldown = triggering_attack.stats.get_stat_value("Cooldown"); target_event = attacker.name + "_start_turn"; util_ref.events.start_listening(target_event, tick); //Get the index of the appropriate skill and set the fill to none attack_reference = triggering_attack; int index_reference = util_ref.p_manager.p_script.inv.get_skill_index(attack_reference); util_ref.p_manager.p_script.inv.hotbar.transform.GetChild(index_reference).GetComponent <Image>().fillAmount = 0f; return(true); } }
public override bool activate(rpg_character attacker, attack_entity triggering_attack) { //Need to set stat in character so other attacks can reference the charges if (triggering_attack.activated_effect) { if (!attacker.stats.has_stat(charge_name)) { attacker.stats.init_stat(charge_name); attacker.stats.set_stat_max(charge_name, max_charge); } if (attacker.stats.get_stat_value(charge_name) == max_charge) { triggering_attack.activated_effect = false; return(false); } attacker.stats.get_stat(charge_name).inc_value(); //triggering_attack.stats.get_stat(charge_name).inc_value(); Debug.Log(charge_name + " is now " + attacker.stats.get_stat_value(charge_name)); } return(triggering_attack.activated_effect); }
public override bool activate(rpg_character attacker, attack_entity triggering_attack) { if (triggering_attack.target_squares.Count <= 0) { return(false); } int cost = triggering_attack.stats.get_stat_value("cost"); int charges = attacker.stats.get_stat_value(charge_name); //Debug.Log("Attempting to remove " + cost + " charges from " + charges + " " + charge_name); if (charges >= cost) { attacker.stats.set_stat(charge_name, charges - cost); //Debug.Log(charge_name + " is now " + attacker.stats.get_stat_value(charge_name)); return(true); } else { triggering_attack.target_squares.Clear(); return(false); } }
public override bool activate(rpg_character attacker, attack_entity triggering_attack) { bool activated_effect = false; for (int i = triggering_attack.target_squares.Count - 1; i >= 0; i--) { if (util_ref.e_manager.is_occupied(triggering_attack.target_squares[i])) { activated_effect = true; GameObject target = util_ref.e_manager.get_at_square(triggering_attack.target_squares[i]); attack_data data = new attack_data(); data.attacker = attacker; data.target = target.GetComponent <rpg_character>(); data.attack_ref = triggering_attack; Vector2Int push_square = get_furthest(data); //Debug.Log("Attempted to push enemy to " + push_square.ToString()); //target.GetComponent<enemy_script>().move(push_square.x, push_square.y); target.GetComponent <rpg_character>().disable_hb(); RaycastHit2D hit = Physics2D.Linecast(target.transform.position + new Vector3(.5f, .5f), push_square); if (hit.collider == null) { target.GetComponent <rpg_character>().move_abs(push_square.x, push_square.y); Debug.DrawLine(target.transform.position, new Vector3(push_square.x, push_square.y), Color.magenta, 2f); } else { //Take damage based on distance to collider float distance = Mathf.Abs(Vector3.Distance(target.transform.position, hit.point)); //target.GetComponent<rpg_character>().take_damage(Mathf.CeilToInt(distance), data); target.GetComponent <rpg_character>().move_abs((int)hit.point.x, (int)hit.point.y); Debug.DrawLine(target.transform.position, hit.point, Color.red, 2f); } target.GetComponent <rpg_character>().enable_hb(); } } return(activated_effect); }
public override void add(attack_entity target) { target.add_component(this); }
public override void editor_layout(attack_entity attack_ref) { target_event = EditorGUILayout.TextField(target_event); charge_name = EditorGUILayout.TextField(charge_name); max_charge = EditorGUILayout.IntField(max_charge); //Probably helps to be able to set max value to non-zero... }
public override void OnInspectorGUI() { attack_ref = target as attack_entity; //Set the icon of the attack attack_ref.icon = (Sprite)EditorGUILayout.ObjectField("Icon:", attack_ref.icon, typeof(Sprite), false); //Set the shape, and the range / radius as applicable if (attack_ref.shape == attack_shape.single || attack_ref.shape == attack_shape.line) { EditorGUILayout.BeginHorizontal(); attack_ref.shape = (attack_shape)EditorGUILayout.EnumPopup("Attack Shape:", attack_ref.shape); attack_ref.stats.set_stat("Range", EditorGUILayout.IntField("Range", attack_ref.stats.get_stat_value("Range")) ); EditorGUILayout.EndHorizontal(); } else if (attack_ref.shape == attack_shape.square) { attack_ref.shape = (attack_shape)EditorGUILayout.EnumPopup("Attack Shape:", attack_ref.shape); int range = attack_ref.stats.get_stat_value("Range"); range = EditorGUILayout.IntField("Range", range); attack_ref.stats.set_stat("Range", range); int radius = attack_ref.stats.get_stat_value("Radius"); radius = EditorGUILayout.IntField("Radius", radius); attack_ref.stats.set_stat("Radius", radius); } //Edit the components component_foldout = EditorGUILayout.Foldout(component_foldout, "Components"); if (component_foldout && attack_ref.components != null) { for (int i = 0; i < attack_ref.components.Length; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(attack_ref.components[i].component_name); attack_ref.components[i].editor_layout(attack_ref); EditorUtility.SetDirty(attack_ref.components[i]); if (i != 0) { if (GUILayout.Button("▲")) { //Move up in list attack_component tmp = attack_ref.components[i]; attack_ref.components[i] = attack_ref.components[i - 1]; attack_ref.components[i - 1] = tmp; break; } } if (i != attack_ref.components.Length - 1) { if (GUILayout.Button("▼")) { //Move down in list attack_component tmp = attack_ref.components[i]; attack_ref.components[i] = attack_ref.components[i + 1]; attack_ref.components[i + 1] = tmp; break; } } //Delete the component if (GUILayout.Button("-")) { //Get all assets attached to the object Object[] assets = UnityEditor.AssetDatabase.LoadAllAssetsAtPath(AssetDatabase.GetAssetPath(attack_ref)); for (int n = 0; n < assets.Length; n++) { //Do a type comparison and destroy if it matches //This will break if there's more than one component of the same type, //but there shouldn't be any purpose for that if (assets[n].GetType() == attack_ref.components[i].GetType()) { //If need be, we could compare IDs Object.DestroyImmediate(assets[n], true); } } attack_ref.remove_component(i); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } EditorGUILayout.EndHorizontal(); } } //Since each menu item has a custom string and custom callback, //we don't really save much space by creating a function to add the two parts //that stay the same throughout if (GUILayout.Button("Add attack component")) { GenericMenu menu = new GenericMenu(); menu.AddItem(new GUIContent("Direct damage"), false, add_component, new direct_damage_component()); menu.AddItem(new GUIContent("Push"), false, add_component, new push_component()); menu.AddItem(new GUIContent("Effect on enemy"), false, add_component, new effects_on_enemy_component()); menu.AddItem(new GUIContent("Effect on attacker"), false, add_component, new effect_on_attacker_component()); menu.AddItem(new GUIContent("Dash"), false, add_component, new dash_component()); menu.AddItem(new GUIContent("Create projectile"), false, add_component, new create_projectile_component()); menu.AddItem(new GUIContent("Limit targets"), false, add_component, new line_limit_targets_component()); menu.AddItem(new GUIContent("Switch skill"), false, add_component, new switch_skill_component()); menu.AddItem(new GUIContent("Force bool"), false, add_component, new force_bool_component()); menu.AddItem(new GUIContent("Temporary condition on target"), false, add_component, new applies_condition_target_component()); menu.AddItem(new GUIContent("Temporary condition on attacker"), false, add_component, new applies_condition_attacker_component()); menu.AddItem(new GUIContent("Cooldown"), false, add_component, new cooldown_component()); menu.AddItem(new GUIContent("Add charge"), false, add_component, new adds_charge_component()); menu.AddItem(new GUIContent("Consumes charge"), false, add_component, new consumes_charge_component()); menu.AddItem(new GUIContent("Add charge on event"), false, add_component, new add_charge_on_event_component()); menu.ShowAsContext(); } if (GUILayout.Button("Check stats")) { attack_ref.stats.print_values(); } if (GUILayout.Button("Print components")) { for (int i = 0; i < attack_ref.components.Length; i++) { Debug.Log("Component " + i + ": " + attack_ref.components[i]); } } EditorUtility.SetDirty(attack_ref); }
public override bool activate(rpg_character attacker, attack_entity triggering_attack) { return(triggering_attack.activated_effect); }
public void set_attack_two(attack_entity template) { attack_two.GetComponent <Image>().sprite = template.icon; attack_two.transform.GetChild(0).GetComponent <Text>().text = attack_description(template); }
public override void editor_layout(attack_entity attack_ref) { int max_cooldown = EditorGUILayout.IntField(attack_ref.stats.get_stat_value("Cooldown")); attack_ref.stats.set_stat("Cooldown", max_cooldown); }
public override void add(attack_entity target) { target.add_component(this); target.stats.init_stat("Pierce"); }
public override void editor_layout(attack_entity attack_ref) { int limit = EditorGUILayout.IntField(attack_ref.stats.get_stat_value("Pierce")); attack_ref.stats.set_stat("Pierce", limit); }
public override void editor_layout(attack_entity attack_ref) { return_val = EditorGUILayout.Toggle(return_val); }
public override bool activate(rpg_character attacker, attack_entity triggering_attack) { return(return_val); }
public void activate_perk() { //Debug.Log("Activated perk " + name); switch (trigger) { case trigger_enum.always: activate_effect(); util_ref.p_manager.cur_player.GetComponent <rpg_character>().stats.add_modifier(mod, stat); break; case trigger_enum.turn_start: attack_data dummy_data = new attack_data(); dummy_data.attacker = util_ref.p_manager.cur_player.GetComponent <rpg_character>(); if (check_condition(dummy_data)) { activate_effect(); util_ref.p_manager.cur_player.GetComponent <rpg_character>().stats.add_modifier(mod, stat); } break; case trigger_enum.on_attack: if (util_ref.events.last_attack.attacker.stats.has_stat(stat) && check_condition(util_ref.events.last_attack)) { activate_effect(); util_ref.events.last_attack.attacker.stats.add_modifier(mod, stat); } else if (util_ref.events.last_attack.attack_ref.stats.has_stat(stat) && check_condition(util_ref.events.last_attack)) { attack_ref = util_ref.events.last_attack.attack_ref; activate_effect(); util_ref.events.last_attack.attack_ref.stats.add_modifier(mod, stat); } else { //Debug.LogError("Could not find stat " + stat + " in attacker or attack"); } break; case trigger_enum.on_attacked: if (util_ref.events.last_attack.target.stats.has_stat(stat) && check_condition(util_ref.events.last_attack)) { activate_effect(); util_ref.events.last_attack.target.stats.add_modifier(mod, stat); } else if (util_ref.events.last_attack.attack_ref.stats.has_stat(stat) && check_condition(util_ref.events.last_attack)) { attack_ref = util_ref.events.last_attack.attack_ref; activate_effect(); util_ref.events.last_attack.attack_ref.stats.add_modifier(mod, stat); } else { //Debug.LogError("Could not find stat " + stat + " in target or attack"); } break; default: Debug.LogError("Activate perk expected nonargument event"); break; } switch (duration) { case duration_enum.for_action: action_remove(); break; case duration_enum.turn_limited: turn_remove(); break; default: break; } }
public int get_skill_index(attack_entity reference) { return(skills.IndexOf(reference)); }
public override void add(attack_entity target) { throw new System.NotImplementedException(); }
public override void editor_layout(attack_entity attack_ref) { throw new System.NotImplementedException(); }
public override bool activate(rpg_character attacker, attack_entity triggering_attack) { throw new System.NotImplementedException(); }