Esempio n. 1
0
    public static void SendProjectile(Projectile projectile, Vector3 start, Vector3 target)
    {
        /*
         * First extend the target point to the bounds
         */
        Vector3 boundsDimensions = instance.mapbounds.GetDimensions();
        float   largestDimension = Mathf.Max(
            boundsDimensions.x,
            boundsDimensions.y,
            boundsDimensions.z
            );
        Vector3 direction = target - start;
        Ray     ray       = new Ray(start, direction);

        // reverse the ray
        ray.origin    = ray.GetPoint(largestDimension);
        ray.direction = -ray.direction;

        RaycastHit info;

        Physics.Raycast(ray, out info, instance.boundsMask);

        target = info.point;
        //Debug.DrawLine(start, target, color: Color.white, duration: .2f);

        Vector3             lastImpact  = target;
        ProcessIntersection onIntersect = (result => {
            result.GetObstacle().HitBy(projectile);

            Vector3 location = result.GetPosition();
            float power = projectile.GetStrength();
            float suppressiveRadius = projectile.GetSuppressiveRadius();
            lastImpact = location;
            EnvironmentInteractions.ProjectileInstantImpactEffect(location, suppressiveRadius, power);


            projectile.SlowedBy(result.GetObstacle());
        });
        ShouldContinueRayCast continueCondition = (result => {
            return(projectile.IsStillActive());
        });

        IncrementalRaycast(start, target, onIntersect, continueCondition);
        projectile.ResetStrength();
        Debug.DrawLine(start, lastImpact, color: Color.white, duration: .2f);
    }
Esempio n. 2
0
    // Use this for initialization

    private void Awake()
    {
        instance            = this;
        humanoidSubscribers = new List <HumanoidModel>();
    }