Example #1
0
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    //  Initializes the projectile, usually called
    //  when it is being reused from an object pool
    /// </summary>
    public void Init(Weapon wep)
    {
        // Reset stats
        _DistanceTravelled = 0f;
        _WeaponAttached    = wep;
        _Velocity          = transform.forward;
        _OriginPosition    = transform.position;
        _Damages           = wep.Damages;

        // This should already be called when it is pulled from its object pool,
        // but this is just incase it somehow isn't
        gameObject.SetActive(true);

        // Set homing target for tracking
        _HomingProjectile = wep.TrackingProjectile;
        _TrackingStrength = wep.TrackingStrength;
        if (_HomingProjectile)
        {
            if (_WeaponAttached.GetUnitAttached() != null)
            {
                HomingTarget = _WeaponAttached.GetUnitAttached().GetAttackTarget();
            }
            if (_WeaponAttached.GetTowerAttached() != null)
            {
                HomingTarget = _WeaponAttached.GetTowerAttached().GetAttackTarget();
            }

            // Set distance for tracking unlock
            _DisableTrackDistance = Vector3.Distance(_OriginPosition, HomingTarget.transform.position);
        }
        else
        {
            _DisableTrackDistance = 100000f;
        }

        // Create parabolic arc component
        ParabolicArc oldArc = GetComponent <ParabolicArc>();

        if (oldArc != null)
        {
            Destroy(oldArc);
        }
        if (AffectedByGravity)
        {
            gameObject.AddComponent <ParabolicArc>();
        }

        // Timed detonation
        if (TimedDetonation)
        {
            StartCoroutine(DetonatorTimer());
        }
    }
Example #2
0
    IEnumerator Jump(Transform target, float timeToPass)
    {
        Vector3 start = transform.position;
        Vector3 end   = target.position + agent.baseOffset * Vector3.up;

        ParabolicArc arc = new ParabolicArc(start, end, 1);

        float timeLeft = timeToPass;

        while (timeLeft > 0)
        {
            timeLeft = timeLeft - Time.deltaTime;

            transform.position =
                arc.Lerp(1 - timeLeft / timeToPass);

            yield return(null);
        }
        currentState       = State.Landed;
        transform.position = end;
    }
    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////

    /// <summary>
    //  Initializes the projectile, usually called
    //  when it is being reused from an object pool
    /// </summary>
    public void Init(Weapon wep)
    {
        // Reset stats
        _DistanceTravelled = 0f;
        _WeaponAttached    = wep;
        _Velocity          = transform.forward;
        _OriginPosition    = transform.position;
        _Damages           = wep.Damages;

        // This should already be called when it is pulled from its object pool,
        // but this is just incase it somehow isn't
        gameObject.SetActive(true);

        // Set homing target for tracking
        if (HomingProjectile)
        {
            if (_WeaponAttached.GetUnitAttached() != null)
            {
                HomingTarget = _WeaponAttached.GetUnitAttached().GetAttackTarget();
            }
            if (_WeaponAttached.GetTowerAttached() != null)
            {
                HomingTarget = _WeaponAttached.GetTowerAttached().GetAttackTarget();
            }
        }

        // Create parabolic arc component
        ParabolicArc oldArc = GetComponent <ParabolicArc>();

        if (oldArc != null)
        {
            Destroy(oldArc);
        }
        if (AffectedByGravity)
        {
            gameObject.AddComponent <ParabolicArc>();
        }
    }
Example #4
0
 public void AcceptGraphicalPrimitiveParabolicArc(ParabolicArc parabolicArc, PrintContext parameter)
 {
     parameter.WriteLine("Parabolic Arc: {0} ({1} to {2})",
                         parabolicArc.TangentIntersectionPoint, parabolicArc.Start, parabolicArc.End);
 }
Example #5
0
 public virtual void AcceptGraphicalPrimitiveParabolicArc(ParabolicArc parabolicArc, T parameter)
 {
     // intentionally left blank
 }