Exemplo n.º 1
0
    /// <summary>
    /// Cập nhật lại vị trí và giao diện
    /// </summary>
    public static void UpdatePlayerSide()
    {
        if (YourController != null)
        {
            YourController.mSide = ESide.Slot_0;
        }

        foreach (PlayerControllerChan p in ListPlayer)
        {
            p.mSide = SlotToSide(p.slotServer);
        }

        foreach (PlayerControllerChan p in ListJoinGameWhenPlaying)
        {
            p.mSide = SlotToSide(p.slotServer);
        }

        //Vẽ thông tin người đang tham gia trận đấu. Khi vẽ thông tin người dùng sẽ tự động destroy các slot trống.
        ListPlayer.ForEach(p => { if (p.cuiPlayer == null && p.slotServer <= 3)
                                  {
                                      CUIPlayerChan.Create(p, game.mPlaymat.locationPlayer[(int)p.mSide]);
                                  }
                           });
        //Vẽ thông tin người đang chờ trận đấu mới.
        ListJoinGameWhenPlaying.ForEach(p => { if (p.cuiPlayer == null)
                                               {
                                                   CUIPlayerChan.Create(p, game.mPlaymat.locationPlayer[(int)p.mSide]);
                                               }
                                        });

        DrawInfoPlayerNoSlot();
    }
Exemplo n.º 2
0
 public bool AddPlayer(Player player)
 {
     if (ListPlayer.Count > 2)
     {
         return(false);
     }
     ListPlayer.Add(player);
     return(true);
 }
Exemplo n.º 3
0
 void Start()
 {
     Controller = FindObjectOfType <Controller>();
     PhotonView = GetComponent <PhotonView>();
     Image      = GetComponent <Image>();
     Name       = transform.Find("Name");
     Name.GetComponent <Text>().text = GetComponent <PhotonView>().Owner.NickName;
     ListPlayer = FindObjectOfType <ListPlayer>();
     ListPlayer.Add(this);
 }
Exemplo n.º 4
0
        /// <summary>
        /// Used by Cutscene
        /// </summary>
        public void SpawnSquad(int PlayerIndex, Squad NewSquad, uint ID, Vector3 Position, int LayerIndex)
        {
            Position.Z = LayerIndex;
            if (Content != null)
            {
                NewSquad.Unit3D = new UnitMap3D(GraphicsDevice, Content.Load <Effect>("Shaders/Squad shader 3D"), NewSquad.CurrentLeader.SpriteMap, 1);
            }

            while (ListPlayer.Count <= PlayerIndex)
            {
                Player NewPlayer = new Player("Enemy", "CPU", false, false, PlayerIndex, Color.Red);
                ListPlayer.Add(NewPlayer);
            }
            ListPlayer[PlayerIndex].IsAlive = true;

            NewSquad.Init(GlobalBattleContext);
            ActivateAutomaticSkills(NewSquad, string.Empty);
            NewSquad.ID = ID;
            NewSquad.SetPosition(Position);

            ListPlayer[PlayerIndex].ListSquad.Add(NewSquad);

            if (NewSquad.CurrentLeader.ListTerrainChoices.Contains(UnitStats.TerrainAir))
            {
                if (NewSquad.CurrentWingmanA != null)
                {
                    if (NewSquad.CurrentWingmanA.ListTerrainChoices.Contains(UnitStats.TerrainAir))
                    {
                        if (NewSquad.CurrentWingmanB != null)
                        {
                            if (NewSquad.CurrentWingmanB.ListTerrainChoices.Contains(UnitStats.TerrainAir))
                            {
                                NewSquad.IsFlying        = true;
                                NewSquad.CurrentMovement = UnitStats.TerrainAir;
                            }
                        }
                        else
                        {
                            NewSquad.IsFlying        = true;
                            NewSquad.CurrentMovement = UnitStats.TerrainAir;
                        }
                    }
                }
                else
                {
                    NewSquad.IsFlying        = true;
                    NewSquad.CurrentMovement = UnitStats.TerrainAir;
                }
            }
            else
            {
                NewSquad.CurrentMovement = UnitStats.TerrainLand;
            }
        }
