本文整理汇总了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);
}
}
示例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();
}
示例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);
}
}
}
示例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);
}
}
}
}
示例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)
//.........这里部分代码省略.........