Exemple #1
0
        /// <summary>
        /// Invokes the command.
        /// </summary>
        public override void Invoke()
        {
            OnInvoking();
            DiplomacyControl.EndNegotiations();
            DiplomacyControl.TaskLinks.Clear();

            DiplomaticTie tie = DiplomacyControl.DiplomaticTie;

            IDiplomacyTaskLinkFactory factory = DiplomacyControl.GetTaskLinkFactory();

            DiplomacyTask[] tasks = DiplomacyHelper.GetDiplomacyTasks(tie, null, null);

            DiplomacyCommand   taskCommand;
            string             taskText;
            IDiplomacyTaskLink taskLink;

            foreach (DiplomacyTask task in tasks)
            {
                taskCommand = DiplomacyHelper.GetTaskCommand(task, DiplomacyControl);
                taskText    = DiplomacyHelper.GetTaskString(task, tie);
                taskLink    = factory.CreateTaskLink(taskText, taskCommand);
                DiplomacyControl.TaskLinks.Add(taskLink);
            }

            DiplomacyControl.ForeignLeaderPhrase = AIDiplomacyPhraseHelper.GenerateBackOutResponse();
            OnInvoked();
        }
        /// <summary>
        /// Invokes the command.
        /// </summary>
        public override void Invoke()
        {
            DiplomaticTie tie = DiplomacyControl.DiplomaticTie;

            DiplomacyControl.StartNegotiations();
            DiplomacyControl.ForeignLeaderPhrase = AIDiplomacyPhraseHelper.GetProposalResponse(tie);
            DiplomacyControl.TaskLinks.Clear();
            //DiplomacyControl.GivenItems.CollectionChanged += new CollectionChangeEventHandler(HandleTradeProposalChange);
            //DiplomacyControl.TakenItems.CollectionChanged += new CollectionChangeEventHandler(HandleTradeProposalChange);

            IDiplomacyTaskLinkFactory factory = DiplomacyControl.GetTaskLinkFactory();

            DiplomacyTask[] tasks = DiplomacyHelper.GetTradingTasks(tie);

            DiplomacyCommand   taskCommand;
            string             taskText;
            IDiplomacyTaskLink taskLink;

            foreach (DiplomacyTask task in tasks)
            {
                taskCommand = DiplomacyHelper.GetTaskCommand(task, DiplomacyControl);
                taskText    = DiplomacyHelper.GetTaskString(task, tie);
                taskLink    = factory.CreateTaskLink(taskText, taskCommand);
                DiplomacyControl.TaskLinks.Add(taskLink);
            }
        }
        /// <summary>
        /// Invokes the command.
        /// </summary>
        public override void Invoke()
        {
            OnInvoking();
            ClientApplication    client = ClientApplication.Instance;
            IDiplomaticTiePicker picker = (IDiplomaticTiePicker)client.GetControl(typeof(IDiplomaticTiePicker));

            picker.ShowSimilizationControl();
            DiplomaticTie tie = picker.DiplomaticTie;

            if (tie == null)
            {
                return;
            }

            //get an instance of the diplomacy control
            DiplomacyControl = (IDiplomacyControl)client.GetControl(typeof(IDiplomacyControl));
            IDiplomacyTaskLinkFactory factory = DiplomacyControl.GetTaskLinkFactory();

            //initialize the properties of the control
            DiplomacyControl.DiplomaticTie = tie;

            DiplomacyControl.ForeignLeaderHeaderText = string.Format(
                CultureInfo.InvariantCulture,
                ClientResources.GetString(StringKey.DiplomacyCountryHeader),
                tie.ForeignCountry.Name,
                ClientApplication.GetAttitudeString(tie.Attitude));

            DiplomacyControl.ForeignLeaderPhrase   = AIDiplomacyPhraseHelper.GetForeignLeaderGreeting(tie);
            DiplomacyControl.AdvisorHelpRequested += new EventHandler(HandleAdvisorHelpRequested);
            _advice = DiplomacyAdvice.GetAdvice(tie);
            DiplomacyControl.AdvisorPhrase = _advice[_adviceIndex];

            //get the tasks
            DiplomacyTask[] tasks = DiplomacyHelper.GetDiplomacyTasks(tie, null, null);

            string             taskText;
            DiplomacyCommand   command;
            IDiplomacyTaskLink taskLink;

            //add the tasks to the diplomacy control.
            foreach (DiplomacyTask task in tasks)
            {
                taskText = DiplomacyHelper.GetTaskString(task, tie);
                command  = DiplomacyHelper.GetTaskCommand(task, DiplomacyControl);
                taskLink = factory.CreateTaskLink(taskText, command);
                DiplomacyControl.TaskLinks.Add(taskLink);
            }

            DiplomacyControl.ShowSimilizationControl();
            OnInvoked();
        }