Пример #1
0
 public StartBattleVM(PokemonLobbyClient client, User rival, GameSettings settings, bool isPassive)
 {
     this.client = client;
       Rival = rival;
       this.isPassive = isPassive;
       RivalAvatar = AvatarVM.GetAvatar(rival.Avatar);
       Teams = Helper.DataMainInstance.PokemonData.Teams.Folders;
       chosenTeam = Teams.FirstOrDefault();
       GameSettings = settings;
       if (isPassive)
       {
     OkCommand = new MenuCommand("接受", Accept);
     CancelCommand = new MenuCommand("拒绝", Refuse);
     client.ChallengeCanceled += OnProcessed;
     PlaySound();
       }
       else
       {
     OkCommand = new MenuCommand("挑战", Challenge);
     CancelCommand = new MenuCommand("取消", Cancel);
     client.ChallengeAccepted += OnProcessed;
     client.ChallengeRefused += OnProcessed;
       }
       client.EnterSucceed += OnProcessed;
       OkCommand.IsEnabled = ChosenTeam != null;
       timer = new DispatcherTimer() { Interval = TimeSpan.FromSeconds(10) };
       timer.Tick += (sender, e) => CancelCommand.IsEnabled = true;
 }
Пример #2
0
        public Pokemon(Player owner, PokemonCustomInfo custom, GameSettings settings)
        {
            Id = settings.NextId();
              Owner = owner;
              TeamId = owner.TeamId;

              Name = custom.Name;
              PokemonType = DataService.GetPokemonType(custom.PokemonTypeId);
              Gender = custom.Gender;
              Lv = custom.Lv;
              Ability = DataService.GetAbility(custom.AbilityId);
              Nature = custom.Nature;

              {
            Moves = new Move[4];
            int i = 0;
            foreach (int moveId in custom.MoveIds)
              if (i < 4) Moves[i++] = new Move(moveId, settings);
            StruggleId = settings.NextId();
            SwitchId = settings.NextId();
              }

              Base = new ReadOnly6D(PokemonType.BaseHp, PokemonType.BaseAtk, PokemonType.BaseDef, PokemonType.BaseSpAtk, PokemonType.BaseSpDef, PokemonType.BaseSpeed);
              Iv = new ReadOnly6D(custom.HpIv, custom.AtkIv, custom.DefIv, custom.SpAtkIv, custom.SpDefIv, custom.SpeedIv);
              Ev = new ReadOnly6D(custom.HpEv, custom.AtkEv, custom.DefEv, custom.SpAtkEv, custom.SpDefEv, custom.SpeedEv);
              Static = new ReadOnly6D(GetState(StatType.Hp), GetState(StatType.Atk), GetState(StatType.Def), GetState(StatType.SpAtk), GetState(StatType.SpDef), GetState(StatType.Speed));

              if (custom.ItemId.HasValue) Item = DataService.GetItem(custom.ItemId.Value);
              State = PokemonState.Normal;
              Hp = new PairValue(Static.Hp, Static.Hp, 48);
        }
Пример #3
0
 public Player(int userId, int teamId, PokemonCustomInfo[] pokemons, GameSettings settings)
 {
     Id = userId;
       TeamId = teamId;
       Pokemons = new Pokemon[pokemons.Length];
       for (int i = 0; i < pokemons.Length; i++)
     Pokemons[i] = new Pokemon(this, pokemons[i], settings);
 }
Пример #4
0
 public SimGame(int userId, int teamId, PokemonCustomInfo[] pms, GameSettings settings)
 {
     Team = new Team(teamId, settings);
       Team.AddPlayer(userId, pms);
       Player = Team.GetPlayer(userId);
       Pokemons = new SimPokemon[settings.XBound];
       pokemons = new List<SimPokemon>();
 }
Пример #5
0
 public GameOutward(GameSettings settings)
 {
     Settings = settings;
       Board = new BoardOutward(Settings);
       Teams = new TeamOutward[Settings.TeamCount];
       for (int t = 0; t < Settings.TeamCount; t++)
     Teams[t] = new TeamOutward(6, 0, 0);
       listeners = new List<IGameEventListener>();
 }
Пример #6
0
Файл: Game.cs Проект: sunoru/PBO
 public GameContext(GameSettings settings)
 {
     Settings = settings;
       Teams = new Team[settings.TeamCount];
       for (int i = 0; i < settings.TeamCount; i++)
     Teams[i] = new Team(i, settings);
       Board = new Board(settings);
       turnBuilder = new TurnBuilder(this);
       actions = new ActionInput[Settings.PlayersPerTeam * Settings.TeamCount];
 }
