当前位置: 首页>>代码示例>>C#>>正文


C# Source.Initialize方法代码示例

本文整理汇总了C#中Source.Initialize方法的典型用法代码示例。如果您正苦于以下问题:C# Source.Initialize方法的具体用法?C# Source.Initialize怎么用?C# Source.Initialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Source的用法示例。


在下文中一共展示了Source.Initialize方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Because_of

 protected override void Because_of()
 {
     var source = new Source { Id = 5, Name = "Bob", Age = 35, Force = "With You" };
     source.Initialize();
     _destination = Mapper.Map<Source, Destination>(source);
     _source = Mapper.Map<Destination, Source>(_destination);
 }
开发者ID:GeertVL,项目名称:AutoMapper,代码行数:7,代码来源:ConditionalMapping.cs

示例2: Update

        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// update the Position of particles, check button presses.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // When the user hits the back button, go back to the title screen
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed) {
                mIsTitleScreenShown = true;
                mIsHiScoreScreenShown = false;
                mIsInstructionsScreenShown = false;
                Sources.Clear();
                TimeLeft = TimeSpan.FromSeconds(30);//as of now games will start off lasting 30 seconds
            }
            //if we are in game, check to make sure there is still time left.
            if (!mIsTitleScreenShown && !mIsHiScoreScreenShown && !mIsInstructionsScreenShown) {
                //make sure there is time left
                if (TimeLeft.Subtract(gameTime.TotalGameTime.Subtract(StartTime)) <= new TimeSpan(0, 0, 0)) {
                    //once game ends, we want to show the high score screen
                    mIsTitleScreenShown = false;
                    mIsHiScoreScreenShown = true;
                    mIsInstructionsScreenShown = false;
                    //check if the new score is better than the old high score
                    if (highScore < PointCounter) {
                        highScore = PointCounter;
                        saveHiScores(highScore);
                    }
                }
            }

            //get the touches on the screen
            TouchCollection touchCollection = TouchPanel.GetState();
            //loop through each touch on the screen
            foreach (TouchLocation tl in touchCollection) {
                if (tl.State == TouchLocationState.Pressed) {
                    //if we are on the title screen, check if the start/instruction buttons are pressed
                    if(mIsTitleScreenShown){
                        if (StartButton.checkClick(tl.Position)) {//start button pressed
                            //initialize a new game
                            PointCounter = 0;
                            StartTime = gameTime.TotalGameTime;
                            mIsTitleScreenShown = false;
                            mIsHiScoreScreenShown = false;
                            mIsInstructionsScreenShown = false;

                        } else if (InstructionsButton.checkClick(tl.Position)) {//instructions button hit
                            //show instructions screen
                            mIsInstructionsScreenShown = true;
                            mIsHiScoreScreenShown = false;
                            mIsTitleScreenShown = false;
                        }
                    //if we are on the high score screen
                    }else if(mIsHiScoreScreenShown){

                        if (ResetButton.checkClick(tl.Position)) {//reset high score button pressed
                            //save a new high score of 0, and set point counter accordinly
                            saveHiScores(0);
                            highScore = 0;
                            PointCounter = 0;
                        } else if (MainMenuButton.checkClick(tl.Position)) {// 'go Home' button pressed
                            //go to main menu, clear the particles, reset timer
                            mIsTitleScreenShown = true;
                            mIsHiScoreScreenShown = false;
                            mIsInstructionsScreenShown = false;

                            Sources.Clear();
                            TimeLeft = TimeSpan.FromSeconds(30);//as of now games will start off lasting 30 seconds

                        }
                    }else if(mIsInstructionsScreenShown){//if we are on the instruction screen, if the user taps anywhere, instruction scren is cleared
                        mIsTitleScreenShown = true;
                        mIsInstructionsScreenShown = false;
                        mIsHiScoreScreenShown = false;
                    }else if(!mIsTitleScreenShown && !mIsHiScoreScreenShown && !mIsInstructionsScreenShown) {//else we are IN GAME
                        //make sure we are above the small buffer on the bottom of the screen (~10% of screen)
                        if (tl.Position.Y < GraphicsAdapter.DefaultAdapter.CurrentDisplayMode.Height / 1.1) {
                            //allow a max of 40 particles on screen
                            if (Sources.Count < 40) {
                                //if there are less than 40 particles, create a new particle where the user tapped
                                Source newSource = new Source(this, new Vector2(tl.Position.X, tl.Position.Y), 1);
                                Sources.Add(newSource);
                                newSource.Initialize();
                            }
                        }
                    }
                    //if the touch was a move, move the basket
                } else if (tl.State == TouchLocationState.Moved ) {
                    if (!mIsTitleScreenShown && !mIsHiScoreScreenShown) {
                        basket.Position.X = tl.Position.X;
                    }
                }
            }
            //if we are ingame, update the Position of sources
            if (!mIsHiScoreScreenShown && !mIsTitleScreenShown && !mIsInstructionsScreenShown) {
                updateSources(gameTime);
            }

            base.Update(gameTime);
//.........这里部分代码省略.........
开发者ID:ExperienceMicrosoft2012,项目名称:Bubble-Basket,代码行数:101,代码来源:Game1.cs


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