Exemplo n.º 1
0
    /// <summary>
    /// 发射子弹的防御塔在发射时调用
    /// </summary>
    /// <param name="es"></param>
    /// <returns></returns>
    public virtual TurretAttack Shoot(EnemyScript es)
    {
        GameObject attack = Instantiate(attackPrefab);

        if (type == BULLET)
        {
            attack.transform.position = this.transform.position;

            BulletScript bs = attack.GetComponent <BulletScript>();

            bs.SetBullet(this);

            bs.flying = true;
            return(bs);
        }
        else if (type == EXPLOSION)
        {
            attack.transform.position = target.transform.position;
            ExplosionScript explode = attack.GetComponent <ExplosionScript>();

            explode.SetExplosion(this);
            explode.Explode();
        }
        else if (type == LASER)
        {
            LaserScript ls = attack.GetComponent <LaserScript>();
            ls.SetLaser(this);
            ls.Emit();
        }

        return(null);
    }
    private ExplosionScript CreateExplosion()
    {
        ExplosionScript es = Instantiate(explosionPrefab).GetComponent <ExplosionScript>();

        es.SetExplosion(this);
        es.Explode();


        return(null);
    }