private bool CutRouteway(Point p)
        {
            if (this.EditingRouteway.CutAt(p))
            {
                return(true);
            }
            ArchitectureList routewayArchitecturesByPosition = this.screen.Scenario.GetRoutewayArchitecturesByPosition(this.EditingRouteway, this.EditingRouteway.LastPoint.Position);

            if (routewayArchitecturesByPosition.Count > 0)
            {
                if (routewayArchitecturesByPosition.Count > 1)
                {
                    routewayArchitecturesByPosition.PropertyName = "Food";
                    routewayArchitecturesByPosition.IsNumber     = true;
                    routewayArchitecturesByPosition.SmallToBig   = true;
                    routewayArchitecturesByPosition.ReSort();
                }
                Architecture architecture = routewayArchitecturesByPosition[0] as Architecture;
                if (architecture != this.EditingRouteway.EndArchitecture)
                {
                    this.EditingRouteway.EndArchitecture = architecture;
                }
            }
            else if (!((this.EditingRouteway.EndArchitecture == null) || this.EditingRouteway.HasPointInArchitectureRoutewayStartArea(this.EditingRouteway.EndArchitecture)))
            {
                this.EditingRouteway.EndArchitecture = null;
            }
            this.RefreshDirectionSwitchState();
            return(false);
        }
 public void Initialize(MainMapLayer mainMapLayer, GameScenario scenario, MainGameScreen mainGameScreen)
 {
     this.mainMapLayer  = mainMapLayer;
     this.Architectures = scenario.Architectures;
     this.gameScenario  = scenario;
     //this.huangditupian = huangditupian;
 }
