Пример #1
0
        public void PlaceShips(IPlayerView playerView, ICollection<IVessel> ships)
        {
            InitializeAI(playerView);

              int x, y;
              Orientation orient;
            #if DEBUG
              Visualizer viz = new Visualizer(_xMax, _yMax);
            #endif

              foreach (IVessel ship in ships)
              {
            do
            {
              x = _rand.Next(0, _xMax) + 1;
              y = _rand.Next(0, _yMax) + 1;
              orient = (_rand.NextDouble() < 0.5) ? Orientation.Horizontal : Orientation.Vertical;
            } while (!playerView.PutShip(ship.SailTo(x, y, orient)));
            #if DEBUG
            for (int i = 0; i < ship.Length; i++)
            {
              if (orient == Orientation.Horizontal)
            viz.SetSquare(x + i, y, false);
              else
            viz.SetSquare(x, y - i, false);
            }
            #endif
              }
            #if DEBUG
              Console.WriteLine("Ships:");
              Console.WriteLine(viz.FieldView());
            #endif
        }
Пример #2
0
        public void Create(IPlayerView world, ICollection<IVessel> countries)
        {
            _enemies = new List<IVessel>();
            Map = new Map(Boundaries);

            CreateInternal(world, countries);
        }
Пример #3
0
 public PlayerDisguiseState(IPlayerView _playerView, PlayerStateMachine playerStateMachine, IPlayerService _playerService)
 {
     playerView       = _playerView;
     playerService    = _playerService;
     stateMachine     = playerStateMachine;
     currentStateType = PlayerStates.DISGUISE;
 }
        /// <summary>
        /// Default constructor requires a player model and a player view
        /// be injected
        /// </summary>
        /// <param name="model">A player model</param>
        public PlayerController(IPlayerModel model, IPlayerView view)
        {
            this.model = model ?? throw new ArgumentNullException(nameof(model));
            this.view  = view ?? throw new ArgumentNullException(nameof(view));

            this.view.OnLoad += HandleOnLoadEvent;
        }
Пример #5
0
 public PlayerShootingState(IPlayerView _playerView, PlayerStateMachine playerStateMachine, IPlayerService _playerService)
 {
     playerView       = _playerView;
     playerService    = _playerService;
     stateMachine     = playerStateMachine;
     currentStateType = PlayerStates.SHOOTING;
 }
Пример #6
0
 public PlayerThrowingState(IPlayerView _playerView, PlayerStateMachine playerStateMachine, IPlayerService _playerService)
 {
     playerView       = _playerView;
     playerService    = _playerService;
     stateMachine     = playerStateMachine;
     currentStateType = PlayerStates.THROWING;
 }
Пример #7
0
    private void pview_remove(int lineNr)
    {
        if (_model.Count < 2)
        {
            return;                   //don't remove last remaining line
        }
        PlayerModel player = _model[lineNr];
        IPlayerView pview  = _view[lineNr];

        pview.OnAddLineClicked    -= pview_add;
        pview.OnRemoveLineClicked -= pview_remove;
        pview.OnColorChosen       -= Pview_OnColorChosen;
        pview.OnNameEdited        -= Pview_OnNameEdited;
        pview.OnPlayertypeChosen  -= Pview_OnPlayertypeChosen;
        pview.OnTeamChosen        -= Pview_OnTeamChosen;

        _model.RemoveAt(lineNr);
        _view.RemoveAt(lineNr);

        _factory.Destroy(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
        }
    }
