示例#1
0
 /// <summary>
 /// suppression de la concrete entity
 /// </summary>
 /// <param name="ce"></param>
 /*public void killEntity(ConcreteEntity ce)
 {
     foreach (Player p in this._players)
     {
         p.killEntity(ce);
     }
 }*/
 /// <summary>
 /// récuprérer les information sur le player
 /// le nombre de cristaux 
 /// le nombre d'armée max et actuuelle
 /// le nombre de gaz
 /// </summary>
 /// <param name="IdPlayer"></param>
 /// <returns></returns>
 public InfoPlayer getInfoPlayer(int IdPlayer)
 {
     InfoPlayer inf = new InfoPlayer();
     foreach (Player p in this._players)
     {
         if (p.Idplayer == IdPlayer)
         {
             return p.getInfoPlayer();
         }
     }
     return inf;
 }
 /*********************************************/
 /********************Player*******************/
 /*********************************************/
 /// <summary>
 /// Génère le code réseau pour envoyer les ressources d'un player
 /// </summary>
 /// <param name="info">les ressources du player</param>
 /// <returns>bytes à envoyer sur le réseau</returns>
 public Byte[] Player_sendressources(InfoPlayer info)
 {
     int i = 0;
     Byte[] bytes = new Byte[10];
     setType(ref bytes, ref i, ServerProtocol.PLAYER_GETRESS);
     addInt16(ref bytes, ref i, info._mineral);
     addInt16(ref bytes, ref i, info._pop);
     addInt16(ref bytes, ref i, info._popMax);
     addInt16(ref bytes, ref i, info._vespene);
     return (bytes);
 }
示例#3
0
        public InfoPlayer getInfoPlayer()
        {
            InfoPlayer inf = new InfoPlayer();

            // pop max
            uint hatcherynumber = 0;
            uint overlordnumber = 0;
            float pop = 0;
            foreach (ConcreteEntity ce in this._ListEntity)
            {
                if (ce.Name == "hatchery")
                {
                    ++hatcherynumber;
                }
                if (ce.Name == "overlord")
                {
                    ++overlordnumber;
                }
                // pop actuel
                PlayableConcreteEntity pce = (PlayableConcreteEntity)ce;
                pop += pce.Supply;
            }

            inf._popMax = (hatcherynumber * 2 + overlordnumber * 8);

            inf._pop = (uint) Math.Round(pop, MidpointRounding.AwayFromZero);

            // vespene
            inf._vespene = this._vespeneNumber;

            // mineral
            inf._mineral = this._mineralNumber;
            return inf;
        }