Exemplo n.º 1
0
        private void _OnCanvasMouseDown(Object Sender, MouseEventArgs EventArguments)
        {
            if (EventArguments.Button == MouseButtons.Right)
            {
                Debug.Assert(_DragPoint == null);
                Debug.Assert(_Dragged == null);
                _DragPoint = EventArguments.Location;
                _Dragged   = false;
            }
            else if (EventArguments.Button == MouseButtons.Left)
            {
                if ((_EntityPrototype != null) && (_EntityPrototype.HasLocation() == true))
                {
                    if (_EntityPrototype.CallGameFunction() == true)
                    {
                        if (ModifierKeys != Keys.Shift)
                        {
                            _UncheckAllToolButtons();
                        }
                    }
                }
                else if (_MovePerson != null)
                {
                    var GamingLocation = _GetGamingLocation(EventArguments.Location);
                    var Desk           = _Game.GetDesk(GamingLocation);

                    if ((Desk != null) && (Desk.IsFree() == true))
                    {
                        _Game.MovePerson(_MovePerson, Desk);
                        _MoveButton.Checked = false;
                    }
                }
                else
                {
                    var GamingLocation = _GetGamingLocation(EventArguments.Location);

                    _MainSplitContainer.Panel1.Controls.Clear();
                    _SelectedObject = null;
                    if (_SelectedObject == null)
                    {
                        foreach (var Person in _Game.Persons)
                        {
                            if (Person.Contains(GamingLocation) == true)
                            {
                                _SelectedObject = Person;

                                var TypeLabel = new Label();

                                TypeLabel.Location = new Point(10, 20);
                                TypeLabel.Size     = new Size(100, 20);
                                TypeLabel.Text     = Person.GetType().Name;
                                _MainSplitContainer.Panel1.Controls.Add(TypeLabel);

                                var NameCaptionLabel = new Label();

                                NameCaptionLabel.Location = new Point(10, 40);
                                NameCaptionLabel.Size     = new Size(100, 20);
                                NameCaptionLabel.Text     = "Name:";
                                _MainSplitContainer.Panel1.Controls.Add(NameCaptionLabel);

                                var NameLabel = new Label();

                                NameLabel.Location = new Point(110, 40);
                                NameLabel.Size     = new Size(100, 20);
                                NameLabel.Text     = Person.Name;
                                _MainSplitContainer.Panel1.Controls.Add(NameLabel);

                                var FireButton = new Button();

                                FireButton.Location = new Point(10, 80);
                                FireButton.Size     = new Size(100, 20);
                                FireButton.Text     = "Fire";
                                FireButton.Click   += delegate
                                {
                                    _Game.FirePerson(Person);
                                    _MainSplitContainer.Panel1Collapsed = true;
                                    _MainSplitContainer.Panel1.Controls.Clear();
                                };
                                _MainSplitContainer.Panel1.Controls.Add(FireButton);
                                _MoveButton                 = new CheckBox();
                                _MoveButton.TextAlign       = ContentAlignment.MiddleCenter;
                                _MoveButton.Location        = new Point(10, 120);
                                _MoveButton.Size            = new Size(100, 20);
                                _MoveButton.Text            = "Move";
                                _MoveButton.Appearance      = Appearance.Button;
                                _MoveButton.Checked         = false;
                                _MoveButton.CheckedChanged += delegate
                                {
                                    if (_MoveButton.Checked == true)
                                    {
                                        _UncheckAllToolButtons();
                                        _MovePerson = Person;
                                    }
                                    else
                                    {
                                        _MovePerson = null;
                                    }
                                };

                                var Y = 150;

                                foreach (var MemoryItemKey in Person.Mind.Memory.Keys)
                                {
                                    var MemoryLabel = new Label();

                                    MemoryLabel.Location    = new Point(10, Y);
                                    MemoryLabel.MaximumSize = new Size(200, 20);
                                    MemoryLabel.AutoSize    = true;
                                    MemoryLabel.Text        = $"{MemoryItemKey} = \"{Person.Mind.Memory.Get(MemoryItemKey).ToString()}\"";
                                    _MainSplitContainer.Panel1.Controls.Add(MemoryLabel);
                                    Y += 20;
                                }
                                _MainSplitContainer.Panel1.Controls.Add(_MoveButton);

                                break;
                            }
                        }
                    }
                    if (_SelectedObject == null)
                    {
                        foreach (var Building in _Game.Buildings)
                        {
                            if (Building.Contains(GamingLocation) == true)
                            {
                                _SelectedObject = Building;

                                var NameCaptionLabel = new Label();

                                NameCaptionLabel.Location = new Point(10, 20);
                                NameCaptionLabel.Size     = new Size(100, 20);
                                NameCaptionLabel.Text     = Building.GetType().Name;
                                _MainSplitContainer.Panel1.Controls.Add(NameCaptionLabel);

                                var DestroyButton = new Button();

                                DestroyButton.Location = new Point(10, 80);
                                DestroyButton.Size     = new Size(120, 20);
                                DestroyButton.Text     = "Destroy";
                                DestroyButton.Enabled  = Building.CanDestroy();
                                DestroyButton.Click   += delegate
                                {
                                    _Game.Destroy(Building);
                                    _MainSplitContainer.Panel1Collapsed = true;
                                    _MainSplitContainer.Panel1.Controls.Clear();
                                };
                                _MainSplitContainer.Panel1.Controls.Add(DestroyButton);

                                var Stairs = Building as Stairs;

                                if (Stairs != null)
                                {
                                    var AddHighestFloorButton = new Button();

                                    AddHighestFloorButton.Location = new Point(10, 110);
                                    AddHighestFloorButton.Size     = new Size(120, 20);
                                    AddHighestFloorButton.Text     = "Add highest floor";
                                    AddHighestFloorButton.Click   += delegate
                                    {
                                        Stairs.AddHighestFloor(_Game);
                                    };
                                    _MainSplitContainer.Panel1.Controls.Add(AddHighestFloorButton);

                                    var RemoveHighestFloorButton = new Button();

                                    RemoveHighestFloorButton.Location = new Point(10, 140);
                                    RemoveHighestFloorButton.Size     = new Size(120, 20);
                                    RemoveHighestFloorButton.Text     = "Remove highest floor";
                                    RemoveHighestFloorButton.Click   += delegate
                                    {
                                        Stairs.RemoveHighestFloor(_Game);
                                    };
                                    _MainSplitContainer.Panel1.Controls.Add(RemoveHighestFloorButton);

                                    var AddLowestFloorButton = new Button();

                                    AddLowestFloorButton.Location = new Point(10, 170);
                                    AddLowestFloorButton.Size     = new Size(120, 20);
                                    AddLowestFloorButton.Text     = "Add lowest floor";
                                    AddLowestFloorButton.Click   += delegate
                                    {
                                        Stairs.AddLowestFloor(_Game);
                                    };
                                    _MainSplitContainer.Panel1.Controls.Add(AddLowestFloorButton);

                                    var RemoveLowestFloorButton = new Button();

                                    RemoveLowestFloorButton.Location = new Point(10, 200);
                                    RemoveLowestFloorButton.Size     = new Size(120, 20);
                                    RemoveLowestFloorButton.Text     = "Remove lowest floor";
                                    RemoveLowestFloorButton.Click   += delegate
                                    {
                                        Stairs.RemoveLowestFloor(_Game);
                                    };
                                    _MainSplitContainer.Panel1.Controls.Add(RemoveLowestFloorButton);
                                }

                                break;
                            }
                        }
                    }
                    _MainSplitContainer.Panel1Collapsed = _SelectedObject == null;
                }
            }
        }
Exemplo n.º 2
0
 public void AddPersistentObject(UInt32 Identifier, PersistentObject PersistentObject)
 {
     _Objects.Add(Identifier, PersistentObject);
 }
Exemplo n.º 3
0
 public override void Load(LoadObjectStore ObjectStore)
 {
     base.Load(ObjectStore);
     _RepairingTarget = ObjectStore.LoadObjectProperty("repairing-target");
 }
Exemplo n.º 4
0
 public void SetRepairingTarget(PersistentObject RepairingTarget)
 {
     _RepairingTarget = RepairingTarget;
 }
Exemplo n.º 5
0
 public void CreateChildElement(XmlElement ParentElement, String Name, PersistentObject PersistentObject)
 {
     _Save(PersistentObject);
     ParentElement.AppendChild(_CreateReference(Name, PersistentObject));
 }
Exemplo n.º 6
0
 public void EnqueueBrokenThing(PersistentObject BrokenThing)
 {
     _BrokenThings.Add(BrokenThing);
 }
Exemplo n.º 7
0
 public void Save(String PropertyName, PersistentObject Value)
 {
     _GameSaver.CreateChildElement(_Element, PropertyName, Value);
 }