void Start() { m_visual = GetComponent <GameVisual>(); }
///Creates a game object as part of an action public GameObject CreateActionObject(ACTION action_id, GameObject action_prefab, int damage) { GAction action = GetAction(action_id); //why are we checking this here??? You really shouldn't be here if this wasn't true. //if(!action.IsReady()) { return; } //Create GameObject associated with this action. GameObject action_object = null; if (action.m_center_on_target && action.m_is_hostile && m_main_hostile_target != null) { action_object = (GameObject)Instantiate(action_prefab, m_main_hostile_target.transform.position + m_attack_position, m_attack_rotation); action_object.transform.localScale = m_entity.m_actor.m_animator.transform.localScale; } else if (action.m_center_on_target && !action.m_is_hostile && m_main_friendly_target != null) { action_object = (GameObject)Instantiate(action_prefab, m_main_friendly_target.transform.position + m_attack_position, m_attack_rotation); action_object.transform.localScale = m_entity.m_actor.m_animator.transform.localScale; } else { action_object = (GameObject)Instantiate(action_prefab, transform.position + m_attack_position, m_attack_rotation); action_object.transform.localScale = m_entity.m_actor.m_animator.transform.localScale; } //Set visual effect movement (might not be needed for this game). if (action_object != null) { Vector2 x_facing = new Vector2(m_entity.m_mobile.GetFacing().x, 0); GameVisual action_effect = action_object.GetComponent <GameVisual>(); if (action_effect != null) { action_effect.move_direction = new Vector2( action_effect.move_direction.x * x_facing.x, action_effect.move_direction.y ); } } //Maybe this should be a feature of the skill? bool enable_autoaim = false; //Set the damage on the shot (or shots) fired by this attack. GDamager root_dmg = action_object.GetComponent <GDamager>(); if (root_dmg != null) { root_dmg.SetDamage(damage); root_dmg.SetOwner(m_entity); if (root_dmg.GetComponent <GBullet>() && enable_autoaim) { root_dmg.GetComponent <GBullet>().SetAutoaimEnabled(enable_autoaim); } } foreach (GDamager dmg in action_object.transform.GetComponentsInChildren <GDamager>()) { dmg.SetDamage(damage); dmg.SetOwner(m_entity); if (dmg.GetComponent <GBullet>() && enable_autoaim) { dmg.GetComponent <GBullet>().SetAutoaimEnabled(enable_autoaim); } } //If this attack summoned a creature, that creature joins the summoner's team. GEntity summoned_entity = action_object.GetComponent <GEntity>(); if (summoned_entity != null) { summoned_entity.m_team_id = m_entity.m_team_id; } //m_entity.m_actor.PlayNormal("Attack"); return(action_object); }