예제 #1
0
        public bool Execute(AbstractSprite host, GameTime gameTime)
        {
            var player = SceneManager.GetSprites <PlayerSprite>().First();

            SceneManager.GetCurrentScene().BufferedAddSprite(new LaserOrb(Position, Direction, ChargeTime, FireTime));
            return(true);
        }
예제 #2
0
파일: Scene.cs 프로젝트: imthe666st/Intro2d
 /// <summary>
 ///     Adds a sprite to the current top layer scene in the next frame
 /// </summary>
 /// <param name="s">Sprite that's being spawned</param>
 public void BufferedAddSprite(AbstractSprite s)
 {
     if (!BufferedSpriteDictionary.ContainsKey(SceneKey))
     {
         BufferedSpriteDictionary[SceneKey] = new List <AbstractSprite>();
     }
     BufferedSpriteDictionary[SceneKey].Add(s);
 }
예제 #3
0
        private void Process(DrawContainer draw, int i, Pair item, int total)
        {
            int    value     = (int)item.Second;
            double angleplus = 360 * value * 1.0 / total;
            double popangle  = this.angle + (angleplus / 2);

            System.Drawing.Color color = this.ColorFromHSL(this.start, 0.5, 0.5);
            int delta = 30;

            System.Drawing.Color bcolor = this.ColorFromHSL(this.start, 1, 0.5);
            int    r   = 200;
            double rad = Math.PI / 180;

            draw.Gradients.Add(new LinearGradient
            {
                Degrees    = 90,
                GradientID = "Grd" + i,
                Stops      =
                {
                    new GradientStop {
                        Offset = 0, Color = System.Drawing.ColorTranslator.ToHtml(bcolor)
                    },
                    new GradientStop {
                        Offset = 100, Color = System.Drawing.ColorTranslator.ToHtml(color)
                    }
                }
            });

            AbstractSprite sector = this.Sector(250, 250, r, this.angle, this.angle + angleplus);

            sector.FillStyle   = "url(#Grd" + i + ")";
            sector.StrokeStyle = "#fff";
            sector.LineWidth   = 3;

            draw.Items.Add(sector);

            TextSprite text = new TextSprite
            {
                SpriteID    = "text" + i,
                X           = Convert.ToInt32(350 + (r + delta + 55) * Math.Cos(-popangle * rad)),
                Y           = Convert.ToInt32(350 + (r + delta + 25) * Math.Sin(-popangle * rad)),
                Text        = item.First.ToString(),
                FillStyle   = System.Drawing.ColorTranslator.ToHtml(bcolor),
                StrokeStyle = "none",
                GlobalAlpha = 0,
                FontSize    = "20"
            };

            draw.Items.Add(text);

            //sector.Listeners.MouseOver.Handler = string.Format("onMouseOver(this, {0});", i);
            //sector.Listeners.MouseOut.Handler = string.Format("onMouseOut(this, {0});", i);

            this.angle += angleplus;
            this.start += 0.1;
        }
예제 #4
0
파일: Scene.cs 프로젝트: imthe666st/Intro2d
        /// <summary>
        ///     Adds a sprite to the current top layer scene
        /// </summary>
        /// <param name="s">Sprite that's being spawned</param>
        public void AddSprite(AbstractSprite s)
        {
            if (!SpriteDictionary[SceneKey].ContainsKey(s.GetType()))
            {
                var listType = typeof(List <>).MakeGenericType(s.GetType());
                var list     = (IList)Activator.CreateInstance(listType);
                SpriteDictionary[SceneKey][s.GetType()] = list;
            }

            SpriteDictionary[SceneKey][s.GetType()].Add(s);
        }
예제 #5
0
        public SingleLaserPattern(SingleLaserPatternTarget target, AbstractSprite host, float chargeTime = 1.0f, float fireTime = 2.5f)
        {
            if (target == SingleLaserPatternTarget.PlayerSprite)
            {
                var player = SceneManager.GetSprites <PlayerSprite>().First();
                this.Direction = host.Position - player.Position;
            }

            this.ChargeTime = chargeTime;
            this.FireTime   = fireTime;
            this.Position   = host.Position;
        }
예제 #6
0
        public bool Execute(AbstractSprite host, GameTime gameTime)
        {
            var curr  = Angle;
            var delta = Offset / Amount;

            for (var i = 0; i <= Amount; i++)
            {
                SceneManager.GetCurrentScene().BufferedAddSprite(new LinearOrb(host.Position, curr.ToVector2(), this.Speed));
                curr += delta;
            }

            return(true);
        }