Пример #8
0
        public PlayerPres(IPlayerView view) : base(ENTITY_TYPE.PLAYER)
        {
            _character           = CharacterModel.Create(Type, Id);
            _character.MoveSpeed = 100;

            var collState          = InteractStateModel.Create(Type, Id);
            var interactController = new InteractController(collState.obj);

            _view = view;
            _view.interactController = interactController;
            _character.Position      = _view.Position;
            _view.Subscribe(OnViewChanged);

            _animState      = AnimStateModel.Create(Type, Id);
            _animController = _view.CreateAnimController(_animState.obj);

            AddAnimation(Const.ANIMATION.IDLE, "Standing Idle");
            AddAnimation(Const.ANIMATION.WALK_FW, "Standing Walk Forward");
            AddAnimation(Const.ANIMATION.WALK_BW, "Standing Walk Back");
            AddAnimation(Const.ANIMATION.WALK_LEFT, "Standing Walk Left");
            AddAnimation(Const.ANIMATION.WALK_RIGHT, "Standing Walk Right");
            AddAnimation(Const.ANIMATION.RUN_FW, "Standing Run Forward");
            AddAnimation(Const.ANIMATION.RUN_BW, "Standing Run Back");
            AddAnimation(Const.ANIMATION.RUN_LEFT, "Standing Run Left");
            AddAnimation(Const.ANIMATION.RUN_RIGHT, "Standing Run Right");
            AddAnimation(Const.ANIMATION.ATTACK_FIREBALL_BIG, "Standing 1H Magic Attack 01");
            AddAnimation(Const.ANIMATION.ATTACK_FIREBALL_SMALL, "Standing 2H Magic Attack 01");
            AddAnimation(Const.ANIMATION.ATTACK_SPELL_GROUND, "Standing 2H Cast Spell 01");

            _fsm = new PlayerFSM(this, _animState.obj, _character.obj);
        }
Пример #9
0
        public void PlaceShips(IPlayerView playerView, ICollection<IVessel> ships)
        {
            /* This AI places ships in the upper right corner and to the left.
             *
             * E.g.
             *
             * 10  #   #   #   #   #
             * 9   #   #   #   #   #
             * 8       #   #   #   #
             * 7               #   #
             * 6                   #
             * 5
             * 4
             * 3
             * 2
             * 1
             *   1 2 3 4 5 6 7 8 9 10
             */

            Placement place;
            Coordinate coord;
            int xMax = playerView.GetXMax();
            int yMax = playerView.GetYMax();

            int i = 0;
            foreach (IVessel ship in ships)
            {
                coord = new Coordinate(xMax - (2 * i), yMax);
                place = new Placement(ship, coord, Orientation.Vertical);
                playerView.PutShip(place);

                i++;
            }
        }
Пример #10
0
 public PlayerEndTurnState(IPlayerView _playerView, PlayerStateMachine playerStateMachine, IPlayerService _playerService)
 {
     playerView       = _playerView;
     playerService    = _playerService;
     stateMachine     = playerStateMachine;
     currentStateType = PlayerStates.END_TURN;
 }
Пример #11
0
 public PlayerWaitingForInputState(IPlayerView _playerView, PlayerStateMachine playerStateMachine, IPlayerService _playerService)
 {
     playerView       = _playerView;
     playerService    = _playerService;
     stateMachine     = playerStateMachine;
     currentStateType = PlayerStates.WAIT_FOR_INPUT;
 }
Пример #12
0
        public override void SetAgent(IPlayerView view, IPieceAgent agent)
        {
            base.SetAgent(view, agent);

            Assert.IsNotNull(agent);
            Assert.IsNotNull(agent.Power);
            Assert.IsNotNull(agent.Health);
            Assert.IsNotNull(Power);
            Assert.IsNotNull(Health);

            agent.Power.Subscribe(p => Power.text   = $"{p}").AddTo(this);
            agent.Health.Subscribe(p => Health.text = $"{p}").AddTo(this);
            //agent.Model.ManaCost.Subscribe(p => Mana.text = $"{p}").AddTo(this);

            FindPiece().GetComponent <Renderer>().material
                = Owner.Value.Color == EColor.Black ? BoardView.BlackMaterial : BoardView.WhiteMaterial;

            MouseOver.DistinctUntilChanged().Subscribe(
                v =>
            {
                //BoardView.ShowSquares(this);
            }
                );
            Dead.Subscribe(d => { if (d)
                                  {
                                      Die();
                                  }
                           });
        }
