Exemplo n.º 1
0
    protected override void Fire()
    {
        base.Fire();

        Vector3 forward = GetForward();

        // Projectile
        for (int i = 0; i < pelletCount; i++)
        {
            Vector2 error      = Random.insideUnitCircle * (accuracy / 10f);
            Vector3 errForward = (forward + (GetRight() * error.x) + (GetUp() * error.y)).normalized;

            Status stat = onHitStatus == null ? null : new Status(onHitStatus.from, onHitStatus.statusType);

            // Either the target requires a raycast to hit, or it became null during a coroutine delay. In this case, we want to shoot anyway
            if (IsNull(target) || target.HasCollision())
            {
                hitscans.SpawnHitscan(scanTemplate, firePos.position, errForward, parentUnit, stat); // TODO: Do we need to make a new status each time?
            }
            else                                                                                     // Explicitly define visuals
            {
                float distance = (firePos.position - target.GetPosition()).magnitude;
                // TODO: Should raycast anyway to check for cover. Currently, we will NOT shoot through allies bc we check for FF, but we CAN ignore enemies and terrain, shooting fighters through them
                hitscans.SpawnHitscan(scanTemplate, firePos.position, errForward, parentUnit, stat, target);                 // TODO: Do we need to make a new status each time?
            }
        }

        // Sound
        PlayShootSound();
    }
Exemplo n.º 2
0
    void Fire()
    {
        // Make sure this shot counts for getting a stack
        Status markStatus = new Status(gameObject, StatusType.SuperlaserMark);

        markStatus.SetTimeLeft(CalcDamage());

        Hitscan shot = new Hitscan(shotTemplate);

        shot.SetDamage(0);
        for (int i = 1; i < sourcePositions.Length; i++)
        {
            hitscans.SpawnHitscan(shot, sourcePositions[i].position, sourcePositions[0].forward, parentUnit, markStatus);
        }
        shot.SetDamage(CalcDamage());
        hitscans.SpawnHitscan(shot, sourcePositions[0].position, sourcePositions[0].forward, parentUnit, markStatus);

        Destroy(countdownStart);                                                     // TODO: ???
        //Instantiate(countdownFinishExplosion, targetUnit.transform.position, Quaternion.identity); // Explosion
        Instantiate(countdownFinishPrefab, transform.position, Quaternion.identity); // Sound TODO: ???

        Reset();
        StartCooldown();         // Now start ability cooldown
    }