예제 #7
0
        public bool Execute(AbstractSprite host, GameTime gameTime)
        {
            Timespan -= gameTime.ElapsedGameTime.TotalSeconds;

            var delta = gameTime.ElapsedGameTime.TotalSeconds;

            if (Timespan < 0.0d)
            {
                delta         += Timespan;
                host.Position += DeltaMovement * (float)delta;
                return(true);
            }

            host.Position += DeltaMovement * (float)delta;
            return(false);
        }
예제 #8
0
        public bool Execute(AbstractSprite host, GameTime gameTime)
        {
            var count = this.Patterns.Count;

            if (count == 0)
            {
                return(true);
            }

            var finished = 0;

            while (finished < count && Patterns.Peek().Execute(host, gameTime))
            {
                Patterns.Dequeue();
                finished++;
            }

            return(finished == count);
        }
예제 #9
0
        public bool Execute(AbstractSprite host, GameTime gameTime)
        {
            this.ElapsedTime += gameTime.ElapsedGameTime.TotalSeconds;

            var isOver = ElapsedTime > this.Timespan;

            if (isOver)
            {
                host.Position += (this.InitialAngle + this.DeltaAngle).ToVector2() * Radius - LastResult;


                return(true);
            }
            else
            {
                var result = (this.InitialAngle + (this.DeltaAngle * (this.ElapsedTime / this.Timespan))).ToVector2() * Radius;
                host.Position  += result - LastResult;
                this.LastResult = result;

                return(false);
            }
        }
예제 #10
0
        public bool Execute(AbstractSprite host, GameTime gameTime)
        {
            this.ElapsedSeconds += gameTime.ElapsedGameTime.TotalSeconds;

            if (ChildLaser == null)
            {
                ChildLaser = new LaserOrb(this.Position, this.Angle.ToVector2(), this.TimespanPreview, this.TimespanFire);
                SceneManager.GetCurrentScene().BufferedAddSprite(ChildLaser);
            }

            if (this.ElapsedSeconds < this.TimespanPreview)
            {
                ChildLaser.Direction = (this.Angle + (this.ElapsedSeconds / this.TimespanPreview) * this.DeltaAngle).ToVector2();
            }
            else if (this.ElapsedSeconds < this.TimespanPreview + this.TimespanFire)
            {
                ChildLaser.Direction = (this.Angle + ((this.ElapsedSeconds - this.TimespanPreview) / this.TimespanFire) * this.DeltaAngle).ToVector2();
            }


            return(this.ElapsedSeconds > this.TimespanPreview + this.TimespanFire);
        }
예제 #11
0
        public bool Execute(AbstractSprite host, GameTime gameTime)
        {
            var finished = true;

            for (var i = 0; i < Patterns.Length; i++)
            {
                if (FinishedPatterns[i])
                {
                    continue;
                }

                if (!Patterns[i].Execute(host, gameTime))
                {
                    finished = false;
                }
                else
                {
                    FinishedPatterns[i] = true;
                }
            }

            return(finished);
        }
예제 #12
0
 public bool Execute(AbstractSprite host, GameTime gameTime)
 {
     host.Position += Delta;
     return(true);
 }
예제 #13
0
 public bool Execute(AbstractSprite host, GameTime gameTime)
 {
     ElapsedSeconds += gameTime.ElapsedGameTime.TotalSeconds;
     return(ElapsedSeconds >= Timeout);
 }
예제 #14
0
        public bool Execute(AbstractSprite host, GameTime gameTime)
        {
            LambdaAction(host, gameTime);

            return(true);
        }
예제 #15
0
 /// <summary>
 /// Draws a sprite.
 /// </summary>
 /// <param name="b">The <see cref="Bitmap"/> object to draw on.</param>
 /// <param name="s">The <see cref="Sprite"/> to draw.</param>
 /// <param name="p">The <see cref="Palette"/> to use to draw the sprite.</param>
 public static void DrawSprite( this Bitmap b, AbstractSprite s, int palette, int portrait )
 {
     s.DrawSprite( b, palette, portrait );
 }
예제 #16
0
 public bool Execute(AbstractSprite host, GameTime gameTime) => LambdaFunc(host, gameTime);
예제 #17
0
 /// <summary>
 /// Draws a sprite.
 /// </summary>
 /// <param name="g">The <see cref="Graphics"/> object to draw on.</param>
 public static void DrawSprite( this Graphics g, AbstractSprite s, int palette, int portrait )
 {
     using (Bitmap b = new Bitmap( s.Width, s.Height ))
     {
         b.DrawSprite( s, palette, portrait );
         g.DrawImage( b, 0, 0 );
     }
 }
예제 #18
0
 public bool Execute(AbstractSprite host, GameTime gameTime)
 {
     host.Health -= this.Amount;
     return(true);
 }