// Use this for initialization
 void Start()
 {
     pullZone = GetComponentInChildren <PullZone>();
     pullZone.OnObjectLoaded += LoadSlingshot;
     // the slingshot's anchor points for the band
     leftAnchorPoint  = transform.Find("LeftAnchorPoint");
     rightAnchorPoint = transform.Find("RightAnchorPoint");
     gameObject.transform.Find("ballisticPathGraphics").gameObject.SetActive(false);
 }
Example #2
0
    // use "LateUpdate to ensure that we get the value for velocityVect.
    void LateUpdate()
    {
        Debug.Log("Drawing Ballistic Arc");
        // we know this is highly inefficient but wanted to get it working asap
        Slingshot ss = gameObject.transform.parent.GetComponent <Slingshot>() as Slingshot;
        PullZone  pz = ss.GetComponentInChildren <PullZone>();

        if ((ss.slingshotHand == "left" && pz.loadedObject != null) ||
            (ss.slingshotHand == "right" && pz.loadedObject != null))
        {
            Vector3 velocityVect = ss.CalculateV();
            lr.positionCount = (int)(timeMaximum / timeStep);

            Vector3 currPos = transform.position;

            int i = 0;             // index


            for (float t = 0.0f; t < timeMaximum; t += timeStep)
            {
                lr.SetPosition(i, currPos);


                // project target impact point
                RaycastHit impact;

                if (Physics.Raycast(currPos, velocityVect, out impact, velocityVect.magnitude, layerMask))
                {
                    lr.positionCount = i + 2;
                    lr.SetPosition(i + 1, impact.point);

                    if (impactCircle != null)
                    {
                        if (impactCircleInstance != null)
                        {
                            impactCircleInstance.transform.position = impact.point;
                        }
                        else
                        {
                            impactCircleInstance = Instantiate(impactCircle, impact.point, Quaternion.identity) as GameObject;
                            impactCircleInstance.transform.parent = gameObject.transform;
                        }
                    }
                    break;
                }
                // update position
                currPos = currPos + (velocityVect * timeStep);

                // account for gravity on arc
                velocityVect += (Physics.gravity * timeStep);
                i++;
            }
        }
    }
Example #3
0
        public void Serialize()
        {
            var zone = new PullZone {
                Id               = 11,
                Type             = 0,
                AddHostHeader    = true,
                BlockedCountries = new[] { "AU" }
            };

            Assert.Equal(@"{
  ""Id"": 11,
  ""AddHostHeader"": true,
  ""Type"": 0,
  ""BlockedCountries"": [
    ""AU""
  ]
}", JsonSerializer.Serialize(zone, JSO.Default));
        }
Example #4
0
        public void Serialize2()
        {
            var zone = new PullZone
            {
                Id         = 11,
                Type       = 0,
                BlockedIps = new[]
                {
                    "1.1.1.1"
                },
                AccessControlOriginHeaderExtensions = new[] { "eot" },
                EnableAccessControlOriginHeader     = true,
                EnableWebPVary     = true,
                EnableAvifVary     = true,
                EnableLogging      = true,
                DisableCookies     = true,
                EnableGeoZoneAF    = true,
                EnableGeoZoneASIA  = true,
                EnableCacheSlice   = true,
                IgnoreQueryStrings = false
            };

            Assert.Equal(@"{
  ""Id"": 11,
  ""BlockedIps"": [
    ""1.1.1.1""
  ],
  ""EnableGeoZoneASIA"": true,
  ""EnableGeoZoneAF"": true,
  ""IgnoreQueryStrings"": false,
  ""Type"": 0,
  ""AccessControlOriginHeaderExtensions"": [
    ""eot""
  ],
  ""EnableAccessControlOriginHeader"": true,
  ""DisableCookies"": true,
  ""EnableLogging"": true,
  ""EnableCacheSlice"": true,
  ""EnableWebPVary"": true,
  ""EnableAvifVary"": true
}", JsonSerializer.Serialize(zone, JSO.Default));
        }
 public async Task <bool> UpdatePullZone(long zoneId, PullZone pullZoneChages)
 {
     return(await Task.Run(() => { return responseBool; }));
 }