コード例 #1
0
    public static OrderStruct FromBytes(byte[] data)
    {
        if (data.Length < SIZE)
        {
            throw new ArgumentException("Size is incorrect");
        }
        GCHandle h = default(GCHandle);

        try
        {
            try
            {
            }
            finally
            {
                h = GCHandle.Alloc(data, GCHandleType.Pinned);
            }
            OrderStruct t = Marshal.PtrToStructure <OrderStruct>(h.AddrOfPinnedObject());
            return(t);
        }
        finally
        {
            if (h.IsAllocated)
            {
                h.Free();
            }
        }
    }
コード例 #2
0
 // Issue an order to the unit
 public void IssueOrder(OrderStruct order)
 {
     // If it's either of the non-motion orders, there shouldn't be a target
     if (order.order == Order.Stop || order.order == Order.HoldPosition) {
         CurrentOrder = order.order;
         TargetPosition = gameObject.transform.position;
         TargetObject = gameObject;
     } else {
         CurrentOrder = order.order;
         // Make sure the target doesn't cause the unit to "sink" in to the ground
         order.target += new Vector3(0, gameObject.transform.position.y, 0);
         TargetPosition = order.target;
     }
 }
コード例 #3
0
    static void Main(string[] args)
    {
        //Generic type instantiation using reference type
        OrderContainer <OrderObj> orderObjContainer = new OrderContainer <OrderObj>(10);

        //Add and retrieve reference type order
        orderObjContainer.AddOrder(new OrderObj());
        OrderObj orderObj = orderObjContainer.GetOrder(0);

        //Generic type instantiation using value type
        OrderContainer <OrderStruct> orderStructContainer = new OrderContainer <OrderStruct>(10);

        //Add and retrieve value type order
        orderStructContainer.AddOrder(new OrderStruct());
        OrderStruct orderStruct = orderStructContainer.GetOrder(0);
    }
コード例 #4
0
 /*
  * Send RTD and trade fill
  */
 public void AddTradeFill(OrderStruct order)
 {
     if (rtdConn.Connected)
     {
         try
         {
             /*
     RID: TRADE REQ ADD
     # Mandatory Parameters:
     account id, context, contract id, contracts long, contracts short, counterparty id, currency id, date,
     exchange id, price, time, value date cash, value date contract (for non-cash trades)
     # Optional Parameters:
     basket id(0), bof sequence no(0), booking price(0), broker id(0), clearing account(""),
     clearing text(""), courtage(0), cpty clr id(0), cpty id(0), currency booking id(0),
     currency courtage id(0), currency fees id(0), currency provision id(0), exchange tran code(0),
     external order no(""), fees(0), match id(""), member clr id(0), member id(0), order number(""),
     posting code(0), provision(0), price type(0), rtd order id(""), trade flags(0), trader id(0),
     trade number(""), trade text(""), underlying contract id(0), user id(0), value(0),
     value date contract(0), value date fees(0)
     If booking price, fees, provision, courtage are not 0 the corresponding currency ids must be specified
     (currency booking id etc.)
              */
             // RID: TRADE REQ ADD - Order request change
             string sTemp = string.Format("61{0}167{0}{1}{0}76{0}{2}{0}1{0}{3}{0}17{0}{4}{0}20{0}{5}"+
                 "{0}21{0}0{0}24{0}203{0}30{0}{6}{0}47{0}{7}{0}33{0}{8}{0}96{0}{9}{0}15{0}005",
                 '\x1F',
                 order.OrderID,
                 order.Price,
                 order.AccountID,
                 order.ContractID,
                 order.QtyOpen,
                 order.CurrencyID,
                 order.ExchangeID,
                 DateTime.Now.ToString("yyyyMMdd"),
                 DateTime.Now.ToString("HHmmss"));
             System.Diagnostics.Debug.WriteLine("ADD RTD TRADE FILL WITH -> " + sTemp);
             //streamOut.WriteLine(sTemp);
             //streamOut.Flush();
         }
         catch (Exception err)
         {
             System.Diagnostics.Debug.WriteLine("Error " + err.Message);
         }
     }
 }
