Exemplo n.º 1
0
    void FireProjectile()
    {
        if (myTarget == null)
        {
            return;
        }

        incrementNextFireTime();

        arrow_count++;
        if (!ammo_by_time)
        {
            UseAmmo();
        }
        else
        {
            start_ammo_by_time = true;
        }

        Vector3 firefrom = transform.position;

        if (arrow_origin != null)
        {
            firefrom = arrow_origin.position;
        }

        StatSum statsum = toy.rune.GetStats(false);

        statsum.towerID = this.gameObject.GetInstanceID();
        float arrow_speed = -1;
        Arrow arrow       = null;

        if (current_arrow_name.type == ArrowType.RapidFire || current_arrow_name.type == ArrowType.Slow)
        {
            getTargetPosition();
            arrow = Get.MakeArrow(current_arrow_name, firefrom, myTargetPosition, statsum, arrow_speed, this, true);
        }
        else
        {
            myTargetPosition.x = myTarget.position.x;
            myTargetPosition.y = myTarget.position.y;
            arrow = Get.MakeArrow(current_arrow_name, firefrom, myTarget, statsum, arrow_speed, this, true);//focus has to aim for an actual moving target, nobody else cares though
        }



        CalcAimPosition(myTarget.position);
        //modifiers on regular arrows
        if (current_arrow_name.type == ArrowType.RapidFire)
        {
            //StatBit force = statsum.GetStatBit(EffectType.VexingForce);
            //  force.updateStat(rapid_fire.GetMass());
            rapid_fire.modifyArrow(arrow);
        }


        toy.my_tower_stats.Shots_fired++;
        arrow.gameObject.SetActive(true);
        if (!EnemyInRange(myTarget))
        {
            myTarget = null;
        }
        //    incrementNextFireTime(); should be first
    }