Exemplo n.º 5
0
        //Return the number of the winner, -1 if no winner
        public int VerifEndGame()
        {
            //Case : No more turn
            if (CurrTurnNumber == TurnMax)
            {
                int winner = -1;
                int score  = 0;
                foreach (Player p in ListPlayer)
                {
                    Map.SetVictoryPoint(p);
                    if (p.VictoryPoint > score)
                    {
                        score  = p.VictoryPoint;
                        winner = ListPlayer.IndexOf(p);
                    }
                }
                if (winner != -1)
                {
                    EndGame(winner);
                    return(winner);
                }
            }
            //Case : Player has no more unit
            int  playerAlive = -1;
            bool verif       = true;

            for (int i = 0; i < ListPlayer.Count; i++)
            {
                foreach (Entity e in ListPlayer[i].EntityList)
                {
                    if (e.Pos != -1)
                    {
                        if (playerAlive == -1)
                        {
                            playerAlive = i;
                        }
                        else if (playerAlive != i)
                        {
                            verif = false;
                        }
                    }
                }
            }
            if (verif == true && playerAlive != -1)
            {
                EndGame(playerAlive);
                return(playerAlive);
            }
            return(-1);
        }
Exemplo n.º 6
0
        public void Inquisitor_ShouldWork()
        {
            var map    = new ListMap(6);
            var player = new ListPlayer(1, map.Size, new Config());

            map.TakeHex(PlayerType.Red, 3, 3);
            var inquisitor = new Inquisitor();
            var testMap    = new ListMap(map.Size);

            testMap.InjectFrom(map);
            inquisitor.StartInquisition(testMap, player);


//            Assert.AreEqual(1, 2);
        }
Exemplo n.º 7
0
        public async Task <ListPlayer> GetMyFriendsDbAsync(ListPlayer players)
        {
            ListPlayer dbPlayers = new ListPlayer {
                Players = new List <Player>()
            };

            using (IDbConnection connection = GetConnection("KBunnySql"))
            {
                foreach (var player in players.Players)
                {
                    var result = await connection.QueryAsync <Player>("KBunnyGame_Players_GetMyFriends", new { player.FacebookId },
                                                                      commandType : CommandType.StoredProcedure);

                    dbPlayers.Players.Add(result.FirstOrDefault());
                }
            }
            return(dbPlayers);
        }
Exemplo n.º 8
0
        public void GetPathForPlayerTest()
        {
            var map       = new ListMap(11);
            var player    = new ListPlayer(1, 11, new Config());
            var redPlayer = new ListPlayer(2, 11, new Config());

            var pathfinder = new Pathfinder(map, player.Me);



            //map.TakeHex(PlayerType.Red, 5, 1);
            pathfinder = new Pathfinder(map, player.Me);
            var path = pathfinder.GetPathForPlayer();

            //Assert.AreEqual(11, path.Count);


            map.TakeHex(PlayerType.Red, 3, 2);
            map.TakeHex(PlayerType.Red, 2, 2);
            map.TakeHex(PlayerType.Red, 2, 0);
            map.TakeHex(PlayerType.Red, 2, 1);
            map.TakeHex(PlayerType.Red, 2, 3);
            map.TakeHex(PlayerType.Red, 2, 4);
            map.TakeHex(PlayerType.Red, 2, 5);

            var blueMap = new ListMap(map.Size);

            blueMap.InjectFrom <CloneInjection>(map);

            pathfinder = new Pathfinder(map, redPlayer.Me);
            path       = pathfinder.GetPathForPlayer();
            TestContext.WriteLine(pathfinder.GetLog());
            path.ForEach(x => map.TakeHex(PlayerType.Red, x.Row, x.Column));
            TestContext.WriteLine(map.GetMapMatrix().ToString().Replace('0', '_'));

            //pathfinder = new Pathfinder(blueMap, player, true);
            //path = pathfinder.GetPathForPlayer();
            //path.ForEach(x => blueMap.TakeHex(PlayerType.Blue, x.Row, x.Column));
            //TestContext.WriteLine(pathfinder.GetLog());

            //TestContext.WriteLine(blueMap.GetMapMatrix().ToString().Replace('0', '_'));

            //Assert.AreEqual(11, path.Count);
        }