Exemple #3
0
 public void Initialize(MainMapLayer mainMapLayer, GameScenario scenario, MainGameScreen mainGameScreen)
 {
     this.screen        = mainGameScreen;
     this.mainMapLayer  = mainMapLayer;
     this.Architectures = scenario.Architectures;
     this.gameScenario  = scenario;
 }
    // Start is called before the first frame update
    void Start()
    {
        ArchitectureList architectures = ArchitectureList.ReadFromJson("architectures.json");

        var simulation = GetComponent <Simulation>();

        simulation.SetRules(architectures.architectures[0].rules);
        simulation.StartSimulation();
    }
        public void FilterCollection(string filteringSubstring)
        {
            filteringSubstring = filteringSubstring.Trim().ToLower();

            if (string.IsNullOrEmpty(filteringSubstring))
            {
                FilteredArchitecturesList.Clear();
                return;
            }

            FilteredArchitecturesList = ArchitectureList.Where(x =>
                                                               x.Address.ToLower().Contains(filteringSubstring) || x.Title.ToLower().Contains(filteringSubstring)).ToList();
        }
        public async Task DeleteArchitecture(object architecture)
        {
            var arch = architecture as ArchitectureModel;

            if (arch == null)
            {
                return;
            }

            await _architecturesManager.RemoveArchitecture(arch.Id);

            ArchitectureList.Remove(arch);
        }
        private void EditArchitectures()
        {
            ArchitectureList list = new ArchitectureList();

            for (int i = 0; i < this.dgvArchitectures.SelectedRows.Count; i++)
            {
                list.Add(this.Architectures[this.dgvArchitectures.SelectedRows[i].Index]);
            }
            frmEditArchitecture architecture = new frmEditArchitecture();

            architecture.MainForm      = this.MainForm;
            architecture.Architectures = list;
            architecture.ShowDialog();
            this.dgvArchitectures.Invalidate();
        }
 private void screen_OnMouseMove(Point position, bool leftDown)
 {
     this.commentDrawing = false;
     if (StaticMethods.PointInRectangle(position, this.BackgroundDisplayPosition))
     {
         this.screen.DefaultMouseArrowTexture = this.DefaultMouseArrowTexture;
         if (StaticMethods.PointInRectangle(position, this.ExtendButtonDisplayPosition))
         {
             if (this.ExtendButtonState == ButtonState.Normal)
             {
                 this.ExtendButtonState = ButtonState.Selected;
             }
             if (this.CutButtonState == ButtonState.Selected)
             {
                 this.CutButtonState = ButtonState.Normal;
             }
             if (this.DirectionSwitchState == ButtonState.Selected)
             {
                 this.DirectionSwitchState = ButtonState.Normal;
             }
             if (this.EndButtonState == ButtonState.Selected)
             {
                 this.EndButtonState = ButtonState.Normal;
             }
             this.commentDrawing = true;
             this.Comment.Clear();
             this.Comment.AddText("延伸粮道", Color.Yellow);
             this.Comment.AddNewLine();
             this.Comment.AddText("请根据实际情况设计粮道的路径。");
             this.Comment.AddNewLine();
             this.Comment.AddText("提示", Color.Lime);
             this.Comment.AddText(":您可以在延伸点按下鼠标之后进行拖拽。");
             this.Comment.ResortTexts();
             this.Comment.DisplayOffset = new Point(this.ExtendButtonDisplayPosition.Right, this.ExtendButtonDisplayPosition.Top);
         }
         else if (StaticMethods.PointInRectangle(position, this.CutButtonDisplayPosition))
         {
             if (this.ExtendButtonState == ButtonState.Selected)
             {
                 this.ExtendButtonState = ButtonState.Normal;
             }
             if (this.CutButtonState == ButtonState.Normal)
             {
                 this.CutButtonState = ButtonState.Selected;
             }
             if (this.DirectionSwitchState == ButtonState.Selected)
             {
                 this.DirectionSwitchState = ButtonState.Normal;
             }
             if (this.EndButtonState == ButtonState.Selected)
             {
                 this.EndButtonState = ButtonState.Normal;
             }
             this.commentDrawing = true;
             this.Comment.Clear();
             this.Comment.AddText("截断粮道", Color.Yellow);
             this.Comment.AddNewLine();
             this.Comment.AddText("用以删除某一点之后的粮道。");
             this.Comment.AddNewLine();
             this.Comment.AddText("提示", Color.Lime);
             this.Comment.AddText(":如果选择粮道的起点则删除整条粮道。请小心操作。");
             this.Comment.ResortTexts();
             this.Comment.DisplayOffset = new Point(this.CutButtonDisplayPosition.Right, this.CutButtonDisplayPosition.Top);
         }
         else if (StaticMethods.PointInRectangle(position, this.DirectionSwitchDisplayPosition))
         {
             if (this.ExtendButtonState == ButtonState.Selected)
             {
                 this.ExtendButtonState = ButtonState.Normal;
             }
             if (this.CutButtonState == ButtonState.Selected)
             {
                 this.CutButtonState = ButtonState.Normal;
             }
             if (this.DirectionSwitchState == ButtonState.Normal)
             {
                 this.DirectionSwitchState = ButtonState.Selected;
             }
             if (this.EndButtonState == ButtonState.Selected)
             {
                 this.EndButtonState = ButtonState.Normal;
             }
             this.commentDrawing = true;
             this.Comment.Clear();
             this.Comment.AddText("转换方向", Color.Yellow);
             this.Comment.AddNewLine();
             this.Comment.AddText("用以转换粮道的运输方向。");
             this.Comment.AddNewLine();
             this.Comment.AddText("提示", Color.Lime);
             this.Comment.AddText(":仅在粮道两端都为我方建筑时有效。未完全疏通的粮道将被关闭。");
             this.Comment.ResortTexts();
             this.Comment.DisplayOffset = new Point(this.DirectionSwitchDisplayPosition.Right, this.DirectionSwitchDisplayPosition.Top);
         }
         else if (StaticMethods.PointInRectangle(position, this.BuildButtonDisplayPosition))
         {
             if (this.ExtendButtonState == ButtonState.Selected)
             {
                 this.ExtendButtonState = ButtonState.Normal;
             }
             if (this.CutButtonState == ButtonState.Selected)
             {
                 this.CutButtonState = ButtonState.Normal;
             }
             if (this.DirectionSwitchState == ButtonState.Selected)
             {
                 this.DirectionSwitchState = ButtonState.Normal;
             }
             if (this.BuildButtonState == ButtonState.Normal)
             {
                 if (leftDown)
                 {
                     this.BuildButtonState = ButtonState.Down;
                 }
                 else
                 {
                     this.BuildButtonState = ButtonState.Selected;
                 }
             }
             if (this.EndButtonState == ButtonState.Selected)
             {
                 this.EndButtonState = ButtonState.Normal;
             }
             this.commentDrawing = true;
             this.Comment.Clear();
             this.Comment.AddText("疏通粮道", Color.Yellow);
             this.Comment.AddNewLine();
             this.Comment.AddText("结束粮道的编辑工作并且开始疏通粮道。");
             this.Comment.AddNewLine();
             this.Comment.ResortTexts();
             this.Comment.DisplayOffset = new Point(this.BuildButtonDisplayPosition.Right, this.BuildButtonDisplayPosition.Top);
         }
         else if (StaticMethods.PointInRectangle(position, this.EndButtonDisplayPosition))
         {
             if (this.ExtendButtonState == ButtonState.Selected)
             {
                 this.ExtendButtonState = ButtonState.Normal;
             }
             if (this.CutButtonState == ButtonState.Selected)
             {
                 this.CutButtonState = ButtonState.Normal;
             }
             if (this.DirectionSwitchState == ButtonState.Selected)
             {
                 this.DirectionSwitchState = ButtonState.Normal;
             }
             if (this.BuildButtonState == ButtonState.Selected)
             {
                 this.BuildButtonState = ButtonState.Normal;
             }
             if (this.EndButtonState == ButtonState.Normal)
             {
                 if (leftDown)
                 {
                     this.EndButtonState = ButtonState.Down;
                 }
                 else
                 {
                     this.EndButtonState = ButtonState.Selected;
                 }
             }
             this.commentDrawing = true;
             this.Comment.Clear();
             this.Comment.AddText("结束编辑", Color.Yellow);
             this.Comment.AddNewLine();
             this.Comment.AddText("结束粮道的编辑工作。");
             this.Comment.AddNewLine();
             this.Comment.ResortTexts();
             this.Comment.DisplayOffset = new Point(this.EndButtonDisplayPosition.Right, this.EndButtonDisplayPosition.Top);
         }
         else
         {
             if (this.ExtendButtonState == ButtonState.Selected)
             {
                 this.ExtendButtonState = ButtonState.Normal;
             }
             if (this.CutButtonState == ButtonState.Selected)
             {
                 this.CutButtonState = ButtonState.Normal;
             }
             if (this.DirectionSwitchState == ButtonState.Selected)
             {
                 this.DirectionSwitchState = ButtonState.Normal;
             }
             if ((this.EndButtonState == ButtonState.Selected) || (this.EndButtonState == ButtonState.Down))
             {
                 this.EndButtonState = ButtonState.Normal;
             }
             this.draging = leftDown && !this.extending;
         }
     }
     else
     {
         if (this.ExtendButtonState == ButtonState.Selected)
         {
             this.ExtendButtonState = ButtonState.Normal;
         }
         if (this.CutButtonState == ButtonState.Selected)
         {
             this.CutButtonState = ButtonState.Normal;
         }
         if (this.DirectionSwitchState == ButtonState.Selected)
         {
             this.DirectionSwitchState = ButtonState.Normal;
         }
         if ((this.BuildButtonState == ButtonState.Selected) || (this.BuildButtonState == ButtonState.Down))
         {
             this.BuildButtonState = ButtonState.Normal;
         }
         if ((this.EndButtonState == ButtonState.Selected) || (this.EndButtonState == ButtonState.Down))
         {
             this.EndButtonState = ButtonState.Normal;
         }
         Point positionByPoint = this.screen.GetPositionByPoint(position);
         if (this.ExtendButtonState == ButtonState.Down)
         {
             if (this.EditingRouteway.CurrentExtendArea.HasPoint(positionByPoint))
             {
                 this.CurrentPositionArchitectures = this.screen.Scenario.GetRoutewayArchitecturesByPosition(this.EditingRouteway, positionByPoint);
                 if (this.extending)
                 {
                     this.ExtendRouteway(positionByPoint);
                 }
                 else if (this.CurrentPositionArchitectures.Count > 0)
                 {
                     if (this.CurrentPositionArchitectures.Count > 1)
                     {
                         this.CurrentPositionArchitectures.PropertyName = "Food";
                         this.CurrentPositionArchitectures.IsNumber     = true;
                         this.CurrentPositionArchitectures.ReSort();
                     }
                     this.commentDrawing = true;
                     this.Comment.Clear();
                     this.Comment.AddText("连接到", Color.Yellow);
                     this.Comment.AddText(this.CurrentPositionArchitectures[0].Name, Color.Lime);
                     this.Comment.ResortTexts();
                     this.Comment.DisplayOffset = new Point(this.screen.GetDestination(positionByPoint).Right, this.screen.GetDestination(positionByPoint).Top);
                 }
                 this.screen.DefaultMouseArrowTexture = this.ExtendMouseArrowTexture;
             }
             else
             {
                 if ((this.extending && (this.EditingRouteway.RoutePoints.Last.Previous != null)) && (positionByPoint == this.EditingRouteway.RoutePoints.Last.Previous.Value.Position))
                 {
                     this.CutRouteway(this.EditingRouteway.LastPoint.Position);
                 }
                 this.screen.DefaultMouseArrowTexture = this.ExtendDisabledMouseArrowTexture;
             }
         }
         else if (this.CutButtonState == ButtonState.Down)
         {
             if (this.EditingRouteway.ContainsPoint(positionByPoint))
             {
                 this.screen.DefaultMouseArrowTexture = this.CutMouseArrowTexture;
             }
             else
             {
                 this.screen.DefaultMouseArrowTexture = this.CutDisabledMouseArrowTexture;
             }
         }
         if (!this.draging && !this.extending)
         {
             RoutePoint point = this.EditingRouteway.GetPoint(positionByPoint);
             if (point != null)
             {
                 this.commentDrawing = true;
                 this.Comment.Clear();
                 this.Comment.AddText("当前坐标粮道信息", Color.Yellow);
                 this.Comment.AddNewLine();
                 this.Comment.AddText("消耗率:");
                 this.Comment.AddText(StaticMethods.GetPercentString(point.ConsumptionRate, 1), Color.Red);
                 this.Comment.AddNewLine();
                 this.Comment.AddText("开通费用:");
                 this.Comment.AddText(point.BuildFundCost.ToString());
                 this.Comment.AddNewLine();
                 this.Comment.AddText("维持费用:");
                 this.Comment.AddText(point.ActiveFundCost.ToString());
                 this.Comment.AddNewLine();
                 this.Comment.ResortTexts();
                 this.Comment.DisplayOffset = new Point(this.screen.GetDestination(positionByPoint).Right, this.screen.GetDestination(positionByPoint).Top);
             }
         }
     }
     if (this.draging)
     {
         this.Drag();
     }
 }
