Exemplo n.º 1
0
    // Applies whatever effect the magic has against the other object.
    private void applyMagicEffect(Collider2D co)
    {
        // Check if the other object has a OnMagicImpact
        GameObject    go     = co.gameObject;
        OnMagicImpact script = go.GetComponent <OnMagicImpact>();

        if (script != null)
        {
            Debug.Log("Lanzando delegado");
            OnMagicImpact.ImpactDetails details = new OnMagicImpact.ImpactDetails();
            details.skillName = skill;
            details.hitPoint  = this.transform.position;

            script.triggerDelegate(details);
        }
    }
Exemplo n.º 2
0
    // Start is called before the first frame update
    public override void Start()
    {
        base.Start();
        magicImpactScript = GetComponent <OnMagicImpact>();
        if (magicImpactScript != null)
        {
            magicImpactScript.effectDelegate = OnMagicImpactEffect;
        }

        animator        = GetComponentInChildren <Animator>();
        rend            = GetComponent <SpriteRenderer>();
        rb              = GetComponent <Rigidbody2D>();
        rb.gravityScale = 0;
        //rb.bodyType = RigidbodyType2D.Static;
        player       = GameObject.FindGameObjectWithTag("Player");
        childrenRend = GetComponentsInChildren <SpriteRenderer>();
    }