Exemplo n.º 9
0
 public bool AddPlayer(Player p)
 {
     if (ListPlayer.Count < NbJoueur)
     {
         foreach (Player i in ListPlayer)
         {
             if (i.RaceString.Equals(p.RaceString))
             {
                 return(false);
             }
         }
         foreach (Entity ent in p.EntityList)
         {
             ent.Pos = Map.SpawnList[ListPlayer.Count];
         }
         ListPlayer.Add(p);
         return(true);
     }
     return(false);
 }
Exemplo n.º 10
0
    // Use this for initialization
    void Start()
    {
        listPlayer = new List <ListPlayer>();

        ListPlayer newObj;

        foreach (GameObject obj in GameObject.FindGameObjectsWithTag("Player"))
        {
            Debug.Log(obj.transform.name);
            newObj             = new ListPlayer();
            newObj.id          = null;
            newObj.playerName  = obj.transform.name;
            newObj.playerColor = obj.GetComponent <MeshRenderer>().material.color.ToString();
            listPlayer.Add(newObj);
        }

        foreach (var item in listPlayer)
        {
            Debug.Log(item.id + "**" + item.playerName + "***" + item.playerColor + "****" + item.playerStatus);
        }
    }
Exemplo n.º 11
0
    IEnumerator GetData()
    {
        using (UnityWebRequest webRequest = UnityWebRequest.Get(GameVariables.api_url + "users"))
        {
            yield return(webRequest.SendWebRequest());

            //Error de Internet o  Error de Servidor
            if (webRequest.isNetworkError || webRequest.isHttpError)
            {
                print("GAAAA");
            }
            else
            {
                string     text    = webRequest.downloadHandler.text;
                ListPlayer players = JsonUtility.FromJson <ListPlayer>(text);
                foreach (Player item in players.data)
                {
                    print(item.ToString());
                }
            }
        }
    }
Exemplo n.º 12
0
        public void GetPossibleMoves_ShouldGivePriorities_Appropriately()
        {
            var map     = new ListMap(6);
            var player  = new ListPlayer(1, map.Size, new Config());
            var player2 = new ListPlayer(2, map.Size, new Config());

            map.TakeHex(PlayerType.Blue, 0, 3);
            map.TakeHex(PlayerType.Red, 3, 3);
            map.TakeHex(PlayerType.Blue, 2, 3);
            map.TakeHex(PlayerType.Red, 3, 2);
            map.TakeHex(PlayerType.Blue, 1, 3);
            map.TakeHex(PlayerType.Red, 3, 1);

            var scout    = new Pathfinder(map, player.Me);
            var redScout = new Pathfinder(map, player2.Me);

            var path    = scout.GetPathForPlayer();
            var redPath = redScout.GetPathForPlayer();

            var inquisitor           = new Inquisitor();
            var possibleMovesForBlue = inquisitor.GetPossibleMoves(redPath, path, player.Me, map);

            TestContext.WriteLine("Blue =========");
            foreach (var move in path.Where(x => x.Owner == PlayerType.White))
            {
                TestContext.WriteLine(move);
            }
            TestContext.WriteLine("Red ========");
            foreach (var move in redPath.Where(x => x.Owner == PlayerType.White))
            {
                TestContext.WriteLine(move);
            }
            TestContext.WriteLine("Result =========");
            foreach (var move in possibleMovesForBlue)
            {
                TestContext.WriteLine(move + " " + move.Priority);
            }
        }