Пример #13
0
 public PlayerAmbushState(IPlayerView _playerView, PlayerStateMachine playerStateMachine, IPlayerService _playerService)
 {
     playerView       = _playerView;
     playerService    = _playerService;
     stateMachine     = playerStateMachine;
     currentStateType = PlayerStates.AMBUSH;
 }
 public PlayerController(IPlayerView playerView, IWeaponePrefabsDatabase weaponePrefabsDatabase,
                         IChangeWeaponeCommand changeWeaponeCommand, IGameSettingsDatabase gameSettingsDatabase)
 {
     _playerView             = playerView;
     _weaponePrefabsDatabase = weaponePrefabsDatabase;
     _changeWeaponeCommand   = changeWeaponeCommand;
     _gameSettingsDatabase   = gameSettingsDatabase;
 }
Пример #15
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Player" /> class.
 /// </summary>di
 /// <param name="gameContext">The game context.</param>
 /// <param name="playerView">The player view.</param>
 public Player(IGameContext gameContext, IPlayerView playerView)
     : this()
 {
     this.gameContext        = gameContext;
     this.PlayerView         = playerView;
     this.PersistenceContext = this.gameContext.RepositoryManager.CreateNewAccountContext(gameContext.Configuration);
     this.walker             = new Walker(this);
 }
Пример #16
0
        public Player(IPlayerView playerView, PlayerModel playerModel, int id)
        {
            PlayerView  = playerView;
            PlayerModel = playerModel;

            PlayerView.Id  = id;
            PlayerModel.Id = id;
        }
Пример #17
0
        public void Customize(ref IPlayerView playerView, CharacterSettings settings)
        {
            playerView.CharAttributes.AgroDistance      = settings.AgroDistance;
            playerView.CharAttributes.Speed             = settings.PlayerMoveSpeed;
            playerView.CharAttributes.RotateSpeedPlayer = settings.RotateSpeedPlayer;

            var person = new PersonCharacter(playerView.Transform.gameObject, _characterData);

            person.CharacterRace   = settings.CharacterRace;
            person.CharacterGender = settings.CharacterGender;

            person.Generate();

            // switch (settings.CharacterRace)
            // {
            //     case CharacterRace.Human:
            //         person.Race =
            //         break;
            //
            //     case CharacterRace.NightElf:
            //         break;
            //
            //     case CharacterRace.BloodElf:
            //         break;
            //
            //     case CharacterRace.Orc:
            //         break;
            //
            //     default:
            //         throw new ArgumentOutOfRangeException();
            // }


            // var person = new PersonCharacter(playerView.Transform.gameObject, settings);

            switch (settings.CharacterClass)
            {
            case CharacterClass.Warrior:
                playerView.CharacterClass = new CharacterClassWarrior();
                break;

            case CharacterClass.Rogue:
                playerView.CharacterClass = new CharacterClassRogue();
                break;

            case CharacterClass.Hunter:
                playerView.CharacterClass = new CharacterClassHunter();
                break;

            case CharacterClass.Mage:
                playerView.CharacterClass = new CharacterClassMage();
                break;

            default:
                throw new Exception(
                          "PlayerFactory. playerData.PlayerSettings.CharacterClass:Недопустимое значение");
            }
        }
Пример #18
0
        public void Homepage(IPlayerView form, IMainController inController, Player player, ITransactionRepository transactionRepository, ITrainerRepository trainerRepository, ITrainingRepository trainingRepository, ITeamRepository teamRepository)
        {
            ITransactionRepository transRep   = transactionRepository;
            ITrainingRepository    trainRep   = trainingRepository;
            ITeamRepository        teamRep    = teamRepository;
            ITrainerRepository     trainerRep = trainerRepository;

            form.ShowViewModaless(inController, player, transRep.GetAll(), trainRep.GetAll(), teamRep.GetAll(), trainerRep.GetAll());
        }
Пример #19
0
        public static void PutCardFromHandOntoDeck(Game game, Player player, IPlayerView view)
        {
            ICard card = view.ChooseCardFromHandRender(player.Hand.Cards);

            if (card != null)
            {
                player.Deck.PutOnto(player.Hand.Remove(card));
            }
        }
Пример #20
0
        public void Play(Game game, IPlayerView playerView)
        {
            if (Player == null)
            {
                throw new Exception("Owner of this card is not set. Cannot play");
            }

            _cardEffects.Invoke(game, Player, playerView);
        }
