Beispiel #1
0
        private void radLabel2_Click(object sender, EventArgs e)
        {
            if (StratigyAlgorithm.SelectedItem == null)
            {
                StratigyAlgorithm.Select();  return;
            }
            if (FirstPlayer.SelectedItem == null)
            {
                FirstPlayer.Select(); return;
            }
            Game.DifficultyLevel level = beginner.IsChecked
                ? Game.DifficultyLevel.Easy
                : medium.IsChecked
                    ? Game.DifficultyLevel.Meduim
                    : Game.DifficultyLevel.Difficult;

            IntelligentAgent agent = StratigyAlgorithm.SelectedItem.Index == 0 ? new IntelligentAgent(level) : new IntelligentAgent(level, true);
            int player             = FirstPlayer.SelectedItem.Index == 0 ? 1 : 2;

            //_game = new Game(level) {NextPlayer = player, Agent = agent};
            //_game = new Game(agent, level,Cell.IntCount) {NextPlayer = player, Agent = agent };
            _game = new Game(level, Cell.IntCount)
            {
                NextPlayer = player, Agent = agent
            };
            _game.Subscribe(this);
            Informant.Text = FirstPlayer.SelectedItem.Index == 0 ? "Computer's Turn" : "Your Turn";
            Curten.Start();
        }
Beispiel #2
0
    public IEnumerator GameRoutine()
    {
        if (Player == PlayerType.Host)
        {
            Communication.SendNewStep(Communication.nwStream);
        }

        // 1- Perform previous commands
        //// Do Kicks First
        if (Player == PlayerType.Guest)
        {
            UpdateStateGuestKick(SharedMemory.PlayerCommand);
            UpdateStateHostKick(SharedMemory.EnemyCommand1);
            UpdateStateHostKick(SharedMemory.EnemyCommand2);
            //// Move Ball
            int goal = Field.Ball.Move(Field);
            if (goal == -1)
            {
                //Goal in host
                GuestScore++;
            }
            else if (goal == 1)
            {
                HostScore++;
            }
            //// Do other actions
            UpdateStateGuestNoKick(SharedMemory.PlayerCommand);
            UpdateStateHostNoKick(SharedMemory.EnemyCommand1);
            UpdateStateHostNoKick(SharedMemory.EnemyCommand2);
        }
        else
        {
            UpdateStateHostKick(SharedMemory.PlayerCommand);
            UpdateStateGuestKick(SharedMemory.EnemyCommand1);
            UpdateStateGuestKick(SharedMemory.EnemyCommand2);
            //// Move Ball
            int goal = Field.Ball.Move(Field);
            if (goal == -1)
            {
                //Goal in host
                GuestScore++;
            }
            else if (goal == 1)
            {
                HostScore++;
            }
            //// Do other actions
            UpdateStateHostNoKick(SharedMemory.PlayerCommand);
            UpdateStateGuestNoKick(SharedMemory.EnemyCommand1);
            UpdateStateGuestNoKick(SharedMemory.EnemyCommand2);
        }

        // 3- Make Decision
        //// Make Decision
        IntelligentAgent.MakeDecision(Field, Player);
        ////// SharedMemory.PlayerCommand = new Command(Player);

        // 4- Send decision in background
        Communication.SendCommand(SharedMemory.PlayerCommand, Communication.nwStream);

        // 2- Draw current state
        yield return(Ninja.JumpToUnity);

        Draw();
        yield return(Ninja.JumpBack);
    }