Exemplo n.º 13
0
        public void ScoreBoard_ShouldWork()
        {
            var map = new ListMap(11);

            var bluePlayer = new ListPlayer(1, map.Size, new Config());
            var redPlayer  = new ListPlayer(2, map.Size, new Config());

            map.TakeHex(PlayerType.Red, 1, 1);
            map.TakeHex(PlayerType.Red, 1, 2);
            map.TakeHex(PlayerType.Red, 1, 3);
            map.TakeHex(PlayerType.Red, 1, 4);
            map.TakeHex(PlayerType.Red, 1, 5);

            map.TakeHex(PlayerType.Blue, 1, 7);
            map.TakeHex(PlayerType.Blue, 1, 8);
            map.TakeHex(PlayerType.Blue, 1, 9);
            map.TakeHex(PlayerType.Blue, 1, 10);

            var matrixForPlayer1 = map.GetPlayerMatrix(PlayerType.Blue);

            TestContext.WriteLine("Player 1 matrix");
            TestContext.WriteLine(matrixForPlayer1.ToString());

            var matrixForPlayer2 = map.GetPlayerMatrix(PlayerType.Red);

            TestContext.WriteLine("Player 2 matrix");
            TestContext.WriteLine(matrixForPlayer2.ToString());

            var appraiser = new Appraiser();

            var player1score = appraiser.ScoreFromBoard(map, bluePlayer);
            var player2score = appraiser.ScoreFromBoard(map, redPlayer);

            Assert.AreNotEqual(player1score, player2score);

            Assert.AreEqual(4, player2score);
            Assert.AreEqual(-4, player1score);
        }
Exemplo n.º 14
0
        public void ShouldPlayListedMoves()
        {
            //Arrange
            var moves = new[]
            {
                Move.Paper,
                Move.Rock,
                Move.Scissors,
                Move.Scissors,
                Move.Rock,
                Move.Paper
            };
            var player = new ListPlayer(moves);
            var result = new List <Move>(moves.Length);

            //Act
            for (var i = 0; i < moves.Length; i++)
            {
                result.Add(player.Play());
            }

            //Assert
            result.Should().BeEquivalentTo(moves);
        }
Exemplo n.º 15
0
 public async Task <ListPlayer> GetMyFriendsDbAsync(ListPlayer players)
 {
     return(await playerDao.GetMyFriendsDbAsync(players));
 }
Exemplo n.º 16
0
 public static PlayerControllerChan GetPlayer(string username)
 {
     return(ListPlayer.Find(p => p.username == username));
 }
Exemplo n.º 17
0
 public PlayerManager(Player player)
 {
     ListPlayer.Add(player);
 }
Exemplo n.º 18
0
        public void AddPlayer(Config playerConfig, int playerNumber)
        {
            switch (playerConfig.type)
            {
            case "Human":
                if (playerNumber == 1)
                {
                    Player1 = new HumanPlayer.HumanPlayer(playerNumber, Size, playerConfig);
                }
                else
                {
                    Player2 = new HumanPlayer.HumanPlayer(playerNumber, Size, playerConfig);
                }

                break;

            case "Dozer AI":
                if (playerNumber == 1)
                {
                    Player1 = new DozerPlayer.DozerPlayer(playerNumber, Size, playerConfig);
                }
                else
                {
                    Player2 = new DozerPlayer.DozerPlayer(playerNumber, Size, playerConfig);
                }

                break;

            case "Minimax Matrix AI":
                if (playerNumber == 1)
                {
                    Player1 = new MatrixPlayer(playerNumber, Size, playerConfig);
                }
                else
                {
                    Player2 = new MatrixPlayer(playerNumber, Size, playerConfig);
                }

                break;

            case "Minimax List AI":
                if (playerNumber == 1)
                {
                    Player1 = new ListPlayer(playerNumber, Size, playerConfig);
                }
                else
                {
                    Player2 = new ListPlayer(playerNumber, Size, playerConfig);
                }

                break;

            case "Replay AI":
                if (playerNumber == 1)
                {
                    Player1 = new Playback(playerNumber, Size, playerConfig);
                }
                else
                {
                    Player2 = new Playback(playerNumber, Size, playerConfig);
                }

                break;

            case "Negamax AI":
                if (playerNumber == 1)
                {
                    Player1 = new Negamax(playerNumber, Size, playerConfig);
                }
                else
                {
                    Player2 = new Negamax(playerNumber, Size, playerConfig);
                }

                break;

            case "MonteCarlo":
                if (playerNumber == 1)
                {
                    Player1 = new MonteCarlo(playerNumber, Size, playerConfig);
                }
                else
                {
                    Player2 = new MonteCarlo(playerNumber, Size, playerConfig);
                }

                break;

            default:
                if (playerNumber == 1)
                {
                    Player1 = new RandomPlayer.RandomPlayer(playerNumber, Size, null);
                }
                else
                {
                    Player2 = new RandomPlayer.RandomPlayer(playerNumber, Size, null);
                }
                break;
            }
        }
