public GameScreen() { BackgroundColor = Color.Black; iArea = new InteractionArea(); iComponent = new InteractionComponent(); iComponent.IsInfinet = true; iComponent.Dragable = false; props = new ScreenPropPanel(); props.OnPropChange += props_onPropChange; props.OnLSpriteRemove += OnPropPanel_LibSpriteRemove; props.OnLSpratePlace += OnPropPanel_LibSpritePlace; props.OnScriptEditClick += OnScriptEdit; iArea.AddEntity(iComponent); iComponent.OnClick += iEntity_Click; AddMenuItem("Delete"); OnMenuItemSelect += OnMenuItemSel; drawables = new List<IDrawable>(); updateables = new List<IUpdateable>(); sprites = new List<Sprite>(); texts = new List<Text>(); lSprites = new List<LibrarySprite>(); }
public void PushMouseEvent(MouseEvent evt) { System.Drawing.Point p = new System.Drawing.Point(); p.X = evt.MouseX; p.Y = evt.MouseY; if (evt.Type == EventType.Click) { for (int i = entities.Count - 1; i >= 0; i--) { InteractionComponent entity = entities[i]; if (entity.IsInfinet || entities[i].IsPointInside(p)) { entity.Click(); break; } } } else if (evt.Type == EventType.Down) { for (int i = entities.Count - 1; i >= 0; i--) { InteractionComponent entity = entities[i]; if (entities[i].IsPointInside(p) && entity.Dragable) { dragedComponent = entity; relativeX = p.X - entity.X; relativeY = p.Y - entity.Y; break; } } } else if (evt.Type == EventType.Move) { if (dragedComponent != null) { dragedComponent.X = p.X - relativeX; dragedComponent.Y = p.Y - relativeY; dragedComponent.Drag(); } } else if (evt.Type == EventType.Up) { dragedComponent = null; } }
public ScreenEntity() { x = y = 0; clipWidth = clipHeight = 60; iComponent = new InteractionComponent(); iComponent.Width = clipWidth; iComponent.Height = clipHeight; fComponent = new FocusComponent(); fComponent.InFocus = false; iComponent.Dragable = true; iComponent.OnClick += IEntity_Click; iComponent.OnDrag += IEntity_Drag; }
public void RemoveEntity(InteractionComponent entity) { entities.Remove(entity); }
public void AddEntity(InteractionComponent entity) { entities.Add(entity); }
public InteractionArea() { entities = new List<InteractionComponent>(); dragedComponent = null; }