Exemple #9
0
        private void ShowOrientationFrame()
        {
            GameDelegates.VoidFunction function  = null;
            GameDelegates.VoidFunction function2 = null;
            GameDelegates.VoidFunction function3 = null;
            switch (this.EditingSection.AIDetail.OrientationKind)
            {
            case SectionOrientationKind.军区:
                this.TabListPlugin.InitialValues(this.EditingFaction.GetOtherSections(this.OriginalSection), null, this.screen.MouseState.ScrollWheelValue, "");
                this.TabListPlugin.SetListKindByName("Section", true, false);
                this.TabListPlugin.SetSelectedTab("");
                this.GameFramePlugin.Kind     = FrameKind.TerrainDetail;
                this.GameFramePlugin.Function = FrameFunction.Transport;
                this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, this.screen.viewportSize);
                this.GameFramePlugin.OKButtonEnabled     = false;
                this.GameFramePlugin.CancelButtonEnabled = true;
                if (function == null)
                {
                    function = delegate {
                        this.EditingSection.OrientationFaction      = null;
                        this.EditingSection.OrientationState        = null;
                        this.EditingSection.OrientationArchitecture = null;
                        this.EditingSection.OrientationSection      = this.TabListPlugin.SelectedItem as Section;
                        this.RefreshOKButton();
                        this.RefreshLabelTextsDisplay();
                    };
                }
                this.GameFramePlugin.SetOKFunction(function);
                break;

            case SectionOrientationKind.势力:
                this.TabListPlugin.InitialValues(this.EditingFaction.Scenario.DiplomaticRelations.GetDiplomaticRelationDisplayListByFactionID(this.EditingFaction.ID).GetList(), null, this.screen.MouseState.ScrollWheelValue, "");
                this.TabListPlugin.SetListKindByName("DiplomaticRelation", true, false);
                this.TabListPlugin.SetSelectedTab("");
                this.GameFramePlugin.Kind     = FrameKind.CastTargetKind;
                this.GameFramePlugin.Function = FrameFunction.GetSectionToDemolish;
                this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, this.screen.viewportSize);
                this.GameFramePlugin.OKButtonEnabled     = false;
                this.GameFramePlugin.CancelButtonEnabled = true;
                if (function2 == null)
                {
                    function2 = delegate {
                        this.EditingSection.OrientationSection      = null;
                        this.EditingSection.OrientationState        = null;
                        this.EditingSection.OrientationArchitecture = null;
                        DiplomaticRelationDisplay selectedItem = this.TabListPlugin.SelectedItem as DiplomaticRelationDisplay;
                        if (selectedItem.LinkedFaction1 == this.EditingFaction)
                        {
                            this.EditingSection.OrientationFaction = selectedItem.LinkedFaction2;
                        }
                        else if (selectedItem.LinkedFaction2 == this.EditingFaction)
                        {
                            this.EditingSection.OrientationFaction = selectedItem.LinkedFaction1;
                        }
                        this.RefreshOKButton();
                        this.RefreshLabelTextsDisplay();
                    };
                }
                this.GameFramePlugin.SetOKFunction(function2);
                break;

            case SectionOrientationKind.州域:
                this.TabListPlugin.InitialValues(this.EditingFaction.Scenario.States.GetList(), null, this.screen.MouseState.ScrollWheelValue, "");
                this.TabListPlugin.SetListKindByName("State", true, false);
                this.TabListPlugin.SetSelectedTab("");
                this.GameFramePlugin.Kind     = FrameKind.SectionAIDetail;
                this.GameFramePlugin.Function = FrameFunction.GetFaction;
                this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, this.screen.viewportSize);
                this.GameFramePlugin.OKButtonEnabled     = false;
                this.GameFramePlugin.CancelButtonEnabled = true;
                if (function3 == null)
                {
                    function3 = delegate {
                        this.EditingSection.OrientationFaction      = null;
                        this.EditingSection.OrientationSection      = null;
                        this.EditingSection.OrientationState        = this.TabListPlugin.SelectedItem as State;
                        this.EditingSection.OrientationArchitecture = null;
                        this.RefreshOKButton();
                        this.RefreshLabelTextsDisplay();
                    };
                }
                this.GameFramePlugin.SetOKFunction(function3);
                break;

            case SectionOrientationKind.建筑:
                ArchitectureList allArch    = this.EditingFaction.Scenario.Architectures;
                ArchitectureList targetArch = new ArchitectureList();
                foreach (Architecture a in allArch)
                {
                    if (a.BelongedFaction != this.EditingFaction)
                    {
                        targetArch.Add(a);
                    }
                }
                this.TabListPlugin.InitialValues(targetArch, null, this.screen.MouseState.ScrollWheelValue, "");
                this.TabListPlugin.SetListKindByName("Architecture", true, false);
                this.TabListPlugin.SetSelectedTab("");
                this.GameFramePlugin.Kind     = FrameKind.Architecture;
                this.GameFramePlugin.Function = FrameFunction.GetFaction;
                this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, this.screen.viewportSize);
                this.GameFramePlugin.OKButtonEnabled     = false;
                this.GameFramePlugin.CancelButtonEnabled = true;
                if (function3 == null)
                {
                    function3 = delegate
                    {
                        this.EditingSection.OrientationFaction      = null;
                        this.EditingSection.OrientationSection      = null;
                        this.EditingSection.OrientationState        = null;
                        this.EditingSection.OrientationArchitecture = this.TabListPlugin.SelectedItem as Architecture;
                        this.RefreshOKButton();
                        this.RefreshLabelTextsDisplay();
                    };
                }
                this.GameFramePlugin.SetOKFunction(function3);
                break;
            }
            this.GameFramePlugin.IsShowing = true;
        }
