} // This is to make sure tiles are only updated once per frame. //----------------------------------------------------------------------------- // Constructors //----------------------------------------------------------------------------- // Use Tile.CreateTile() instead of this constructor. protected Tile() { tileGridArea = Rectangle2I.Zero; isAlive = false; isInitialized = false; location = Point2I.Zero; layer = 0; offset = Point2I.Zero; size = Point2I.One; spriteAsObject = new SpriteAnimation(); isSolid = false; isMoving = false; pushDelay = 20; properties = new Properties(this); tileData = null; moveDirection = Point2I.Zero; dropList = null; hasMoved = false; path = null; pathTimer = 0; pathMoveIndex = 0; fallsInHoles = true; soundMove = GameData.SOUND_BLOCK_PUSH; conveyorVelocity = Vector2F.Zero; surfaceTile = null; collisionStyle = CollisionStyle.Rectangular; graphics = new TileGraphicsComponent(this); }
/// <summary> /// The only reason you would pass in your own guid is when loading a previously saved scene (the token /// works good for processing in ram, but when stuff needs to go to file, use the guid) /// </summary> public RadarBlip(Sphere sphere, CollisionStyle collisionStyle, RadarBlipQual blipQual, long token, Guid objectID) { _sphere = sphere; _collisionStyle = collisionStyle; _token = token; _qual = blipQual; _qualInt = _qual.GetHashCode(); _objectID = objectID; }
/// <summary> /// This is the basic constructor. These are the only things that need to be passed in. /// </summary> public RadarBlip(Sphere sphere, CollisionStyle collisionStyle, RadarBlipQual blipQual, long token) : this(sphere, collisionStyle, blipQual, token, Guid.NewGuid()) { }
/// <summary> /// The opacity passed in will be applied after figuring out the opacity of mode (if mode says 128, and opacity is .5, then /// the final opacity is 64) /// </summary> public void DrawBall(Ball ball, DrawMode mode, CollisionStyle collisionStyle, bool drawRed, double opacity) { Color color; #region Figure out the color if (drawRed) { color = REDCOLOR; } else { color = Color.Gold; } #endregion int finalOpacity; #region Figure out the opacity switch (mode) { case DrawMode.Building: finalOpacity = BUILDINGBALLFILLOPACTIY; break; case DrawMode.Selected: case DrawMode.Standard: finalOpacity = STANDARDBALLFILLOPACTIY; break; default: throw new ApplicationException("Unknown DrawMode: " + mode.ToString()); } finalOpacity = Convert.ToInt32(finalOpacity * opacity); if (finalOpacity < 0) { finalOpacity = 0; } else if (finalOpacity > 255) { finalOpacity = 255; } #endregion // Collision Style DrawCollisionStyle(ball.Position, ball.Radius, collisionStyle); // Fill the circle using (Brush brush = new SolidBrush(Color.FromArgb(finalOpacity, color))) { _viewer.FillCircle(brush, ball.Position, ball.Radius); } #region Draw the edge switch (mode) { case DrawMode.Building: _viewer.DrawCircle(Color.FromArgb(finalOpacity, _buildingPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius); break; case DrawMode.Standard: _viewer.DrawCircle(Color.FromArgb(finalOpacity, _standardPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius); break; case DrawMode.Selected: _viewer.DrawCircle_Selected(ball.Position, ball.Radius); break; } #endregion //TODO: Show Stats }
public void DrawBall(Ball ball, DrawMode mode, CollisionStyle collisionStyle, bool drawRed) { DrawBall(ball, mode, collisionStyle, drawRed, 1d); }
/// <summary> /// The only reason you would pass in your own guid is when loading a previously saved scene (the token /// works good for processing in ram, but when stuff needs to go to file, use the guid) /// </summary> public BallBlip(Ball ball, CollisionStyle collisionStyle, RadarBlipQual blipQual, long token, Guid objectID) : base(ball, collisionStyle, blipQual, token, objectID) { _ball = ball; _torqueBall = ball as TorqueBall; // if it's not, null will be stored }
public virtual void Reset(Challenge c, string img, int fc, CollisionStyle col, bool left, int xp, int yp, int w, int h, int diff) { challenge = c; Difficulty = diff; collisionStyle = col; frameCount = fc; assetName = img; LoadContent(); Play("default"); bounds = new Rectangle(0, 0, w, h); int x = 0; if (left) { x = xp - SpriteWidth; leftToRight = true; } else { x = xp; leftToRight = false; } startPosition = new Vector2(x, yp); position = startPosition; velocity = new Vector2(0, 0); alive = true; visible = true; VisualWidth = w; VisualHeight = h; c.EnemyCreated(this); }
/// <summary> /// This is the basic constructor. These are the only things that need to be passed in. /// </summary> public BallBlip(Ball ball, CollisionStyle collisionStyle, RadarBlipQual blipQual, long token) : this(ball, collisionStyle, blipQual, token, Guid.NewGuid()) { }
private void DrawCollisionStyle(MyVector position, double bodyRadius, CollisionStyle collisionStyle) { const double MINSIZE = 75d; const double MAXSIZE = 250d; if (collisionStyle == CollisionStyle.Standard) { return; } #region Figure out how big to make it double radius = bodyRadius * .5d; if (radius < MINSIZE) { if (bodyRadius > MINSIZE) { radius = MINSIZE; } else { radius = bodyRadius; // I don't want to use MINSIZE, because this could look funny } } else if (radius > MAXSIZE) { radius = MAXSIZE; } double halfRadius = radius * .5d; #endregion // Figure out the line thickness double lineThickness = UtilityCore.GetScaledValue_Capped(4d, 15d, MINSIZE, MAXSIZE, radius); // Draw Icon switch (collisionStyle) { case CollisionStyle.Ghost: #region Ghost // Make a tilde (I was going to make two, but one seems to get the point across) MyVector[] points = new MyVector[4]; points[0] = new MyVector(position.X - halfRadius, position.Y + (halfRadius / 8d), position.Z); points[1] = new MyVector(position.X - (halfRadius / 3d), position.Y - (halfRadius / 4d), position.Z); points[2] = new MyVector(position.X + (halfRadius / 3d), position.Y + (halfRadius / 4d), position.Z); points[3] = new MyVector(position.X + halfRadius, position.Y - (halfRadius / 8d), position.Z); _viewer.DrawArc(Color.Navy, lineThickness, points, false); #endregion break; case CollisionStyle.Stationary: #region Stationary _viewer.DrawLine(Color.Maroon, lineThickness, new MyVector(position.X - halfRadius, position.Y - halfRadius, position.Z), new MyVector(position.X + halfRadius, position.Y + halfRadius, position.Z)); _viewer.DrawLine(Color.Maroon, lineThickness, new MyVector(position.X - halfRadius, position.Y + halfRadius, position.Z), new MyVector(position.X + halfRadius, position.Y - halfRadius, position.Z)); #endregion break; case CollisionStyle.StationaryRotatable: #region StationaryRotatable _viewer.DrawCircle(Color.Maroon, lineThickness, position, halfRadius); #endregion break; default: throw new ApplicationException("Unknown CollisionStyle: " + collisionStyle.ToString()); } }
public void DrawRigidBody(RigidBody body, DrawMode mode, CollisionStyle collisionStyle, bool drawRed) { }
/// <summary> /// The opacity passed in will be applied after figuring out the opacity of mode (if mode says 128, and opacity is .5, then /// the final opacity is 64) /// </summary> public void DrawSolidBall(SolidBall ball, DrawMode mode, CollisionStyle collisionStyle, bool drawRed, double opacity) { Color color; #region Figure out the color if (drawRed) { color = REDCOLOR; } else { color = Color.RoyalBlue; } #endregion int finalOpacity; #region Figure out the opacity switch (mode) { case DrawMode.Building: finalOpacity = BUILDINGBALLFILLOPACTIY; break; case DrawMode.Selected: case DrawMode.Standard: finalOpacity = STANDARDBALLFILLOPACTIY; break; default: throw new ApplicationException("Unknown DrawMode: " + mode.ToString()); } finalOpacity = Convert.ToInt32(finalOpacity * opacity); if (finalOpacity < 0) { finalOpacity = 0; } else if (finalOpacity > 255) { finalOpacity = 255; } #endregion MyVector dirFacing; #region Figure out direction facing dirFacing = ball.DirectionFacing.Standard.Clone(); dirFacing.BecomeUnitVector(); dirFacing.Multiply(ball.Radius); dirFacing.Add(ball.Position); #endregion // Collision Style DrawCollisionStyle(ball.Position, ball.Radius, collisionStyle); // Fill the circle using (Brush brush = new SolidBrush(Color.FromArgb(finalOpacity, color))) { _viewer.FillCircle(brush, ball.Position, ball.Radius); } // Draw direction facing _viewer.DrawLine(Color.FromArgb(finalOpacity, Color.White), 2d, ball.Position, dirFacing); #region Draw the edge switch (mode) { case DrawMode.Building: _viewer.DrawCircle(Color.FromArgb(finalOpacity, _buildingPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius); break; case DrawMode.Standard: _viewer.DrawCircle(Color.FromArgb(finalOpacity, _standardPenColor), STANDARDOUTLINEWIDTH, ball.Position, ball.Radius); break; case DrawMode.Selected: _viewer.DrawCircle_Selected(ball.Position, ball.Radius); break; } #endregion //TODO: Show Stats }
public CycSprite Create(Challenge c, string img, int fc, CollisionStyle col, string curveSet, bool left, int y, int w, int h, double timeScale, int diff) { ShipEnemy enemy = (ShipEnemy)FindOrMakeEnemy(); enemy.Reset(c, img, fc, col, curveSet, left, left ? 0 : CycGame.View.Width, y, w, h, timeScale, diff); return enemy; }
// Timer private void timer1_Tick(object sender, EventArgs e) { Collision[] collisions = null; if (btnRunning.Checked) { #region Physics _map.PrepareForNewTimerCycle(); if (_gravMouse.Active) { _gravMouse.Timer(); } _shipController.Timer(ELAPSEDTIME); _gravController.Timer(); collisions = _map.Timer(ELAPSEDTIME); if (_selector.Active) { _selector.TimerTick(ELAPSEDTIME); } #endregion } #region Examine Collisions if (collisions != null) { foreach (Collision collision in collisions) { #region Check Temps bool wasTemp = false; if (_tempObjects.Contains(collision.Blip1.Token)) { _tempObjects.Remove(collision.Blip1.Token); _map.Remove(collision.Blip1.Token); wasTemp = true; } if (_tempObjects.Contains(collision.Blip2.Token)) { _tempObjects.Remove(collision.Blip2.Token); _map.Remove(collision.Blip2.Token); wasTemp = true; } if (wasTemp) { continue; } #endregion if (_ignoreTokens.Contains(collision.Blip1.Token) || _ignoreTokens.Contains(collision.Blip2.Token)) { continue; } if (collision.Blip1 is Projectile && !(collision.Blip2 is Projectile)) { HurtBlip((Projectile)collision.Blip1, collision.Blip2); } else if (collision.Blip2 is Projectile && !(collision.Blip1 is Projectile)) { HurtBlip((Projectile)collision.Blip2, collision.Blip1); } } } #endregion #region Reset Z _zeroResetCntr++; if (_zeroResetCntr % 100000 == 0) { _zeroResetCntr = 0; foreach (RadarBlip blip in _map.GetAllBlips()) { blip.Sphere.Position.Z = 0; if (blip is BallBlip) { if (((BallBlip)blip).Ball.Velocity.Z != 0d) { MessageBox.Show("not zero velocity"); } ((BallBlip)blip).Ball.Velocity.Z = 0; } } } #endregion #region Draw pictureBox1.PrepareForNewDraw(); if (_gravMouse.Active) { _gravMouse.Draw(); } RadarBlip[] blips = _map.GetAllBlips(); // Draw all the blips for (int blipCntr = 0; blipCntr < blips.Length; blipCntr++) { if (_ignoreTokens.Contains(blips[blipCntr].Token)) { continue; } // Ask the selecter if this is selected ObjectRenderer.DrawMode drawMode = ObjectRenderer.DrawMode.Standard; if (_selector.IsSelected(blips[blipCntr].Token)) { drawMode = ObjectRenderer.DrawMode.Selected; } // See if it should be displayed as standard CollisionStyle collisionStyle = blips[blipCntr].CollisionStyle; if (_selector.TempStationaryObjects.Contains(blips[blipCntr].Token)) { collisionStyle = CollisionStyle.Standard; } // Draw the blip if (blips[blipCntr] is Projectile) { _renderer.DrawProjectile((Projectile)blips[blipCntr], drawMode, false); } else if (blips[blipCntr].Sphere is RigidBody) { _renderer.DrawRigidBody((RigidBody)blips[blipCntr].Sphere, drawMode, collisionStyle, false); } else if (blips[blipCntr].Sphere is SolidBall) { _renderer.DrawSolidBall((SolidBall)blips[blipCntr].Sphere, drawMode, collisionStyle, false); } else if (blips[blipCntr].Sphere is Ball) { _renderer.DrawBall((Ball)blips[blipCntr].Sphere, drawMode, collisionStyle, false); } else { MessageBox.Show("Unknown blip", this.Text, MessageBoxButtons.OK, MessageBoxIcon.Error); } } _shipController.Draw(); // Let the active adder/selecter have a chance to draw if (_ballAdder.Mode != BallAdder.AddingMode.Inactive) { _ballAdder.Draw(); } else if (_selector.Active) { _selector.Draw(); } pictureBox1.FinishedDrawing(); #endregion }
//----------------------------------------------------------------------------- // Constructors //----------------------------------------------------------------------------- // Use Tile.CreateTile() instead of this constructor. protected Tile() { tileGridArea = Rectangle2I.Zero; isAlive = false; isInitialized = false; location = Point2I.Zero; layer = 0; offset = Point2I.Zero; size = Point2I.One; spriteAsObject = new SpriteAnimation(); isSolid = false; isMoving = false; pushDelay = 20; properties = new Properties(this); tileData = null; moveDirection = Point2I.Zero; dropList = null; hasMoved = false; path = null; pathTimer = 0; pathMoveIndex = 0; fallsInHoles = true; soundMove = GameData.SOUND_BLOCK_PUSH; conveyorVelocity = Vector2F.Zero; surfaceTile = null; collisionStyle = CollisionStyle.Rectangular; graphics = new TileGraphicsComponent(this); }