public ActionsNotificationManager(List <Action> actions) { background = new Visual2D(new Rectangle(0, 0, 900, 40 ), TextureType.ActionsBG); Notifications = new List <Visual2D>(); if (actions != null) { actions = actions.Where(action => !(action is VoidAction)).ToList(); int xCurrent = -((actions.Count - 1) * scaleX - 400); actions.Reverse(); foreach (var action in actions) { if (!(action is VoidAction)) { Notifications.Add(new Visual2D(new Rectangle(xCurrent, 10, scaleX, scaleY), GetNotifAction(action))); xCurrent += scaleX; } } } //marker = new Visual2D(new Rectangle(_notifications[notifNr].RectangleArea.X, // _notifications[notifNr].RectangleArea.Y - 8, // _notifications[notifNr].RectangleArea.Width, // 6), TextureType.Red); }
public static RigidBody CatchNearestRigidBody(Visual2D refVisual2D, int areaRadius, bool isFirstCatch = false) { RigidBody rigidToReturn = null; foreach (var rigidBox in StaticData.EngineManager.RigidsManagerEngine.ListOfBoxRigids) { if (IsCloseEnough(rigidBox, refVisual2D, areaRadius)) { rigidToReturn = rigidBox; if (isFirstCatch) { break; } } } if (rigidToReturn == null) { foreach (var rigidCircle in StaticData.EngineManager.RigidsManagerEngine.ListOfSphereRigids) { if (IsCloseEnough(rigidCircle, refVisual2D, areaRadius)) { rigidToReturn = rigidCircle; break; } } } return(rigidToReturn); }
public void Update(GameTime gameTime) { shiftMargin += 0.8f; //if (shouldShift) { if (shiftMargin > 1) { foreach (var notification in Notifications) { notification.RectangleArea = new Rectangle(notification.RectangleArea.X + 1, notification.RectangleArea.Y, notification.RectangleArea.Width, notification.RectangleArea.Height); int index = Notifications.Count - notifNr - 1; if (index >= 0) { marker = new Visual2D(new Rectangle(Notifications[index].RectangleArea.X, Notifications[index].RectangleArea.Y - 10, Notifications[index].RectangleArea.Width, 10), TextureType.Red); } else { marker = new Visual2D(new Rectangle(0, -100, 1, 10), TextureType.Red); } } shiftMargin = 0; } } }
public static float Distance(Visual2D c1, Visual2D c2) { float length = (c1.Center - c2.Center).Length(); return(length); //return false; }
public void Draw(GameTime gameTime) { if (StaticData.GameSessionMode == SessionMode.DesignMode && StaticData.IsNotification) { if (_notifications.Count > 0) { if (lastNotificationStartTimeStamp != 0) { if (_y < 0) { _y += 0.5f; } int startX = 150; Visual2D vis = new Visual2D(new Vector3(startX, (int)_y, 0), 600, 40, _notifications[0]); vis.Draw(gameTime); //var spriteBatch = StaticData.EngineManager.Game1.SpriteBatch; //spriteBatch.Begin(); //spriteBatch.DrawString(StaticData.EngineManager.Game1.Font, // _notifications[0], // new Vector2(startX + 20, 5), Color.White); //spriteBatch.End(); } else { lastNotificationStartTimeStamp = gameTime.TotalGameTime.Seconds; } } } }
public static bool IsCloseEnough(Visual2D vis, Vector3 posCenter, int areaRadius) { if ((new Vector3(vis.RectangleArea.Center.X, vis.RectangleArea.Center.Y, 0) - new Vector3(posCenter.X, posCenter.Y, 0)).Length() < areaRadius) { return(true); } return(false); }
private void SetPinRing() { //this._initialPos = pin.PositionXNA3D; Vector3 posRing3D = Masses[0].PositionXNA3D - new Vector3(Length, Length, 0) + this._rigidSize; //Vector3 posRing3D = new Vector3(posRing2D.X, posRing2D.Y, 0); //pin = new Visual2D(pin.PositionXNA3D, (int)(_rigidSize.X * 2), (int)(_rigidSize.Y * 2), TextureType.Pin); ring = new Visual2D(posRing3D, 2 * Length, 2 * Length, TextureType.PinRing); }
public static bool IsMouseOverDrawableComponent(Vector2 mousePosition, Visual2D comopnent) { return( (mousePosition.X >= comopnent.RectangleArea.X) && (mousePosition.X <= comopnent.RectangleArea.X + comopnent.RectangleArea.Width) && (mousePosition.Y >= comopnent.RectangleArea.Y) && (mousePosition.Y <= comopnent.RectangleArea.Y + comopnent.RectangleArea.Height) ); }
private void SetPinRingFirstTime() { //pin = new Visual2D(this.Masses[0].PositionXNA, 15, 15, TextureType.Pin); Vector3 posPin = this.Masses[0].PositionXNA3D; Vector3 posRing3D = posPin - new Vector3(Length, Length, 0) + this._rigidSize; //Vector3 posRing3D = new Vector3(posRing2D.X, posRing2D.Y, 0); //pin = new Visual2D(posPin, (int) (_rigidSize.X * 2), (int) (_rigidSize.Y * 2), TextureType.Pin); ring = new Visual2D(posRing3D, 2 * Length, 2 * Length, TextureType.PinRing); }
public static bool IsCloseEnough(Visual2D vis1, Visual2D vis2, int areaRadius) { float length = (new Vector3(vis1.RectangleArea.Center.X, vis1.RectangleArea.Center.Y, 0) - new Vector3(vis2.RectangleArea.Center.X, vis2.RectangleArea.Center.Y, 0)).Length(); if (length < areaRadius) { return(true); } return(false); }
public static bool IsCloseEnough(RigidBody rigidBody, Visual2D component, int areaRadius) { float length = (rigidBody.Center - component.Center).Length (); if (length < areaRadius) { return(true); } return(false); }
private bool IsRopePin(Visual2D vis) { foreach (SpringService service in StaticData.EngineManager.SpringsManagerEngine.ListOfServices) { if (vis == service.Masses[0]) { return(true); } } return(false); }
public static double GetDistance(Visual2D v1, Visual2D v2) { try { return((new Vector3(v1.RectangleArea.Center.X, v1.RectangleArea.Center.Y, 0) - new Vector3(v2.RectangleArea.Center.X, v2.RectangleArea.Center.Y, 0)).Length()); } catch (Exception) { } return(Double.MaxValue); }
//private void KillFinishedThreads() //{ // if (_threads.Count > 1) // { // int kkk = 0; // } // _threadsToKill.Clear(); // foreach (Thread thread in _threads) // { // if (!thread.IsAlive) // _threadsToKill.Add(thread); // } // foreach (Thread thread in _threadsToKill) // { // thread.Abort(); // _threads.Remove(thread); // } //} //private void KillOverloadedThreads() //{ // if (_threads.Count > 3) // { // for (int i = 0; i < _threads.Count - 2; i++) // { // _threads.RemoveAt(0); // } // } //} public void Draw(GameTime gameTime) { UpdateUI(); if (_bitmapToDraw != null) { var texToDraw = GetTexture2DFromBitmap(StaticData.EngineManager.Game1.GraphicsDevice, _bitmapToDraw); Visual2D vis = new Visual2D(new Rectangle(0, 0, StaticData.LevelFarWidth, StaticData.LevelFarHeight), texToDraw); vis.Draw(gameTime); } }
public void Draw(GameTime gameTime) { if (_bitmapPath != null) { _texToDraw = EntraManager.GetTexture2DFromBitmap(StaticData.EngineManager.Game1.GraphicsDevice, _bitmapPath); Visual2D vis = new Visual2D(new Rectangle(0, 0, StaticData.LevelFarWidth, StaticData.LevelFarHeight), _texToDraw); vis.Draw(gameTime); } }
public void Draw(GameTime gameTime) { for (int i = 0; i < _comps.Count; i++) { Visual2D vis = _comps[i]; var newRect = new Rectangle(vis.RectangleArea.X - 10, vis.RectangleArea.Y - 10, vis.RectangleArea.Width + 20, vis.RectangleArea.Height + 20); Visual2D visBorder = new Visual2D(newRect, TextureType.Border); Color newColor = _colorProvider.ColorifyDrawing(gameTime); visBorder.Draw(gameTime, newColor); } }
private bool CanBePreferred(Visual2D vis) { if (vis is FrogRB || IsRopePin(vis) || vis is RocketCarrierService || vis is BubbleService || vis is BlowerService || vis is BumpRigid) { return(true); } return(false); }
private static Visual2D CatchVisual2D(Vector2 mousePosition) { Visual2D visual2D = null; for (int i = 0; i < StaticData.EngineManager.RigidsManagerEngine.ListOfRigids.Count; i++) { Visual2D current = StaticData.EngineManager.RigidsManagerEngine.ListOfRigids[i]; if (IsMouseOverRectArea(mousePosition, current.RectangleArea)) { return(current); } } //for (int i = 0; i < StaticData.EngineManager.SpringsManagerEngine.ListOfServices.Count; i++) //{ // var current = StaticData.EngineManager.SpringsManagerEngine.ListOfServices[i]; // if (current is CatchableRopeService) // { // CatchableRopeService cRope = (CatchableRopeService) current; // if (IsMouseOverRectArea(mousePosition, cRope.pin.RectangleArea)) // { // return cRope.pin; // } // } //} for (int i = 0; i < StaticData.EngineManager.BubbleManagerEngine.ListOfServices.Count; i++) { Visual2D current = StaticData.EngineManager.BubbleManagerEngine.ListOfServices[i]; if (IsMouseOverRectArea(mousePosition, current.RectangleArea)) { return(current); } } for (int i = 0; i < StaticData.EngineManager.BlowerManagerEngine.ListOfServices.Count; i++) { Visual2D current = StaticData.EngineManager.BlowerManagerEngine.ListOfServices[i]; if (IsMouseOverRectArea(mousePosition, current.RectangleArea)) { return(current); } } return(visual2D); }
public void ToggleComponentSetterState(Visual2D vis) { if (CanBePreferred(vis)) { if (vis != null) { if (_comps.Contains(vis)) { _comps.Remove(vis); } else { _comps.Add(vis); } } } }
public static Visual2D CatchVisual2D() { MouseState mouseState = Mouse.GetState(); Vector2 mousePosition = new Vector2(mouseState.X, mouseState.Y); Visual2D visual2D = CatchVisual2D(mousePosition); //if (rectRigid != null) //{ // return rectRigid; //} //else //{ // SphereRigid SphereRigid = CatchSphereRigid(mousePosition); // if (SphereRigid != null) // { // return SphereRigid; // } //} return(visual2D); }
//public int LiquidLevel //{ // set // { // _LiquidLevel = StaticData.EngineManager.Window.ClientBounds.Height - value; // } // get // { // return _LiquidLevel + StaticData.EngineManager.Window.ClientBounds.Height; // } //} public LiquidService() { /* * StaticData.EngineManager.RigidsManagerEngine.AddRigidBody(DefaultAdder.GetDefaultBox(new Vector3(10, 10, 0), * Material.Steel, * new Vector3(10, 10 ,0), * new Vector3(0, -9.8f, 0), null, null)); * * StaticData.EngineManager.RigidsManagerEngine.AddRigidBody(DefaultAdder.GetDefaultSphere(new Vector3(60, 10, 0), * Material.Steel, * 10, * new Vector3(0, -9.8f, 0), null, null)); */ this._wave1 = new Visual2D(new Rectangle(0, 0, 0, 0), TextureType.WaterWave); this._wave2 = new Visual2D(new Rectangle(0, 0, 0, 0), TextureType.WaterWave); this._waterVisual = new Visual2D(new Rectangle(0, LiquidLevel + 10, StaticData.LevelFarWidth, StaticData.LevelFarHeight - LiquidLevel), TextureType.VisualWater); RigidsInService = new List <RigidBody>(); }
private Visual2DRotatable GetMatchedSelectedBox() { Visual2DRotatable catchedRotatable = null; MouseState mouseState = Mouse.GetState(); if (_canSelectNewBox) { Vector2 mousePosition = new Vector2(mouseState.X, mouseState.Y); List <Visual2D> listOfVisual2DTags = new List <Visual2D>(); listOfVisual2DTags.AddRange(_listOfTags); Visual2D catechedDrawable = MouseManager.CatchDrawableComponent(mousePosition, listOfVisual2DTags); if (catechedDrawable is Visual2DRotatable) { catchedRotatable = catechedDrawable as Visual2DRotatable; } } else { catchedRotatable = _currentSelectedDrawable; } return(catchedRotatable); }
public static Visual2D CatchNearestVisual2D(Visual2D refVisual2D, List <Visual2D> listCompare, int areaRadius, bool isFirstCatch = false) { Visual2D visual2DToReturn = null; float minDist = float.MaxValue; foreach (var visual2D in listCompare) { if (IsCloseEnough(visual2D, refVisual2D, areaRadius)) { float dis = Distance(visual2D, refVisual2D); if (dis < minDist) { minDist = dis; visual2DToReturn = visual2D; } if (isFirstCatch) { break; } } } return(visual2DToReturn); }