コード例 #5
0
    // Issue an order to the unit
    public void IssueOrder(OrderStruct order)
    {
        // If it's either of the non-motion orders, there shouldn't be a target
        if (order.order == Order.Stop || order.order == Order.HoldPosition) {
            CurrentOrder = order.order;
            TargetPosition = gameObject.transform.position;
            TargetObject = gameObject;
        } else if (order.order == Order.Face) {
            RTSShipMovement obj = gameObject.GetComponent<RTSShipMovement>();
            gameObject.transform.LookAt(order.target + new Vector3(0, gameObject.transform.position.y - order.target.y, 0));
        } else {
            gameObject.transform.LookAt(order.target + new Vector3(0, gameObject.transform.position.y - order.target.y, 0));
            CurrentOrder = order.order;
            TargetPosition = order.target;

            MovementManager.Move(TargetPosition);
        }
    }
コード例 #6
0
        private void DecodeMessage(string strMessage)
        {
            string[] arrMessage;

            string strRID = strMessage.Substring(0, strMessage.IndexOf('\x1F'));

            switch (strRID)
            {
                case "3":
                    strMessage = strMessage.Substring(strMessage.IndexOf('\x1F') + 1);
                    //arrFIDs = strMessage.Split('\x1F');
                    System.Diagnostics.Debug.WriteLine("Answer - " + strMessage);
                    break;

                case "45":
                    OrderStruct order = new OrderStruct();

                    strMessage = strMessage.Substring(strMessage.IndexOf('\x1F') + 1);
                    arrMessage = strMessage.Split('\x1F');

                    // Lets loop over a bunch of times to get the shit we need

                    // fid_order_id
                    for (int y = 0; y < arrMessage.Length; y++)
                        if (arrMessage[y] == "167")
                        {
                            order.OrderID = int.Parse(arrMessage[++y]);
                            break;
                        }
                    // fid_contract_id
                    for (int y = 0; y < arrMessage.Length; y++)
                        if (arrMessage[y] == "17")
                        {
                            order.ContractID = int.Parse(arrMessage[++y]);
                            break;
                        }
                    // fid_currency_id
                    for (int y = 0; y < arrMessage.Length; y++)
                        if (arrMessage[y] == "30")
                        {
                            order.Text = arrMessage[++y];
                            break;
                        }
                    // fid_exchange_id
                    for (int y = 0; y < arrMessage.Length; y++)
                        if (arrMessage[y] == "47")
                        {
                            order.ExchangeID = int.Parse(arrMessage[++y]);
                            break;
                        }
                    // fid_state
                    for (int y = 0; y < arrMessage.Length; y++)
                        if (arrMessage[y] == "202")
                        {
                            order.State = int.Parse(arrMessage[++y]);
                            break;
                        }
                    // fid_order_bid
                    for (int y = 0; y < arrMessage.Length; y++)
                        if (arrMessage[y] == "150")
                        {
                            order.IsBid = arrMessage[++y] == "1" ? true : false;
                            break;
                        }
                    // fid_total_qty
                    for (int y = 0; y < arrMessage.Length; y++)
                        if (arrMessage[y] == "170")
                        {
                            order.Qty = int.Parse(arrMessage[++y]);
                            break;
                        }
                    // fid_open_qty
                    for (int y = 0; y < arrMessage.Length; y++)
                        if (arrMessage[y] == "149")
                        {
                            order.QtyOpen = int.Parse(arrMessage[++y]);
                            break;
                        }
                    // fid_price
                    for (int y = 0; y < arrMessage.Length; y++)
                        if (arrMessage[y] == "76")
                        {
                            // Prices in RTD are GBP, prices in VOLT are GPX (pence)
                            order.Price = double.Parse(arrMessage[++y]) * 100;
                            break;
                        }
                    // fid_text
                    for (int y = 0; y < arrMessage.Length; y++)
                        if (arrMessage[y] == "203")
                        {
                            order.Text = arrMessage[++y];
                            break;
                        }

                    if (BadHackFilter(order))
                    {
                        System.Diagnostics.Debug.WriteLine("Order " + order.OrderID + " found,ACC=" + order.Text + ",CTR=" + order.ContractID);
                        myRoltor.IncomingRTDOrderEvent(order.OrderID, order);
                    }

                    break;

                default:
                    System.Diagnostics.Debug.WriteLine(strMessage);
                    break;
            }
        }