Пример #7
0
Файл: Host.cs Проект: sunoru/PBO
 public Host(GameSettings settings)
 {
   users = new HashSet<int>();
   players = new ObservableCollection<int>();
   spectators = new ObservableCollection<int>();
   Players = new ReadOnlyObservableCollection<int>(players);
   Spectators = new ReadOnlyObservableCollection<int>(spectators);
   game = GameFacade.CreateGame(settings);
   game.Turn += (turn) => InformTurn(turn);
   game.RequireInput += (player) => InformRequireInput(player);
 }
Пример #8
0
 public Board(GameSettings settings)
 {
     mode = settings.Mode;
       weather = Data.Weather.Normal;
       terrain = settings.Terrain;
       pokemons = new OnboardPokemon[settings.TeamCount, settings.XBound];
       Pokemons = new List<OnboardPokemon>();
       BoardConditions = new ConditionsDictionary();
       FieldConditions = new ConditionsDictionary[settings.TeamCount];
       for (int i = 0; i < settings.TeamCount; i++) FieldConditions[i] = new ConditionsDictionary();
 }
Пример #9
0
Файл: Team.cs Проект: sunoru/PBO
 public Team(int id, GameSettings settings)
 {
     Id = id;
       this.settings = settings;
       switch (settings.Mode)
       {
     case GameMode.Single:
       PlayerCount = 1;
       break;
       }
       Players = new List<Player>();
       Pokemons = new Dictionary<int, Pokemon>();
 }
Пример #10
0
        internal BoardOutward(GameSettings settings)
        {
            this.settings = settings;
              teams = new ObservableCollection<PokemonOutward>[settings.TeamCount];
              Teams = new ReadOnlyObservableCollection<PokemonOutward>[settings.TeamCount];
              pokemons = new List<PokemonOutward>();
              weather = Data.Weather.Normal;
              Terrain = settings.Terrain;

              var empty = new PokemonOutward[settings.XBound];
              for (int i = 0; i < settings.TeamCount; i++)
              {
            teams[i] = new ObservableCollection<PokemonOutward>(empty);
            Teams[i] = new ReadOnlyObservableCollection<PokemonOutward>(teams[i]);
              }

              listeners = new List<IBoardEvent>();
        }
Пример #11
0
 public bool Challenge(int target, PokemonCustomInfo[] pokemons, GameSettings settings)
 {
   User u = GetUser(target);
   if (u != null && u.State != UserState.Battling && pokemons != null && pokemons.Length > 0) //it's impossible for a client to get UserState.Invalid
     lock (roomLock)
     {
       if (challengingPms == null)
       {
         SendMessage(CHALLENGE, writer => settings.WriteToMessage(writer), target);
         challengingPms = pokemons;
         currentSettings = settings;
         return true;
       }
     }
   return false;
 }
Пример #12
0
 public static IGame CreateGame(GameSettings settings)
 {
     return new GameContext(settings);
 }
Пример #13
0
Файл: Move.cs Проект: sunoru/PBO
 public Move(int moveType, GameSettings settings)
 {
     Id = settings.NextId();
       Type = DataService.GetMoveType(moveType);
       PP = new PairValue((int)(Type.PP * settings.PPUp));
 }
Пример #14
0
 public static GameSettings ReadFromMessage(BinaryReader reader)
 {
     GameSettings s = new GameSettings((GameMode)reader.ReadByte());
       s.PPUp = reader.ReadDouble();
       int n = reader.ReadInt32();
       while (n-- > 0)
     s.AddRule(DataService.GetRule(reader.ReadInt32()));
       s.Lock();
       return s;
 }
Пример #15
0
Файл: Move.cs Проект: sunoru/PBO
 public Move(int id, Move move, GameSettings settings)
 {
     Id = id;
       Type = move.Type;
       PP = new PairValue(5);
 }
Пример #16
0
 private void OnChallenged(int userId, GameSettings settings)
 {
   Challenged(GetUser(userId), settings);
 }
Пример #17
0
 /// <param name="settings">主动的话这个不应该是null么</param>
 public StartBattle(PokemonLobbyClient client, User rival, GameSettings settings, bool isPassitive)
 {
     InitializeComponent();
       DataContext = vm = new StartBattleVM(client, rival, settings, isPassitive);
       vm.Processed += () => Close();
 }