internal void CopyElements(MagicElement Other) { for (int E = 0; E < Other.ListLinkedMagicElement.Count; ++E) { MagicElement NewMagicElement = Other.ListLinkedMagicElement[E].Copy(); NewMagicElement.CopyElements(Other.ListLinkedMagicElement[E]); ListLinkedMagicElement.Add(NewMagicElement); } }
public void InitMagicElement(MagicElement ActiveMagicElement) { ActiveMagicElement.InitGraphics(Content); foreach (MagicElement FollowingMagicElement in ActiveMagicElement.ListLinkedMagicElement) { InitMagicElement(FollowingMagicElement); ListMagicElement.Add(FollowingMagicElement); } }
public override void Load() { sprMagicCircle = Content.Load <Texture2D>("Triple Thunder/Magic Ring"); for (int i = ListMagicElement.Count - 1; i >= 0; --i) { MagicElement ActiveMagicElement = ListMagicElement[i]; InitMagicElement(ActiveMagicElement); } }
public MagicEditor(MagicSpell ActiveMagicSpell, ProjectileContext GlobalProjectileContext, ProjectileParams.SharedProjectileParams SharedParams) { this.ActiveMagicSpell = ActiveMagicSpell; this.GlobalProjectileContext = GlobalProjectileContext; this.SharedParams = SharedParams; ZoomLevel = 1f; SelectionRadius = 10; MagicElementSelected = null; ListMagicElement = new List <MagicElement>(); ListMagicElement.AddRange(ActiveMagicSpell.ListMagicCore); ListActionMenuChoice = new ActionPanelHolder(); }
public override void Draw(CustomSpriteBatch g) { GameScreen.DrawBox(g, new Vector2(SpellBoxX, 30), 200, MenuMaxVisibleHeight, Color.White); for (int i = MenuOffset * 2, j = 0; i < ListAllMagicElementChoice.Count && j < MaxNumberVisibleElement; ++i, ++j) { int VisibleElementIndex = (i / 2) - MenuOffset; int X = SpellBoxX + 10 + (i % 2) * ElementSize; int Y = 40 + VisibleElementIndex * ElementSize; MagicElement ActiveElement = ListAllMagicElementChoice[i]; g.Draw(Editor.sprMagicCircle, new Rectangle(X, Y, ElementSize, ElementSize), Color.White); GameScreen.DrawTextMiddleAligned(g, ActiveElement.ToString(), new Vector2(X + 38, Y + ElementSize), Color.White); } }
internal void Load(BinaryReader BR, Dictionary <string, MagicElement> DicMagicElement) { Position = new Vector2(BR.ReadSingle(), BR.ReadSingle()); DoLoad(BR); int ListLinkedMagicElementCount = BR.ReadInt32(); for (int C = 0; C < ListLinkedMagicElementCount; ++C) { string NewMagicElementName = BR.ReadString(); MagicElement NewMagicElement = DicMagicElement[NewMagicElementName].Copy(); NewMagicElement.Load(BR, DicMagicElement); ListLinkedMagicElement.Add(NewMagicElement); } }
public MagicElementSelectionPanel(MagicEditor Editor) : base("Magic Elements", Editor.ListActionMenuChoice, true) { this.Editor = Editor; ListAllMagicElementChoice = new List <MagicElement>(); ListAllMagicElementChoice.AddRange(MagicElement.LoadAllMagicElements().Values); foreach (MagicElement ActiveMagicElement in ListAllMagicElementChoice) { ActiveMagicElement.InitGraphics(Editor.Content); } MenuOffset = 0; ElementSize = 75; MenuMaxVisibleHeight = Constants.Height - 50; MaxNumberVisibleElement = ((MenuMaxVisibleHeight - 40) / ElementSize) * 2; MaxOffset = (int)Math.Ceiling((ListAllMagicElementChoice.Count - MaxNumberVisibleElement) / 2d); SpellBoxX = Constants.Width - 200; }
public void DoUpdateEditor(GameTime gameTime) { if (MouseHelper.InputLeftButtonPressed()) { if (CursorPosition.X >= Constants.Width - 200 && CursorPosition.Y <= 30) { if (ListActionMenuChoice.HasMainPanel && !(ListActionMenuChoice.Last() is MagicElementSelectionPanel)) { ListActionMenuChoice.RemoveAllActionPanels(); } if (!ListActionMenuChoice.HasMainPanel) { ListActionMenuChoice.AddToPanelListAndSelect(new MagicElementSelectionPanel(this)); } else if (ListActionMenuChoice.HasMainPanel && ListActionMenuChoice.Last() is MagicElementSelectionPanel) { ListActionMenuChoice.RemoveAllActionPanels(); } } else if (CursorPosition.X >= Constants.Width - 400 && CursorPosition.Y <= 30) { ListActionMenuChoice.RemoveAllActionPanels(); ListActionMenuChoice.AddToPanelListAndSelect(new MagicPreviewerPanel(Content, ActiveMagicSpell, ListActionMenuChoice, GlobalProjectileContext, SharedParams)); } else { if (ListActionMenuChoice.HasMainPanel && CursorPosition.X >= Constants.Width - 200) { return; } if (ListActionMenuChoice.HasMainPanel && ListActionMenuChoice.Last() is MagicAttributesEditonPanel) { ListActionMenuChoice.RemoveAllActionPanels(); } foreach (MagicElement ActiveMagicElement in ListMagicElement) { if (Math.Sqrt(Math.Pow(CursorPosition.X - ActiveMagicElement.Position.X, 2) + Math.Pow(CursorPosition.Y - ActiveMagicElement.Position.Y, 2)) < ActiveMagicElement.Radius) { MagicElementSelected = ActiveMagicElement; ListActionMenuChoice.AddToPanelListAndSelect(new MagicAttributesEditonPanel(this, ActiveMagicElement)); break; } } } } else if (MouseHelper.InputLeftButtonReleased()) { MagicElementSelected = null; } else if (MouseHelper.InputLeftButtonHold()) { if (MagicElementSelected != null) { MagicElementSelected.Position = CursorPosition; MagicElementSelected.IsValid = true; //Unlink all Magic foreach (MagicElement ActiveMagicElement in ListMagicElement) { ActiveMagicElement.ListLinkedMagicElement.Remove(MagicElementSelected); if (ActiveMagicElement == MagicElementSelected) { continue; } double DistanceBetweenMagicElement = Math.Sqrt(Math.Pow(MagicElementSelected.Position.X - ActiveMagicElement.Position.X, 2) + Math.Pow(MagicElementSelected.Position.Y - ActiveMagicElement.Position.Y, 2)); float TotalRadius = MagicElementSelected.Radius + ActiveMagicElement.Radius; // Collision if (DistanceBetweenMagicElement <= TotalRadius) { MagicElementSelected.IsValid = false; return; } } //Recompute all Magic links foreach (MagicElement ActiveMagicElement in ListMagicElement) { if (ActiveMagicElement == MagicElementSelected) { continue; } double DistanceBetweenMagicElement = Math.Sqrt(Math.Pow(MagicElementSelected.Position.X - ActiveMagicElement.Position.X, 2) + Math.Pow(MagicElementSelected.Position.Y - ActiveMagicElement.Position.Y, 2)); float TotalRadius = MagicElementSelected.Radius + ActiveMagicElement.Radius; // Collision if (DistanceBetweenMagicElement > TotalRadius && DistanceBetweenMagicElement < TotalRadius + SelectionRadius) { ActiveMagicElement.ListLinkedMagicElement.Add(MagicElementSelected); break; } } } else if (KeyboardHelper.KeyHold(Microsoft.Xna.Framework.Input.Keys.LeftAlt)) { CameraOffset.X += MouseHelper.MouseStateCurrent.X - MouseHelper.MouseStateLast.X; CameraOffset.Y += MouseHelper.MouseStateCurrent.Y - MouseHelper.MouseStateLast.Y; ZoomLevel += (MouseHelper.MouseStateCurrent.ScrollWheelValue - MouseHelper.MouseStateLast.ScrollWheelValue) / 100; } } }
public MagicAttributesEditonPanel(MagicEditor Editor, MagicElement ActiveMagicElement) : base("Magic Elements", Editor.ListActionMenuChoice, true) { this.ActiveMagicElement = ActiveMagicElement; }