Exemple #10
0
        private void ShowAIDetailFrame()
        {
            this.TabListPlugin.InitialValues(this.EditingFaction.Scenario.GameCommonData.AllSectionAIDetails.GetSectionAIDetailList(), this.EditingSection.AIDetail, this.screen.MouseState.ScrollWheelValue, "");
            this.TabListPlugin.SetListKindByName("SectionAIDetail", true, false);
            this.TabListPlugin.SetSelectedTab("");
            this.GameFramePlugin.Kind     = FrameKind.Section;
            this.GameFramePlugin.Function = FrameFunction.GetSection;
            this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, this.screen.viewportSize);
            this.GameFramePlugin.OKButtonEnabled     = false;
            this.GameFramePlugin.CancelButtonEnabled = true;
            this.GameFramePlugin.SetOKFunction(delegate {
                this.EditingSection.AIDetail = this.TabListPlugin.SelectedItem as SectionAIDetail;
                switch (this.EditingSection.AIDetail.OrientationKind)
                {
                case SectionOrientationKind.军区:
                    {
                        SectionList otherSections = this.EditingFaction.GetOtherSections(this.OriginalSection);
                        if (otherSections.Count == 1)
                        {
                            this.EditingSection.OrientationSection = otherSections[0] as Section;
                        }
                        break;
                    }

                case SectionOrientationKind.势力:
                    {
                        GameObjectList diplomaticRelationListByFactionID = this.EditingFaction.Scenario.DiplomaticRelations.GetDiplomaticRelationListByFactionID(this.EditingFaction.ID);
                        if (diplomaticRelationListByFactionID.Count == 1)
                        {
                            this.EditingSection.OrientationFaction = (diplomaticRelationListByFactionID[0] as DiplomaticRelation).GetDiplomaticFaction(this.EditingFaction.ID);
                        }
                        break;
                    }

                case SectionOrientationKind.州域:
                    {
                        StateList states = this.EditingFaction.Scenario.States;
                        if (states.Count == 1)
                        {
                            this.EditingSection.OrientationState = states[0] as State;
                        }
                        break;
                    }

                case SectionOrientationKind.建筑:
                    {
                        ArchitectureList allArch    = this.EditingFaction.Scenario.Architectures;
                        ArchitectureList targetArch = new ArchitectureList();
                        foreach (Architecture a in allArch)
                        {
                            if (a.BelongedFaction != this.EditingFaction)
                            {
                                targetArch.Add(a);
                            }
                        }
                        if (targetArch.Count == 1)
                        {
                            this.EditingSection.OrientationArchitecture = targetArch[0] as Architecture;
                        }
                        break;
                    }
                }
                this.RefreshOKButton();
                if (this.IsNew)
                {
                    this.EditingSection.RefreshSectionName();
                }
                this.RefreshOrientationButton();
                this.RefreshLabelTextsDisplay();
            });
            this.GameFramePlugin.IsShowing = true;
        }
