コード例 #1
0
ファイル: VehicleLapData.cs プロジェクト: Alvys34/capstone
    void Awake()
    {
        LapsCompleted   = 0;
        currentLegID    = LegId.Zero;
        legDatas        = GameObject.FindObjectsOfType <LegTriggerBehavior>();
        lapManager      = GameObject.FindObjectOfType <LapManager>();
        vehicleBehavior = GetComponent <VehicleBehavior>();
        playerHUD       = GetComponent <VehicleBehavior>().playerHUD;

        foreach (LegTriggerBehavior l in legDatas)
        {
            switch (l.legID)
            {
            case LegId.One:
                leg1 = l.transform;
                continue;

            case LegId.Two:
                leg2 = l.transform;
                continue;

            case LegId.Three:
                leg3 = l.transform;
                continue;

            default:
                break;
            }
        }
        leg4 = lapManager.transform;

        allPlayers = GameObject.FindGameObjectsWithTag("GameController");
    }
コード例 #2
0
        public string GetOrderString()
        {
            var order            = new StringBuilder();
            var error            = new StringBuilder();
            var confirmMsg       = string.Empty;
            var orderDescription = string.Empty;

            if (TDANET.client == null || string.IsNullOrEmpty(TDANET.client.AssociatedAccountId))
            {
                error.AppendLine("Error: No logged accound ID found. Please check if logged in.");
                return(error.ToString());
            }

            string legIdStr = (LegId > 0) ? LegId.ToString() : string.Empty;

            order.AppendFormat("~symbol{0}={1}", legIdStr, Symbol);
            order.AppendFormat("~action{0}={1}", legIdStr, Action.ToString("g"));
            order.AppendFormat("~ordtype{0}={1}", legIdStr, OrderType.ToString("g"));
            order.AppendFormat("~quantity{0}={1}", legIdStr, Quantity.ToString());

            if (Quantity <= 0)
            {
                error.AppendLine("Order Error : Quantity must be greater than 0.");
            }

            switch (OrderType)
            {
            case EquityOrderTypes.market:

                #region Market

                if (Expire != EquityOrderExpires.day && Expire != EquityOrderExpires.moc)
                {
                    error.AppendLine("Market Order Error : Expire must be day or moc.");
                }

                Routing       = EquityOrderRoutings.auto;
                SpInstruction = EquityOrderSpecialInstructions.none;

                order.AppendFormat("~spinstructions{0}={1}", legIdStr, SpInstruction.ToString("g"));

                confirmMsg = string.Format("Please confirm your {0} {1} order.\r\n\r\nShares: {2:N0}", this.OrderType, this.Action, this.Quantity);

                break;

                #endregion

            case EquityOrderTypes.limit:

                #region Limit

                if (Price <= 0)
                {
                    error.AppendLine("Limit Order Error: Price must be a valid value.");
                }
                else
                {
                    order.AppendFormat("~price{0}={1}", legIdStr, Price);
                }
                if (Expire == EquityOrderExpires.day)
                {
                    if (SpInstruction != EquityOrderSpecialInstructions.none &&
                        SpInstruction != EquityOrderSpecialInstructions.aon &&
                        SpInstruction != EquityOrderSpecialInstructions.fok)
                    {
                        error.AppendLine("Limit Order Error: SpInstruction must be none, aon, fok.");
                    }
                }
                else if (Expire == EquityOrderExpires.day_ext &&
                         Expire == EquityOrderExpires.gtc_ext &&
                         Expire == EquityOrderExpires.am &&
                         Expire == EquityOrderExpires.pm)
                {
                    if (SpInstruction != EquityOrderSpecialInstructions.none)
                    {
                        error.AppendLine("Limit Order Error : SpInstruction must be none.");
                    }
                }
                else if (Expire == EquityOrderExpires.gtc)
                {
                    if (SpInstruction != EquityOrderSpecialInstructions.none &&
                        SpInstruction != EquityOrderSpecialInstructions.aon &&
                        SpInstruction != EquityOrderSpecialInstructions.dnr &&
                        SpInstruction != EquityOrderSpecialInstructions.aon_dnr)
                    {
                        error.AppendLine("Limit Order Error : SpInstruction must be none, aon, dnr, aon_dnr.");
                    }
                }
                else
                {
                    order.AppendFormat("~spinstructions{0}={1}", legIdStr, SpInstruction.ToString("g"));
                }


                if (this.Action == EquityOrderActions.buy)
                {
                    orderDescription = string.Format("The {0} order will be executed when the price <= {1}", this.Action.ToString().ToUpper(), this.Price);
                }
                else if (this.Action == EquityOrderActions.sell)
                {
                    orderDescription = string.Format("The {0} order will be executed when the price >= {1}", this.Action.ToString().ToUpper(), this.Price);
                }

                confirmMsg = string.Format("Please confirm your {0} {1} order.\r\n\r\nLimit: {2:$0.00##},  Shares: {3:N0}\r\n\r\nEstimated Total: {4:C2}\r\n\r\n{5}", this.OrderType, this.Action, this.Price, this.Quantity, this.Price * this.Quantity, orderDescription);

                break;

                #endregion

            case EquityOrderTypes.stop_limit:

                #region Stop Limit

                if (Price <= 0 || ActPrice <= 0)
                {
                    error.AppendLine("Stop Limit Order Error : Price or ActPrice must be a valid value.");
                }
                else
                {
                    order.AppendFormat("~price{0}={1}", legIdStr, Price);
                    order.AppendFormat("~actprice{0}={1}", legIdStr, ActPrice);
                }

                if (Expire != EquityOrderExpires.day && Expire != EquityOrderExpires.gtc)
                {
                    error.AppendLine("Stop Limit Order Error : Expire must be day or gtc.");
                }
                else if (Expire != EquityOrderExpires.day && SpInstruction != EquityOrderSpecialInstructions.none)
                {
                    error.AppendLine("Stop Limit Order Error : SpInstruction must be none.");
                }
                else
                {
                    order.AppendFormat("~spinstructions{0}={1}", legIdStr, SpInstruction.ToString("g"));
                }


                if (this.Action == EquityOrderActions.buy)
                {
                    orderDescription = string.Format("The {0} order will be executed when the stop price >= {2} and then the limt price <= {1}", this.Action.ToString().ToUpper(), this.Price, this.ActPrice);
                }
                else if (this.Action == EquityOrderActions.sell)
                {
                    orderDescription = string.Format("The {0} order will be executed when the stop price <= {2} and then the limit price >= {1}", this.Action.ToString().ToUpper(), this.Price, this.ActPrice);
                }

                confirmMsg = string.Format("Please confirm your {0} {1} order.\r\n\r\nLimit: {2:$0.00##}, Stop: {3:$0.00##},  Shares: {4:N0}\r\n\r\nEstimated Total: {5:C2}\r\n\r\n{6}", this.OrderType, this.Action, this.Price, this.ActPrice, this.Quantity, this.Price * this.Quantity, orderDescription);

                break;

                #endregion

            case EquityOrderTypes.stop_market:

                #region Stop Market

                if (ActPrice <= 0)
                {
                    error.AppendLine("Stop Market Order Error : ActPrice must be a valid value.");
                }
                else
                {
                    order.AppendFormat("~actprice{0}={1}", legIdStr, ActPrice);
                }

                if (Expire != EquityOrderExpires.day && Expire != EquityOrderExpires.gtc)
                {
                    error.AppendLine("Stop Market Order Error : Expire must be day or gtc.");
                }


                if (this.Action == EquityOrderActions.buy)
                {
                    orderDescription = string.Format("The {0} order will be executed when the market price >= {1}", this.Action.ToString().ToUpper(), this.ActPrice);
                }
                else if (this.Action == EquityOrderActions.sell)
                {
                    orderDescription = string.Format("The {0} order will be executed when the market price <= {1}", this.Action.ToString().ToUpper(), this.ActPrice);
                }

                confirmMsg = string.Format("Please confirm your {0} {1} order.\r\n\r\nStop: {2:$0.00##},  Shares: {3:N0}\r\n\r\nEstimated Total: {4:C2}\r\n\r\n{5}", this.OrderType, this.Action, this.ActPrice, this.Quantity, this.ActPrice * this.Quantity, orderDescription);

                break;

                #endregion

            case EquityOrderTypes.tstoppercent:

                #region TsTopPercent

                if (TsParam < 1 || TsParam > 99)
                {
                    error.AppendLine("TsTopPercent Order Error : TsParam must be a whole number 1 and 99: 5 means 5 percent (%).");
                }
                else
                {
                    order.AppendFormat("~tsparam{0}={1}", legIdStr, TsParam);
                }

                if (Expire != EquityOrderExpires.day && Expire != EquityOrderExpires.gtc)
                {
                    error.AppendLine("TsTopPercent Order Error : Expire must be day or gtc.");
                }

                confirmMsg = string.Format("Please confirm your {0} {1} order.\r\n\r\nTsTopPercent: {2:P2}", this.OrderType, this.Action, Convert.ToDouble(this.ActPrice) / 100.0d);

                break;

                #endregion

            case EquityOrderTypes.tstopdollar:

                #region TsTopDollar

                if (TsParam <= 0)
                {
                    error.AppendLine("TsTopPercent Order Error : TsParam must be greater than 0 and a decimal value (#.##).");
                }
                else
                {
                    order.AppendFormat("~tsparam{0}={1}", legIdStr, TsParam);
                }

                if (Expire != EquityOrderExpires.day && Expire != EquityOrderExpires.gtc)
                {
                    error.AppendLine("TsTopPercent Order Error : Expire must be day or gtc.");
                }

                confirmMsg = string.Format("Please confirm your {0} {1} order.\r\n\r\nTsTopDollar: {2:$0.00##}", this.OrderType, this.Action, this.ActPrice);

                break;

                #endregion

            default:
                error.AppendLine("Invalid Order Type.");
                break;
            }
            order.AppendFormat("~expire{0}={1}", legIdStr, Expire.ToString("g"));

            if (ConditionalyOrderType == ConditionalOrderTypes.single)
            {
                order.AppendFormat("~routing{0}={1}", legIdStr, Routing.ToString("g") + "~");
            }

            string errorString = error.ToString();
            if (string.IsNullOrEmpty(errorString))
            {
                this.ConfirmMessage = confirmMsg;
                string orderString = order.ToString();
                return(orderString.Replace("~~", "~"));
            }
            else
            {
                Error = errorString;
                return(errorString);
            }
        }
