private PlayerSet GetPlayerSet(
            string deviceID)
        {
            var ps  = default(PlayerSet);
            var key = !string.IsNullOrEmpty(deviceID) ?
                      deviceID :
                      this.GetDefaultAudioDevice().ID;

            lock (this.players)
            {
                if (this.players.ContainsKey(key))
                {
                    ps = this.players[key];
                }
                else
                {
                    var device = this.GetDevices().FirstOrDefault(x => x.ID == deviceID);

                    if (device != null)
                    {
                        ps = new PlayerSet();
                        ps.Init(device);

                        this.players[key] = ps;
                    }
                }
            }

            return(ps);
        }
Esempio n. 2
0
        public static void PlayNotificationSoundSetPicked()
        {
            double volume = Properties.Settings.Default.Volume / 100.0;

            PlayerSet.Volume   = volume;
            PlayerSet.Position = TimeSpan.Zero;
            PlayerSet.Play();
        }
Esempio n. 3
0
        public void Apply(PlayerSet eventDto)
        {
            Board[eventDto.Row][eventDto.Column] = eventDto.Player;

            var winner = GetWinner();

            if (winner != null)
            {
                _context.Notify(new GameOver(winner));
            }
        }
Esempio n. 4
0
        private PlayerManager()
        {
            PlayerSet = InitializePlayerSet();

            Task.Run(async() =>
            {
                //Check for old player data and update
                bool anyUpdate = false;
                foreach (var player in PlayerSet.Where(player => !player.OfflineChar && (DateTime.Now - player.LastUpdated).TotalDays > 7d))
                {
                    await player.Update();
                    Console.WriteLine("Updated data for player " + player);
                    anyUpdate = true;
                }
                if (anyUpdate)
                {
                    SafePlayersToFile();
                }
            });
        }
Esempio n. 5
0
    public override void Awake()
    {
        base.Awake();
        _setting = new PlayerSet();
        setting = (PlayerSet)_setting;
        hp = setting.hp;
        stamina = setting.stamina;
        magic = setting.magic;

        //anim = GetComponent<Animator>();
        anim = GetComponent<Animator>();
        addButtonDetect("left");
        addButtonDetect("right");
        hurtFlashAmount = 0.5f;

        playerAudio = GetComponent<AudioSource>();

        addSkill("normalAttack", normalAttack);
        addSkill("dodge", dodge);
        addSkill("overheadSwing", overheadSwing);
        addSkill("block", block);
        addSkill("dropAttack", dropAttack);
        addSkill("eruptionFire", eruptionFire);
    }
        private PlayerSet GetPlayerSet(
            string deviceID)
        {
            var ps = default(PlayerSet);

            lock (this.players)
            {
                if (this.defaultAudioDevice == null ||
                    this.defaultComAudioDevice == null)
                {
                    this.UpdateDefaultAudioDevices();
                }

                var key = !string.IsNullOrEmpty(deviceID) ?
                          deviceID :
                          this.defaultAudioDevice.ID;

                var isNew = false;

                if (!this.players.ContainsKey(key))
                {
                    isNew = true;
                }
                else
                {
                    ps = this.players[key];

                    switch (deviceID)
                    {
                    case PlayDevice.DefaultDeviceID:
                        isNew = ps.DeviceID != this.defaultAudioDevice.ID;
                        break;

                    case PlayDevice.DefaultComDeviceID:
                        isNew = ps.DeviceID != this.defaultComAudioDevice.ID;
                        break;
                    }

                    if (isNew)
                    {
                        ps.Dispose();
                        this.players.Remove(key);
                    }
                }

                if (isNew)
                {
                    var device = deviceID switch
                    {
                        PlayDevice.DefaultDeviceID => this.GetDevices().FirstOrDefault(x => x.ID == this.defaultAudioDevice.ID),
                        PlayDevice.DefaultComDeviceID => this.GetDevices().FirstOrDefault(x => x.ID == this.defaultComAudioDevice.ID),
                        _ => this.GetDevices().FirstOrDefault(x => x.ID == deviceID)
                    };

                    if (device != null)
                    {
                        ps = new PlayerSet();
                        ps.Init(device);

                        this.players[key] = ps;
                    }
                }
            }

            return(ps);
        }
Esempio n. 7
0
 /// <summary>
 /// Converts the player state to the converted Player state
 /// </summary>
 /// <param name="playerSet">The player state to be converted</param>
 /// <returns>The converted player state</returns>
 public static MaednPlayerState GetMaednPlayerState(this PlayerSet playerSet)
 => playerSet.State.GetMaednPlayerState();
 public void Apply(PlayerSet eventDto)
 {
     Info  = "";
     Error = "";
 }
 public void Apply(PlayerSet eventDto)
 {
     _context.ExecuteCommand(new SelectNextPlayerCommand());
 }
Esempio n. 10
0
        static void Main(string[] args)
        {
            //初期化
            Random random = new Random();

            //個体数
            int biont;

            Console.WriteLine("input biont...");
            int.TryParse(Console.ReadLine(), out biont);
            if (biont <= 0)
            {
                biont = 10;
            }

            //プレイヤー数
            int players;

            /*Console.WriteLine("input players...");
             * int.TryParse(Console.ReadLine(), out players);
             * if (players <= 0)*/
            {
                players = 6;
            }

            //世代内試行回数
            int count;

            Console.WriteLine("input count...");
            int.TryParse(Console.ReadLine(), out count);
            if (count <= 0)
            {
                count = 100000;
            }

            //同一ハンド試行回数
            int hand;

            Console.WriteLine("input hand...");
            int.TryParse(Console.ReadLine(), out hand);
            if (hand <= 0)
            {
                hand = 1;
            }

            //試行世代数
            int gen;

            Console.WriteLine("input gen...");
            int.TryParse(Console.ReadLine(), out gen);
            if (gen <= 0)
            {
                gen = 100;
            }


            /*
             * 個体群を生成
             */
            PlayerSet[][] playerSets = new PlayerSet[players][];

            int elements = 1;

            for (int i = 0; i < playerSets.Length; i++)
            {
                playerSets[i] = new PlayerSet[elements];

                for (int j = 0; j < playerSets[i].Length; j++)
                {
                    if (i == 0 && j == 0)
                    {
                        playerSets[i][j] = new PlayerSet(biont, random);
                    }
                    else
                    {
                        playerSets[i][j] = new PlayerSet(biont, false);
                    }
                }

                elements *= 2;
            }

            //訓練開始
            Game game = new Game(random, playerSets, biont, players);

            while (true)
            {
                for (int g = 0; g < gen; g++)
                {
                    for (int c = 0; c < count; c++)
                    {
                        game.Play(hand);
                    }

                    playerSets[0][0].NextGen_Rank(random);

                    for (int i = 0; i < playerSets.Length; i++)
                    {
                        for (int j = 0; j < playerSets[i].Length; j++)
                        {
                            //playerSets[i][j].NextGen_Rank(random);
                        }
                    }
                }

                for (int i = 0; i < biont; i++)
                {
                    playerSets[0][0].players[i].ShowHandRange();
                }

                //Console.ReadKey();
            }
        }