Ejemplo n.º 1
0
    void OnCollisonStay(Collision col)
    {
        if (dmgTimer > 0.5f && !inUse)
        {
            StatBlock        enemy        = col.gameObject.GetComponent <StatBlock>();
            ControlStatBlock enemyControl = col.gameObject.GetComponent <ControlStatBlock>();
            IAttackIgnored   colProj      = col.gameObject.GetComponent <IAttackIgnored>();
            if (colProj == null) //check to see if we collided with another projectile. if so ignore
            {
                //Debug.Log("Col with non-proj, Proj is: " + friendly);

                if (enemy != null)
                {
                    //Debug.Log("Enemy has stat block, enem is friendly: " + enemy.Friendly);
                    if (enemy.Friendly)
                    {
                        dmgTimer = 0f;

                        enemy.TakeDamage(collideDmg, col.gameObject);
                        if (enemyControl != null)
                        {
                            enemyControl.OnHit(collideDmg);
                        }
                    }
                }
            }
        }
    }
Ejemplo n.º 2
0
    void OnTriggerEnter(Collider col)
    {
        StatBlock        enemy        = col.gameObject.GetComponent <StatBlock>();
        ControlStatBlock enemyControl = col.gameObject.GetComponent <ControlStatBlock>();
        IAttackIgnored   colProj      = col.gameObject.GetComponent <IAttackIgnored>();

        if (colProj == null) //check to see if we collided with another projectile. if so ignore
        {
            //Debug.Log("Col with non-proj, Proj is: " + friendly);

            if (enemy != null)
            {
                //Debug.Log("Enemy has stat block, enem is friendly: " + enemy.Friendly);
                if (friendly != enemy.Friendly)
                {
                    enemy.TakeDamage(dmg, col.gameObject);
                    if (enemyControl != null)
                    {
                        enemyControl.OnHit(dmg);
                    }
                    PlayAnim(col);
                    //Debug.Log("Destroy due to hit non friend");
                    // Destroy(gameObject);
                }
            }
            else
            {
                PlayAnim(col);
                //Debug.Log("Destroy due to hit non stat char " + col.gameObject.name);
                // Destroy(gameObject);
            }
        }
    }
    void OnTriggerEnter(Collider col)
    {
        StatBlock        enemy        = col.gameObject.GetComponent <StatBlock>();
        ControlStatBlock enemyControl = col.gameObject.GetComponent <ControlStatBlock>();
        IAttackIgnored   colProj      = col.gameObject.GetComponent <IAttackIgnored>();

        if (colProj == null) //check to see if we collided with another projectile. if so ignore
        {
            //Debug.Log("Col with non-proj, Proj is: " + friendly);

            if (enemy != null)
            {
                //Debug.Log("Enemy has stat block, enem is friendly: " + enemy.Friendly);
                if (friendly != enemy.Friendly)
                {
                    float dmgTaken = enemy.TakeDamage(dmg, col.gameObject);
                    if (enemyControl != null)
                    {
                        enemyControl.OnHit(dmg);
                    }
                    if (dmg.callback != null)
                    {
                        dmg.callback.Callback(dmgTaken);
                    }
                    if (destroyable)
                    {
                        OnDeath();
                        PlayAnim(col);
                        Destroy(gameObject);
                    }
                }
            }
            else
            {
                if (destroyable)
                {
                    OnDeath();
                    PlayAnim(col);
                    Destroy(gameObject);
                }
            }
        }
    }