Exemple #11
0
        public NewFactionWindow(bool editing, DataGrid dataGrid, GameScenario scen)
        {
            this.scen = scen;
            edit      = editing;
            InitializeComponent();
            faction = new Faction();
            if (editing)
            {
                //faction2 = JsonConvert.DeserializeObject<Faction>(JsonConvert.SerializeObject(scen.Factions.GetGameObject(int.Parse(((DataRowView)dataGrid.SelectedItem).Row["ID"].ToString())) as Faction)) ;
                faction = scen.Factions.GetGameObject(int.Parse(((DataRowView)dataGrid.SelectedItem).Row["ID"].ToString())) as Faction;
            }
            else
            {
                faction.Name       = "新势力";
                faction.ID         = scen.Factions.GetFreeGameObjectID();
                faction.ColorIndex = 52;
                faction.guanjue    = 0;
                faction.BaseMilitaryKindsString     = "0 1 3";
                faction.UpgradingTechnique          = -1;
                faction.TransferingMilitaries       = new MilitaryList();
                faction.TransferingMilitariesString = "";
                faction.TransferingMilitaryCount    = 0;
                faction.AvailableTechniquesString   = "";
                faction.PreferredTechniqueKinds     = new List <int>()
                {
                    0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
                };
                faction.PlanTechniqueString           = -1;
                faction.GetGeneratorPersonCountString = "0:0,1:0,2:0,3:0,4:0,5:0,6:0,7:0,8:0";
                faction.InformationsString            = "";
                faction.LegionsString    = "";
                faction.MilitariesString = "";
                faction.RoutewaysString  = "";
                faction.SectionsString   = "";
                faction.TroopListString  = "";
            }
            //this.Closed += NewFactionWindow_Closed;
            leadertemp              = this.faction.Leader;
            princetemp              = this.faction.Prince;
            architectureListtemp    = this.faction.Architectures;
            capitaltemp             = this.faction.Capital;
            availableTechniquestemp = faction.AvailableTechniques;
            baseMilitaryKindstemp   = faction.BaseMilitaryKinds;
            coloridtemp             = faction.ColorIndex;
            guanjuezhitemp          = faction.guanjue;


            BtFcationColor.Background = new SolidColorBrush(Color.FromArgb(scen.GameCommonData.AllColors[this.faction.ColorIndex].A, scen.GameCommonData.AllColors[this.faction.ColorIndex].R, scen.GameCommonData.AllColors[this.faction.ColorIndex].G, scen.GameCommonData.AllColors[this.faction.ColorIndex].B));
            InitArchis();
            InitTechniques();
            InitMilkinds();
            InitDipRelations();
            txname.Text               = this.faction.Name;
            btleader.Content          = leadertemp;
            btPrince.Content          = princetemp;
            txTechniquePoint.Text     = this.faction.TechniquePoint.ToString();
            txReputation.Text         = this.faction.Reputation.ToString();
            txgongxiandu.Text         = this.faction.chaotinggongxiandu.ToString();
            btguanjuezi.Content       = this.faction.guanjuezifuchuan;
            btCapital.Content         = this.faction.Capital;
            cmUpingTec.SelectedIndex  = this.faction.UpgradingTechnique;
            txleftdays.Text           = this.faction.UpgradingDaysLeft.ToString();
            cbIsAlien.IsChecked       = this.faction.IsAlien;
            cbNoPSelectable.IsChecked = this.faction.NotPlayerSelectable;

            //txname.SetBinding(TextBox.TextProperty, new Binding("Name") { Source = faction });
            //btleader.SetBinding(Button.ContentProperty, new Binding("Leader") { Source = faction });
            //btPrince.SetBinding(Button.ContentProperty, new Binding("Prince") { Source = faction });
            //txTechniquePoint.SetBinding(TextBox.TextProperty, new Binding("TechniquePoint") { Source = faction });
            //txReputation.SetBinding(TextBox.TextProperty, new Binding("Reputation") { Source = faction });
            //txgongxiandu.SetBinding(TextBox.TextProperty, new Binding("chaotinggongxiandu") { Source = faction });
            //btguanjuezi.SetBinding(Button.ContentProperty, new Binding("guanjuezifuchuan") { Source = faction });
            //btCapital.SetBinding(Button.ContentProperty, new Binding("Capital") { Source = faction });
            //cmUpingTec.SelectedIndex = faction.UpgradingTechnique;
            //txleftdays.SetBinding(TextBox.TextProperty, new Binding("UpgradingDaysLeft") { Source = faction });
            //cbIsAlien.SetBinding(CheckBox.IsCheckedProperty, new Binding("IsAlien") { Source = faction });
            //cbNoPSelectable.SetBinding(CheckBox.IsCheckedProperty, new Binding("NotPlayerSelectable") { Source = faction});
            // btleader.Content = faction.Leader;
        }