Exemplo n.º 19
0
 public static void RemoveAllPlayerWhenAddWaitingPlayer()
 {
     ListWaitingPlayer.Clear();
     ListPlayer.ForEach(p => { GameModelChan.SetPlayer(p.slotServer, null); });
     ListPlayer.Clear();
 }
Exemplo n.º 20
0
        public frmPlayer(string[] args)
        {
            InitializeComponent();
            Form esplas = new frmSplash();

            esplas.Show();
            bool    value = false;
            DataSet data;

            // Used to store the return value

            /*
             * var thread = new Thread(
             * () =>
             * {*/
            Size size = new Size(15, 450);
            int  sais = size.Width;

            for (byte i = 0; i <= Gelida_Player.Properties.Settings.Default.Players; i++)
            {
                ListPlayer lp = new ListPlayer();
                if ((i + 1) % 2 == 0)
                {
                    lp.outDev = Properties.Settings.Default.OutputDev2;
                }
                else
                {
                    lp.outDev = Properties.Settings.Default.OutputDev1;
                }
                lp.Dock         = DockStyle.Fill;
                lp.AutoSize     = true;
                lp.AutoSizeMode = AutoSizeMode.GrowOnly;
                lp.Padding      = new Padding(5);
                //panel1.Controls.Add(lp);
            }

            /*
             * value = true; // Publish the return value
             * });
             */


            var t2 = new Thread(
                () =>
            {
            });

            /*
             * thread.Start();
             * t2.Start();
             * //thread.Join();
             * thread.Join();
             * //thread.Join();
             *
             */
            esplas.Close();
            //foreach (Control ctr in GetAll(this, typeof(ListPlayer)))
            //{


            //    sais += (ctr.MinimumSize.Width);

            //}
            //size.Width = sais;
            //MinimumSize = size;
        }
Exemplo n.º 21
0
 public ListPlayer GetMyFriends(ListPlayer players)
 {
     return(playerDao.GetMyFriendsDb(players));
 }
Exemplo n.º 22
0
        public async Task <ListPlayer> GetMyFriends([FromBody] ListPlayer players)
        {
            return(await playerService.GetMyFriendsDbAsync(players));

            //return playerService.GetMyFriends(players);
        }