Пример #21
0
        public static void GainCardWorthUpTo5(Game game, Player player, IPlayerView view)
        {
            CardName cardName = view.GainCardRender(5, game.CardsInPlay.FindAll(c => c.Peek().Cost <= 5));

            if (!cardName.Equals(null))
            {
                player.Gain(game.TakeCard(cardName));
            }
        }
Пример #22
0
 private void SpawnPlayerView()
 {
     // currentPlayerView=scriptableObject.playerView;
     playerInstance     = GameObject.Instantiate(scriptableObject.playerView.gameObject);
     currentPlayerView  = playerInstance.GetComponent <PlayerView>();
     playerStateMachine = new PlayerStateMachine(currentPlayerView, playerService);
     playerNodeID       = 0;
     playerInstance.transform.localPosition = spawnLocation;
 }
Пример #23
0
 public BattleInitialization(IGeneratorDungeon generatorDungeon,
                             IReactiveProperty <EnumBattleWindow> battleState,
                             IReactiveProperty <EnumMainWindow> activeWindow, IPlayerView player)
 {
     _player           = player;
     _generatorDungeon = generatorDungeon;
     _battleState      = battleState;
     _activeWindow     = activeWindow;
 }
Пример #24
0
        public void PlaceShips(IPlayerView playerView, ICollection<IVessel> ships)
        {
            World.Boundaries = new Boundaries();
            World.Map = new Map(World.Boundaries);
            World.Create(playerView, ships);

            God.World = World;
            God.Play();
        }
Пример #25
0
        public override void SetAgent(IPlayerView view, IBoardAgent agent)
        {
            Assert.IsNotNull(agent);
            base.SetAgent(view, agent);
            Clear();
            CreateBoard();

            agent.Pieces.ObserveAdd().Subscribe(PieceAdded);
            agent.Pieces.ObserveRemove().Subscribe(PieceRemoved);
        }
Пример #26
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="view"></param>
        /// <param name="mainPresenter"></param>
        /// <param name="mainState"></param>
        public PlayerPresenter(IPlayerView view, ApplicationPresenter mainPresenter, ApplicationState mainState)
        {
            View = view;
            View.SetPresenterReference(this);

            // View events
            View.DownLevel += View_DownLevel;
            View.UpLevel += View_UpLevel;
            View.NextSection += View_NextSection;
            View.PreviousSection += View_PreviousSection;
            View.TogglePlayPause += View_TogglePlayPause;
            View.SetBookmark += View_SetBookmark;
            View.AudioCompleted += View_AudioCompleted;
            View.VolumeChanged += View_VolumeChanged;
            View.PreviousPage += View_PreviousPage;
            View.NextPage += view_NextPage;
            View.ToggleSelfVoicing += new EventHandler(View_ToggleSelfVoicing);
            View.ToggleMuting += new EventHandler(View_ToggleMuting);

            View.SelfVoicingSpeakText += View_SelfVoicingSpeakText;
            View.SpeakableElementSelected += View_SpeakableElementSelected;
            View.SectionChanged += View_SectionChanged;

            // Hook into relevent dependent view events
            View.ApplicationView.BookChanged += ApplicationView_BookChanged;
            View.ApplicationView.BookLoadStarted += ApplicationView_BookLoadStarted;
            View.ApplicationView.BookLoadFailed += ApplicationView_BookLoadFailed;
            View.ApplicationView.BookDisplayed += ApplicationView_BookDisplayed;

            View.ApplicationView.DisplaySurface.ItemSelected += DisplaySurface_ItemSelected;
            View.ApplicationView.DisplaySurface.GestureRaised += DisplaySurface_GestureRaised;
            View.NavigationView.ItemSelected += NavigationView_ItemSelected;

            View.SearchView.NavigateToPage += SearchView_NavigateToPage;
            View.SearchView.SearchForSection += SearchView_SearchForSection;
            View.SearchView.SearchSelected += SearchView_SearchSelected;

            // Initialise Button State
            View.SetNavButtonState(false);
            View.SetPlayButtonState(false, false);

            _mainPresenter = mainPresenter;
            base.MainState = mainState;
            _state = MainState.PlayerState;
            _state.PresentPhrase = PlayPhrase;

            _timer = new DispatcherTimer();
            _timer.Interval = new TimeSpan(0, 0, 0);
            _timer.Tick += new EventHandler(MoveNextEvent);
        }
