Ejemplo n.º 1
0
    void ObjectCapture()
    {
        //additional check if in camera
        RaycastHit2D cast = PointInDirection();

        if (cast.collider != null)
        {
            toCapture = PointInDirection().collider.gameObject;
        }
        else
        {
            toCapture = null;
        }

        if (toCapture != null)
        {
            CaptureObject cap = toCapture.GetComponent <CaptureObject>();
            if (cap != null)
            {
                if (cap.Capturable())
                {
                    if (TheBar.GetCount() > 2)
                    {
                        Launch(0, direction, director.transform.position);
                    }
                    cap.IsLaunched = false;
                    TheBar.OnCapture(toCapture);
                }
            }
        }
    }
Ejemplo n.º 2
0
    void Highlight()
    {
        GameObject   toHighlight = null;
        RaycastHit2D cast        = PointInDirection(LayerMask.GetMask("Objects"));
        RaycastHit2D groundCast  = PointInDirection(groundMask);

        if (groundCast.distance < cast.distance)
        {
            return;
        }

        if (cast.collider != null)
        {
            toHighlight = cast.collider.gameObject;
        }
        else
        {
            toHighlight = null;
        }

        if (toHighlight != null)
        {
            CaptureObject cap = toHighlight.GetComponent <CaptureObject>();
            if (cap != null)
            {
                if (cap.Capturable())
                {
                    //put a highlight behind the object, or enable highlight effect
                }
            }
        }
    }
Ejemplo n.º 3
0
    void Highlight()
    {
        GameObject   toHighlight = null;
        RaycastHit2D cast        = PointInDirection();

        if (cast.collider != null)
        {
            toHighlight = PointInDirection().collider.gameObject;
        }
        else
        {
            toHighlight = null;
        }

        if (toHighlight != null)
        {
            CaptureObject cap = toHighlight.GetComponent <CaptureObject>();
            if (cap != null)
            {
                if (cap.Capturable())
                {
                    //put a highlight behind the object, or enable highlight effect
                }
            }
        }
    }
Ejemplo n.º 4
0
    void Launch(int toLaunch, Vector3 direction, Vector3 origin)
    {
        Vector2    launchDir = new Vector2(direction.x, direction.y);
        GameObject launched  = TheBar.OnLaunch(toLaunch);

        if (launched != null)
        {
            launched.transform.position = origin + 0.05f * direction;

            CaptureObject cap = launched.GetComponent <CaptureObject>();
            if (cap != null)
            {
                cap.OnLaunch(direction);
            }
        }
    }
        /// <summary>
        /// Creates capture and follow the Location header to fetch the data
        /// <a href="https://developers.klarna.com/api/#order-management-api-create-capture">
        ///     https://developers.klarna.com/api/#order-management-api-create-capture
        /// </a>
        /// </summary>
        /// <param name="orderId">Id of order to create capture</param>
        /// <param name="capture">The <see cref="OrderManagementCapture"/> object</param>
        /// <returns>Object of <see cref="OrderManagementCapture"/> </returns>
        public async Task <Capture> CreateAndFetchCapture(string orderId, CaptureObject capture)
        {
            var url      = ApiUrlHelper.GetApiUrlForController(ApiSession.ApiUrl, ApiControllerUri, $"{orderId}/captures");
            var response = new Ref <HttpResponseMessage>();

            await Post(url, capture, null, response).ConfigureAwait(false);

            var headers = response.Value.Headers;

            url = headers.Location.ToString();

            if (!string.IsNullOrEmpty(url))
            {
                return(await Get <Capture>(url).ConfigureAwait(false));
            }

            return(default(Capture));
        }
Ejemplo n.º 6
0
    void ObjectCapture()
    {
        //additional check if in camera
        RaycastHit2D cast       = PointInDirection(LayerMask.GetMask("Objects"));
        RaycastHit2D groundCast = PointInDirection(groundMask);

        if (groundCast.distance < cast.distance)
        {
            return;
        }

        if (cast.collider != null)
        {
            toCapture = cast.collider.gameObject;
        }
        else
        {
            toCapture = null;
        }

        if (toCapture != null)
        {
            CaptureObject cap = toCapture.GetComponent <CaptureObject>();
            if (cap != null)
            {
                if (cap.Capturable())
                {
                    if (TheBar.GetCount() > 2)
                    {
                        Launch(0, direction, director.transform.position);
                    }
                    cap.IsLaunched = false;
                    TheBar.OnCapture(toCapture);
                }
            }
        }
    }