Exemplo n.º 23
0
        public override void Init()
        {
            base.Init();
            ListActionMenuChoice.Add(new ActionPanelPhaseChange(this));

            if (GameMode == 0)
            {
                ListPlayer.Clear();

                Player NewPlayer = new Player("Player", "Human", true, false, 0, Color.Blue);
                ListPlayer.Add(NewPlayer);

                if (ListSpawnSquad.Count > 0)
                {
                    int SpawnSquadIndex = 0;
                    for (int S = 0; S < ListSingleplayerSpawns.Count; S++)
                    {
                        if (ListSingleplayerSpawns[S].Tag == "P")
                        {
                            for (int U = 0; U < ListSpawnSquad[SpawnSquadIndex].UnitsInSquad; ++U)
                            {
                                ListSpawnSquad[SpawnSquadIndex].At(U).ReinitializeMembers(DicUnitType[ListSpawnSquad[SpawnSquadIndex].At(U).UnitTypeName]);
                            }
                            ListSpawnSquad[SpawnSquadIndex].ReloadSkills(DicRequirement, DicEffect, ManualSkillTarget.DicManualSkillTarget);
                            SpawnSquad(0, ListSpawnSquad[SpawnSquadIndex], 0, ListSingleplayerSpawns[S].Position);
                            ++SpawnSquadIndex;
                        }
                    }
                }
            }
            else if (GameMode == 1)
            {
                for (int P = 0; P < ListPlayer.Count; P++)
                {
                    ListPlayer[P].Color = ArrayMultiplayerColor[P];

                    for (int S = 0; S < ListPlayer[P].ListSpawnPoint.Count; S++)
                    {
                        if (string.IsNullOrEmpty(ListPlayer[P].ListSpawnPoint[S].LeaderTypeName))
                        {
                            continue;
                        }

                        Unit      NewLeaderUnit  = Unit.FromType(ListPlayer[P].ListSpawnPoint[S].LeaderTypeName, ListPlayer[P].ListSpawnPoint[S].LeaderName, Content, DicUnitType, DicRequirement, DicEffect);
                        Character NewLeaderPilot = new Character(ListPlayer[P].ListSpawnPoint[S].LeaderPilot, Content, DicRequirement, DicEffect);
                        NewLeaderPilot.Level = 1;
                        NewLeaderUnit.ArrayCharacterActive = new Character[1] {
                            NewLeaderPilot
                        };

                        Unit NewWingmanAUnit = null;
                        Unit NewWingmanBUnit = null;

                        if (!string.IsNullOrEmpty(ListPlayer[P].ListSpawnPoint[S].WingmanAName))
                        {
                            NewWingmanAUnit = Unit.FromType(ListPlayer[P].ListSpawnPoint[S].WingmanATypeName, ListPlayer[P].ListSpawnPoint[S].WingmanAName, Content, DicUnitType, DicRequirement, DicEffect);
                            Character NewWingmanAPilot = new Character(ListPlayer[P].ListSpawnPoint[S].WingmanAPilot, Content, DicRequirement, DicEffect);
                            NewWingmanAPilot.Level = 1;
                            NewWingmanAUnit.ArrayCharacterActive = new Character[1] {
                                NewWingmanAPilot
                            };
                        }

                        if (!string.IsNullOrEmpty(ListPlayer[P].ListSpawnPoint[S].WingmanBName))
                        {
                            NewWingmanBUnit = Unit.FromType(ListPlayer[P].ListSpawnPoint[S].WingmanBTypeName, ListPlayer[P].ListSpawnPoint[S].WingmanBName, Content, DicUnitType, DicRequirement, DicEffect);
                            Character NewWingmanBPilot = new Character(ListPlayer[P].ListSpawnPoint[S].WingmanBPilot, Content, DicRequirement, DicEffect);
                            NewWingmanBPilot.Level = 1;
                            NewWingmanBUnit.ArrayCharacterActive = new Character[1] {
                                NewWingmanBPilot
                            };
                        }

                        Squad NewSquad = new Squad("", NewLeaderUnit, NewWingmanAUnit, NewWingmanBUnit);

                        if (!ListPlayer[P].IsHuman)
                        {
                            NewSquad.SquadAI = new DeathmatchScripAIContainer(new DeathmatchAIInfo(this, NewSquad));
                            NewSquad.SquadAI.Load("SRWE Enemy AI");
                        }
                        else
                        {
                            NewSquad.IsPlayerControlled = true;
                        }

                        SpawnSquad(P, NewSquad, 0, ListPlayer[P].ListSpawnPoint[S].Position);
                    }
                }
            }
        }