Пример #27
0
 public PlayerCapturerBin()
 {
     this.Build ();
     replayhbox.HeightRequest = livebox.HeightRequest = StyleConf.PlayerCapturerControlsHeight;
     replayimage.Pixbuf = Misc.LoadIcon ("longomatch-replay", StyleConf.PlayerCapturerIconSize);
     liveimage.Pixbuf = Misc.LoadIcon ("longomatch-live", StyleConf.PlayerCapturerIconSize);
     livelabel.ModifyFg (Gtk.StateType.Normal, Misc.ToGdkColor (Config.Style.PaletteActive));
     replaylabel.ModifyFg (Gtk.StateType.Normal, Misc.ToGdkColor (Config.Style.PaletteActive));
     livebox.Visible = replayhbox.Visible = true;
     playerview = Config.GUIToolkit.GetPlayerView ();
     playerbox.PackEnd (playerview as Gtk.Widget);
     (playerview as Gtk.Widget).ShowAll ();
     Player = playerview.Player;
 }
Пример #28
0
        private void CreateInternal(IPlayerView world, ICollection<IVessel> enemies)
        {
            Coordinate coordinate;
            int tries = 0;
            Orientation orientation = Orientation.Horizontal;

            foreach (IVessel enemy in enemies.OrderByDescending(v => v.Length))
            {
                Enemies.Add(enemy);
                coordinate = RandomCoordinate;
                orientation = Dice.Next(2) == 1 ? Orientation.Horizontal : Orientation.Vertical;

                if (orientation == Orientation.Horizontal && coordinate.Latitude + enemy.Length > Boundaries.East)
                    coordinate.Latitude -= coordinate.Latitude + enemy.Length - Boundaries.East;

                if (orientation == Orientation.Vertical && coordinate.Longitude - enemy.Length < 1)
                    coordinate.Longitude = enemy.Length;

                if (AvoidEdge)
                    AvoidEdges(coordinate);

                while (!world.PutShip(enemy.SailTo(coordinate.ToInterfaceCoordinate(), orientation)))
                {
                    if (++coordinate.Latitude > Boundaries.East)
                        coordinate.Latitude = Boundaries.West;

                    if (++coordinate.Longitude > Boundaries.North)
                        coordinate.Longitude = Boundaries.South;

                    if (++tries > 10)
                        orientation = orientation == Orientation.Horizontal ? Orientation.Vertical : Orientation.Horizontal;

                    if (tries > 20)
                    {
                        tries = 0;
                        coordinate = RandomCoordinate;
                    }

                    if (AvoidEdge)
                        AvoidEdges(coordinate);
                }
            }
        }
Пример #29
0
        public Shot YourTurn(IPlayerView playerView)
        {
            int xMax = playerView.GetXMax();
            int yMax = playerView.GetYMax();

            Shot fireZeMissles = new Shot(_nextShot.X, _nextShot.Y);

            _nextShot.X++;

            if (_nextShot.X > xMax)
            {
                _nextShot.Y++;
                _nextShot.X = 1;
            }

            if (_nextShot.Y > yMax)
                _nextShot.Y = 1;

            return fireZeMissles;
        }
Пример #30
0
        public void PlaceShips(IPlayerView playerView, ICollection<IVessel> ships)
        {
            int maxX = playerView.GetXMax();
            int maxY = playerView.GetYMax();

            Placement placement;
            int xPos;
            int yPos;
            Orientation direction;

            foreach (IVessel ship in ships)
            {
                do
                {
                    xPos = _rand.Next(maxX) + 1;
                    yPos = _rand.Next(maxY) + 1;
                    direction = _rand.NextDouble() > 0.5 ? Orientation.Horizontal : Orientation.Vertical;
                    placement = new Placement(ship, xPos, yPos, direction);
                } while (!playerView.PutShip(placement));
            }
        }
