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


C# IObservable.GetType方法代码示例

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


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

示例1: checkColisions

        private void checkColisions(IObservable o)
        {
            if (o.GetType().Name == "Pacman")
            {
                Pacman p = (Pacman)o;
                // if teleport then return
                if (p.pos_logic.x == -1 || p.pos_logic.x == 28) { return; }
                // Else check colisions
                var startChecking = setColisionCheckOrder("Pacman");

                startChecking.checkColision(o);
            }
            else if (o.GetType().Name == "Ghosts")
            {
                var startChecking = setColisionCheckOrder("Ghosts");
                startChecking.checkColision(o);
            }
        }
开发者ID:Nady93,项目名称:PacmanAlpha,代码行数:18,代码来源:ColisionControler.cs

示例2: Update

        public void Update(IObservable observer, object arg)
        {
            if (observer.GetType() != typeof (WeatherData)) return;

            var weatherData = (WeatherData) observer;
            _temperature = weatherData.Temperature;
            _humidity = weatherData.Humidity;
            _pressure = weatherData.Pressure;
            Display();
        }
开发者ID:c9952594,项目名称:HeadFirstDesignPatterns,代码行数:10,代码来源:CurrentConditionsDisplay.cs

示例3: checkColision

 public override void checkColision(IObservable o)
 {
     if (o.GetType().Name == "Pacman")
     {
         Pacman pacman = (Pacman)o;
         if (_maze.maze[pacman.pos_logic.x, pacman.pos_logic.y] == 'O')
         {
             SoundEffect.Instance.playPower();
             pacman.eatDot(new Dot(pacman.pos_logic.x, pacman.pos_logic.y));
             notifyObservers();
             GhostModeControler.Instance.frightenedStart();
         }
         else if (next_controler != null)
         {
             next_controler.checkColision(o);
         }
     }
 }
开发者ID:Nady93,项目名称:PacmanAlpha,代码行数:18,代码来源:SuperDotsColisionControler.cs

示例4: checkColision

 public override void checkColision(IObservable o)
 {
     if (o.GetType().Name == "Pacman")
     {
         Pacman pacman = (Pacman)o;
         if (_maze.maze[pacman.pos_logic.x, pacman.pos_logic.y] == '*')
         {
             pacman.eatDot(new Dot(pacman.pos_logic.x, pacman.pos_logic.y));
             notifyObservers();
             SoundEffect.Instance.playEatDot();
         }
         else
         {
             SoundEffect.Instance.stopEatDot();
             if (next_controler != null)
             {
                 next_controler.checkColision(o);
             }
         }
     }
 }
开发者ID:Nady93,项目名称:PacmanAlpha,代码行数:21,代码来源:DotsColisionControler.cs

示例5: updateData

        public void updateData(IObservable o)
        {
            int tmp_score = _score;
            if (o.GetType().Name == "DotsColisionControler")
            {
                _score += 10;
                _dots_left--;

                switch (_dots_left)
                {
                    case 210: 
                    case 160:
                        GhostModeControler.Instance.releaseGost();
                        break;
                    case 170: // Spawn fruit when pacman eats 70 & 170 dots
                    case 239: // change to 70
                        _maze.fruit = new FoodFactory(13, 20, _grid_pacman, FoodType.Fruit, _level).getFood();
                        break;
                    case 0: // Go to nexe level
                        stopGame();
                        SoundEffect.Instance.stopAll();

                        _game_timer = new DispatcherTimer();
                        _game_timer.Tick += new EventHandler(Next_Level);
                        _game_timer.Interval = new TimeSpan(0, 0, 0, 2);
                        _game_timer.Start();
                    break;
                }

            }
            else if (o.GetType().Name == "SuperDotsColisionControler")
            {
                _score += 50;
            }
            else if (o.GetType().Name == "GhostsColisionControler")
            {
                int points = 200 * (int)Math.Pow(2, ghosts_eaten);
                ghosts_eaten++;
                _score += points;
            }
            else if (o.GetType().Name == "FruitColisionControler")
            {
                Console.Write("You have eaten fruit! \n");
                int points = 250;
                _score += points;
            }
            else
            {
               // Console.Write("Unknow controler \n");

                // Fires when SoundEffects finish play intro music
                if (o.GetType().Name == "SoundEffect" && pacman.is_alive )
                {
                        startGame();
                }
                else if (o.GetType().Name == "Pacman")
                {
                    if (!pacman.is_alive && _game_running)
                    {
                        _game_running = false;
                    }

                }
                else if (o.GetType().Name == "SoundEffect" && !pacman.is_alive)
                {
                    _grid_pacman.Children.Remove(pacman.pacman_img);
                    System.Threading.Thread.Sleep(1000);

                    if (_pacman_lifes >= 0) // Life lost, continue game
                    {
                        if(_pacman_lifes <= 5)
                            removeLifeImg();

                        Console.Write("Pozostało " + _pacman_lifes + " żyć.\n");

                        GhostModeControler.Instance.reset();
                        
                        pacman.revive(_grid_pacman);
                        _ghosts.revive();
                        
                        _game_timer.Start();
                        _labelGetReady.Visibility = Visibility.Visible;
                    }
                    else // End Game, save score
                    {
                        stopGame();
                        
                        _labelSubmitScore.Content = _labelScore.Content;
                        _grid_highscore.Visibility = Visibility.Visible;
                        _maze.clear();
                        removeFruitImgs();
                        Console.Write("Game OVER!!! \n");
                    }
                }
            }

            if (tmp_score != _score)
            {
                _labelScore.Content = String.Format("{0:n0}", _score);
                if(_score >= _highscore)
//.........这里部分代码省略.........
开发者ID:Nady93,项目名称:PacmanAlpha,代码行数:101,代码来源:GameControler.cs


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