• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# BCBlockGameState类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中BCBlockGameState的典型用法代码示例。如果您正苦于以下问题:C# BCBlockGameState类的具体用法?C# BCBlockGameState怎么用?C# BCBlockGameState使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



BCBlockGameState类属于命名空间,在下文中一共展示了BCBlockGameState类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: BehaviourAdded

        /// <summary>
        /// sealed override, responsible for most of the bulk of the work of the TimedBehaviour.
        /// </summary>
        /// <param name="toPaddle"></param>
        /// <param name="gamestate"></param>
        public override sealed void BehaviourAdded(Paddle toPaddle, BCBlockGameState gamestate)
        {
            //call base implementation
            base.BehaviourAdded(toPaddle, gamestate);
            //check if we are SingleInstance. If so, that means that there can only be one instance at a time, which may not be surprising given the name.
            if (SingleInstance())
            {
                //check for existing instances of our class. If found, add our delay time to them.
                foreach (var iterate in (from p in toPaddle.Behaviours where p != this select p))
                {
                    if (iterate.GetType() == GetType())
                    {
                        //if same type, change delay, and break from routine.
                        (iterate as TimedPaddleBehaviour).ChangeDelayTime(gamestate, _BehaviourTime, true);
                        //make sure this instance get's removed, too! we are redundant now.
                        gamestate.NextFrameCalls.Enqueue
                            (new BCBlockGameState.NextFrameStartup(() => toPaddle.Behaviours.Remove(this)));

                        return;
                    }
                }
            }

            //if we are either not singleinstance or we are single instance but there are no existing  behaviours of our type attached,
            //do the stuff to add us.
            DelayIdentifier = gamestate.DelayInvoke(_BehaviourTime, TimeDelayRoutine, new object[] {gamestate});
            //if we have ability music, we play it now. Use the SoundManager's capacity to handle temporary music, which works rather well.
            if (_AbilityMusic != "") BCBlockGameState.Soundman.PlayTemporaryMusic(_AbilityMusic, 1.0f, true);
            //hook Death function. If the paddle dies, obviously the time delay will break out early, so we will need to stop the temporary music ourself.
            toPaddle.OnDeath += new Func<Paddle, bool>(toPaddle_OnDeath);
            //call abstract method for initialization.
            TimedBehaviourInitialize(toPaddle, gamestate);
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:38,代码来源:TimedPaddleBehaviour.cs


示例2: getPowerup

 public override bool getPowerup(BCBlockGameState gstate,Paddle onPaddle, GamePowerUp gpower)
 {
     if(onPaddle==null) return false;
     //don't accept it.
     //reject it with great prejudice.
     //move the location temporarily.
     PointF oldposition = gpower.Location;
     SizeF oldsize = gpower.Size;
     gpower.Location = PointF.Empty;
     //draw to a temporary bitmap.
     Bitmap drawtothis = new Bitmap(16, 16);
     Graphics useg = Graphics.FromImage(drawtothis);
     useg.Clear(Color.Transparent);
     gpower.Draw(useg);
     //reset position.
     gpower.Location = oldposition;
     gpower.Size = oldsize;
     //get average.
     var averagedpixel = Color.FromArgb((int)((from p in drawtothis.getPixels() select p.ToArgb()).Average()));
     ExplosionEffect ee = new ExplosionEffect(gpower.Location, 72);
     ee.ExplosionColor = averagedpixel;
     ee.DamageBlocks = false;
     ee.DamagePaddle = false;
     gstate.Defer(() => gstate.GameObjects.AddLast(ee));
     //move  gpower to above the paddle, and invert the Y speed.
     gpower.Location = new PointF(gpower.Location.X, onPaddle.BlockRectangle.Top - gpower.getRectangle().Height - 1);
     gpower.Velocity = new PointF(gpower.Velocity.X, -Math.Abs(gpower.Velocity.Y)*1.1f);
     return true;
 }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:29,代码来源:DeflectorBehaviour.cs


示例3: getRespawnCandidates

        /// <summary>
        /// routine finds all the blocks that can be candidates for respawning.
        /// </summary>
        /// <returns></returns>
        public static List<Block> getRespawnCandidates(BCBlockGameState stateobj)
        {
            //first, we copy the Blocks from the state. This is to prevent a race condition. Note that
            //since it is a shallow clone, it shouldn't have a huge impact on memory usage.
            if (stateobj.PlayingLevel == null) return new List<Block>();
            List<Block> clonedlist;
            try
            {
                clonedlist = stateobj.Blocks.ShallowClone().ToList();

            }
            catch
            {
                return new List<Block>();
            }

            //the primary "issue" here is that we cloned them to make them disparate entities, so we can't just do a direct comparison.
            //truly, the best we can do is compare BlockRectangles. This has something of a weird effect in that Blocks that move can and may very well be
            //"respawned" by virtue of them no longer being in their original positions. It sounds like it could be an interestiong quirk and there isn't
            //a whole lot I can do to prevent it without keeping track of a lot of crap, so I'll see how that goes.

            //get all blocks in stateobj.PlayingLevel.levelblocks for which there is no block in clonedlist with the same BlockRectangle...

            var queried = from bb in stateobj.PlayingLevel.levelblocks
                          where (bb.GetType() != typeof(FrustratorBlock) &&
                                 !(clonedlist.Any((wep) => wep.BlockRectangle == bb.BlockRectangle)))
                          select bb;

            //convert to list, and return.
            return queried.ToList();
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:35,代码来源:FrustratorBlock.cs


示例4: Callback

        public bool Callback(BCBlockGameState gamestate)
        {
            //iterate through all balls...
            BCBlockGameState.Soundman.PlaySound("RANDOMY");

            foreach (cBall iterateball in gamestate.Balls)
            {
                var gotspeed = iterateball.getMagnitude();
                //set a new velocity with that speed.
                iterateball.Velocity = BCBlockGameState.GetRandomVelocity(gotspeed);
                //add some randomly coloured lightorbs...
                foreach (Color addcolor in chosencolors)
                {
                    LightOrb lo = new LightOrb(iterateball.Location, addcolor, 17);
                    PointF usevelocity = BCBlockGameState.GetRandomVelocity(2, 5, BCBlockGameState.GetAngle(new PointF(0, 0), iterateball.Velocity));
                    BCBlockGameState.VaryVelocity(usevelocity, Math.PI / 4);
                    lo.Velocity = usevelocity;
                    gamestate.Particles.Add(lo);

                }

            }

            return true;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:25,代码来源:RandomizerPowerup.cs


示例5: StickyBehaviour

 public StickyBehaviour(BCBlockGameState stateobject)
 {
     //add a hook to the stateobject's targetarea...
     //((PictureBox) stateobject.TargetObject).MouseClick += new MouseEventHandler(StickyBehaviour_MouseClick);
     //((PictureBox)stateobject.TargetObject).MouseClick += new MouseEventHandler(StickyBehaviour_MouseClick);
     stateobject.ClientObject.ButtonDown += ClientObject_ButtonDown;
     stateobject.ClientObject.ButtonUp += ClientObject_ButtonUp;
 }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:8,代码来源:StickyBehaviour.cs


示例6: BuilderShotBehaviour

        public BuilderShotBehaviour(BCBlockGameState stateobject)
        {
            gstate = stateobject;
            //stateobject.ClientObject.ButtonDown += new Func<ButtonConstants, bool>(ClientObject_ButtonDown);
            //stateobject.ClientObject.ButtonUp += new Func<ButtonConstants, bool>(ClientObject_ButtonUp);

            gstate.ClientObject.ButtonDown += ClientObject_ButtonDown;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:8,代码来源:BuilderShotBehaviour.cs


示例7: getAboveBlocks

 public static IEnumerable<Block> getAboveBlocks(BCBlockGameState gstate, RectangleF testrect)
 {
     var aboveblocks = from b in gstate.Blocks where b.BlockRectangle.IntersectsWith(testrect) select b;
     return from bb in aboveblocks
            where Math.Abs(bb.CenterPoint().Y - testrect.CenterPoint().Y) >
                Math.Abs(bb.CenterPoint().X - testrect.CenterPoint().Y)
            select bb;
 }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:8,代码来源:FallingBlockObject.cs


示例8: PerformFrame

        public override bool PerformFrame(BCBlockGameState gamestate)
        {
            if (removeobject is BasePaddleBehaviour)
                ((BasePaddleBehaviour) removeobject).BehaviourRemoved(RemoveFrompaddle, gamestate);

            RemoveFrompaddle.Behaviours.Remove(removeobject);
            Debug.Print("removed...");

            return true;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:10,代码来源:BehaviourRemoverProxy.cs


示例9: BallSplit

        private bool BallSplit(BCBlockGameState gs)
        {
            List<cBall> removethese = new List<cBall>();
            List<cBall> addballs = new List<cBall>();
            if (gs.PlayerPaddle != null)
            {
                //check for Sticky...
                if (gs.PlayerPaddle.Behaviours.Any((w) => w is StickyBehaviour))
                {
                    foreach (var unstick in gs.PlayerPaddle.Behaviours.Where((w) => w is StickyBehaviour))
                        ((StickyBehaviour)unstick).ReleaseAllBalls();

                }

            }
            //            foreach(var splitball in (from m in gs.Balls where !m.hasBehaviour(typeof(TempBallBehaviour)) select m))
            foreach (var splitball in gs.Balls)
            {
                //split splitball into SplitCount new balls.
                //first, take note of the absolute speed of the ball.
                double magnitude = splitball.TotalSpeed;
                //how big will the angle be between them?
                double anglediff = (Math.PI * 2) / SplitCount;
                double startangle = BCBlockGameState.rgen.NextDouble() * Math.PI * 2;

                for (int i = 0; i < SplitCount; i++)
                {
                    double fireangle = startangle + (anglediff * i);

                    PointF usevelocity = new PointF((float)(Math.Cos(fireangle) * magnitude), (float)(Math.Sin(fireangle) * magnitude));

                    //clone the ball...
                    //use the proper type of the object, it could be a subclass!
                    cBall ballcreate = (cBall)Activator.CreateInstance(splitball.GetType(), splitball);

                    //set the velocity of the clone to the calculated value.

                    ballcreate.Velocity = usevelocity;
                    addballs.Add(ballcreate);

                }

                removethese.Add(splitball);
            }
            foreach (var addit in addballs) gs.Balls.AddLast(addit);

            foreach (cBall removeit in removethese)
            {
                gs.Balls.Remove(removeit);

            }
            BCBlockGameState.Soundman.PlaySound("ELECTRICLASER", false);
            return true;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:54,代码来源:BallSplitterPowerup.cs


示例10: GivePowerTo

        public override bool GivePowerTo(BCBlockGameState gamestate, GameCharacter gamechar)
        {
            BCBlockGameState.Soundman.PlaySound("1up");
            BasicFadingText bft = new BasicFadingText("1-Up", Location, new PointF(0, -2), new Font(BCBlockGameState.GetMonospaceFont(), 14), new Pen(Color.Black,2), new SolidBrush(Color.Green), 500);

            gamestate.playerLives++;
            gamestate.Forcerefresh = true;
            gamestate.Defer(() => gamestate.GameObjects.AddLast(bft));

            return true;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:11,代码来源:GameCharacter.cs


示例11: BehaviourAdded

        public override void BehaviourAdded(Paddle toPaddle, BCBlockGameState gamestate)
        {
            ownerpaddle = toPaddle;

            //remove any existing terminator behaviour.
            foreach (var loopbeh in toPaddle.Behaviours)
            {
                if (loopbeh is TerminatorBehaviour)
                    gstate.GameObjects.AddLast(new BehaviourRemoverProxy(toPaddle, loopbeh));
            }

            base.BehaviourAdded(toPaddle, gamestate);
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:13,代码来源:BuilderShotBehaviour.cs


示例12: PerformFrame

        public override void PerformFrame(BCBlockGameState gamestate, Paddle pPaddle)
        {
            var rg = BCBlockGameState.rgen;
            base.PerformFrame(gamestate, pPaddle);
            useoverlaybrush = new SolidBrush(new HSLColor(rg.NextDouble()*240, 240f, 120f));
            //spawn a sparkle.
            var paddlerect = pPaddle.Getrect();
            PointF randompoint = new PointF(paddlerect.Left + (float) (paddlerect.Width*rg.NextDouble()),
                                            paddlerect.Top + (float) (paddlerect.Height*rg.NextDouble()));

            Sparkle s = new Sparkle(randompoint, BCBlockGameState.GetRandomVelocity(0, 2),
                                    new HSLColor(rg.NextDouble()*240, 240, 120));
            gamestate.NextFrameCalls.Enqueue(new BCBlockGameState.NextFrameStartup(() => gamestate.Particles.Add(s)));
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:14,代码来源:InvinciblePaddleBehaviour.cs


示例13: BehaviourAdded

        public override void BehaviourAdded(Paddle toPaddle, BCBlockGameState gamestate)
        {
            base.BehaviourAdded(toPaddle, gamestate);
            gamestate.Defer(()=>{
                                    addedobject = new ProxyObject((po, gs) =>
                                                                      {

                                                                          PerformFrame(toPaddle, gamestate);
                                                                          return false;

                                                                      }, null);
                                    gamestate.GameObjects.AddLast(addedobject);
            });
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:14,代码来源:DeflectorBehaviour.cs


示例14: PowerupCallback

        public bool PowerupCallback(BCBlockGameState gamestate)
        {
            //PaddleMinusPowerup makes the paddle smaller...
            if ((gamestate.PlayerPaddle.PaddleSize.Width) > paddlesizechangeamount + 10)
            {

                SizeF changedsize = new SizeF(gamestate.PlayerPaddle.PaddleSize.Width - paddlesizechangeamount, gamestate.PlayerPaddle.PaddleSize.Height);
                //gamestate.PlayerPaddle.PaddleSize =
                //give it a size object that will change it's size...
                gamestate.PlayerPaddle.Behaviours.Add(new PaddleBehaviours.SizeChangeBehaviour(changedsize, new TimeSpan(0, 0, 0, 1)));
                BCBlockGameState.Soundman.PlaySound("shrink");
            }
            AddScore(gamestate, -5, "Paddle--");
            return true;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:15,代码来源:PaddleMinusPowerup.cs


示例15: PerformBlockHit

        public override bool PerformBlockHit(BCBlockGameState parentstate, cBall ballhit)
        {
            bool nodef = false;
            DefaultHitSound = "";

            if(!Silent) PlayBlockSound(ballhit, "METAL");
            RaiseBlockHit(parentstate, ballhit, ref nodef);

            //temporary code for testing powerup:
            //invincible blocks will now "emerge" a mushroom.
            //MushroomPower mp = new MushroomPower(this);
            //parentstate.GameObjects.AddLast(mp);

            return false;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:15,代码来源:InvincibleBlock.cs


示例16: PerformBlockHit

        public override bool PerformBlockHit(BCBlockGameState parentstate, cBall ballhit, ref List<cBall> ballsadded)
        {
            BASeBlock.BCBlockGameState.Soundman.PlaySound("1UP", 0.9f);
            Block.PlayDefaultSound(ballhit);
            //base.AddScore(parentstate, 40);
            //no idea why the above is broken...
            float useangle = (float)BCBlockGameState.rgen.NextDouble() * (float)(2 * Math.PI);
            PointF spawnlocation = new PointF((float)BlockRectangle.Left+(BlockRectangle.Width/2),(float)BlockRectangle.Top + (BlockRectangle.Height/2));

            float useXSpeed = (float)Math.Sin(useangle) * spawnvelocity;
            float useYSpeed = (float)Math.Cos(useangle) * spawnvelocity;
            PointF spawnvel = new PointF(useXSpeed,useYSpeed);
            ballsadded.Add(new cBall(spawnlocation,spawnvel));
            StandardSpray(parentstate, ballhit);

            return true;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:17,代码来源:testscript.cs


示例17: PowerUpCallback

        public bool PowerUpCallback(BCBlockGameState gamestate)
        {
            //Old code...
            //has the same effect as a frustratorblock.
            //and how do we get the frustrator effect to "engage"?
            //we add a frustrator block, and break it off-screen. couldn't be simpler.
            // FrustratorBlock createblock = new FrustratorBlock(new RectangleF(-500, -500, 50, 50));
            // gamestate.Blocks.AddLast(createblock);
            // BCBlockGameState.Block_Hit(gamestate, createblock);
            //HAHAHA...

            //Change: this powerup now spawns a frustratorball instead...
            FrustratorBall fb = new FrustratorBall(Location, BCBlockGameState.GetRandomVelocity(3, 6));
            gamestate.Balls.AddLast(fb);

            return true;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:17,代码来源:FrustratorPowerup.cs


示例18: PerformBlockHit

        public override bool PerformBlockHit(BCBlockGameState parentstate, cBall ballhit)
        {
            var ballrel = getBallRelative(ballhit);

            //we only take damage if we are hit on one of the sides...
            if (ballrel == BallRelativeConstants.Relative_Left || ballrel == BallRelativeConstants.Relative_Right)
            {
                Damage++;
                base.PerformBlockHit(parentstate, ballhit);
                return Health < Damage;
            }
            else
            {
                base.PerformBlockHit(parentstate, ballhit);
                return false;

            }
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:18,代码来源:WoodBlock.cs


示例19: PowerUpCallback

        public bool PowerUpCallback(BCBlockGameState gamestate)
        {
            float randgen = (float)BCBlockGameState.rgen.NextDouble() * Spawnchancesum;
            int useindex = RandomValueToIndex(randgen, spawnchance);
            Type grabtype = spawntypes[useindex];

            SizeF useSize = new SizeF(16, 16);
            PointF useposition =
                new PointF(gamestate.GameArea.Width * (float)BCBlockGameState.rgen.NextDouble(), (gamestate.GameArea.Height - 72) * (float)BCBlockGameState.rgen.NextDouble());

            GameEnemy genenemy = (GameEnemy)Activator.CreateInstance(grabtype, useposition, useSize);
            gamestate.Defer(() =>
                                {
                                    gamestate.GameObjects.AddLast(genenemy);

                                    AddScore(gamestate, 10);
                                });
            return true;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:19,代码来源:EnemySpawnerPowerUp.cs


示例20: Callback

        public bool Callback(BCBlockGameState gamestate)
        {
            BCBlockGameState.Soundman.PlaySound("RANDOMY");
            int numchange = Math.Min(BCBlockGameState.rgen.Next(4, 10),gamestate.Blocks.Count);

            for (int i = 0; i < numchange; i++)
            {
                bool err = true;
                while (err)
                {
                    try
                    {
                        //choose a random block...
                        Block chosenblock = BCBlockGameState.Choose(gamestate.Blocks);
                        //choose a random block type to replace it with.
                        //Type replacewith = BCBlockGameState.Choose(BCBlockGameState.BlockTypes.ManagedTypes);
                        Type replacewith = BCBlockGameState.Choose(PossibleTypes);
                        Block createdblock = (Block)Activator.CreateInstance(replacewith, chosenblock.BlockRectangle);

                        //remove the old block...
                        gamestate.Blocks.Remove(chosenblock);
                        //add the new one (the "swapped" one...
                        gamestate.Blocks.AddLast(createdblock);
                        //set refresh variable to tell the paint routine that it has to refresh the blocks.

                        err = false;
                    }
                    catch
                    {
                        err = true;

                    }
                    //create the new block. remember, block constructor is a single RectangleF. catch errors
                }

            }
            gamestate.Forcerefresh = true;
            gamestate.NextFrameCalls.Enqueue(new BCBlockGameState.NextFrameStartup((a, q) => { gamestate.Forcerefresh = true; return true; },null));

            return true;
        }
开发者ID:BCProgramming,项目名称:BASeBlock,代码行数:41,代码来源:BlockRandomizerPowerup.cs



注:本文中的BCBlockGameState类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# BD类代码示例发布时间:2022-05-24
下一篇:
C# BAsyncResultSendMethod类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap