public void ServerActivity() { GotoTarget(); //restore removed mobs if (Removed) { ShapeManager.AddCircle(this); Removed = false; } switch (State) { case MobState.Roaming: ServerRoaming(); break; case MobState.Chasing: ServerChasing(); break; case MobState.Atacking: ServerAttacking(); break; default: break; } }
public Hero(string name, HeroClass heroClass) { Collect = false; Online = TimeSpan.Zero; Target = Position; AcceptArrows = true; zLastPosition = Position; Netid = 0; Name = name; Class = heroClass; Position.Z = ZLayer.Npc; WalkingSpeed = 10; SpriteManager.AddPositionedObject(this); Collider = ShapeManager.AddCircle(); Collider.AttachTo(this, false); Collider.Visible = false; Sprite = LoadSprite(); Sprite.AttachTo(this, false); Sprite.Resize(4); Sprite.AnimationSpeed = 0.1f; Label = TextManager.AddText(name, Globals.Font); Label.AttachTo(this, false); Label.HorizontalAlignment = HorizontalAlignment.Center; Label.RelativePosition = new Vector3(0, 4, ZLayer.NpcLabel - Position.Z); InitStats(); }
private void CreateCollision() { Circle mCollision = new Circle(); mCollision.AttachTo(this, false); // Comment the following if you want the collision to be invisible. ShapeManager.AddCircle(mCollision); }
public DamageCircle(Hero heroOwner, Mob mobOwner, bool destroyOnHit, int id, MapRoom room) { Id = id; HeroOwner = heroOwner; MobOwner = mobOwner; DestroyOnHit = destroyOnHit; Room = room; ShapeManager.AddCircle(this); }
private void _DrawDebugVisualForPortal(double startX, double startY, double endX, double endY) { Dbg.ShowLine(startX, startY, endX, endY, Color.Yellow); var circle = ShapeManager.AddCircle(); circle.Radius = 3f; circle.Color = Color.Yellow; circle.X = (float)startX; circle.Y = (float)startY; }
public Handle(Layer layer, Circle circle) { mLayer = layer; mCircle = circle; ScaleXCoefficient = 0; ScaleYCoefficient = 0; ShapeManager.AddCircle(mCircle); ShapeManager.AddToLayer(mCircle, mLayer); }
public SplinePointSelectionMarker() { mRectangle = ShapeManager.AddAxisAlignedRectangle(); mLine = ShapeManager.AddLine(); mRectangle.Color = Color.LightBlue; mEndpoint1 = ShapeManager.AddCircle(); mEndpoint1.Color = Color.Yellow; mEndpoint2 = ShapeManager.AddCircle(); mEndpoint2.Color = Color.Yellow; }
public TriggerTile(Vector3 pos, float radius, string name) { Collect = false; Name = name; Collider = ShapeManager.AddCircle(); Collider.Position = pos; Collider.Radius = radius; Globals.EventManager.AddEvent(Trigger, $"trigger{Id}"); Id++; InitializeEvent(); }
private Mob() { MovingSpeed = 6; Removed = false; Netid = 0; State = MobState.Roaming; SenseDistance = 8; AttackDistance = 2; AttackSpeed = TimeSpan.FromSeconds(2); HeroTarget = null; ShapeManager.AddCircle(this); }
public override void Initialize(bool addToManagers) { base.Initialize(addToManagers); for (var i = 0; i < 1000; i++) { var angle = FlatRedBallServices.Random.Between(-3.14f, 3.14f); var c = ShapeManager.AddCircle(); c.Radius = FlatRedBallServices.Random.Between(4f, 15f); c.Position.X = FlatRedBallServices.Random.Between(Camera.Main.AbsoluteLeftXEdgeAt(0), Camera.Main.AbsoluteRightXEdgeAt(0)); c.Position.Y = FlatRedBallServices.Random.Between(Camera.Main.AbsoluteBottomYEdgeAt(0), Camera.Main.AbsoluteTopYEdgeAt(0)); c.Color = Microsoft.Xna.Framework.Color.Aquamarine; c.Velocity.X = (float)Math.Sin(angle) * movementVelocity; c.Velocity.Y = (float)Math.Cos(angle) * movementVelocity; circles.Add(c); } for (var i = 0; i < 1000; i++) { var angle = FlatRedBallServices.Random.Between(-3.14f, 3.14f); var r = ShapeManager.AddAxisAlignedRectangle(); r.Width = FlatRedBallServices.Random.Between(4f, 15f); r.Height = FlatRedBallServices.Random.Between(4f, 15f); r.Position.X = FlatRedBallServices.Random.Between(Camera.Main.AbsoluteLeftXEdgeAt(0), Camera.Main.AbsoluteRightXEdgeAt(0)); r.Position.Y = FlatRedBallServices.Random.Between(Camera.Main.AbsoluteBottomYEdgeAt(0), Camera.Main.AbsoluteTopYEdgeAt(0)); r.Color = Microsoft.Xna.Framework.Color.GreenYellow; r.Velocity.X = (float)Math.Sin(angle) * movementVelocity; r.Velocity.Y = (float)Math.Cos(angle) * movementVelocity; rectangles.Add(r); } for (var i = 0; i < 1000; i++) { var angle = FlatRedBallServices.Random.Between(-3.14f, 3.14f); var p = ShapeManager.AddPolygon(); p.Points = new List <Point>() { new Point(-8, 8), new Point(8, 8), new Point(8, -8), new Point(-8, -8), new Point(-8, 8) }; p.Position.X = FlatRedBallServices.Random.Between(Camera.Main.AbsoluteLeftXEdgeAt(0), Camera.Main.AbsoluteRightXEdgeAt(0)); p.Position.Y = FlatRedBallServices.Random.Between(Camera.Main.AbsoluteBottomYEdgeAt(0), Camera.Main.AbsoluteTopYEdgeAt(0)); p.Color = Microsoft.Xna.Framework.Color.Pink; p.Velocity.X = (float)Math.Sin(angle) * movementVelocity; p.Velocity.Y = (float)Math.Cos(angle) * movementVelocity; p.RotationZVelocity = FlatRedBallServices.Random.Between(-1.5f, 1.5f); polygons.Add(p); } }
public void CopyCurrentCircles() { foreach (Circle circle in CurrentShapeCollection.Circles) { Circle newCircle = circle.Clone <Circle>(); ShapeManager.AddCircle(newCircle); EditorData.ShapeCollection.Circles.Add(newCircle); StringFunctions.MakeNameUnique <Circle>(newCircle, EditorData.Circles); } }
public void AddCircle() { Circle circle = new Circle(); ShapeManager.AddCircle(circle); circle.Color = EditorProperties.CircleColor; circle.X = SpriteManager.Camera.X; circle.Y = SpriteManager.Camera.Y; float scale = (float)Math.Abs( 18 / SpriteManager.Camera.PixelsPerUnitAt(0)); circle.Radius = scale; EditorData.ShapeCollection.Circles.Add(circle); circle.Name = "Circle" + EditorData.Circles.Count; StringFunctions.MakeNameUnique <Circle>(circle, EditorData.Circles); }
public HierarchyNode(VisibleRepresentationType visibleRepresentationType) { SpriteManager.AddPositionedObject(this); if (visibleRepresentationType == VisibleRepresentationType.Circle) { mCircleVisibleRepresentation = ShapeManager.AddCircle(); } else { mSpriteVisibleRepresentation = SpriteManager.AddSprite((Texture2D)null); #if FRB_MDX mSpriteVisibleRepresentation.ColorOperation = Microsoft.DirectX.Direct3D.TextureOperation.SelectArg2; #else mSpriteVisibleRepresentation.ColorOperation = ColorOperation.Color; #endif mSpriteVisibleRepresentation.Red = 1; mSpriteVisibleRepresentation.Green = 1; mSpriteVisibleRepresentation.Blue = 1; } mParentLine = ShapeManager.AddLine(); mParentLine.Visible = false; mParentAttachmentPoint = ShapeManager.AddCircle(); mParentAttachmentPoint.Visible = false; mParentAttachmentPoint.Radius = .2f; mText = TextManager.AddText(""); mText.Blue = 1; mText.Green = 1; mText.Red = 0; mText.HorizontalAlignment = HorizontalAlignment.Center; }
private object CreateFlatRedBallTypeNos(NamedObjectSave namedObjectSave, PositionedObjectList <ElementRuntime> listToPopulate, Layer layerToPutOn) { object returnObject = null; ElementRuntime newElementRuntime = null; switch (namedObjectSave.SourceClassType) { case "Layer": case "FlatRedBall.Graphics.Layer": returnObject = CreateLayerObject(namedObjectSave, returnObject); break; case "AxisAlignedRectangle": case "FlatRedBall.Math.Geometry.AxisAlignedRectangle": AxisAlignedRectangle aaRectangle = ShapeManager.AddAxisAlignedRectangle(); if (layerToPutOn != null) { ShapeManager.AddToLayer(aaRectangle, layerToPutOn); } aaRectangle.Name = namedObjectSave.InstanceName; returnObject = aaRectangle; break; case "Camera": case "FlatRedBall.Camera": if (namedObjectSave.IsNewCamera) { returnObject = null; } else { returnObject = SpriteManager.Camera; } break; case "Circle": case "FlatRedBall.Math.Geometry.Circle": Circle circle = ShapeManager.AddCircle(); circle.Name = namedObjectSave.InstanceName; if (layerToPutOn != null) { ShapeManager.AddToLayer(circle, layerToPutOn); } returnObject = circle; break; case "Polygon": case "FlatRedBall.Math.Geometry.Polygon": Polygon polygon = ShapeManager.AddPolygon(); polygon.Name = namedObjectSave.InstanceName; if (layerToPutOn != null) { ShapeManager.AddToLayer(polygon, layerToPutOn); } returnObject = polygon; break; case "Sprite": case "FlatRedBall.Sprite": Sprite sprite = SpriteManager.AddSprite((Texture2D)null); if (layerToPutOn != null) { SpriteManager.AddToLayer(sprite, layerToPutOn); } sprite.Name = namedObjectSave.InstanceName; returnObject = sprite; break; case "SpriteFrame": case "FlatRedBall.ManagedSpriteGroups.SpriteFrame": SpriteFrame spriteFrame = SpriteManager.AddSpriteFrame(null, SpriteFrame.BorderSides.All); if (layerToPutOn != null) { SpriteManager.AddToLayer(spriteFrame, layerToPutOn); } spriteFrame.Name = namedObjectSave.InstanceName; returnObject = spriteFrame; break; case "Text": case "FlatRedBall.Graphics.Text": Text text = TextManager.AddText(""); if (layerToPutOn != null) { TextManager.AddToLayer(text, layerToPutOn); text.SetPixelPerfectScale(layerToPutOn); } text.Name = namedObjectSave.InstanceName; returnObject = text; break; case "Scene": case "FlatRedBall.Scene": Scene scene = new Scene(); scene.Name = namedObjectSave.InstanceName; returnObject = scene; break; default: // do nothing - need to add more types? break; } if (returnObject != null) { if (returnObject is IScalable) { newElementRuntime = new ScalableElementRuntime(null, layerToPutOn, namedObjectSave, CreationOptions.OnBeforeVariableSet, CreationOptions.OnAfterVariableSet); } else { newElementRuntime = new ElementRuntime(null, layerToPutOn, namedObjectSave, CreationOptions.OnBeforeVariableSet, CreationOptions.OnAfterVariableSet); } newElementRuntime.mDirectObjectReference = returnObject; if (returnObject is Camera && !namedObjectSave.IsNewCamera) { SpriteManager.Camera.AttachTo(newElementRuntime, false); SpriteManager.Camera.RelativePosition = Vector3.Zero; newElementRuntime.Z = 40; newElementRuntime.Name = namedObjectSave.InstanceName; } else if (returnObject is FlatRedBall.Utilities.INameable) { newElementRuntime.Name = ((FlatRedBall.Utilities.INameable)returnObject).Name; } else { object nameValueAsObject; if (LateBinder.TryGetValueStatic(returnObject, "Name", out nameValueAsObject)) { newElementRuntime.Name = (string)nameValueAsObject; } } listToPopulate.Add(newElementRuntime); } return(returnObject); }
private void CreateCollision() { frbCollision = ShapeManager.AddCircle(); frbCollision.Radius = 1f; frbCollision.AttachTo(this, false); }
public void UpdateShapes() { #region If Invisible, remove everything if (mVisible == false) { while (mSplinePointsCircles.Count != 0) { ShapeManager.Remove(mSplinePointsCircles.Last); } while (mPathRectangles.Count != 0) { ShapeManager.Remove(mPathRectangles.Last); } } #endregion else { float radius = SplinePointVisibleRadius; #region Create enough SplinePoint Circles for the Spline while (mSplinePoints.Count > mSplinePointsCircles.Count) { Circle newCircle = ShapeManager.AddCircle(); mSplinePointsCircles.Add(newCircle); } #endregion #region Remove any extra SplinePoints while (mSplinePoints.Count < mSplinePointsCircles.Count) { ShapeManager.Remove(mSplinePointsCircles.Last); } #endregion double duration = Duration; int numberOfRectangles = 1 + (int)(duration / PointFrequency); #region Create enough Path Rectangles for the Spline while (numberOfRectangles > mPathRectangles.Count) { AxisAlignedRectangle aar = ShapeManager.AddAxisAlignedRectangle(); mPathRectangles.Add(aar); } #endregion #region Remove any extra Path Rectangles while (numberOfRectangles < mPathRectangles.Count) { ShapeManager.Remove(mPathRectangles.Last); } #endregion #region Update the SplinePoint Circle Positions and Colors for (int i = 0; i < mSplinePoints.Count; i++) { mSplinePointsCircles[i].Position = mSplinePoints[i].Position; mSplinePointsCircles[i].Color = PointColor; mSplinePointsCircles[i].Radius = radius; } #endregion #region Update the Path Rectangle Positions and Colors double fractionOfTime = this.Duration / (double)mPathRectangles.Count; double startTime = 0; if (mSplinePoints.Count != 0) { startTime = mSplinePoints[0].Time; } for (int i = 0; i < mPathRectangles.Count; i++) { mPathRectangles[i].Position = GetPositionAtTime(startTime + i * fractionOfTime); mPathRectangles[i].Color = PathColor; mPathRectangles[i].ScaleX = mPathRectangles[i].ScaleY = radius / 2.0f; } #endregion } }