Exemple #1
0
 public void MouseClicked(MouseEvent evt)
 {
     if (IsActive && ((clickableRegion == null && BoundingBox.Contains(evt.CurrentLocation)) ||
                      (clickableRegion != null && clickableRegion.Contains(evt.CurrentLocation)))) {
         foreach (ActionListener al in actionListeners) {
             al.ActionPerformed(new ActionEvent(this));
         }
         evt.Consumed = true;
     }
 }
Exemple #2
0
        public void MouseClicked(MouseEvent evt)
        {
            Point gridLocation = Display.RelativeViewportToGridLocation(evt.CurrentLocation);

            if (World.ItemToPlace != null) {
                World.PlaceItem(gridLocation);
            }

            HashSet <Entity> entities = World.GetEntities(gridLocation.X, gridLocation.Y);
            if (entities.Count > 0) {
                Entity entity = entities.First();
                if (entity.Selectable) {
                    if (!evt.IsShiftDown) {
                        World.ClearSelection();
                    }

                    if (evt.IsShiftDown && World.SelectedEntities.Contains(entity)) {
                        World.DeselectEntity(entity);
                    } else {
                        World.SelectEntity(entity);
                    }
                } else {
                    World.ClearSelection();
                }
            } else {
                World.ClearSelection();
            }

            informationPanel.UpdateInformationPanel();
        }
Exemple #3
0
        public void MouseReleased(MouseEvent evt)
        {
            Point gridLocation = Display.RelativeViewportToGridLocation(evt.CurrentLocation);

            if (evt.Button == MouseEvent.MouseButton.Right) {
                if (World.SelectedEntities.Count == 0) {
                    return;
                }
                if (World.SelectedEntities.Count == 1 && World.SelectedEntityType == World.EntityType.Person) {
                    if (World.IsClear(gridLocation.X, gridLocation.Y)) {
                        Person person = (Person) World.SelectedEntities.First();
                        Dictionary <Point, Person.SearchNode> range = person.ComputeMovementRange();
                        if (range.ContainsKey(gridLocation)) {
                            World.MovePerson(person, gridLocation);
                            person.RemainingMovement -= range[gridLocation].cost;
                            PersonAnimation.CreateMovementAnimation(person, range[gridLocation]);

                            World.ClearSelection();
                            informationPanel.UpdateInformationPanel();
                        }
                    }
                }
            }
        }
Exemple #4
0
 public void MousePressed(MouseEvent evt)
 {
     /* Ignore */
 }
Exemple #5
0
        public void MouseMoved(MouseEvent evt)
        {
            Point gridLocation = Display.RelativeViewportToGridLocation(evt.CurrentLocation);
            if (World.ItemToPlace != null) {
                World.RemoveAllHighlight();

                Tile.TileHighlightColor highlightColor = World.IsClear(gridLocation, World.ItemToPlace.ItemDimension) ?
                    Tile.TileHighlightColor.Green : Tile.TileHighlightColor.Red;

                World.AddHighlight(gridLocation, World.ItemToPlace.ItemDimension, highlightColor);
            }
        }
Exemple #6
0
 public void MouseDragged(MouseEvent evt)
 {
 }
Exemple #7
0
 public void MouseReleased(MouseEvent evt)
 {
     /* Ignore */
 }
Exemple #8
0
 private void ConsumeMouseEvent(MouseEvent evt)
 {
     if (consumesMouseEvent && isActive && boundingBox.Contains(evt.CurrentLocation)) {
         evt.Consumed = true;
     }
 }
Exemple #9
0
 public void MouseReleased(MouseEvent evt)
 {
     ConsumeMouseEvent(evt);
 }
Exemple #10
0
 public void MousePressed(MouseEvent evt)
 {
     ConsumeMouseEvent(evt);
 }
Exemple #11
0
 public void MouseClicked(MouseEvent evt)
 {
     ConsumeMouseEvent(evt);
 }