Exemple #12
0
        public NewEventWindow(bool editing, DataGrid dataGrid, GameScenario scen)
        {
            this.scen = scen;
            edit      = editing;
            InitializeComponent();

            ev = new Event();

            if (editing)
            {
                ev = scen.AllEvents.GetGameObject(int.Parse(((DataRowView)dataGrid.SelectedItem).Row["ID"].ToString())) as Event;
            }
            else
            {
                ev.ID = scen.AllEvents.GetFreeGameObjectID();
            }

            tempDialog = ev.dialog;
            if (tempDialog == null)
            {
                tempDialog = new List <PersonIdDialog>();
            }
            tempYesDialog = ev.yesdialog;
            if (tempYesDialog == null)
            {
                tempYesDialog = new List <PersonIdDialog>();
            }
            tempNoDialog = ev.nodialog;
            if (tempNoDialog == null)
            {
                tempNoDialog = new List <PersonIdDialog>();
            }

            tempPerson = ev.person;
            if (tempPerson == null)
            {
                tempPerson = new Dictionary <int, List <Person> >();
            }
            tempPersonCond = ev.personCond;
            if (tempPersonCond == null)
            {
                tempPersonCond = new Dictionary <int, List <GameObjects.Conditions.Condition> >();
            }
            tempEffect = ev.effect;
            if (tempEffect == null)
            {
                tempEffect = new Dictionary <int, List <GameObjects.ArchitectureDetail.EventEffect.EventEffect> >();
            }
            tempBiography = ev.scenBiography;
            if (tempBiography == null)
            {
                tempBiography = new List <PersonIdDialog>();
            }
            tempYesEffect = ev.yesEffect;
            if (tempYesEffect == null)
            {
                tempYesEffect = new Dictionary <int, List <GameObjects.ArchitectureDetail.EventEffect.EventEffect> >();
            }
            tempNoEffect = ev.noEffect;
            if (tempNoEffect == null)
            {
                tempNoEffect = new Dictionary <int, List <GameObjects.ArchitectureDetail.EventEffect.EventEffect> >();
            }

            tempArchitecture = ev.architecture;
            if (tempArchitecture == null)
            {
                tempArchitecture = new ArchitectureList();
            }
            tempArchitectureCond = ev.architectureCond;
            if (tempArchitectureCond == null)
            {
                tempArchitectureCond = new List <GameObjects.Conditions.Condition>();
            }
            tempArchEffect = ev.architectureEffect;
            if (tempArchEffect == null)
            {
                tempArchEffect = new List <GameObjects.ArchitectureDetail.EventEffect.EventEffect>();
            }
            tempArchYesEffect = ev.yesArchitectureEffect;
            if (tempArchYesEffect == null)
            {
                tempArchYesEffect = new List <GameObjects.ArchitectureDetail.EventEffect.EventEffect>();
            }
            tempArchNoEffect = ev.noArchitectureEffect;
            if (tempArchNoEffect == null)
            {
                tempArchNoEffect = new List <GameObjects.ArchitectureDetail.EventEffect.EventEffect>();
            }

            tempFactions = ev.faction;
            if (tempFactions == null)
            {
                tempFactions = new FactionList();
            }
            tempFactionCond = ev.factionCond;
            if (tempFactionCond == null)
            {
                tempFactionCond = new List <GameObjects.Conditions.Condition>();
            }
            tempFactionEffect = ev.factionEffect;
            if (tempFactionEffect == null)
            {
                tempFactionEffect = new List <GameObjects.ArchitectureDetail.EventEffect.EventEffect>();
            }

            txname.Text                   = ev.Name;
            cbHappened.IsChecked          = ev.happened;
            cbRepeatable.IsChecked        = ev.repeatable;
            cbMinor.IsChecked             = ev.Minor;
            cbGloballyDisplayed.IsChecked = ev.GloballyDisplayed;
            tbHappenChance.Text           = ev.happenChance.ToString();
            tbStartYear.Text              = ev.StartYear.ToString();
            tbStartMonth.Text             = ev.StartMonth.ToString();
            tbEndYear.Text                = ev.EndYear.ToString();
            tbEndMonth.Text               = ev.EndMonth.ToString();
            tbImage.Text                  = ev.Image;
            tbSound.Text                  = ev.Sound;

            PopulateAllPersonData();

            lblArchitcture.Content          = String.Join(" ", tempArchitecture.GameObjects.Select(p => p.Name));
            lblArchitctureCond.Content      = String.Join(" ", tempArchitectureCond.Select(p => p.Name));
            lblArchitctureEffect.Content    = String.Join(" ", tempArchEffect.Select(p => p.Name));
            lblArchitctureYesEffect.Content = String.Join(" ", tempArchYesEffect.Select(p => p.Name));
            lblArchitctureNoEffect.Content  = String.Join(" ", tempArchNoEffect.Select(p => p.Name));
            lblFaction.Content       = String.Join(" ", tempFactions.GameObjects.Select(p => p.Name));
            lblFactionCond.Content   = String.Join(" ", tempFactionCond.Select(p => p.Name));
            lblFactionEffect.Content = String.Join(" ", tempFactionEffect.Select(p => p.Name));

            List <string> events = new List <string>();

            events.Add("-1 无");
            events.AddRange(scen.AllEvents.GameObjects.Select(e => e.ID + " " + e.Name));
            cbAfterEventHappened.ItemsSource = events;
            GameObject currentAfterHappened = scen.AllEvents.GetGameObject(ev.AfterEventHappened);

            cbAfterEventHappened.SelectedItem = ev.AfterEventHappened + " " + (currentAfterHappened == null ? "无" : currentAfterHappened.Name);
        }
Exemple #13
0
 public void Init()
 {
     Architectures = new ArchitectureList();
     States        = new StateList();
 }
