public virtual bool TemplateEquals(SpellGlyph other) { if (object.ReferenceEquals(other, this)) { return(true); } if (object.ReferenceEquals(other, null)) { return(false); } return(other.GetType() == this.GetType()); }
private void ScrollGlyphType(int cellX, int cellY, int offset) { SpellGlyph glyph = this.script[cellX, cellY]; int index; if (glyph == null) { index = this.glyphTemplates.Length; } else { index = this.glyphTemplates.IndexOfFirst(t => t.Glyph.TemplateEquals(glyph)); } index = (index + offset + (this.glyphTemplates.Length + 1)) % (this.glyphTemplates.Length + 1); this.script[cellX, cellY] = this.CreateGlyph(index); }
public void Advance() { if (this.HasEnded) { return; } SpellGlyph current = this.CurrentGlyph; Log.Game.Write("[ {0}, {1}] {2}", this.pos.X.ToString().PadRight(3), this.pos.Y.ToString().PadRight(3), current.GetType().Name); Log.Game.PushIndent(); if (current.Activate(this)) { this.pos.X += 1; } Log.Game.PopIndent(); }
public SpellGlyphEntry(SpellGlyph glyph, string shortcut) { this.Glyph = glyph; this.Shortcut = shortcut; }
void ICmpUpdatable.OnUpdate() { if (this.script == null) { return; } if (DualityApp.Mouse.Vel.Length > 0.0f) { this.activeCell = this.PixelToGrid(DualityApp.Mouse.X, DualityApp.Mouse.Y); } if (this.activeCell.X != -1 && DualityApp.Mouse.WheelSpeed != 0) { this.ScrollGlyphType(this.activeCell.X, this.activeCell.Y, -DualityApp.Mouse.WheelSpeed); } if (this.activeCell.X != -1 && DualityApp.Mouse.ButtonHit(MouseButton.Right)) { this.script[this.activeCell.X, this.activeCell.Y] = null; } if (DualityApp.Keyboard.KeyHit(Key.Left)) { this.activeCell.X = (this.activeCell.X - 1 + this.script.Width) % this.script.Width; } else if (DualityApp.Keyboard.KeyHit(Key.Right)) { this.activeCell.X = (this.activeCell.X + 1 + this.script.Width) % this.script.Width; } if (DualityApp.Keyboard.KeyHit(Key.Up)) { this.activeCell.Y = (this.activeCell.Y - 1 + this.script.Height) % this.script.Height; } else if (DualityApp.Keyboard.KeyHit(Key.Down)) { this.activeCell.Y = (this.activeCell.Y + 1 + this.script.Height) % this.script.Height; } else if (DualityApp.Keyboard.KeyHit(Key.BackSpace)) { this.script[this.activeCell.X, this.activeCell.Y] = null; this.activeCell.X = (this.activeCell.X - 1 + this.script.Width) % this.script.Width; } if (this.activeCell.X != -1 && (DualityApp.Keyboard.KeyHit(Key.Plus) || DualityApp.Keyboard.KeyHit(Key.KeypadAdd))) { this.ScrollGlyphType(this.activeCell.X, this.activeCell.Y, 1); } else if (this.activeCell.X != -1 && (DualityApp.Keyboard.KeyHit(Key.Minus) || DualityApp.Keyboard.KeyHit(Key.KeypadSubtract))) { this.ScrollGlyphType(this.activeCell.X, this.activeCell.Y, -1); } if (this.activeCell.X != -1 && (DualityApp.Keyboard.KeyHit(Key.Delete))) { this.script[this.activeCell.X, this.activeCell.Y] = null; } if (this.activeCell.X != -1 && (DualityApp.Keyboard.KeyHit(Key.Comma))) { SpellGlyph glyph = this.script[this.activeCell.X, this.activeCell.Y]; if (glyph != null) { glyph.IsNegated = !glyph.IsNegated; } } if (DualityApp.Keyboard[Key.ShiftLeft] || DualityApp.Keyboard[Key.ShiftRight]) { for (int i = 0; i < 9; i++) { if (DualityApp.Keyboard.KeyHit((Key)((int)Key.F1 + i))) { Serializer.WriteObject(this.script, "SpellScript" + i + ".spl", typeof(XmlSerializer)); break; } } } else { for (int i = 0; i < 9; i++) { if (DualityApp.Keyboard.KeyHit((Key)((int)Key.F1 + i))) { this.script = Serializer.TryReadObject <SpellScript>("SpellScript" + i + ".spl") ?? new SpellScript(); break; } } } }
void ICmpRenderer.Draw(IDrawDevice device) { Canvas canvas = new Canvas(device, this.buffer); canvas.State.SetMaterial(new BatchInfo(DrawTechnique.Alpha, ColorRgba.White)); if (activeCell.X != -1) { Point2 cellPos = this.GridToPixel(activeCell.X, activeCell.Y); canvas.PushState(); canvas.State.ColorTint = ColorRgba.White.WithAlpha(0.25f); canvas.FillRect(cellPos.X, cellPos.Y, CellSize, CellSize); canvas.PopState(); } if (this.script != null) { canvas.PushState(); canvas.State.ColorTint = ColorRgba.White.WithAlpha(0.25f); for (int y = 0; y < this.script.Height; y++) { for (int x = 0; x < this.script.Width; x++) { SpellGlyph glyph = this.script[x, y]; Point2 cellPos = this.GridToPixel(x, y); canvas.DrawRect(cellPos.X, cellPos.Y, CellSize, CellSize); } } canvas.PopState(); canvas.PushState(); Texture glyphTex = this.glyphIcons.IsAvailable ? this.glyphIcons.Res.MainTexture.Res : null; canvas.State.SetMaterial(this.glyphIcons); for (int y = 0; y < this.script.Height; y++) { for (int x = 0; x < this.script.Width; x++) { SpellGlyph glyph = this.script[x, y]; if (glyph == null) { continue; } Point2 cellPos = this.GridToPixel(x, y); if (glyphTex != null) { canvas.State.TextureCoordinateRect = glyphTex.LookupAtlas(glyph.GlyphSpriteIndex); } canvas.FillRect(cellPos.X, cellPos.Y, CellSize, CellSize); } } canvas.PopState(); canvas.PushState(); canvas.State.SetMaterial(new BatchInfo(DrawTechnique.Invert, ColorRgba.White)); for (int y = 0; y < this.script.Height; y++) { for (int x = 0; x < this.script.Width; x++) { SpellGlyph glyph = this.script[x, y]; if (glyph == null) { continue; } if (!glyph.IsNegated) { continue; } Point2 cellPos = this.GridToPixel(x, y); canvas.FillRect(cellPos.X, cellPos.Y, CellSize, CellSize); } } canvas.PopState(); } if (activeCell.X != -1) { Point2 cellPos = this.GridToPixel(activeCell.X, activeCell.Y); canvas.PushState(); canvas.State.ColorTint = ColorRgba.White; canvas.DrawRect(cellPos.X, cellPos.Y, CellSize, CellSize); canvas.PopState(); } }