コード例 #7
0
        private bool BadHackFilter(OrderStruct order)
        {
            bool bIsGood = false;

            if (dicAccountTexts.ContainsValue(order.Text)
                && dicExchangeIDs.ContainsValue(order.ExchangeID)
                && myRoltor.dicContractMap.ContainsKey(order.ContractID))
            {
                bIsGood = true;
            }

            return bIsGood;
        }
コード例 #8
0
 public void PullOrder(OrderStruct order)
 {
     this.Invoke(new Roltor.BoolFunction(myRoltor.PullOrderOlt), new object[] { order });
 }
コード例 #9
0
    private void InitOrderStructs()
    {
        // itt osszerakjuk a parancsok listajat, és azt kapjak meg a jatekosok
        OrderStruct temp = new OrderStruct();

        //attack
        temp.name = "Attack";
        temp.used = false;
        temp.star = false;
        temp.modifyer = 0;
        temp.icon = orderIcons[0];

        mOrderList.Add(temp);
        //attack+
        temp = new OrderStruct();

        temp.name = "Attack+";
        temp.used = false;
        temp.star = true;
        temp.modifyer = 1;
        temp.icon = orderIcons[1];

        mOrderList.Add(temp);
        //attack-
        temp = new OrderStruct();

        temp.name = "Attack-";
        temp.used = false;
        temp.star = false;
        temp.modifyer = -1;
        temp.icon = orderIcons[2];

        mOrderList.Add(temp);
        //consolidate
        temp = new OrderStruct();

        temp.name = "Consolidate";
        temp.used = false;
        temp.star = false;
        temp.modifyer = 0;
        temp.icon = orderIcons[3];

        mOrderList.Add(temp);
        //consolidate
        temp = new OrderStruct();

        temp.name = "Consolidate";
        temp.used = false;
        temp.star = false;
        temp.modifyer = 0;
        temp.icon = orderIcons[3];

        mOrderList.Add(temp);
        //consolidate+
        temp = new OrderStruct();

        temp.name = "Consolidate+";
        temp.used = false;
        temp.star = true;
        temp.modifyer = 1;
        temp.icon = orderIcons[4];

        mOrderList.Add(temp);
        //defend+
        temp = new OrderStruct();

        temp.name = "Defend+";
        temp.used = false;
        temp.modifyer = +1;
        temp.icon = orderIcons[5];

        mOrderList.Add(temp);
        //defend+
        temp = new OrderStruct();

        temp.name = "Defend+";
        temp.used = false;
        temp.modifyer = +1;
        temp.icon = orderIcons[5];

        mOrderList.Add(temp);
        //defend++
        temp = new OrderStruct();

        temp.name = "Defend++";
        temp.used = false;
        temp.star = true;
        temp.modifyer = +2;
        temp.icon = orderIcons[6];

        mOrderList.Add(temp);
        //raid
        temp = new OrderStruct();

        temp.name = "Raid";
        temp.used = false;
        temp.star = false;
        temp.modifyer = 0;
        temp.icon = orderIcons[7];

        mOrderList.Add(temp);
        //raid
        temp = new OrderStruct();

        temp.name = "Raid";
        temp.used = false;
        temp.star = false;
        temp.modifyer = 0;
        temp.icon = orderIcons[7];

        mOrderList.Add(temp);
        //raid+
        temp = new OrderStruct();

        temp.name = "Raid+";
        temp.used = false;
        temp.star = true;
        temp.modifyer = 0;
        temp.icon = orderIcons[8];

        mOrderList.Add(temp);
        //support
        temp = new OrderStruct();

        temp.name = "Support";
        temp.used = false;
        temp.star = false;
        temp.modifyer = 0;
        temp.icon = orderIcons[9];

        mOrderList.Add(temp);
        //support
        temp = new OrderStruct();

        temp.name = "Support";
        temp.used = false;
        temp.star = false;
        temp.modifyer = 0;
        temp.icon = orderIcons[9];

        mOrderList.Add(temp);
        //support+
        temp = new OrderStruct();

        temp.name = "Support+";
        temp.used = false;
        temp.star = true;
        temp.modifyer = 0;
        temp.icon = orderIcons[10];

        mOrderList.Add(temp);
    }
コード例 #10
0
 public PlacedOrderStruct(string _name, regionStruct _region, OrderStruct _order)
 {
     this.ownerPlayerName = _name;
     this.region = _region;
     this.order = _order;
 }