public GamePresenter(IGameModel model, IGameView view) { _model = model; _view = view; _view.Init(this); }
/// <inheritdoc/> public void MakeDecision(IGameModel model, IGameLogic logic) { List <IActiveNetworkController> owned = this.GetOwnedNetworkController(model); List <INetworkController> notowned = this.GetNotOwnedNetworkController(model); foreach (var item in owned) { foreach (var utp in item.Utps) { if (utp.IsActive && utp.Target.Owner == this && utp.Target.IsEnable && utp.Target is IServerNetworkController && this.RandomDecision(this.abackLimit)) { logic.DisconectUtp(utp); } if (utp.IsActive && utp.Mode == UtpModes.ConnectedToServer && utp.Target.Owner != this && utp.Target.Life < utp.Cables.Count - 5 && this.RandomDecision(this.cutLimit)) { logic.CutUtp(utp, utp.Cables[utp.Target.Life]); } } if (this.RandomDecision(this.attackLimit) && item.Utps.Count < item.CableCapacity && notowned.Count != 0) { logic.ConnectTwoServer(item, notowned[random.Next(0, notowned.Count)]); } } }
/// <summary> /// Initializes a new instance of the <see cref="GameLogic"/> class. /// Sets up the dependency injection to the game's model. /// </summary> /// <param name="gameModel">Model of the game's elements.</param> public GameLogic(IGameModel gameModel) { this.gameModel = gameModel; gameModel.FlyingTrackingPath = this.BreadthFirstSearch(this.GetFlyingEnemyNeighbours); gameModel.BasicTrackingPath = this.BreadthFirstSearch(this.GetRegularEnemyNeighbours); this.InitailzeTimers(); }
private List <IActiveNetworkController> GetOwnedNetworkController(IGameModel model) { return(model.GameObjects .Where(x => x is IActiveNetworkController) .Select(x => x as IActiveNetworkController) .Where(x => x.Owner == this).ToList()); }
public PopBalloonCommand(IGameModel gameModel, IGameLogicProvider gameLogicProvider, int row, int col) : base(gameModel) { this.gameLogicProvider = gameLogicProvider; this.row = row; this.col = col; }
public void init(ISpotlightModel spotlightModel, IList <Vector2> drillAirBubblePositionList, IPlayerModel playerModel, IGameModel gameModel) { // get the model from the mediator this.m = spotlightModel; this.playerModel = playerModel; this.gameModel = gameModel; // get the reference to the list of airbubbles from the mediator; this.drillAirBubblePositionList = drillAirBubblePositionList; // call View object's start base.Start(); // position well above everything else transform.position = new Vector3(transform.position.x, transform.position.y, -9); // start at the median angle m.currentAngle = m.spotMedianAngle - m.fieldOfViewRange / 2; // Add required Mesh components meshRenderer = gameObject.AddComponent <MeshRenderer>(); meshRenderer.material = Resources.Load <Material>("Materials/Transparent-VertexLit"); meshRenderer.castShadows = meshRenderer.receiveShadows = false; meshRenderer.sortingLayerName = "SpotLight"; meshFilter = gameObject.AddComponent <MeshFilter>(); // if the parent is a zeppelin, adjust the cone of the spotlight if (transform.parent.gameObject.GetComponent <ZeppelinView>() != null) { m.updateConeSettingsForZeppelin(); } }
void Start() { _model = new GameModel(); var v = FindObjectsOfType <MonoBehaviour>().OfType <IGameView>(); var gameViews = v.ToList(); if (gameViews.Any()) { _view = gameViews[0]; } if (_view == null) { throw new Exception("Не найден объект IGameView"); } Instantiate(_model.GetBackgroundManager(), Vector3.zero, Quaternion.identity, _view.GetTransform); Instantiate(_model.GetCharacterManager(), Vector3.zero, Quaternion.identity, _view.GetTransform); Instantiate(_model.GetDialogManager(), Vector3.zero, Quaternion.identity, _view.GetTransform); // foreach (var prefab in _prefabs) { // Instantiate(prefab, Vector3.zero, Quaternion.identity, _view.GetTransform); // } _view.Init(this); ShowFirstScene(); }
public FieldPage() { InitializeComponent (); Padding = new Thickness (0, Device.OnPlatform (20, 0, 0), 0, 0); GameModel = DependencyService.Get<IGameModel> (); }
void Start() { transform.Find("BtnStart").GetComponent <Button>() .onClick.AddListener(() => { gameObject.SetActive(false); this.SendCommand <StartGameCommand>(); }); transform.Find("BtnBuyLife").GetComponent <Button>() .onClick.AddListener(() => { this.SendCommand <BuyLifeCommand>(); }); mGameModel = this.GetModel <IGameModel>(); mGameModel.Gold.Register(OnGoldValueChanged); mGameModel.Life.Register(OnLifeValueChanged); // 第一次需要调用一下 OnGoldValueChanged(mGameModel.Gold.Value); OnLifeValueChanged(mGameModel.Life.Value); transform.Find("BestScoreText").GetComponent <Text>().text = "最高分:" + mGameModel.BestScore.Value; }
/// <summary> /// Method for Loading the game to our gamemodel. /// </summary> /// <param name="gamemodel">The status that we're getting from the load.</param> /// <param name="loadFile">The file we're loading from.</param> public void LoadGame(out IGameModel gamemodel, string loadFile) { gamemodel = null; if (Directory.Exists(this.path)) { gamemodel = this.DeserializeFromTxtFile(loadFile); } }
public GamePresenter(GameSettings settings) { _model = new GameModel(settings); _view = new GameForm(); HookViewEvents(); HookModelEvents(); _model.StartGame(); }
public MainGamePage() { this.InitializeComponent(); _engine = new GameEngine(); _gameMode = _gameModel.GameModeModel; Loaded += MainGamePageLoaded; this.DataContext = _gameModel; }
private INetworkController FindNetworkController(Point location, IGameModel gm) { return(this.GameObjects .Where(x => x is INetworkController) .Select(x => x as INetworkController) .Where(x => new Rectangle((int)(x.X - (gm.TileSize / 2)), (int)(x.Y - (gm.TileSize / 2)), gm.TileSize, gm.TileSize).Contains(location)) .FirstOrDefault()); }
public GameStartingPresenter(IPlayerBallEntity playerBallEntity, IPlayerBallView playerBallView, IGameModel gameModel) { PlayerBallEntity = playerBallEntity.CheckNull(); PlayerBallView = playerBallView.CheckNull(); GameModel = gameModel.CheckNull(); }
private void OnDestroy() { mGameModel.Gold.UnRegister(OnGoldValueChanged); mGameModel.Life.UnRegister(OnLifeValueChanged); mGameModel.Score.UnRegister(OnScoreValueChanged); mGameModel = null; mCountDownSystem = null; }
public override void Copy(out IModel result, IModel rawModel = null) { CopyRaw(); IGameModel target = GetNewModel(); target.InitModel(ref mRawCopy); result = target as IModel; }
public Engine(IUserInterface ui, IUserInputValidator validator, ICommandFactory commandFactory, IGameModel gameModel, IGameLogicProvider gameLogicProvider) { this.userInterface = ui; this.validator = validator; this.create = commandFactory; this.game = gameModel; this.gameLogicProvider = gameLogicProvider; this.highScoreChart = new string[2, 5]; }
/// <inheritdoc/> public IGameModel InitModel() { this.model = new GameModel(new Player(GameModel.GameWidth / 2, GameModel.GameHeight - 150, 100, 100, 3), new List <Enemy>(), new List <Bullet>(), new List <Bullet>(), 1); this.space = GameModel.GameWidth / 8; this.model.Enemiesinthiswave = this.model.Wave * 10; this.model.Enemies = this.EnemyPlacer(); this.model.Score = this.Score; return(this.model); }
public RoyalRoomLogic(int GamersInRoom) { RoomModel = new RoyalGameModel(GamersInRoom); RoomModel.Event_HappenedEndGame += RoomModel_Event_HappenedEndGame; timerNewIteration = new Timer(16) { SynchronizingObject = null, AutoReset = true }; timerNewIteration.Elapsed += TickQuantTimer; quantTimer = new QuantTimer(); }
public Controller(IViewPlayer viewPlayer1, IViewPlayer viewPlayer2, IViewLog viewLog, IGameModel gameModel) { this.viewPlayer1 = viewPlayer1; this.viewPlayer2 = viewPlayer2; this.viewLog = viewLog; this.gameModel = gameModel; viewPlayer1.SetController(this); viewPlayer2.SetController(this); viewLog.SetController(this); gameModel.AddObservers(viewPlayer1, viewPlayer2, viewLog); StartNewGame(); }
/// <summary> /// Initializes a new instance of the <see cref="GameDisplay"/> class. /// </summary> /// <param name="model">IGameModel object</param> /// <param name="width">Width of field</param> /// <param name="height">Height of field</param> public GameDisplay(IGameModel model, double width, double height) { this.model = model; this.width = width; this.height = height; this.tileSize = 20; this.player1Brush = this.GetPlayerBrush(@"..\..\Images\player1.png"); this.player2Brush = this.GetPlayerBrush(@"..\..\Images\player2.png"); this.obstacleBrush = this.GetObjectBrush(@"..\..\Images\obstacle.png"); this.turboBrush = this.GetObjectBrush(@"..\..\Images\turbo.png"); }
public GameMaster(IFigureController figureController, IBoardModel boardModel, IGameModel gameModel, IFigurePostTurnLogicManager figurePostTurnLogicManager, IGameMoveTurnManager gameMoveTurnManager) { FigureController = figureController.CheckNull(); BoardModel = boardModel.CheckNull(); GameModel = gameModel.CheckNull(); FigurePostTurnLogicManager = figurePostTurnLogicManager.CheckNull(); GameMoveTurnManager = gameMoveTurnManager.CheckNull(); }
public NetworkClient(IGameModel model, int index, ConnectedClient <IMessage> client, string nick, string password) { this.model = model; this.Player = model.Players[index]; visibleArea = new RectangleF(0, 0, widthVisibleArea, heightVisibleArea); Nick = nick; this.client = client; this.client.Controler = this; this.client.EventEndSession += Client_EventEndSession; Password = password; //посылаем сообщение о том, что игрок добавлен в игровую комнату this.client.SendMessage(new AddInBattle(Player.ID)); }
public GameViewModel(IGameModel gameModel, IUserViewModel userViewModel, IUserCollection userCollection) { this.gameModel = gameModel; this.userViewModel = userViewModel; this.userCollection = userCollection; this.gameModel.PropertyChanged += GameModel_PropertyChanged; this.User1.PropertyChanged += User1_PropertyChanged; this.User2.PropertyChanged += User1_PropertyChanged; if (User1.Army.Count() != 0) { int i = 0; foreach (var mage in User1.Army) { var mageViewModel = new MageKnightBattleViewModel(mage, this.User1); mageViewModel.PropertyChanged += MageViewModel_PropertyChanged; double range = mageViewModel.Range; double speed = mageViewModel.Dial.Click.Speed.Value; double max = Math.Max(range, speed); double height = max * 100; double x = height - 50 - 1100; double y = height - 50 - 200; mageViewModel.XCord = -x + 100 * i; mageViewModel.YCord = -y; i++; userViewModel.ArmyViewModels.Add(mageViewModel); activeMageKnights.Add(mageViewModel); } } if (User2.Army.Count() != 0 && User2.Id != User1.Id) { int i = 0; foreach (var mage in User2.Army) { var mageViewModel = new MageKnightBattleViewModel(mage, this.User2); double range = mageViewModel.Range; double speed = mageViewModel.Dial.Click.Speed.Value; double max = Math.Max(range, speed); double height = max * 100; double x = height - 50 - 1100; double y = height - 50 - 3700; mageViewModel.XCord = -x + 100 * i; mageViewModel.YCord = -y; i++; mageViewModel.PropertyChanged += MageViewModel_PropertyChanged; userViewModel.ArmyViewModels.Add(mageViewModel); activeMageKnights.Add(mageViewModel); } } }
private void Control_Loaded(object sender, RoutedEventArgs e) { this.model = new GameModel(); this.highscoreRepo = new HighscoreRepository(); Window win = Window.GetWindow(this); if ((win as MainWindow).AutoOrManual) { this.saveGameRepo = new ManualSaveGameRepository((win as MainWindow).LoadFilePath); } else { this.saveGameRepo = new AutoSaveGameRepository(); } this.loadigLogic = new LoadingLogic(this.model, this.saveGameRepo, this.highscoreRepo); this.model = this.loadigLogic.Play(); this.gameLogic = new GameLogic(this.model); this.renderer = new GameRenderer(this.model); if (win != null) { win.KeyDown += this.Win_KeyDown; win.MouseLeftButtonDown += this.Left_MouseButtonDown; win.MouseMove += this.Win_MouseMove; } this.updateTimer = new System.Timers.Timer(); this.updateTimer.Elapsed += new ElapsedEventHandler(this.UpdateScreen); this.updateTimer.Interval = 30; this.updateTimer.AutoReset = true; this.shootOnce = new DispatcherTimer(); this.shootOnce.Interval = TimeSpan.FromMilliseconds(this.rnd.Next(1000, 2000)); this.shootOnce.Tick += this.ShootingEnemies; this.moveOnce = new DispatcherTimer(); this.moveOnce.Interval = TimeSpan.FromMilliseconds(this.rnd.Next(200, 500)); this.moveOnce.Tick += this.MoveEnemies; this.moveBossTimer = new DispatcherTimer(); this.moveBossTimer.Interval = TimeSpan.FromMilliseconds(800); this.moveBossTimer.Tick += this.MoveBoss; this.levelTimer = new DispatcherTimer(); this.levelTimer.Interval = TimeSpan.FromMilliseconds(200); this.levelTimer.Tick += this.LevelTimer_Tick; if (!this.model.GameIsPaused) { this.updateTimer.Enabled = true; this.levelTimer.Start(); } this.InvalidateVisual(); }
/// <inheritdoc/> public void LoadGame(IGameModel gameModel) { this.GameObjects = gameModel.GameObjects; this.LifeLimit = gameModel.LifeLimit; this.LocalPlayer = gameModel.LocalPlayer; this.Messages = gameModel.Messages; this.Players = gameModel.Players; this.Score = gameModel.Score; this.TickCount = gameModel.TickCount; this.MapWidth = gameModel.MapWidth; this.MapHeight = gameModel.MapHeight; this.GameType = gameModel.GameType; this.MapNumber = gameModel.MapNumber; }
/// <summary> /// Instances A game by its name /// </summary> /// <param name="GameNumberToStart">The index of the game in the config</param> public void StartGameByName(object StartRequester, string GameNameToStart) { IGameModel gameConfig = Config.GetGameByName(GameNameToStart); GameIsStartingEvent?.Invoke(this, new GameStartingEventArgs { GameName = gameConfig.Name, RequestingObj = StartRequester }); RunningGame = new InstanceGame(gameConfig); RunningGame.GameHasEndedEvent += GameEndedEventChain; RunningGame.StartGame(); GameHasStartedEvent?.Invoke(this, new GameStartedEventArgs { GameName = gameConfig.Name }); }
public GameCompletedPresenter(IBoardTileModel boardTileModel, IBoardTileRemover boardTileRemover, ILootModel lootModel, ILootRemover lootRemover, IGameModel gameModel, IPlayerBallView playerBallView) { BoardTileModel = boardTileModel.CheckNull(); BoardTileRemover = boardTileRemover.CheckNull(); LootModel = lootModel.CheckNull(); LootRemover = lootRemover.CheckNull(); GameModel = gameModel.CheckNull(); PlayerBallView = playerBallView.CheckNull(); }
/// <summary> /// SaveHighScore method. /// </summary> /// <param name="gm">the first parameter of the constuctor.</param> public /*static*/ void SaveHighScore(IGameModel gm) { if (File.Exists("highscores.txt")) { StreamWriter sw = File.AppendText("highscores.txt"); sw.WriteLine(gm.Name + ";" + gm.BlockNumber); sw.Close(); } else { StreamWriter sw = new StreamWriter("highscores.txt"); sw.WriteLine(gm.Name + ";" + gm.BlockNumber); sw.Close(); } }
// Utiliza el modelo y bindea un comando a un evento. public InputHandler(IGameModel model) { commands[Key.F] = new ShowBoundingBoxCommand(model); commands[Key.Left] = new MoveLeftCommand(model); commands[Key.A] = commands[Key.Left]; commands[Key.Right] = new MoveRightCommand(model); commands[Key.D] = commands[Key.Right]; commands[Key.Up] = new MoveUpCommand(model); commands[Key.W] = commands[Key.Up]; commands[Key.Down] = new MoveDownCommand(model); commands[Key.S] = commands[Key.Down]; commands[Key.Space] = new JumpCommand(model); commands[(Key)TgcD3dInput.MouseButtons.BUTTON_LEFT] = new ClickLeftCommand(model); commands[(Key)TgcD3dInput.MouseButtons.BUTTON_RIGHT] = new ClickRightCommand(model); }
/// <inheritdoc/> public IGameModel Play() { this.gameModel = this.saveGameRepository.GetSaveGame(); AutoSaveGameRepository asgr = new AutoSaveGameRepository(); asgr.Insert(this.gameModel as GameModel); if (this.gameModel == null) { this.GenerateMap(); this.saveGameRepository.Insert(this.gameModel as GameModel); return(this.gameModel); } return(this.gameModel); }
public GraphicEngine(IEventBasedUserInterface ui, IUserInputValidator validator, ICommandFactory commandFactory, IGameModel gameModel, IGameLogicProvider gameLogicProvider) : base(ui, validator, commandFactory, gameModel, gameLogicProvider) { ui.Raise += new EventHandler(this.HandleUserInput); }
public GameViewModel(bool playerIsWhite) { _theGame = new GameModel(); ChessGridItem[] items = new ChessGridItem[64]; bool switcher = true; PrintToScreen = "Welcome Make Your Move"; for (int i = 0; i < items.Length; i++) { items[i] = new ChessGridItem {Index = i}; if (switcher) { items[i].SquareColor = LightSquare; } else { items[i].SquareColor = DarkSquare; } //items[i].PieceColor = "Red"; if (_theGame.AllPieces[i]) // can this block be refactored to be the refresh board it needs to be a // //loop but this may be a method that the larger method uses { if (_theGame.AllWhitePieces[i]) { items[i].PieceColor = White; if (_theGame.WhitePawns[i]) { items[i].PieceShape = Pawn; } else if(_theGame.WhiteRooks[i]) { items[i].PieceShape = Rook; } else if(_theGame.WhiteKnights[i]) { items[i].PieceShape = Knight; } else if(_theGame.WhiteBishops[i]) { items[i].PieceShape = Bishop; } else if(_theGame.WhiteQueens[i]) { items[i].PieceShape = Queen; } else if (_theGame.WhiteKing[i]) { items[i].PieceShape = King; } else { throw new Exception("White Bit Board Showed Piece Existed But No matching piece found in White piece bitboards"); } } else if(_theGame.AllBlackPieces[i]) { items[i].PieceColor = Black; if (_theGame.BlackPawns[i]) { items[i].PieceShape = Pawn; } else if (_theGame.BlackRooks[i]) { items[i].PieceShape = Rook; } else if (_theGame.BlackKnights[i]) { items[i].PieceShape = Knight; } else if (_theGame.BlackBishops[i]) { items[i].PieceShape = Bishop; } else if (_theGame.BlackQueens[i]) { items[i].PieceShape = Queen; } else if (_theGame.BlackKing[i]) { items[i].PieceShape = King; } else { throw new Exception("Black Bit Board Showed Piece Existed But No matching piece found in Black piece bitboards"); } } } if ((i+1)%8 != 0 || i==0) { switcher = !switcher; } items[i].Index = i; } TheBoard = new ObservableCollection<ChessGridItem>(items); }
public RestartCommand(IGameModel gameModel) : base(gameModel) { }
public GameConsoleView(IGameModel game) { Game = game; }
public void Before() { gameModel = new GameModel(); }
public FieldViewModel () { GameModel = DependencyService.Get<IGameModel> (); }
void Start() { _game = GameModel.Current; _image = GetComponent<Image> (); }
public ICommand PopBalloonCommand(IGameModel gameModel, IGameLogicProvider gameLogicProvider, int row, int col) { return new PopBalloonCommand(gameModel, gameLogicProvider, row, col); }
public GameCommand(IGameModel gameModel) { this.gameModel = gameModel; }
public ICommand RestartCommand(IGameModel gameModel) { return new RestartCommand(gameModel); }