예제 #1
0
    private void pview_add(int lineNr)
    {
        //no more than 6 players
        if (_model.Count > 5)
        {
            return;
        }

        PlayerModel player = _model[lineNr].Duplicate();
        IPlayerView pview  = _factory.CreateNewPlayer();

        Link(lineNr, player, pview);

        _model.Insert(lineNr, player);
        _view.Insert(lineNr, pview);

        for (int p = lineNr; p < _view.Count; ++p)
        {
            _view[p].SetLineNr(p);
            _model[p].Color = p; //workaround, because I dont want to implement color picker
        }
    }
예제 #2
0
    public PlayerCtrl(PlayerListModel model, PlayerViewFactory factory)
    {
        _model   = model;
        _factory = factory;

        if (_model.Count == 0)
        {
            PlayerModel defaultPlayer = new PlayerModel()
            {
                Color = 0, Name = "Hooman", Team = 0, Type = PlayerTypeEnum.Human
            };
            _model.Add(defaultPlayer);
        }

        _view = new List <IPlayerView>(_model.Count);
        for (int p = 0; p < _model.Count; ++p)
        {
            PlayerModel player = _model[p];
            IPlayerView pview  = _factory.CreateNewPlayer();
            _view.Add(pview);
            Link(p, player, pview);
        }
    }