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); } } }
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); }
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); }
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); }
public override void ObjectAddedUpdate(MappableObject obj) { }
public virtual void ObjectAddedUpdate(MappableObject obj) { }