Exemple #14
0
        private void generatePerson()
        {
            this.scen.GameCommonData.PersonGeneratorSetting.bornLo       = int.Parse(tbBornYearLo.Text);
            this.scen.GameCommonData.PersonGeneratorSetting.bornHi       = int.Parse(tbBornYearHi.Text);
            this.scen.GameCommonData.PersonGeneratorSetting.debutLo      = int.Parse(tbDebutAgeLo.Text);
            this.scen.GameCommonData.PersonGeneratorSetting.debutHi      = int.Parse(tbDebutAgeHi.Text);
            this.scen.GameCommonData.PersonGeneratorSetting.dieLo        = int.Parse(tbAgeLo.Text);
            this.scen.GameCommonData.PersonGeneratorSetting.dieHi        = int.Parse(tbAgeHi.Text);
            this.scen.GameCommonData.PersonGeneratorSetting.debutAtLeast = int.Parse(tbDebutAtLeast.Text);

            try
            {
                ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[0]).generationChance = int.Parse(tbPersonType0.Text);
                ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[1]).generationChance = int.Parse(tbPersonType1.Text);
                ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[2]).generationChance = int.Parse(tbPersonType2.Text);
                ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[3]).generationChance = int.Parse(tbPersonType3.Text);
                ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[4]).generationChance = int.Parse(tbPersonType4.Text);
                ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[5]).generationChance = int.Parse(tbPersonType5.Text);
                ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[6]).generationChance = int.Parse(tbPersonType6.Text);
                ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[7]).generationChance = int.Parse(tbPersonType7.Text);
                ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[8]).generationChance = int.Parse(tbPersonType8.Text);
                ((PersonGeneratorType)this.scen.GameCommonData.AllPersonGeneratorTypes.GameObjects[9]).generationChance = int.Parse(tbPersonType9.Text);
            }
            catch (ArgumentOutOfRangeException) { }

            int count = GameObject.Random(int.Parse(tbAddPersonLo.Text), int.Parse(tbAddPersonHi.Text));

            int joinChance = int.Parse(tbJoinedFactionChance.Text);

            for (int i = 0; i < count; ++i)
            {
                bool joined = GameObject.Chance(joinChance);

                Architecture location = null;
                if (joined)
                {
                    ArchitectureList candidates = new ArchitectureList();
                    foreach (Architecture j in scen.Architectures)
                    {
                        if (j.BelongedFaction != null)
                        {
                            candidates.Add(j);
                        }
                    }
                    if (candidates.Count > 0)
                    {
                        location = (Architecture)candidates.GetRandomObject();
                    }
                    else
                    {
                        joined = false;
                    }
                }

                if (!joined)
                {
                    location = (Architecture)scen.Architectures.GetRandomObject();
                }

                Person p = Person.createPerson(scen, location, null, false, false);
                if (joined && location.BelongedFaction != null)
                {
                    p.ChangeFaction(location.BelongedFaction);
                }
            }
        }
