Ejemplo n.º 1
0
        public static Spell Cast(ISpellHost boundTo, SpellScript script)
        {
            if (script == null)
            {
                throw new ArgumentNullException("script");
            }

            Spell spell = new Spell();

            spell.boundTo = boundTo;
            spell.script  = script;
            spell.InitThreads();
            return(spell);
        }
Ejemplo n.º 2
0
        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;
                    }
                }
            }
        }