Ejemplo n.º 7
0
        /// <summary>
        /// Captures the order.
        /// </summary>
        public void CaptureOrder()
        {
            var username = "******";
            var password = "******";

            var klarna  = new Klarna(username, password, KlarnaEnvironment.TestingEurope);
            var orderId = "abc-abcdefg-abc";

            try
            {
                var captureData = new CaptureObject()
                {
                    CapturedAmount = 10000,
                    Description    = "Full capture of the order",
                    OrderLines     = new List <OrderLine>()
                    {
                        new OrderLine
                        {
                            Type                = OrderLineType.physical,
                            Name                = "Foo",
                            Quantity            = 1,
                            UnitPrice           = 10000,
                            TaxRate             = 2500,
                            TotalAmount         = 10000,
                            TotalTaxAmount      = 2000,
                            TotalDiscountAmount = 0,
                        }
                    },
                    ShippingInfo = new List <ShippingInfo>()
                    {
                        new ShippingInfo
                        {
                            ShippingMethod        = OrderManagementShippingMethod.PickUpPoint,
                            ShippingCompany       = "PostNord",
                            TrackingUri           = "https://trackingpageofcarrier.com",
                            TrackingNumber        = "345...33",
                            ReturnTrackingUri     = "https://trackingpageofreturntracking.com",
                            ReturnTrackingNumber  = "675...575",
                            ReturnShippingCompany = "PostNord"
                        }
                    }
                };
                klarna.OrderManagement.CreateCapture(orderId, captureData).RunSynchronously();
            }
            catch (AggregateException ae)
            {
                foreach (var e in ae.InnerExceptions)
                {
                    if (e is ApiException)
                    {
                        var apiException = (ApiException)e;
                        Console.WriteLine("Status code: " + apiException.StatusCode);
                        Console.WriteLine("Error: " + string.Join("; ", apiException.ErrorMessage.ErrorMessages));
                    }
                    else
                    {
                        // Rethrow any other exception or process it
                        Console.WriteLine(e.Message);
                        throw;
                    }
                }
            }
        }
Ejemplo n.º 8
0
 private void OnCollisionEnter2D(Collision2D collider)
 {
     //If player character, be pushed in response
     //If capture and hit by capture ray, disappear to open slot location
     if (IsLaunched)
     {
         if (collider.gameObject.layer == 8 || collider.gameObject.layer == 12)
         {
             if (IsBreakable)
             {
                 if (IsExplosive)
                 {
                     //do something to explode
                 }
                 Destroy(gameObject);
             }
             IsLaunched = false;
         }
         if (collider.gameObject.layer == 16)
         {
             if (IsBreakable)
             {
                 Destroy(gameObject);
             }
             IsLaunched         = false;
             transform.position = resetPoint;
         }
         if (FlyStraight)
         {
             Debug.Log("Missile collided");
             Rigidbody2D body = GetComponent <Rigidbody2D>();
             if (body != null)
             {
                 body.isKinematic = false;
             }
         }
     }
     else
     {
         if (collider.gameObject.layer == 12)
         {
             CaptureObject cap = collider.gameObject.GetComponent <CaptureObject>();
             if (cap != null)
             {
                 if (cap.Launched())
                 {
                     if (IsBreakable)
                     {
                         if (IsExplosive)
                         {
                             //do something to explode
                         }
                         Destroy(gameObject);
                     }
                 }
             }
         }
         if (collider.gameObject.layer == 16)
         {
             transform.position = resetPoint;
         }
     }
 }
Ejemplo n.º 9
0
 void _capturer_CaptureFinished(object sender, EventArgs e)
 {
     _capturer.SaveAsVideo();
       _capturer = null;
       _images.Clear();
       toolStripStatusLabel1.Text = "Done";
 }
Ejemplo n.º 10
0
        private void CaptureVideo()
        {
            if (_capturer != null)
              {
            return;
              }

              _capturer = new CaptureObject(_dataPath);
              _capturer.Start(_maxBuffer * 2, _images, _fps);
              _capturer.CaptureFinished += _capturer_CaptureFinished;
              toolStripStatusLabel1.Text = "Capturing";
        }
        /// <summary>
        /// Creates capture
        /// <a href="https://developers.klarna.com/api/#order-management-api-create-capture">
        ///     https://developers.klarna.com/api/#order-management-api-create-capture
        /// </a>
        /// </summary>
        /// <param name="orderId">Id of order to create capture</param>
        /// <param name="capture">The <see cref="CaptureObject"/> object</param>
        /// <returns></returns>
        public Task CreateCapture(string orderId, CaptureObject capture)
        {
            var url = ApiUrlHelper.GetApiUrlForController(ApiSession.ApiUrl, ApiControllerUri, $"{orderId}/captures");

            return(Post(url, capture));
        }