Exemple #15
0
        private void deleteArchitecture()
        {
            int toDeleteCnt          = GameObject.Random(int.Parse(tbDeleteArchitectureLo.Text), int.Parse(tbDeleteArchitectureHi.Text));
            int toDeletePopulationLo = int.Parse(tbDeleteArchitecturePopulationLo.Text);
            int toDeletePopulationHi = int.Parse(tbDeleteArchitecturePopulationHi.Text);

            if (toDeleteCnt == 0)
            {
                return;
            }

            ArchitectureList candidates = new ArchitectureList();

            foreach (Architecture a in this.scen.Architectures)
            {
                if (a.PopulationCeiling >= toDeletePopulationLo && a.PopulationCeiling <= toDeletePopulationHi)
                {
                    candidates.Add(a);
                }
            }

            GameObjectList toDelete = candidates.GetRandomList();
            GameObjectList list     = this.scen.Architectures.GetList();
            int            deleted  = 0;

            foreach (Architecture a in list)
            {
                if (toDelete.GameObjects.Contains(a))
                {
                    if (a.BelongedFaction != null)
                    {
                        Architecture moveTo = a.BelongedFaction.Capital;
                        if (a == moveTo)
                        {
                            continue;
                        }
                        foreach (Person p in a.Persons)
                        {
                            p.MoveToArchitecture(a);
                            p.ArrivingDays = 0;
                        }
                    }
                    foreach (Architecture i in a.AILandLinks.GetList())
                    {
                        foreach (Architecture j in a.AILandLinks.GetList())
                        {
                            if (i != j && a != i && a != j && !i.AILandLinks.GameObjects.Contains(j) && !j.AILandLinks.GameObjects.Contains(i))
                            {
                                i.AILandLinks.Add(j);
                                j.AILandLinks.Add(i);
                            }
                        }
                    }

                    foreach (Architecture i in a.AIWaterLinks.GetList())
                    {
                        foreach (Architecture j in a.AIWaterLinks.GetList())
                        {
                            if (i != j && a != i && a != j && !i.AIWaterLinks.GameObjects.Contains(j) && !j.AIWaterLinks.GameObjects.Contains(i))
                            {
                                i.AIWaterLinks.Add(j);
                                j.AIWaterLinks.Add(i);
                            }
                        }
                    }
                    this.scen.Architectures.Remove(a);
                    deleted++;
                    if (toDeleteCnt <= deleted)
                    {
                        break;
                    }

                    this.scen.ClearPersonStatusCache();
                }
            }

            this.scen.ClearPersonStatusCache();
        }
        private void ShowOrientationFrame()
        {
            if (this.EditingFaction == null || this.EditingSection.AIDetail == null || this.TabListPlugin == null || this.GameFramePlugin == null)
            {
                return;
            }

            try
            {
                GameDelegates.VoidFunction function  = null;
                GameDelegates.VoidFunction function2 = null;
                GameDelegates.VoidFunction function3 = null;
                switch (this.EditingSection.AIDetail.OrientationKind)
                {
                case SectionOrientationKind.军区:
                    this.TabListPlugin.InitialValues(this.EditingFaction.GetOtherSections(this.OriginalSection), null, InputManager.NowMouse.ScrollWheelValue, "");
                    this.TabListPlugin.SetListKindByName("Section", true, false);
                    this.TabListPlugin.SetSelectedTab("");
                    this.GameFramePlugin.Kind     = FrameKind.TerrainDetail;
                    this.GameFramePlugin.Function = FrameFunction.Transport;
                    this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, Session.MainGame.mainGameScreen.viewportSizeFull);
                    this.GameFramePlugin.OKButtonEnabled     = false;
                    this.GameFramePlugin.CancelButtonEnabled = true;
                    if (function == null)
                    {
                        function = delegate
                        {
                            this.EditingSection.OrientationFaction      = null;
                            this.EditingSection.OrientationState        = null;
                            this.EditingSection.OrientationArchitecture = null;
                            this.EditingSection.OrientationSection      = this.TabListPlugin.SelectedItem as Section;
                            this.RefreshOKButton();
                            this.RefreshLabelTextsDisplay();
                        };
                    }
                    this.GameFramePlugin.SetOKFunction(function);
                    break;

                case SectionOrientationKind.势力:
                    var list0 = Session.Current.Scenario.DiplomaticRelations.GetDiplomaticRelationDisplayListByFactionID(this.EditingFaction.ID);

                    if (list0 == null)
                    {
                        WebTools.TakeWarnMsg("list0 == null", "", new Exception("list0为空"));
                        return;
                    }

                    var list = list0.GetList();

                    this.TabListPlugin.InitialValues(list, null, InputManager.NowMouse.ScrollWheelValue, "");
                    this.TabListPlugin.SetListKindByName("DiplomaticRelation", true, false);
                    this.TabListPlugin.SetSelectedTab("");
                    this.GameFramePlugin.Kind     = FrameKind.CastTargetKind;
                    this.GameFramePlugin.Function = FrameFunction.GetSectionToDemolish;
                    this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, Session.MainGame.mainGameScreen.viewportSizeFull);
                    this.GameFramePlugin.OKButtonEnabled     = false;
                    this.GameFramePlugin.CancelButtonEnabled = true;
                    if (function2 == null)
                    {
                        function2 = delegate
                        {
                            this.EditingSection.OrientationSection      = null;
                            this.EditingSection.OrientationState        = null;
                            this.EditingSection.OrientationArchitecture = null;
                            DiplomaticRelationDisplay selectedItem = this.TabListPlugin.SelectedItem as DiplomaticRelationDisplay;
                            if (selectedItem.LinkedFaction1 == this.EditingFaction)
                            {
                                this.EditingSection.OrientationFaction = selectedItem.LinkedFaction2;
                            }
                            else if (selectedItem.LinkedFaction2 == this.EditingFaction)
                            {
                                this.EditingSection.OrientationFaction = selectedItem.LinkedFaction1;
                            }
                            this.RefreshOKButton();
                            this.RefreshLabelTextsDisplay();
                        };
                    }
                    this.GameFramePlugin.SetOKFunction(function2);
                    break;

                case SectionOrientationKind.州域:
                    this.TabListPlugin.InitialValues(Session.Current.Scenario.States.GetList(), null, InputManager.NowMouse.ScrollWheelValue, "");
                    this.TabListPlugin.SetListKindByName("State", true, false);
                    this.TabListPlugin.SetSelectedTab("");
                    this.GameFramePlugin.Kind     = FrameKind.SectionAIDetail;
                    this.GameFramePlugin.Function = FrameFunction.GetFaction;
                    this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, Session.MainGame.mainGameScreen.viewportSizeFull);
                    this.GameFramePlugin.OKButtonEnabled     = false;
                    this.GameFramePlugin.CancelButtonEnabled = true;
                    if (function3 == null)
                    {
                        function3 = delegate
                        {
                            this.EditingSection.OrientationFaction      = null;
                            this.EditingSection.OrientationSection      = null;
                            this.EditingSection.OrientationState        = this.TabListPlugin.SelectedItem as State;
                            this.EditingSection.OrientationArchitecture = null;
                            this.RefreshOKButton();
                            this.RefreshLabelTextsDisplay();
                        };
                    }
                    this.GameFramePlugin.SetOKFunction(function3);
                    break;

                case SectionOrientationKind.建筑:
                    ArchitectureList allArch    = Session.Current.Scenario.Architectures;
                    ArchitectureList targetArch = new ArchitectureList();
                    foreach (Architecture a in allArch)
                    {
                        if (a.BelongedFaction != this.EditingFaction)
                        {
                            targetArch.Add(a);
                        }
                    }
                    this.TabListPlugin.InitialValues(targetArch, null, InputManager.NowMouse.ScrollWheelValue, "");
                    this.TabListPlugin.SetListKindByName("Architecture", true, false);
                    this.TabListPlugin.SetSelectedTab("");
                    this.GameFramePlugin.Kind     = FrameKind.Architecture;
                    this.GameFramePlugin.Function = FrameFunction.GetFaction;
                    this.GameFramePlugin.SetFrameContent(this.TabListPlugin.TabList, Session.MainGame.mainGameScreen.viewportSizeFull);
                    this.GameFramePlugin.OKButtonEnabled     = false;
                    this.GameFramePlugin.CancelButtonEnabled = true;
                    if (function3 == null)
                    {
                        function3 = delegate
                        {
                            this.EditingSection.OrientationFaction      = null;
                            this.EditingSection.OrientationSection      = null;
                            this.EditingSection.OrientationState        = null;
                            this.EditingSection.OrientationArchitecture = this.TabListPlugin.SelectedItem as Architecture;
                            this.RefreshOKButton();
                            this.RefreshLabelTextsDisplay();
                        };
                    }
                    this.GameFramePlugin.SetOKFunction(function3);
                    break;
                }
                this.GameFramePlugin.IsShowing = true;
            }
            catch (Exception ex)
            {
                WebTools.TakeWarnMsg("MarshalSectionDialog.ShowOrientationFrame", "", ex);
            }
        }