Beispiel #1
0
        public static DialogResult ShowDialog(Exception ex, ICloseable parent)
        {
            ErrorWindow win = new ErrorWindow(ex, parent);

            return(win.ShowDialog());
        }
Beispiel #2
0
 public static DialogResult ShowDialog(Exception ex, ICloseable parent)
 {
     ErrorWindow win = new ErrorWindow(ex, parent);
     return win.ShowDialog();
 }
Beispiel #3
0
        private void TimeTick(int time)
        {
            _time = time;
            if (!_readyToSendItems)
            {
                return;
            }
            try
            {
                //check timeline for a new item to process
                List <T_Item>        items          = new List <T_Item>();
                List <ScheduledItem> itemsToProcess = null;// new List<ScheduledItem>();
                itemsToProcess = _timelineEvents.GetItemsUpTo(time);
                // itemsToProcess[4].DM_ID = "!!";
                if (itemsToProcess == null)
                {
                    return;
                }
                //Thread.Sleep(2000);
                foreach (ScheduledItem i in itemsToProcess)
                {
                    T_Item myItem = null;
                    //i.DM_ID;
                    if (_items.ContainsKey(i.ID))
                    {
                        myItem = _items[i.ID];
                    }
                    else if (_ptItems.ContainsKey(i.ID))
                    {
                        myItem = _ptItems[i.ID];
                    }
                    else
                    {
                        continue;
                    }

                    _ddd.SendItemInfo(i.DM_ID, i.ID, myItem.Parameters.FF_Difficulty, myItem.Parameters.TT_Difficulty, time);
                    String infoText = String.Format("Processing item id={0}; For DM={1}; Current Time={2}\r\n", i.ID, i.DM_ID, i.Time);
                    //AD: TODO: Need to add in specific strings that describe the actions taking place in the item
                    items.Add(myItem.DeepCopy());
                    T_Item        item = myItem.DeepCopy();
                    StringBuilder sb   = new StringBuilder();
                    if (item.Parameters.Crossing)
                    {
                        sb.AppendFormat("Crossing;");
                    }
                    else
                    {
                        sb.AppendFormat("Non-Crossing;");
                    }
                    if (item.Parameters.Groupings == T_Groupings.Two)
                    {
                        sb.AppendFormat("Two-Grouping;");
                    }
                    else
                    {
                        sb.AppendFormat("One-Grouping;");
                    }
                    if (item.Parameters.PlayerResources == T_ResourceAvailability.Available)
                    {
                        sb.AppendFormat("PlayerHasResources;");
                    }
                    else
                    {
                        sb.AppendFormat("PlayerHas_NO_Resources;");
                    }
                    if (item.Parameters.TeammateResources == T_ResourceAvailability.Available)
                    {
                        sb.AppendFormat("TeammateHasResources;");
                    }
                    else
                    {
                        sb.AppendFormat("TeammateHas_NO_Resources;");
                    }
                    // if (item.Parameters.ThreatTypeSpecified)
                    // {
                    if (item.Parameters.ThreatType == T_ThreatType.Imminent)
                    {
                        sb.AppendFormat("Imminent;");
                    }
                    else
                    {
                        sb.AppendFormat("Non-imminent;");
                    }
                    //}
                    if (item.Parameters.Threat == T_Threat.Ambiguous)
                    {
                        sb.AppendFormat("AmbiguousThreat;");
                    }
                    else if (item.Parameters.Threat == T_Threat.Unambiguous)
                    {
                        sb.AppendFormat("UnambiguousThreat;");
                    }
                    else
                    {
                        sb.AppendFormat("Non-Threat;");
                    }

                    infoText = String.Format("{0}\t{1}\r\n", infoText, sb.ToString());
                    if (item.Action.Count() == 0)
                    {
                        PirateGenerator pirateGenerator = new PirateGenerator(_ddd);
                        pirateGenerator.Generate(item, i.DM_ID);

                        MerchantGenerator merchantGenerator = new MerchantGenerator(_ddd);
                        merchantGenerator.Generate(item, i.DM_ID);

                        CourseGenerator courseGenerator = new CourseGenerator(_ddd);
                        courseGenerator.Generate(item, i.DM_ID);

                        InterceptGenerator interceptGenerator = new InterceptGenerator(_ddd);
                        interceptGenerator.Generate(item, i.DM_ID);
                    }


                    foreach (ActionBase action in item.Action)
                    {
                        if (action != null && !(action is T_ScriptedItem))
                        {
                            _ddd.AddDDDEventToQueue(action.ToDDDEvent(time, _ddd));
                        }

                        //ADAMS STUB: Might not work 100%, Lisa please fix if it won't work.
                        String stimType = "";
                        String objectID = "";
                        if (action is T_Reveal)
                        {
                            stimType = "Reveal";
                            objectID = ((T_Reveal)action).ID;
                            if (((T_Reveal)action).Location.Item is Aptima.Asim.DDD.CommonComponents.DataTypeTools.LocationValue)
                            {
                                if (((Aptima.Asim.DDD.CommonComponents.DataTypeTools.LocationValue)((T_Reveal)action).Location.Item).exists == false)
                                {
                                    Console.WriteLine("Uh oh, null location");
                                }
                            }
                            String IFF = "";
                            if (((T_Reveal)action).StartupParameters.Items.Length > 0)
                            {
                                for (int c = 0; c < ((T_Reveal)action).StartupParameters.Items.Length; c++)
                                {
                                    if (((T_Reveal)action).StartupParameters.Items[c] == "ObjectName")
                                    {
                                        IFF = "Squawking=" + ((T_Reveal)action).StartupParameters.Items[c + 1];
                                    }
                                    c++;     //get past the "value" item, which is the even numbered entry
                                }
                            }
                            infoText = String.Format("{0}\tREVEAL; object_id={1}; Owned_by={2}; Revealed_at={3}\r\n", infoText, objectID, ((T_Reveal)action).Owner, ((T_Reveal)action).Location.ToString());
                        }
                        else if (action is T_Move)
                        {
                            stimType = "Move";
                            objectID = ((T_Move)action).ID;
                            infoText = String.Format("{0}\tMOVE; object_id={1}; Throttle={2:0.00}; Destination={3}\r\n", infoText, objectID, ((T_Move)action).Throttle, ((T_Move)action).Location.ToString());
                        }
                        else if (action is T_ScriptedItem)
                        {
                            //TODO: check to see that the object is not dead -Lisa
                            objectID = ((T_ScriptedItem)action).ID;
                            stimType = ((T_ScriptedItem)action).ActionType;
                        }

                        if (stimType != "")
                        {
                            _ddd.SendStimulusEvent(i.ID, i.DM_ID, objectID, stimType, time, item.Parameters.FF_Difficulty, item.Parameters.TT_Difficulty);
                        }
                    }
                    AppendToInfoBox(tbInfoBox, infoText);
                    _readyToSendItems = false;    //re-set for next time;
                }
            }
            catch (Exception ex)
            {
                ErrorWindow.ShowDialog(ex, this);
            }
        }