コード例 #3
0
    void Awake()
    {
        saveGameManager = GameObject.FindGameObjectWithTag("SaveGameManager").GetComponent <SaveGameManager>();

        LapsCompleted   = 0;
        currentLegID    = LegId.Zero;
        legDatas        = GameObject.FindObjectsOfType <LegTriggerBehavior>();
        lapManager      = GameObject.FindObjectOfType <LapManager>();
        lapTransform    = lapManager.transform;
        vehicleBehavior = GetComponent <VehicleBehavior>();
        playerHUD       = GetComponent <VehicleBehavior>().playerHUD;

        foreach (LegTriggerBehavior l in legDatas)
        {
            switch (l.legID)
            {
            case LegId.One:
                leg1 = l.transform;
                continue;

            case LegId.Two:
                leg2 = l.transform;
                continue;

            case LegId.Three:
                leg3 = l.transform;
                continue;

            case LegId.Four:
                leg4 = l.transform;
                continue;

            case LegId.Five:
                leg5 = l.transform;
                continue;

            case LegId.Six:
                leg6 = l.transform;
                continue;

            case LegId.Seven:
                leg7 = l.transform;
                continue;

            case LegId.Eight:
                leg8 = l.transform;
                continue;

            case LegId.Nine:
                leg9 = l.transform;
                continue;

            case LegId.Ten:
                leg10 = l.transform;
                continue;

            case LegId.Eleven:
                leg11 = l.transform;
                continue;

            case LegId.Twelve:
                leg12 = l.transform;
                continue;

            case LegId.Thirteen:
                leg13 = l.transform;
                continue;

            default:
                break;
            }
        }
        leg4 = lapManager.transform;

        allPlayers = GameObject.FindGameObjectsWithTag("GameController");
    }