Exemple #1
0
 public void AddMappableObject(string id, MappableObject obj)
 {
     lock (this)
     {
         if (!_playfield_objects.ContainsKey(id))
         {
             _playfield_objects.Add(id, obj);
             _stacking_order.AddFirst(id);
             ObjectAddedUpdate(obj);
         }
     }
 }
Exemple #2
0
        public bool SelectSingle(float xpos, float ypos)
        {
            lock (this)
            {
                // If more than one selection exists, remove the last selection so only
                // one exists.
                if (_select_buffer.Count > 1)
                {
                    _select_buffer.RemoveRange(1, _select_buffer.Count - 1);

                    //return true;
                }


                LinkedListNode <string> current_node = _stacking_order.Last;

                while (current_node != null)
                {
                    MappableObject p = _playfield_objects[current_node.Value];

                    if (p.HitTest(xpos, ypos) && p.CanSelect)
                    {
                        switch (_select_buffer.Contains(p.ID))
                        {
                        case true:
                            _select_buffer.Clear();
                            _stacking_order.Remove(current_node);
                            _stacking_order.AddFirst(current_node);
                            return(SelectSingle(xpos, ypos));

                        case false:
                            _select_buffer.Clear();
                            _select_buffer.Add(p.ID);
                            _stacking_order.Remove(current_node);
                            _stacking_order.AddLast(current_node);
                            return(true);
                        }
                    }

                    current_node = current_node.Previous;
                }
            }
            return(false);
        }
Exemple #3
0
        public bool RightClickSelect(float xpos, float ypos)
        {
            lock (this)
            {
                LinkedListNode <string> current_node = _stacking_order.Last;

                while (current_node != null)
                {
                    MappableObject p = _playfield_objects[current_node.Value];
                    if (p.HitTest(xpos, ypos) && p.CanSelect)
                    {
                        switch (_select_buffer.Contains(p.ID))
                        {
                        case true:
                            // If we already have a p.id and its not the primary selection, then remove it.
                            if ((_select_buffer.Count > 1) && (_select_buffer[0] != p.ID))
                            {
                                _select_buffer.Remove(p.ID);
                            }
                            break;

                        case false:
                            // If we have 2 selections overwrite the second one, otherwise assume 1 already selected, add another.
                            if (_select_buffer.Count == MAX_SELECTIONS)
                            {
                                _select_buffer[1] = p.ID;
                            }
                            else
                            {
                                _select_buffer.Add(p.ID);
                            }
                            break;
                        }

                        return(true);
                    }

                    current_node = current_node.Previous;
                }
            }

            return(false);
        }
Exemple #4
0
        public bool SelectionExists(float xpos, float ypos)
        {
            lock (this)
            {
                LinkedListNode <string> current_node = _stacking_order.Last;

                while (current_node != null)
                {
                    MappableObject p = _playfield_objects[current_node.Value];

                    if (p.HitTest(xpos, ypos) && p.CanSelect)
                    {
                        return(true);
                    }

                    current_node = current_node.Previous;
                }
            }
            return(false);
        }
Exemple #5
0
 public override void ObjectAddedUpdate(MappableObject obj)
 {
 }
Exemple #6
0
 public virtual void ObjectAddedUpdate(MappableObject obj)
 {
 }
Exemple #7
0
 public void AddMappableObject(string id, MappableObject obj)
 {
     lock (this)
     {
         if (!_playfield_objects.ContainsKey(id))
         {
             _playfield_objects.Add(id, obj);
             _stacking_order.AddFirst(id);
             ObjectAddedUpdate(obj);
         }
     }
 }
Exemple #8
0
 public virtual void ObjectAddedUpdate(MappableObject obj)
 {
 }