Пример #31
0
 public override void PushPlayerSubview(IPlayerView playerView, IBaseView view)
 {
     Debug.WriteLine("WindowsPhoneNavigationManager - PushPlayerSubview");
 }
Пример #32
0
        private void InitializeAI(IPlayerView playerView)
        {
            _xMax = playerView.GetXMax();
              _yMax = playerView.GetYMax();
              byte[] randomBytes = new byte[1];
              System.Security.Cryptography.RNGCryptoServiceProvider.Create().GetNonZeroBytes(randomBytes);
              _rand = new Random(Environment.TickCount + 1337 + 42 + randomBytes[0]);

              SetUpStrategy();
        }
Пример #33
0
        public Shot YourTurn(IPlayerView playerView)
        {
            God.Smite();

            return God.Smote();
        }
Пример #34
0
        public Shot YourTurn(IPlayerView playerView)
        {
            _turn++;

            #if DEBUG
              if ((_turn % 20) == 0 && _turn < 150)
              {
            Console.WriteLine("Eliminated squares:");
            Visualizer.ConsolePrintField(_xMax, _yMax, _eliminatedCoords);
            Console.WriteLine("Ships hit:");
            Visualizer.ConsolePrintField(_xMax, _yMax, _hitRecord);
            Console.WriteLine("Firing Solution:");
            Visualizer.ConsolePrintField(_xMax, _yMax, _firingPattern);
            Console.ReadKey(true);
              }
            #endif
              Coordinate firingSolution;

              if (IsDroneDeployed)
              {
            firingSolution = _attackDrone.ContinueMission();
              }
              else
              {
            firingSolution = PickRandomFiringSolution();

            // FIXME
            if (firingSolution == null)
              firingSolution = new Coordinate(1, 1);

            _firingPattern.Remove(firingSolution);
            _eliminatedCoords.Add(firingSolution);
              }

              Shot bang = new Shot(firingSolution.X, firingSolution.Y);

              _lastShot = bang;

              return bang;
        }
Пример #35
0
 public override void PushPlayerSubview(IPlayerView playerView, IBaseView view)
 {
 }
Пример #36
0
 public Shot YourTurn(IPlayerView playerView)
 {
     int x = _rand.Next(playerView.GetXMax()) + 1;
     int y = _rand.Next(playerView.GetYMax()) + 1;
     return new Shot(x, y);
 }
Пример #37
0
        public virtual void CreatePlayerView(MobileNavigationTabType tabType)
        {
            if (_playerView == null)
                _playerView = Bootstrapper.GetContainer().Resolve<IPlayerView>();

            // This is only used on iOS. Shouldn't this be routed to the main view? IMobileMainView.PushTabView?
            PushTabView(tabType, _playerView);
        }
Пример #38
0
        public virtual void BindPlayerView(MobileNavigationTabType tabType, IPlayerView view)
        {
            _playerView = view;
            _playerView.OnViewDestroy = (view2) =>
            {
                _playerPresenter.ViewDestroyed();
                _playerPresenter = null;
                _playerView = null;
            };
            _playerPresenter = Bootstrapper.GetContainer().Resolve<IPlayerPresenter>();
            _playerPresenter.BindView(view);

            // Create sub views
            var playerMetadata = CreatePlayerMetadataView();
            var loops = CreateLoopsView();
            var markers = CreateMarkersView();
            var timeShifting = CreateTimeShiftingView();
            var pitchShifting = CreatePitchShiftingView();

            _playerView.PushSubView(playerMetadata);
            _playerView.PushSubView(loops);
            _playerView.PushSubView(markers);
            _playerView.PushSubView(timeShifting);
            _playerView.PushSubView(pitchShifting);

            // Check if the Start Resume Playback view must be shown after startup
            if (_resumeCloudDeviceInfo != null)
            {
                Tracing.Log("MobileNavigationManager - BindPlayerView - showing Start Resume Playback view...");
                var startResumePlaybackView = CreateStartResumePlaybackView();
                PushDialogView(MobileDialogPresentationType.Overlay, "Resume Playback", _playerView, startResumePlaybackView);
                _resumeCloudDeviceInfo = null;
            }
        }