// Change mode public void changeMode(GhostMode m) { switch(m) { case GhostMode.Chase: if (mode != GhostMode.House && mode != GhostMode.Eyes && mode != GhostMode.HouseExit) { if (mode == GhostMode.Frightened) { reverseDirection(); _speed = _speed_default; _timer_move.Interval = new TimeSpan(0, 0, 0, 0, _speed); } mode = m; Console.Write(name + " swith to mode: " + m.ToString() + "\n"); } break; case GhostMode.Eyes: if (mode == GhostMode.Frightened) { SoundEffect.Instance.playEatGhost(); SoundEffect.Instance.playAlarm(); // Create label with points int points = 200 * (int)Math.Pow(2, GameControler.Instance.ghosts_eaten - 1); Label label = new Label(); label.Content = points; label.Foreground = new SolidColorBrush(Colors.Gold); label.FontWeight = FontWeights.Bold; Thickness ma = new Thickness(); ma.Left = pos_logic.x * 16 + 16; ma.Top = (pos_logic.y - 2) * 16 - 16; label.Margin = ma; _grid.Children.Add(label); _labelPoints = label; // Init timer which will remove label with points DispatcherTimer timer; timer = new DispatcherTimer(); timer.Interval = new TimeSpan(0, 0, 1); timer.Tick += new EventHandler(Label_Remove); _timerPoints = timer; timer.Start(); // Speed up ghost _speed = 5; _timer_move.Interval = new TimeSpan(0, 0, 0, 0, _speed); mode = m; Console.Write(name + " swith to mode: " + m.ToString() + "\n"); // Change graphic to eyes _ghost_image[0] = Constants.eyesGhostImg[_direction * 2 - 2]; _ghost_image[1] = Constants.eyesGhostImg[_direction * 2 - 1]; } break; case GhostMode.Frightened: if (mode != GhostMode.Scatter && mode != GhostMode.Chase && mode != GhostMode.Frightened) return; Console.Write(name + " swith to mode: " + m.ToString() + "\n"); if(mode != GhostMode.Frightened) reverseDirection(); mode = m; // Slow down ghost _speed = 50; _timer_move.Interval = new TimeSpan(0, 0, 0, 0, _speed); // Change graphic to frightened _ghost_image[0] = Constants.frightenedGhostImg[0]; _ghost_image[1] = Constants.frightenedGhostImg[1]; break; // case GhostMode.House: // break; case GhostMode.HouseExit: can_exit = true; // Reset speed _speed = _speed_default; _timer_move.Interval = new TimeSpan(0, 0, 0, 0, _speed); mode = m; break; case GhostMode.Scatter: if (mode != GhostMode.House && mode != GhostMode.Eyes) { if (mode == GhostMode.Frightened) { reverseDirection(); _speed = _speed_default; _timer_move.Interval = new TimeSpan(0, 0, 0, 0, _speed); } mode = m; Console.Write(name + " swith to mode: " + m.ToString() + "\n"); } break; } }