Exemplo n.º 1
0
    // it is assumed the current projectile is a generic projectile with an empty reference behaviour to fill up
    public void Clone(Projectile p_projectile, ProjectileInfo p_projectileInfo, List <string> p_extraBehaviours)
    {
        m_reference = false;

        p_projectile.LoadComponents();
        LoadComponents();

        SpriteRenderer render   = m_render;
        BoxCollider2D  collider = m_boxCollider;

        render.sprite   = p_projectile.m_render.sprite;
        collider.size   = p_projectile.m_boxCollider.size;
        collider.offset = p_projectile.m_boxCollider.offset;

        // this will overwrite any assignment done to this projectile beforehand
        p_projectile.Copy(typeof(Projectile), gameObject);

        m_render           = render;
        m_boxCollider      = collider;
        m_info             = p_projectileInfo;
        m_behaviourManager = GetComponent <BehaviourManager>();
        m_behaviourManager.m_behaviours = new Dictionary <ProjectileBehaviour, bool>();

        foreach (string behaviour in p_extraBehaviours)
        {
            ProjectileBehaviour clone = ProjectileBehaviour.Get(behaviour, false);

            if (clone != null)
            {
                m_behaviourManager.m_behaviours.Add(clone, false);
            }
        }

        m_original = p_projectile;
    }